Date: 2022-03-04T17:40:02+00:00

Actual source code: logimpl.h

      1: #ifndef PETSC_LOGIMPL_H
      2: #define PETSC_LOGIMPL_H

      4: #include <petsc/private/petscimpl.h>
      5: #include <petsctime.h>

      7: /* A simple stack */
      8: struct _n_PetscIntStack {
      9:   int  top;   /* The top of the stack */
     10:   int  max;   /* The maximum stack size */
     11:   int *stack; /* The storage */
     12: };

     14: /* The structure for action logging */
     15: #define CREATE      0
     16: #define DESTROY     1
     17: #define ACTIONBEGIN 2
     18: #define ACTIONEND   3
     19: typedef struct _Action {
     20:   int            action;        /* The type of execution */
     21:   PetscLogEvent  event;         /* The event number */
     22:   PetscClassId   classid;        /* The event class id */
     23:   PetscLogDouble time;          /* The time of occurence */
     24:   PetscLogDouble flops;         /* The cumlative flops */
     25:   PetscLogDouble mem;           /* The current memory usage */
     26:   PetscLogDouble maxmem;        /* The maximum memory usage */
     27:   int            id1, id2, id3; /* The ids of associated objects */
     28: } Action;

     30: /* The structure for object logging */
     31: typedef struct _Object {
     32:   PetscObject    obj;      /* The associated PetscObject */
     33:   int            parent;   /* The parent id */
     34:   PetscLogDouble mem;      /* The memory associated with the object */
     35:   char           name[64]; /* The object name */
     36:   char           info[64]; /* The information string */
     37: } Object;

     39: /* Action and object logging variables */
     40: PETSC_EXTERN Action    *petsc_actions;
     41: PETSC_EXTERN Object    *petsc_objects;
     42: PETSC_EXTERN PetscBool  petsc_logActions;
     43: PETSC_EXTERN PetscBool  petsc_logObjects;
     44: PETSC_EXTERN int        petsc_numActions;
     45: PETSC_EXTERN int        petsc_maxActions;
     46: PETSC_EXTERN int        petsc_numObjects;
     47: PETSC_EXTERN int        petsc_maxObjects;
     48: PETSC_EXTERN int        petsc_numObjectsDestroyed;

     50: PETSC_EXTERN FILE          *petsc_tracefile;
     51: PETSC_EXTERN int            petsc_tracelevel;
     52: PETSC_EXTERN const char    *petsc_traceblanks;
     53: PETSC_EXTERN char           petsc_tracespace[128];
     54: PETSC_EXTERN PetscLogDouble petsc_tracetime;

     56: #ifdef PETSC_USE_LOG

     58: PETSC_EXTERN PetscErrorCode PetscIntStackCreate(PetscIntStack *);
     59: PETSC_EXTERN PetscErrorCode PetscIntStackDestroy(PetscIntStack);
     60: PETSC_EXTERN PetscErrorCode PetscIntStackPush(PetscIntStack, int);
     61: PETSC_EXTERN PetscErrorCode PetscIntStackPop(PetscIntStack, int *);
     62: PETSC_EXTERN PetscErrorCode PetscIntStackTop(PetscIntStack, int *);
     63: PETSC_EXTERN PetscErrorCode PetscIntStackEmpty(PetscIntStack, PetscBool  *);

     65: /* Creation and destruction functions */
     66: PETSC_EXTERN PetscErrorCode PetscEventRegLogCreate(PetscEventRegLog *);
     67: PETSC_EXTERN PetscErrorCode PetscEventRegLogDestroy(PetscEventRegLog);
     68: PETSC_EXTERN PetscErrorCode PetscEventPerfLogCreate(PetscEventPerfLog *);
     69: PETSC_EXTERN PetscErrorCode PetscEventPerfLogDestroy(PetscEventPerfLog);
     70: /* General functions */
     71: PETSC_EXTERN PetscErrorCode PetscEventPerfLogEnsureSize(PetscEventPerfLog, int);
     72: PETSC_EXTERN PetscErrorCode PetscEventPerfInfoClear(PetscEventPerfInfo *);
     73: PETSC_EXTERN PetscErrorCode PetscEventPerfInfoCopy(PetscEventPerfInfo *, PetscEventPerfInfo *);
     74: /* Registration functions */
     75: PETSC_EXTERN PetscErrorCode PetscEventRegLogRegister(PetscEventRegLog, const char [], PetscClassId, PetscLogEvent *);
     76: /* Query functions */
     77: PETSC_EXTERN PetscErrorCode PetscEventPerfLogSetVisible(PetscEventPerfLog, PetscLogEvent, PetscBool);
     78: PETSC_EXTERN PetscErrorCode PetscEventPerfLogGetVisible(PetscEventPerfLog, PetscLogEvent, PetscBool  *);
     79: /* Activaton functions */
     80: PETSC_EXTERN PetscErrorCode PetscEventPerfLogActivate(PetscEventPerfLog, PetscLogEvent);
     81: PETSC_EXTERN PetscErrorCode PetscEventPerfLogDeactivate(PetscEventPerfLog, PetscLogEvent);
     82: PETSC_EXTERN PetscErrorCode PetscEventPerfLogDeactivatePush(PetscEventPerfLog,PetscLogEvent);
     83: PETSC_EXTERN PetscErrorCode PetscEventPerfLogDeactivatePop(PetscEventPerfLog,PetscLogEvent);
     84: PETSC_EXTERN PetscErrorCode PetscEventPerfLogActivateClass(PetscEventPerfLog, PetscEventRegLog, PetscClassId);
     85: PETSC_EXTERN PetscErrorCode PetscEventPerfLogDeactivateClass(PetscEventPerfLog, PetscEventRegLog, PetscClassId);

     87: /* Logging functions */
     88: PETSC_EXTERN PetscErrorCode PetscLogEventBeginDefault(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
     89: PETSC_EXTERN PetscErrorCode PetscLogEventEndDefault(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
     90: PETSC_EXTERN PetscErrorCode PetscLogEventBeginComplete(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
     91: PETSC_EXTERN PetscErrorCode PetscLogEventEndComplete(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
     92: PETSC_EXTERN PetscErrorCode PetscLogEventBeginTrace(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
     93: PETSC_EXTERN PetscErrorCode PetscLogEventEndTrace(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);

     95: /* Creation and destruction functions */
     96: PETSC_EXTERN PetscErrorCode PetscClassRegLogCreate(PetscClassRegLog *);
     97: PETSC_EXTERN PetscErrorCode PetscClassRegLogDestroy(PetscClassRegLog);
     98: PETSC_EXTERN PetscErrorCode PetscClassPerfLogCreate(PetscClassPerfLog *);
     99: PETSC_EXTERN PetscErrorCode PetscClassPerfLogDestroy(PetscClassPerfLog);
    100: PETSC_EXTERN PetscErrorCode PetscClassRegInfoDestroy(PetscClassRegInfo *);
    101: /* General functions */
    102: PETSC_EXTERN PetscErrorCode PetscClassPerfLogEnsureSize(PetscClassPerfLog, int);
    103: PETSC_EXTERN PetscErrorCode PetscClassPerfInfoClear(PetscClassPerfInfo *);
    104: /* Registration functions */
    105: PETSC_EXTERN PetscErrorCode PetscClassRegLogRegister(PetscClassRegLog, const char [], PetscClassId);
    106: /* Query functions */
    107: PETSC_EXTERN PetscErrorCode PetscClassRegLogGetClass(PetscClassRegLog, PetscClassId, int *);
    108: /* Logging functions */
    109: PETSC_EXTERN PetscErrorCode PetscLogObjCreateDefault(PetscObject);
    110: PETSC_EXTERN PetscErrorCode PetscLogObjDestroyDefault(PetscObject);

    112: /* Creation and destruction functions */
    113: PETSC_EXTERN PetscErrorCode PetscStageLogCreate(PetscStageLog *);
    114: PETSC_EXTERN PetscErrorCode PetscStageLogDestroy(PetscStageLog);
    115: /* Registration functions */
    116: PETSC_EXTERN PetscErrorCode PetscStageLogRegister(PetscStageLog, const char [], int *);
    117: /* Runtime functions */
    118: PETSC_EXTERN PetscErrorCode PetscStageLogPush(PetscStageLog, int);
    119: PETSC_EXTERN PetscErrorCode PetscStageLogPop(PetscStageLog);
    120: PETSC_EXTERN PetscErrorCode PetscStageLogSetActive(PetscStageLog, int, PetscBool);
    121: PETSC_EXTERN PetscErrorCode PetscStageLogGetActive(PetscStageLog, int, PetscBool  *);
    122: PETSC_EXTERN PetscErrorCode PetscStageLogSetVisible(PetscStageLog, int, PetscBool);
    123: PETSC_EXTERN PetscErrorCode PetscStageLogGetVisible(PetscStageLog, int, PetscBool  *);
    124: PETSC_EXTERN PetscErrorCode PetscStageLogGetStage(PetscStageLog, const char [], PetscLogStage *);
    125: PETSC_EXTERN PetscErrorCode PetscStageLogGetClassRegLog(PetscStageLog, PetscClassRegLog *);
    126: PETSC_EXTERN PetscErrorCode PetscStageLogGetEventRegLog(PetscStageLog, PetscEventRegLog *);
    127: PETSC_EXTERN PetscErrorCode PetscStageLogGetClassPerfLog(PetscStageLog, int, PetscClassPerfLog *);

    129: PETSC_EXTERN PetscErrorCode PetscEventRegLogGetEvent(PetscEventRegLog, const char [], PetscLogEvent *);

    131: PETSC_INTERN PetscErrorCode PetscLogView_Nested(PetscViewer);
    132: PETSC_INTERN PetscErrorCode PetscLogNestedEnd(void);
    133: PETSC_INTERN PetscErrorCode PetscLogView_Flamegraph(PetscViewer);
    134: #endif /* PETSC_USE_LOG */
    135: #endif /* PETSC_LOGIMPL_H */