VecGetKokkosView — PETSc 3.23.0 documentation

Skip to main content
`Ctrl`+`K`

# VecGetKokkosView

Returns a constant Kokkos View that contains up-to-date data of a vector in the specified memory space.

## Synopsis

    template <class MemorySpace>
    PetscErrorCode VecGetKokkosView(Vec, Kokkos::View<const PetscScalar *, MemorySpace> *)

## Synopsis

    #include <petscvec_kokkos.hpp>
    PetscErrorCode VecGetKokkosView  (Vec v,Kokkos::View<const PetscScalar*,MemorySpace>* kv);
    PetscErrorCode VecGetKokkosView  (Vec v,Kokkos::View<PetscScalar*,MemorySpace>* kv);

Logically Collective, No Fortran Support

## Input Parameter

- v - the vector in type of `VECKOKKOS`

## Output Parameter

- kv - the Kokkos View with a user-specified template parameter MemorySpace

## Notes

If the vector is not of type `VECKOKKOS`, an error will be raised.

The functions are similar to `VecGetArrayRead()` and `VecGetArray()` respectively. One can read-only or read/write the returned Kokkos View.

Passing in a const View enables read-only access.

One must return the View by a matching `VecRestoreKokkosView()` after finishing using the View. Currently, only two memory spaces are supported: HostMirrorMemorySpace and Kokkos::DefaultExecutionSpace::memory_space. If needed, a memory copy will be internally called to copy the latest vector data to the specified memory space.

## See Also

`VecRestoreKokkosView()`, `VecRestoreArray()`, `VecGetKokkosViewWrite()`, `VecGetArrayRead()`, `VecGetArrays()`, `VecPlaceArray()`, `VecGetArray2d()`, `VecGetArrayPair()`, `VecRestoreArrayPair()`, `VecGetArrayWrite()`, `VecRestoreArrayWrite()`

## Level

beginner

## Location

include/petscvec_kokkos.hpp

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