Actual source code: logimpl.h

petsc-main 2021-03-02
Report Typos and Errors
  1: #include <petsc/private/petscimpl.h>
  2: #include <petsctime.h>

  4: /* A simple stack */
  5: struct _n_PetscIntStack {
  6:   int  top;   /* The top of the stack */
  7:   int  max;   /* The maximum stack size */
  8:   int *stack; /* The storage */
  9: };

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

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

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

 47: PETSC_EXTERN FILE          *petsc_tracefile;
 48: PETSC_EXTERN int            petsc_tracelevel;
 49: PETSC_EXTERN const char    *petsc_traceblanks;
 50: PETSC_EXTERN char           petsc_tracespace[128];
 51: PETSC_EXTERN PetscLogDouble petsc_tracetime;

 53: #ifdef PETSC_USE_LOG

 55: PETSC_EXTERN PetscErrorCode PetscIntStackCreate(PetscIntStack *);
 56: PETSC_EXTERN PetscErrorCode PetscIntStackDestroy(PetscIntStack);
 57: PETSC_EXTERN PetscErrorCode PetscIntStackPush(PetscIntStack, int);
 58: PETSC_EXTERN PetscErrorCode PetscIntStackPop(PetscIntStack, int *);
 59: PETSC_EXTERN PetscErrorCode PetscIntStackTop(PetscIntStack, int *);
 60: PETSC_EXTERN PetscErrorCode PetscIntStackEmpty(PetscIntStack, PetscBool  *);

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

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

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

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

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

128: PETSC_INTERN PetscErrorCode PetscLogView_Nested(PetscViewer);
129: PETSC_INTERN PetscErrorCode PetscLogNestedEnd(void);
130: #endif /* PETSC_USE_LOG */