:orphan:
# PetscDeviceContextSetDevice
Set the underlying `PetscDevice` for a `PetscDeviceContext` 
## Synopsis
```
#include <petscdevice.h> 
PetscErrorCode PetscDeviceContextSetDevice(PetscDeviceContext dctx, PetscDevice device)
```
Not Collective


## Input Parameters

- ***dctx   -*** The `PetscDeviceContext`
- ***device -*** The `PetscDevice`





## Notes
This routine is effectively `PetscDeviceContext`'s "set-type" (so every `PetscDeviceContext` must
also have an attached `PetscDevice`). Unlike the usual set-type semantics, it is not strictly
necessary to set a contexts device to enable usage, any created `PetscDeviceContext`s will
always come equipped with the "default" device.

This routine is a no-op if `device` is already attached to `dctx`.

This routine may (but is very unlikely to) initialize the backend device and may incur
synchronization.


## See Also
 `PetscDeviceCreate()`, `PetscDeviceConfigure()`, `PetscDeviceContextGetDevice()`,
`PetscDeviceContextGetDeviceType()`

## Level
intermediate

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


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


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