Actual source code: devicereg.cxx

  1: #include <petsc/private/deviceimpl.h>

  3: const char *const PetscStreamTypes[] = {"global_blocking","default_blocking","global_nonblocking","max","PetscStreamType","PETSC_STREAM_",PETSC_NULLPTR};

  5: const char *const PetscDeviceContextJoinModes[] = {"destroy","sync","no_sync","PetscDeviceContextJoinMode","PETSC_DEVICE_CONTEXT_JOIN_",PETSC_NULLPTR};

  7: static PetscBool PetscDevicePackageInitialized = PETSC_FALSE;

  9: /*@C
 10:   PetscDeviceFinalizePackage - This function cleans up all components of the PetscDevice package.
 11:   It is called from PetscFinalize().

 13:   Developer Notes:
 14:   This function is automatically registered to be called during PetscFinalize() by PetscDeviceInitializePackage() so
 15:   there should be no need to call it yourself.

 17:   Level: developer

 19: .seealso: PetscFinalize(), PetscDeviceInitializePackage()
 20: @*/
 21: PetscErrorCode PetscDeviceFinalizePackage(void)
 22: {
 24:   PetscDevicePackageInitialized = PETSC_FALSE;
 25:   return(0);
 26: }

 28: /*@C
 29:   PetscDeviceInitializePackage - This function initializes everything in the PetscDevice package. It is called from
 30:   PetscDLLibraryRegister_petscsys() when using dynamic libraries, and on the first call to PetscDeviceContextCreate()
 31:   when using shared or static libraries.

 33:   Level: developer

 35: .seealso: PetscInitialize(), PetscDeviceFinalizePackage(), PetscDeviceContextCreate()
 36: @*/
 37: PetscErrorCode PetscDeviceInitializePackage(void)
 38: {

 42:   if (PETSC_DEVICE_DEFAULT == PETSC_DEVICE_INVALID) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP_SYS,"No suitable PetscDeviceKind found, must configure PETSc with a device backend enabled");
 43:   if (PetscDevicePackageInitialized) return(0);
 44:   PetscDevicePackageInitialized = PETSC_TRUE;
 45:   PetscRegisterFinalize(PetscDeviceFinalizePackage);
 46:   return(0);
 47: }