1: #include <petsc/private/deviceimpl.h> 3: static PetscBool PetscDevicePackageInitialized = PETSC_FALSE; 5: /*@C 6: PetscDeviceFinalizePackage - This function cleans up all components of the PetscDevice package. 7: It is called from PetscFinalize(). 9: Developer Notes: 10: This function is automatically registered to be called during PetscFinalize() by 11: PetscDeviceInitializePackage() so there should be no need to call it yourself. 13: Level: developer 15: .seealso: PetscFinalize(), PetscDeviceInitializePackage() 16: @*/ 17: PetscErrorCode PetscDeviceFinalizePackage(void) 18: { 19: PetscDevicePackageInitialized = PETSC_FALSE; 20: return 0; 21: } 23: /*@C 24: PetscDeviceInitializePackage - This function initializes everything in the PetscDevice 25: package. It is called on the first call to PetscDeviceContextCreate() or PetscDeviceCreate() 26: when using shared or static libraries. 28: Level: developer 30: .seealso: PetscInitialize(), PetscDeviceFinalizePackage(), PetscDeviceContextCreate(), PetscDeviceCreate() 31: @*/ 32: PetscErrorCode PetscDeviceInitializePackage(void) 33: { 34: if (PetscLikely(PetscDevicePackageInitialized)) return 0; 36: PetscDevicePackageInitialized = PETSC_TRUE; 37: PetscRegisterFinalize(PetscDeviceFinalizePackage); 38: return 0; 39: }