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: /* The structure for action logging */
41: #define CREATE 0
42: #define DESTROY 1
43: #define ACTIONBEGIN 2
44: #define ACTIONEND 3
45: typedef struct _Action {
46: int action; /* The type of execution */
47: PetscEvent event; /* The event number */
48: PetscCookie cookie; /* The event class id */
49: PetscLogDouble time; /* The time of occurence */
50: PetscLogDouble flops; /* The cumlative flops */
51: PetscLogDouble mem; /* The current memory usage */
52: PetscLogDouble maxmem; /* The maximum memory usage */
53: int id1, id2, id3; /* The ids of associated objects */
54: } Action;
56: /* The structure for object logging */
57: typedef struct _Object {
58: PetscObject obj; /* The associated PetscObject */
59: int parent; /* The parent id */
60: PetscLogDouble mem; /* The memory associated with the object */
61: char name[64]; /* The object name */
62: char info[64]; /* The information string */
63: } Object;
65: /* Action and object logging variables */
74: /* Global counters */
77: /* A simple stack */
78: struct _n_IntStack {
79: int top; /* The top of the stack */
80: int max; /* The maximum stack size */
81: int *stack; /* The storage */
82: };
84: #ifdef PETSC_USE_LOG
86: /* Runtime functions */
87: EXTERN PetscErrorCode StageLogGetClassRegLog(StageLog, ClassRegLog *);
88: EXTERN PetscErrorCode StageLogGetEventRegLog(StageLog, EventRegLog *);
89: EXTERN PetscErrorCode StageLogGetClassPerfLog(StageLog, int, ClassPerfLog *);
90: EXTERN PetscErrorCode StageLogGetEventPerfLog(StageLog, int, EventPerfLog *);
91: /* Stack Functions */
92: EXTERN PetscErrorCode StackCreate(IntStack *);
93: EXTERN PetscErrorCode StackDestroy(IntStack);
94: EXTERN PetscErrorCode StackPush(IntStack, int);
95: EXTERN PetscErrorCode StackPop(IntStack, int *);
96: EXTERN PetscErrorCode StackTop(IntStack, int *);
97: EXTERN PetscErrorCode StackEmpty(IntStack, PetscTruth *);
99: /* Creation and destruction functions */
100: EXTERN PetscErrorCode EventRegLogCreate(EventRegLog *);
101: EXTERN PetscErrorCode EventRegLogDestroy(EventRegLog);
102: EXTERN PetscErrorCode EventPerfLogCreate(EventPerfLog *);
103: EXTERN PetscErrorCode EventPerfLogDestroy(EventPerfLog);
104: /* General functions */
105: EXTERN PetscErrorCode EventPerfLogEnsureSize(EventPerfLog, int);
106: EXTERN PetscErrorCode EventPerfInfoClear(EventPerfInfo *);
107: EXTERN PetscErrorCode EventPerfInfoCopy(EventPerfInfo *, EventPerfInfo *);
108: /* Registration functions */
109: EXTERN PetscErrorCode EventRegLogRegister(EventRegLog, const char [], PetscCookie, PetscEvent *);
110: /* Query functions */
111: EXTERN PetscErrorCode EventPerfLogSetVisible(EventPerfLog, PetscEvent, PetscTruth);
112: EXTERN PetscErrorCode EventPerfLogGetVisible(EventPerfLog, PetscEvent, PetscTruth *);
113: /* Activaton functions */
114: EXTERN PetscErrorCode EventPerfLogActivate(EventPerfLog, PetscEvent);
115: EXTERN PetscErrorCode EventPerfLogDeactivate(EventPerfLog, PetscEvent);
116: EXTERN PetscErrorCode EventPerfLogActivateClass(EventPerfLog, EventRegLog, PetscCookie);
117: EXTERN PetscErrorCode EventPerfLogDeactivateClass(EventPerfLog, EventRegLog, PetscCookie);
119: /* Logging functions */
127: /* Creation and destruction functions */
128: EXTERN PetscErrorCode ClassRegLogCreate(ClassRegLog *);
129: EXTERN PetscErrorCode ClassRegLogDestroy(ClassRegLog);
130: EXTERN PetscErrorCode ClassPerfLogCreate(ClassPerfLog *);
131: EXTERN PetscErrorCode ClassPerfLogDestroy(ClassPerfLog);
132: EXTERN PetscErrorCode ClassRegInfoDestroy(ClassRegInfo *);
133: /* General functions */
134: EXTERN PetscErrorCode ClassPerfLogEnsureSize(ClassPerfLog, int);
135: EXTERN PetscErrorCode ClassPerfInfoClear(ClassPerfInfo *);
136: /* Registration functions */
137: EXTERN PetscErrorCode ClassRegLogRegister(ClassRegLog, const char [], PetscCookie *);
138: /* Query functions */
139: EXTERN PetscErrorCode ClassRegLogGetClass(ClassRegLog, PetscCookie, int *);
140: /* Logging functions */
141: EXTERN PetscErrorCode PetscLogObjCreateDefault(PetscObject);
142: EXTERN PetscErrorCode PetscLogObjDestroyDefault(PetscObject);
144: #endif /* PETSC_USE_LOG */