# PetscDeviceContextSetFromOptions
Configure a `PetscDeviceContext` from the options database 
## Synopsis
```
#include <petscdevice.h> 
PetscErrorCode PetscDeviceContextSetFromOptions(MPI_Comm comm, PetscDeviceContext dctx)
```
Collective on `comm` or `dctx`


## Input Parameters

- ***comm -*** MPI communicator on which to query the options database (optional)
- ***dctx -*** The `PetscDeviceContext` to configure



## Output Parameter

- ***dctx -*** The `PetscDeviceContext`



## Options Database Keys

- ***-device_context_stream_type -*** type of stream to create inside the `PetscDeviceContext` -
`PetscDeviceContextSetStreamType()`
- ***-device_context_device_type -*** the type of `PetscDevice` to attach by default - `PetscDeviceType`



## Notes
The user may pass `MPI_COMM_NULL` for `comm` in which case the communicator of `dctx` is
used (which is always `PETSC_COMM_SELF`).




## See Also
 `PetscDeviceContextSetStreamType()`, `PetscDeviceContextSetDevice()`,
`PetscDeviceContextView()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/objects/device/interface/dcontext.cxx.html#PetscDeviceContextSetFromOptions">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](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
