VecCreateSeqWithArrayAndMemType#

Creates a sequential array-style vector using a user-provided array with the specified memory type

Synopsis#

#include "petscvec.h" 
PetscErrorCode VecCreateSeqWithArrayAndMemType(MPI_Comm comm, PetscMemType mtype, PetscInt bs, PetscInt n, const PetscScalar array[], Vec *V)

Collective

Input Parameters#

  • comm - the communicator, should be PETSC_COMM_SELF

  • mtype - the memory type of array, which must be the same on all processes in comm

  • bs - the block size

  • n - the vector length

  • array - memory where the vector elements are to be stored

Output Parameter#

  • V - the vector

Notes#

mtype determines whether the resulting vector is a standard, CUDA, or HIP vector. Since PETSC_MEMTYPE_DEVICE and PETSC_MEMTYPE_CUDA have the same value, that value creates a CUDA vector when CUDA is configured and otherwise creates a HIP vector when HIP is configured.

mtype alone does not identify the Kokkos implementation, and native SYCL vectors are not supported, so this function does not create Kokkos or SYCL vectors.

array remains owned by the caller and is not freed when the vector is destroyed via VecDestroy().

See Also#

VecCreateSeqWithArray(), VecCreateMPIWithArrayAndMemType(), VecCreateSeqCUDAWithArray(), VecCreateSeqHIPWithArray(), PetscMemType

Level#

intermediate

Location#

src/vec/vec/utils/veccreatememtype.c


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