VecGetArrayAndMemTypeAsync#

Returns a pointer to this MPI process’s portion of the vector data for reading and writing.

Synopsis#

#include "petscvec.h"   
PetscErrorCode VecGetArrayAndMemTypeAsync(Vec x, PetscScalar *a[], PetscMemType *mtype)

Logically Collective; No Fortran Support

Input Parameter#

  • x - the vector

Output Parameters#

  • a - pointer to this MPI process’s portion of the vector data, borrowed from the vector

  • mtype - memory type of the array, or NULL if not needed

Notes#

For CUDA and HIP vectors that are not bound to the CPU, this routine always returns a device pointer, even when the latest values are on the host. It queues any required host-to-device copy on the current PetscDeviceContext without waiting for it. The caller must order subsequent accesses after that context’s work, for example with PetscDeviceContextSynchronize(). Do not modify host storage while its copy is pending. Device allocation and runtime staging of pageable host memory may still block.

Other vector types, including vectors bound to the CPU, use VecGetArrayAndMemType() and retain its synchronization behavior.

The existing entries are preserved and may be modified. The pointer is borrowed until VecRestoreArrayAndMemType() is called. Complete external asynchronous work before restoring the array. Do not replace the vector’s storage or change its type or CPU binding while the array is acquired.

See Also#

Vectors and Parallel Data, Vec, VecGetArrayAndMemType(), VecRestoreArrayAndMemType(), VecGetArrayReadAndMemTypeAsync(), VecGetArrayWriteAndMemTypeAsync(), PetscDeviceContextGetCurrentContext(), PetscDeviceContextSynchronize()

Level#

advanced

Location#

src/vec/vec/interface/rvector.c

Examples#

src/vec/vec/tests/ex65.c


Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages