# VecCUDAGetArrayRead
Provides read access to the CUDA buffer inside a vector. 
## Synopsis
```
#include "petscvec.h"   
PETSC_EXTERN PetscErrorCode VecCUDAGetArrayRead(Vec v, const PetscScalar **a)
```
Not Collective; No Fortran Support


## Input Parameter

- ***v -*** the vector



## Output Parameter

- ***a -*** the CUDA pointer.





## Notes
This function is analogous to `VecGetArrayRead()`:  The pointer
returned by this function points to a consistent view of the vector
data.  This may involve a copy operation of data from the host to the
device if the data on the device is out of date.  If the device
memory hasn't been allocated previously it will be allocated as part
of this function call.  `VecCUDAGetArrayRead()` assumes that the
user will not modify the vector data.  This is analgogous to
intent(in) in Fortran.

The CUDA device pointer has to be released by calling
`VecCUDARestoreArrayRead()`.  If the data on the host side was
previously up to date it will remain so, i.e. data on both the device
and the host is up to date.  Accessing data on the host side does not
incur a device to host data transfer.


## See Also
 [](chapter_vectors), `Vec`, `VecCUDARestoreArrayRead()`, `VecCUDAGetArray()`, `VecCUDAGetArrayWrite()`, `VecGetArray()`, `VecGetArrayRead()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/interface/rvector.c.html#VecCUDAGetArrayRead">src/vec/vec/interface/rvector.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex47cu.cu.html">src/snes/tutorials/ex47cu.cu.html</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/vec/interface/rvector.c)


[Index of all Vec routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
