VecGetArrayReadAndMemTypeAsync#

Returns a read-only pointer to this MPI process’s portion of the vector data.

Synopsis#

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

Not 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 VecGetArrayReadAndMemType() and retain its synchronization behavior.

The array must not be modified. The pointer is borrowed until VecRestoreArrayReadAndMemType() 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, VecGetArrayReadAndMemType(), VecRestoreArrayReadAndMemType(), VecGetArrayAndMemTypeAsync(), 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