# PetscMemType
Memory type of a pointer 
## Synopsis
```
#include <petscdevicetypes.h> 
typedef enum {
  PETSC_MEMTYPE_HOST    = 0,
  PETSC_MEMTYPE_DEVICE  = 0x01,
  PETSC_MEMTYPE_CUDA    = 0x01,
  PETSC_MEMTYPE_NVSHMEM = 0x11,
  PETSC_MEMTYPE_HIP     = 0x03,
  PETSC_MEMTYPE_SYCL    = 0x05,
} PetscMemType;
```

## Developer Note
Encoding of the bitmask in binary: xxxxyyyz

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

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




## Notes
`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()`.


## See Also
 `PetscMemTypeToString()`, `VecGetArrayAndMemType()`,
`PetscSFBcastWithMemTypeBegin()`, `PetscSFReduceWithMemTypeBegin()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscdevicetypes.h.html#PetscMemType">include/petscdevicetypes.h</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscdevicetypes.h)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
