# PetscDeviceGetDeviceId
Get the device ID for a `PetscDevice` 
## Synopsis
```
#include <petscdevice.h> 
PetscErrorCode PetscDeviceGetDeviceId(PetscDevice device, PetscInt *id)
```
Not Collective


## Input Parameter

- ***device -*** The `PetscDevice`



## Output Parameter

- ***id -*** The id



## Notes
The returned ID may have been assigned by the underlying device backend. For example if the
backend is CUDA then `id` is exactly the value returned by `cudaGetDevice()` at the time when
this device was configured.




## See Also
 `PetscDevice`, `PetscDeviceCreate()`, `PetscDeviceGetType()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/objects/device/interface/device.cxx.html#PetscDeviceGetDeviceId">src/sys/objects/device/interface/device.cxx</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/objects/device/interface/device.cxx)


[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)  
