Skip to main content
`Ctrl`+`K`

# PetscMemType

Memory type of a pointer

## Synopsis

    #include <petscdevicetypes.h>
    typedef enum {
      PETSC_MEMTYPE_HOST    = 0,
      PETSC_MEMTYPE_DEVICE  = 1,  /* 0x01 */
      PETSC_MEMTYPE_CUDA    = 1,  /* 0x01 */
      PETSC_MEMTYPE_NVSHMEM = 17, /* 0x11 */
      PETSC_MEMTYPE_HIP     = 3,  /* 0x03 */
      PETSC_MEMTYPE_SYCL    = 5   /* 0x05 */
    } PetscMemType;

## Note

`PETSC_MEMTYPE_KOKKOS` depends on the Kokkos backend configuration

## Developer Notes

This enum uses a function (`PetscMemTypeToString()`) to convert to string representation so cannot be used in `PetscOptionsEnum()`.

Encoding of the bitmask in binary: xxxxyyyz

     z = 0                - Host memory
     z = 1                - Device memory
     yyy = 000            - CUDA-related memory
     yyy = 001            - HIP-related memory
     yyy = 010            - SYCL-related memory
     xxxxyyy1 = 0000,0001 - CUDA memory
     xxxxyyy1 = 0001,0001 - CUDA NVSHMEM memory
     xxxxyyy1 = 0000,0011 - HIP memory
     xxxxyyy1 = 0000,0101 - SYCL memory

Other types of memory, e.g., CUDA managed memory, can be added when needed.

## See Also

`PetscMemTypeToString()`, `VecGetArrayAndMemType()`, `PetscSFBcastWithMemTypeBegin()`, `PetscSFReduceWithMemTypeBegin()`

## Level

intermediate

## Location

include/petscdevicetypes.h

## Examples

src/mat/tutorials/ex19.c

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