VecCreateSeqCUDAWithArrays#

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

Synopsis#

#include <petscvec.h> 
PetscErrorCode VecCreateSeqCUDAWithArrays(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 VecCUDAPlaceArray() 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(), VecCreateSeqCUDA(), VecCreateSeqCUDAWithArray(), VecCreateMPICUDA(), VecCreateMPICUDAWithArray(), VecCreateMPICUDAWithArrays(), VecCUDAPlaceArray() C@*/ PetscErrorCode VecCreateSeqCUDAWithArrays(MPI_Comm comm, PetscInt bs, PetscInt n, const PetscScalar cpuarray[], const PetscScalar gpuarray[], Vec *v) { PetscFunctionBegin; PetscCall(VecCreateSeqCUPMWithArraysAsyncDeviceType::CUDA(comm, bs, n, cpuarray, gpuarray, v)); PetscFunctionReturn(PETSC_SUCCESS); }

// PetscClangLinter pragma disable: -fdoc-internal-linkage /*@C VecCreateSeqCUDAWithArray - Creates a sequential, array-style vector using CUDA, where the user provides the device array space to store the vector values.

Collective, Possibly Synchronous

Input Parameters#

  • comm - the communicator, must be PETSC_COMM_SELF

  • bs - the block size

  • n - the vector length

  • 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 VecCUDAPlaceArray() 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.

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

Use VecDuplicate() or VecDuplicateVecs() to form additional vectors of the same type as an existing vector.

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

See Also#

Vectors and Parallel Data, PetscDeviceInitialize(), VecCreate(), VecCreateSeq(), VecCreateSeqWithArray(), VecCreateMPIWithArray(), VecCreateSeqCUDA(), VecCreateMPICUDAWithArray(), VecCUDAPlaceArray(), VecDuplicate(), VecDuplicateVecs(), VecCreateGhost()

Level#

intermediate

Location#

src/vec/vec/impls/seq/cupm/cuda/vecseqcupm.cu


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