VecGetArrayAndMemType — PETSc 3.23.0 documentation

Skip to main content
`Ctrl`+`K`

# VecGetArrayAndMemType

Like `VecGetArray()`, but if this is a standard device vector (e.g., `VECCUDA`), the returned pointer will be a device pointer to the device memory that contains this MPI processes’s portion of the vector data.

## Synopsis

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

Logically Collective; No Fortran Support

## Input Parameter

- x - the vector

## Output Parameters

- a - location to put pointer to the array

- mtype - memory type of the array

## Note

Device data is guaranteed to have the latest value. Otherwise, when this is a host vector (e.g., `VECMPI`), this routine functions the same as `VecGetArray()` and returns a host pointer.

For `VECKOKKOS`, if Kokkos is configured without device (e.g., use serial or openmp), per this function, the vector works like `VECSEQ`/`VECMPI`; otherwise, it works like `VECCUDA` or `VECHIP` etc.

Use `VecRestoreArrayAndMemType()` when the array access is no longer needed.

## See Also

Vectors and Parallel Data, `Vec`, `VecRestoreArrayAndMemType()`, `VecGetArrayReadAndMemType()`, `VecGetArrayWriteAndMemType()`, `VecRestoreArray()`, `VecGetArrayRead()`, `VecGetArrays()`, `VecPlaceArray()`, `VecGetArray2d()`, `VecGetArrayPair()`, `VecRestoreArrayPair()`, `VecGetArrayWrite()`, `VecRestoreArrayWrite()`

## Level

beginner

## Location

src/vec/vec/interface/rvector.c

## Implementations

VecGetArrayAndMemType_SeqKokkos() in src/vec/vec/impls/seq/kokkos/veckok.kokkos.cxx

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