Skip to main content
`Ctrl`+`K`

# VecCreateSeqHIPWithArrays

Creates a sequential, array-style vector using HIP, where the user provides the complete array space to store the vector values.

## Synopsis

    #include <petscvec.h>
    PetscErrorCode VecCreateSeqHIPWithArrays(MPI_Comm comm, PetscInt bs, PetscInt n, const PetscScalar cpuarray[], const PetscScalar gpuarray[], Vec *v)

Collective, Possibly Synchronous

## Input Parameters

- comm - the communicator, must be `PETSC_COMM_SELF`

- bs - the block size

- n - the local vector length

- cpuarray - CPU memory where the vector elements are to be stored (or `NULL`)

- gpuarray - GPU memory where the vector elements are to be stored (or `NULL`)

## Output Parameter

- v - the vector

## Notes

If the user-provided array is `NULL`, then `VecHIPPlaceArray()` can be used at a later stage to SET the array for storing the vector values. Otherwise, the array must be allocated on the device.

If both `cpuarray` and `gpuarray` are provided, the provided arrays must have identical values.

The arrays are NOT freed when the vector is destroyed via `VecDestroy()`. The user must free them themselves, but not until the vector is destroyed.

This function may initialize `PetscDevice`, which may incur a device synchronization.

## See Also

Vectors and Parallel Data, `PetscDeviceInitialize()`, `VecCreate()`, `VecCreateSeqWithArray()`, `VecCreateSeqHIP()`, `VecCreateSeqHIPWithArray()`, `VecCreateMPIHIP()`, `VecCreateMPIHIPWithArray()`, `VecCreateMPIHIPWithArrays()`, `VecHIPPlaceArray()`

## Level

intermediate

## 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