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