Skip to main content
`Ctrl`+`K`

# 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

src/sys/objects/device/interface/dcontext.cxx

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