PetscDeviceContextDefault#

Placeholder for the default-stream context on the current device

Notes#

Pass this symbol to device-memory operations or to device-context operations that inspect, synchronize, duplicate, or fork a context. It is also accepted by PetscDeviceContextSetUp(), PetscDeviceContextSetCurrentContext(), and as the parent argument of PetscDeviceContextJoin(). When a call needs a context, it resolves this symbol to a PETSc-owned PETSC_STREAM_DEFAULT context for the backend and device attached to the current context, creating that context lazily. It does not select the current stream. No-work returns do not resolve the placeholder or initialize a device.

Saving this placeholder does not capture a context. After changing the current device, another call resolves it for the new device. Use PetscDeviceContextGetDefaultContext() to capture a concrete handle. A fork and its destroying join must resolve to the same parent; keep the device unchanged between those calls or capture the parent first. Join child arrays must contain concrete handles.

This symbol cannot be destroyed, reconfigured with PetscDeviceContextSetDevice(), PetscDeviceContextSetStreamType(), or PetscDeviceContextSetFromOptions(), or passed to generic PetscObject routines. It does not represent a NULL pointer. Default-stream selection does not synchronize unrelated nonblocking streams or establish dependencies on them.

Developer Note#

This placeholder is for application use. Resolve it at public API boundaries before ordinary object validation, object access, or backend dispatch.

Some private helpers accept a NULL context to request the current context. They resolve it to a concrete context before passing it to a public device API or accessing its state.

See Also#

PetscDeviceContext, PetscDeviceContextGetDefaultContext(), PetscDeviceContextGetCurrentContext(), PetscStreamType

Level#

beginner

Location#

include/petscdevice.h

Examples#

src/sys/objects/device/tests/ex13.cxx
src/sys/objects/device/tests/ex3.c
src/sys/objects/device/tests/ex4.c
src/sys/objects/device/tests/ex6.c
src/sys/objects/device/tests/ex7.c
src/sys/objects/device/tests/ex9.c


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