Actual source code: dlregissf.c
1: #include <petsc/private/sfimpl.h>
3: static PetscBool PetscSFPackageInitialized = PETSC_FALSE;
5: PetscClassId PETSCSF_CLASSID;
7: PetscLogEvent PETSCSF_SetGraph;
8: PetscLogEvent PETSCSF_SetUp;
9: PetscLogEvent PETSCSF_BcastBegin;
10: PetscLogEvent PETSCSF_BcastEnd;
11: PetscLogEvent PETSCSF_ReduceBegin;
12: PetscLogEvent PETSCSF_ReduceEnd;
13: PetscLogEvent PETSCSF_FetchAndOpBegin;
14: PetscLogEvent PETSCSF_FetchAndOpEnd;
15: PetscLogEvent PETSCSF_EmbedSF;
16: PetscLogEvent PETSCSF_DistSect;
17: PetscLogEvent PETSCSF_SectSF;
18: PetscLogEvent PETSCSF_RemoteOff;
19: PetscLogEvent PETSCSF_Pack;
20: PetscLogEvent PETSCSF_Unpack;
22: /*@C
23: PetscSFInitializePackage - Initialize `PetscSF` package
25: Logically Collective
27: Level: developer
29: .seealso: `PetscSF`, `PetscSFFinalizePackage()`
30: @*/
31: PetscErrorCode PetscSFInitializePackage(void)
32: {
33: char logList[256];
34: PetscBool opt, pkg;
36: PetscFunctionBegin;
37: if (PetscSFPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
38: PetscSFPackageInitialized = PETSC_TRUE;
39: /* Register Class */
40: PetscCall(PetscClassIdRegister("Star Forest Graph", &PETSCSF_CLASSID));
41: /* Register Constructors */
42: PetscCall(PetscSFRegisterAll());
43: /* Register Events */
44: PetscCall(PetscLogEventRegister("SFSetGraph", PETSCSF_CLASSID, &PETSCSF_SetGraph));
45: PetscCall(PetscLogEventRegister("SFSetUp", PETSCSF_CLASSID, &PETSCSF_SetUp));
46: PetscCall(PetscLogEventRegister("SFBcastBegin", PETSCSF_CLASSID, &PETSCSF_BcastBegin));
47: PetscCall(PetscLogEventRegister("SFBcastEnd", PETSCSF_CLASSID, &PETSCSF_BcastEnd));
48: PetscCall(PetscLogEventRegister("SFReduceBegin", PETSCSF_CLASSID, &PETSCSF_ReduceBegin));
49: PetscCall(PetscLogEventRegister("SFReduceEnd", PETSCSF_CLASSID, &PETSCSF_ReduceEnd));
50: PetscCall(PetscLogEventRegister("SFFetchOpBegin", PETSCSF_CLASSID, &PETSCSF_FetchAndOpBegin));
51: PetscCall(PetscLogEventRegister("SFFetchOpEnd", PETSCSF_CLASSID, &PETSCSF_FetchAndOpEnd));
52: PetscCall(PetscLogEventRegister("SFCreateEmbed", PETSCSF_CLASSID, &PETSCSF_EmbedSF));
53: PetscCall(PetscLogEventRegister("SFDistSection", PETSCSF_CLASSID, &PETSCSF_DistSect));
54: PetscCall(PetscLogEventRegister("SFSectionSF", PETSCSF_CLASSID, &PETSCSF_SectSF));
55: PetscCall(PetscLogEventRegister("SFRemoteOff", PETSCSF_CLASSID, &PETSCSF_RemoteOff));
56: PetscCall(PetscLogEventRegister("SFPack", PETSCSF_CLASSID, &PETSCSF_Pack));
57: PetscCall(PetscLogEventRegister("SFUnpack", PETSCSF_CLASSID, &PETSCSF_Unpack));
58: /* Process Info */
59: {
60: PetscClassId classids[1];
62: classids[0] = PETSCSF_CLASSID;
63: PetscCall(PetscInfoProcessClass("sf", 1, classids));
64: }
65: /* Process summary exclusions */
66: PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt));
67: if (opt) {
68: PetscCall(PetscStrInList("sf", logList, ',', &pkg));
69: if (pkg) PetscCall(PetscLogEventExcludeClass(PETSCSF_CLASSID));
70: }
71: /* Register package finalizer */
72: PetscCall(PetscRegisterFinalize(PetscSFFinalizePackage));
73: PetscFunctionReturn(PETSC_SUCCESS);
74: }
76: /*@C
77: PetscSFFinalizePackage - Finalize `PetscSF` package, it is called from `PetscFinalize()`
79: Logically Collective
81: Level: developer
83: .seealso: `PetscSF`, `PetscSFInitializePackage()`
84: @*/
85: PetscErrorCode PetscSFFinalizePackage(void)
86: {
87: PetscFunctionBegin;
88: PetscCall(PetscFunctionListDestroy(&PetscSFList));
89: PetscSFPackageInitialized = PETSC_FALSE;
90: PetscSFRegisterAllCalled = PETSC_FALSE;
91: PetscFunctionReturn(PETSC_SUCCESS);
92: }