Actual source code: logimpl.h
petsc-3.13.6 2020-09-29
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 PetscEventPerfLogActivateClass(PetscEventPerfLog, PetscEventRegLog, PetscClassId);
80: PETSC_EXTERN PetscErrorCode PetscEventPerfLogDeactivateClass(PetscEventPerfLog, PetscEventRegLog, PetscClassId);
82: /* Logging functions */
83: PETSC_EXTERN PetscErrorCode PetscLogEventBeginDefault(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
84: PETSC_EXTERN PetscErrorCode PetscLogEventEndDefault(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
85: PETSC_EXTERN PetscErrorCode PetscLogEventBeginComplete(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
86: PETSC_EXTERN PetscErrorCode PetscLogEventEndComplete(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
87: PETSC_EXTERN PetscErrorCode PetscLogEventBeginTrace(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
88: PETSC_EXTERN PetscErrorCode PetscLogEventEndTrace(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
90: /* Creation and destruction functions */
91: PETSC_EXTERN PetscErrorCode PetscClassRegLogCreate(PetscClassRegLog *);
92: PETSC_EXTERN PetscErrorCode PetscClassRegLogDestroy(PetscClassRegLog);
93: PETSC_EXTERN PetscErrorCode PetscClassPerfLogCreate(PetscClassPerfLog *);
94: PETSC_EXTERN PetscErrorCode PetscClassPerfLogDestroy(PetscClassPerfLog);
95: PETSC_EXTERN PetscErrorCode PetscClassRegInfoDestroy(PetscClassRegInfo *);
96: /* General functions */
97: PETSC_EXTERN PetscErrorCode PetscClassPerfLogEnsureSize(PetscClassPerfLog, int);
98: PETSC_EXTERN PetscErrorCode PetscClassPerfInfoClear(PetscClassPerfInfo *);
99: /* Registration functions */
100: PETSC_EXTERN PetscErrorCode PetscClassRegLogRegister(PetscClassRegLog, const char [], PetscClassId);
101: /* Query functions */
102: PETSC_EXTERN PetscErrorCode PetscClassRegLogGetClass(PetscClassRegLog, PetscClassId, int *);
103: /* Logging functions */
104: PETSC_EXTERN PetscErrorCode PetscLogObjCreateDefault(PetscObject);
105: PETSC_EXTERN PetscErrorCode PetscLogObjDestroyDefault(PetscObject);
107: /* Creation and destruction functions */
108: PETSC_EXTERN PetscErrorCode PetscStageLogCreate(PetscStageLog *);
109: PETSC_EXTERN PetscErrorCode PetscStageLogDestroy(PetscStageLog);
110: /* Registration functions */
111: PETSC_EXTERN PetscErrorCode PetscStageLogRegister(PetscStageLog, const char [], int *);
112: /* Runtime functions */
113: PETSC_EXTERN PetscErrorCode PetscStageLogPush(PetscStageLog, int);
114: PETSC_EXTERN PetscErrorCode PetscStageLogPop(PetscStageLog);
115: PETSC_EXTERN PetscErrorCode PetscStageLogSetActive(PetscStageLog, int, PetscBool );
116: PETSC_EXTERN PetscErrorCode PetscStageLogGetActive(PetscStageLog, int, PetscBool *);
117: PETSC_EXTERN PetscErrorCode PetscStageLogSetVisible(PetscStageLog, int, PetscBool );
118: PETSC_EXTERN PetscErrorCode PetscStageLogGetVisible(PetscStageLog, int, PetscBool *);
119: PETSC_EXTERN PetscErrorCode PetscStageLogGetStage(PetscStageLog, const char [], PetscLogStage *);
120: PETSC_EXTERN PetscErrorCode PetscStageLogGetClassRegLog(PetscStageLog, PetscClassRegLog *);
121: PETSC_EXTERN PetscErrorCode PetscStageLogGetEventRegLog(PetscStageLog, PetscEventRegLog *);
122: PETSC_EXTERN PetscErrorCode PetscStageLogGetClassPerfLog(PetscStageLog, int, PetscClassPerfLog *);
124: PETSC_EXTERN PetscErrorCode PetscEventRegLogGetEvent(PetscEventRegLog, const char [], PetscLogEvent *);
126: PETSC_INTERN PetscErrorCode PetscLogView_Nested(PetscViewer);
127: PETSC_INTERN PetscErrorCode PetscLogNestedEnd(void);
128: #endif /* PETSC_USE_LOG */