Actual source code: dlregispetsc.c
2: #include <petscdraw.h>
3: #include <petscviewer.h>
4: #include <petsc/private/viewerimpl.h>
6: static PetscBool PetscSysPackageInitialized = PETSC_FALSE;
8: /*@C
9: PetscSysFinalizePackage - This function destroys everything in the system library portion of PETSc.
10: It is called from `PetscFinalize()`.
12: Level: developer
14: .seealso: `PetscSysInitializePackage()`, `PetscFinalize()`
15: @*/
16: PetscErrorCode PetscSysFinalizePackage(void)
17: {
18: PetscFunctionBegin;
19: if (Petsc_Seq_keyval != MPI_KEYVAL_INVALID) PetscCallMPI(MPI_Comm_free_keyval(&Petsc_Seq_keyval));
20: PetscSysPackageInitialized = PETSC_FALSE;
21: PetscFunctionReturn(PETSC_SUCCESS);
22: }
24: /*@C
25: PetscSysInitializePackage - This function initializes everything in the system library portion of PETSc. It is called
26: from `PetscDLLibraryRegister_petsc()` when using dynamic libraries, and in the call to `PetscInitialize()`
27: when using shared or static libraries.
29: Level: developer
31: .seealso: `PetscSysFinalizePackage()`, `PetscInitialize()`
32: @*/
33: PetscErrorCode PetscSysInitializePackage(void)
34: {
35: char logList[256];
36: PetscBool opt, pkg;
38: PetscFunctionBegin;
39: if (PetscSysPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
40: PetscSysPackageInitialized = PETSC_TRUE;
41: /* Register Classes */
42: PetscCall(PetscClassIdRegister("Object", &PETSC_OBJECT_CLASSID));
43: PetscCall(PetscClassIdRegister("Container", &PETSC_CONTAINER_CLASSID));
45: /* Register Events */
46: PetscCall(PetscLogEventRegister("PetscBarrier", PETSC_SMALLEST_CLASSID, &PETSC_Barrier));
47: PetscCall(PetscLogEventRegister("BuildTwoSided", PETSC_SMALLEST_CLASSID, &PETSC_BuildTwoSided));
48: PetscCall(PetscLogEventRegister("BuildTwoSidedF", PETSC_SMALLEST_CLASSID, &PETSC_BuildTwoSidedF));
49: /* Process Info */
50: {
51: PetscClassId classids[1];
53: classids[0] = PETSC_SMALLEST_CLASSID;
54: PetscCall(PetscInfoProcessClass("sys", 1, classids));
55: }
56: /* Process summary exclusions */
57: PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt));
58: if (opt) {
59: PetscCall(PetscStrInList("null", logList, ',', &pkg));
60: if (pkg) PetscCall(PetscLogEventExcludeClass(PETSC_SMALLEST_CLASSID));
61: }
62: PetscCall(PetscRegisterFinalize(PetscSysFinalizePackage));
63: PetscFunctionReturn(PETSC_SUCCESS);
64: }
66: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
68: #if defined(PETSC_USE_SINGLE_LIBRARY)
69: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscvec(void);
70: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscmat(void);
71: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void);
72: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void);
73: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsnes(void);
74: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscts(void);
75: #endif
77: /*
78: PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.
80: This one registers all the system level objects.
82: */
83: #if defined(PETSC_USE_SINGLE_LIBRARY)
84: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petsc(void)
85: #else
86: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsys(void)
87: #endif
88: {
89: PetscFunctionBegin;
90: /*
91: If we got here then PETSc was properly loaded
92: */
93: PetscCall(PetscSysInitializePackage());
94: PetscCall(PetscDrawInitializePackage());
95: PetscCall(PetscViewerInitializePackage());
96: PetscCall(PetscRandomInitializePackage());
98: #if defined(PETSC_USE_SINGLE_LIBRARY)
99: PetscCall(PetscDLLibraryRegister_petscvec());
100: PetscCall(PetscDLLibraryRegister_petscmat());
101: PetscCall(PetscDLLibraryRegister_petscdm());
102: PetscCall(PetscDLLibraryRegister_petscksp());
103: PetscCall(PetscDLLibraryRegister_petscsnes());
104: PetscCall(PetscDLLibraryRegister_petscts());
105: #endif
106: PetscFunctionReturn(PETSC_SUCCESS);
107: }
108: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */