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