VecHIPReplaceArray — PETSc 3.25.0 documentation

Skip to main content
`Ctrl`+`K`

# VecHIPReplaceArray

Permanently replace the GPU array in a vector with a GPU array provided by the user.

## Synopsis

    #include <petscvec.h>
    PetscErrorCode VecHIPReplaceArray(Vec vin, const PetscScalar array[])

Logically Collective; No Fortran Support

## Input Parameters

- vec - the vector

- array - the GPU array

## Notes

Adding `const` to `array` was an oversight, see notes in `VecPlaceArray()`.

This is useful to avoid copying a GPU array into a vector.

This frees the memory associated with the old GPU array. The vector takes ownership of the passed array so it CANNOT be freed by the user. It will be freed when the vector is destroyed.

## See Also

Vectors and Parallel Data, `VecGetArray()`, `VecRestoreArray()`, `VecPlaceArray()`, `VecResetArray()`, `VecHIPResetArray()`, `VecHIPPlaceArray()`, `VecReplaceArray()`

## Level

advanced

## Location

src/vec/vec/impls/seq/cupm/hip/vecseqcupm.hip.cxx

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