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:   /* Flag non-collective events */
     59:   PetscCall(PetscLogEventSetCollective(PETSCSF_Pack, PETSC_FALSE));
     60:   PetscCall(PetscLogEventSetCollective(PETSCSF_Unpack, PETSC_FALSE));

     62:   /* Process Info */
     63:   {
     64:     PetscClassId classids[1];

     66:     classids[0] = PETSCSF_CLASSID;
     67:     PetscCall(PetscInfoProcessClass("sf", 1, classids));
     68:   }
     69:   /* Process summary exclusions */
     70:   PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt));
     71:   if (opt) {
     72:     PetscCall(PetscStrInList("sf", logList, ',', &pkg));
     73:     if (pkg) PetscCall(PetscLogEventExcludeClass(PETSCSF_CLASSID));
     74:   }
     75:   /* Register package finalizer */
     76:   PetscCall(PetscRegisterFinalize(PetscSFFinalizePackage));
     77:   PetscFunctionReturn(PETSC_SUCCESS);
     78: }

     80: /*@C
     81:   PetscSFFinalizePackage - Finalize `PetscSF` package, it is called from `PetscFinalize()`

     83:   Logically Collective

     85:   Level: developer

     87: .seealso: `PetscSF`, `PetscSFInitializePackage()`
     88: @*/
     89: PetscErrorCode PetscSFFinalizePackage(void)
     90: {
     91:   PetscFunctionBegin;
     92:   PetscCall(PetscFunctionListDestroy(&PetscSFList));
     93:   PetscSFPackageInitialized = PETSC_FALSE;
     94:   PetscSFRegisterAllCalled  = PETSC_FALSE;
     95:   PetscFunctionReturn(PETSC_SUCCESS);
     96: }