PetscDeviceContextSetCurrentContext#
Set the current active PetscDeviceContext
Synopsis#
#include <petscdevice.h>
PetscErrorCode PetscDeviceContextSetCurrentContext(PetscDeviceContext dctx)
Not Collective
Input Parameter#
dctx - The
PetscDeviceContext
Notes#
This routine selects the context used by subsequent operations of PETSc’s built-in CUDA and HIP implementations. Kokkos-based types keep the execution space created when PETSc initialized Kokkos, and external packages may use their own streams. Selecting another context does not replace PETSc’s root context.
The supplied context must be set up, or be PetscDeviceContextDefault, which is resolved before
being installed as current. To restore a previous context, pass the handle
saved from PetscDeviceContextGetCurrentContext().
This routine does not take ownership of a user-created context; keep it alive while it is current
and destroy it before PetscFinalize(). PETSc retains ownership of its root and cached default contexts.
See Also#
PetscDeviceContextGetCurrentContext(), PetscDeviceContextFork(),
PetscDeviceContextJoin(), PetscDeviceContextCreate()
Level#
beginner
Location#
Examples#
src/sys/objects/device/tests/ex1k.kokkos.cxx
src/sys/objects/device/tests/ex2.c
src/sys/objects/device/tests/ex7.c
src/sys/objects/device/tests/ex9.c
src/dm/tests/ex56.c
src/ksp/ksp/utils/lmvm/tests/ex4.c
src/ksp/pc/tests/ex17.c
src/mat/tests/ex254.c
src/mat/tests/ex324.c
src/vec/is/sf/tests/ex26.c
Index of all Device routines
Table of Contents for all manual pages
Index of all manual pages