Actual source code: plog.h
2: /* The class naming scheme procedes as follows:
4: Event:
5: Events are a class which describes certain blocks of executable
6: code. The corresponding instantiations of events are Actions.
8: Class:
9: Classes are the classes representing Petsc structures. The
10: corresponding instantiations are called Objects.
12: StageLog:
13: This type holds information about stages of computation. These
14: are understood to be chunks encompassing several events, or
15: alternatively, as a covering (possibly nested) of the timeline.
17: StageInfo:
18: The information about each stage. This log contains an
19: EventPerfLog and a ClassPerfLog.
21: EventRegLog:
22: This type holds the information generated for each event as
23: it is registered. This information does not change and thus is
24: stored separately from performance information.
26: EventPerfLog:
27: This type holds the performance information logged for each
28: event. Usually this information is logged for only one stage.
30: ClassRegLog:
31: This type holds the information generated for each class as
32: it is registered. This information does not change and thus is
33: stored separately from performance information.
35: ClassPerfLog:
36: This class holds information describing class/object usage during
37: a run. Usually this information is logged for only one stage.
38: */
40: #include petscsys.h
41: #include petsctime.h
42: #include petsclog.h
44: /* The structure for action logging */
45: #define CREATE 0
46: #define DESTROY 1
47: #define ACTIONBEGIN 2
48: #define ACTIONEND 3
49: typedef struct _Action {
50: int action; /* The type of execution */
51: PetscLogEvent event; /* The event number */
52: PetscCookie cookie; /* The event class id */
53: PetscLogDouble time; /* The time of occurence */
54: PetscLogDouble flops; /* The cumlative flops */
55: PetscLogDouble mem; /* The current memory usage */
56: PetscLogDouble maxmem; /* The maximum memory usage */
57: int id1, id2, id3; /* The ids of associated objects */
58: } Action;
60: /* The structure for object logging */
61: typedef struct _Object {
62: PetscObject obj; /* The associated PetscObject */
63: int parent; /* The parent id */
64: PetscLogDouble mem; /* The memory associated with the object */
65: char name[64]; /* The object name */
66: char info[64]; /* The information string */
67: } Object;
69: /* Action and object logging variables */
78: /* A simple stack */
79: struct _n_IntStack {
80: int top; /* The top of the stack */
81: int max; /* The maximum stack size */
82: int *stack; /* The storage */
83: };
85: #ifdef PETSC_USE_LOG
87: /* Runtime functions */
88: EXTERN PetscErrorCode StageLogGetClassRegLog(StageLog, ClassRegLog *);
89: EXTERN PetscErrorCode StageLogGetEventRegLog(StageLog, EventRegLog *);
90: EXTERN PetscErrorCode StageLogGetClassPerfLog(StageLog, int, ClassPerfLog *);
91: EXTERN PetscErrorCode StageLogGetEventPerfLog(StageLog, int, EventPerfLog *);
92: /* Stack Functions */
93: EXTERN PetscErrorCode StackCreate(IntStack *);
94: EXTERN PetscErrorCode StackDestroy(IntStack);
95: EXTERN PetscErrorCode StackPush(IntStack, int);
96: EXTERN PetscErrorCode StackPop(IntStack, int *);
97: EXTERN PetscErrorCode StackTop(IntStack, int *);
98: EXTERN PetscErrorCode StackEmpty(IntStack, PetscTruth *);
100: /* Creation and destruction functions */
101: EXTERN PetscErrorCode EventRegLogCreate(EventRegLog *);
102: EXTERN PetscErrorCode EventRegLogDestroy(EventRegLog);
103: EXTERN PetscErrorCode EventPerfLogCreate(EventPerfLog *);
104: EXTERN PetscErrorCode EventPerfLogDestroy(EventPerfLog);
105: /* General functions */
106: EXTERN PetscErrorCode EventPerfLogEnsureSize(EventPerfLog, int);
107: EXTERN PetscErrorCode EventPerfInfoClear(EventPerfInfo *);
108: EXTERN PetscErrorCode EventPerfInfoCopy(EventPerfInfo *, EventPerfInfo *);
109: /* Registration functions */
110: EXTERN PetscErrorCode EventRegLogRegister(EventRegLog, const char [], PetscCookie, PetscLogEvent *);
111: /* Query functions */
112: EXTERN PetscErrorCode EventPerfLogSetVisible(EventPerfLog, PetscLogEvent, PetscTruth);
113: EXTERN PetscErrorCode EventPerfLogGetVisible(EventPerfLog, PetscLogEvent, PetscTruth *);
114: /* Activaton functions */
115: EXTERN PetscErrorCode EventPerfLogActivate(EventPerfLog, PetscLogEvent);
116: EXTERN PetscErrorCode EventPerfLogDeactivate(EventPerfLog, PetscLogEvent);
117: EXTERN PetscErrorCode EventPerfLogActivateClass(EventPerfLog, EventRegLog, PetscCookie);
118: EXTERN PetscErrorCode EventPerfLogDeactivateClass(EventPerfLog, EventRegLog, PetscCookie);
120: /* Logging functions */
121: EXTERN PetscErrorCode PetscLogEventBeginDefault(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
122: EXTERN PetscErrorCode PetscLogEventEndDefault(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
123: EXTERN PetscErrorCode PetscLogEventBeginComplete(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
124: EXTERN PetscErrorCode PetscLogEventEndComplete(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
125: EXTERN PetscErrorCode PetscLogEventBeginTrace(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
126: EXTERN PetscErrorCode PetscLogEventEndTrace(PetscLogEvent, int, PetscObject, PetscObject, PetscObject, PetscObject);
128: /* Creation and destruction functions */
129: EXTERN PetscErrorCode ClassRegLogCreate(ClassRegLog *);
130: EXTERN PetscErrorCode ClassRegLogDestroy(ClassRegLog);
131: EXTERN PetscErrorCode ClassPerfLogCreate(ClassPerfLog *);
132: EXTERN PetscErrorCode ClassPerfLogDestroy(ClassPerfLog);
133: EXTERN PetscErrorCode ClassRegInfoDestroy(ClassRegInfo *);
134: /* General functions */
135: EXTERN PetscErrorCode ClassPerfLogEnsureSize(ClassPerfLog, int);
136: EXTERN PetscErrorCode ClassPerfInfoClear(ClassPerfInfo *);
137: /* Registration functions */
138: EXTERN PetscErrorCode ClassRegLogRegister(ClassRegLog, const char [], PetscCookie);
139: /* Query functions */
140: EXTERN PetscErrorCode ClassRegLogGetClass(ClassRegLog, PetscCookie, int *);
141: /* Logging functions */
142: EXTERN PetscErrorCode PetscLogObjCreateDefault(PetscObject);
143: EXTERN PetscErrorCode PetscLogObjDestroyDefault(PetscObject);
145: #endif /* PETSC_USE_LOG */