Actual source code: plog.h

  1: /* $Id: plog.h,v 1.1 2000/01/10 03:28:57 knepley Exp $ */

  3: /* The class naming scheme procedes as follows:

  5:    Event:
  6:      Events are a class which describes certain blocks of executable
  7:      code. The corresponding instantiations of events are Actions.

  9:    Class:
 10:      Classes are the classes representing Petsc structures. The
 11:      corresponding instantiations are called Objects.

 13:    StageLog:
 14:      This type holds information about stages of computation. These
 15:      are understood to be chunks encompassing several events, or
 16:      alternatively, as a covering (possibly nested) of the timeline.

 18:    StageInfo:
 19:      The information about each stage. This log contains an
 20:      EventPerfLog and a ClassPerfLog.

 22:    EventRegLog:
 23:      This type holds the information generated for each event as
 24:      it is registered. This information does not change and thus is
 25:      stored separately from performance information.

 27:    EventPerfLog:
 28:      This type holds the performance information logged for each
 29:      event. Usually this information is logged for only one stage.

 31:    ClassRegLog:
 32:      This type holds the information generated for each class as
 33:      it is registered. This information does not change and thus is
 34:      stored separately from performance information.

 36:    ClassPerfLog:
 37:      This class holds information describing class/object usage during
 38:      a run. Usually this information is logged for only one stage.
 39: */

 41: /* The structure for action logging */
 42: #define CREATE      0
 43: #define DESTROY     1
 44: #define ACTIONBEGIN 2
 45: #define ACTIONEND   3
 46: typedef struct _Action {
 47:   int            action;        /* The type of execution */
 48:   int            event;         /* The event number */
 49:   int            cookie;        /* The event class id */
 50:   PetscLogDouble time;          /* The time of occurence */
 51:   PetscLogDouble flops;         /* The cumlative flops */
 52:   PetscLogDouble mem;           /* The current memory usage */
 53:   PetscLogDouble maxmem;        /* The maximum memory usage */
 54:   int            id1, id2, id3; /* The ids of associated objects */
 55: } Action;

 57: /* The structure for object logging */
 58: typedef struct _Object {
 59:   PetscObject    obj;      /* The associated PetscObject */
 60:   int            parent;   /* The parent id */
 61:   PetscLogDouble mem;      /* The memory associated with the object */
 62:   char           name[64]; /* The object name */
 63:   char           info[64]; /* The information string */
 64: } Object;

 66: /* Action and object logging variables */
 67: extern Action    *actions;
 68: extern Object    *objects;
 69: extern PetscTruth logActions;
 70: extern PetscTruth logObjects;
 71: extern int        numActions, maxActions;
 72: extern int        numObjects, maxObjects;
 73: extern int        numObjectsDestroyed;

 75: /* Global counters */
 76: extern PetscLogDouble BaseTime;

 78: /* A simple stack */
 79: struct _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 int StageLogGetClassRegLog(StageLog, ClassRegLog *);
 89: EXTERN int StageLogGetEventRegLog(StageLog, EventRegLog *);
 90: EXTERN int StageLogGetClassPerfLog(StageLog, int, ClassPerfLog *);
 91: EXTERN int StageLogGetEventPerfLog(StageLog, int, EventPerfLog *);
 92: /* Stack Functions */
 93: EXTERN int StackCreate(IntStack *);
 94: EXTERN int StackDestroy(IntStack);
 95: EXTERN int StackPush(IntStack, int);
 96: EXTERN int StackPop(IntStack, int *);
 97: EXTERN int StackTop(IntStack, int *);
 98: EXTERN int StackEmpty(IntStack, PetscTruth *);

100: /* Creation and destruction functions */
101: EXTERN int EventRegLogCreate(EventRegLog *);
102: EXTERN int EventRegLogDestroy(EventRegLog);
103: EXTERN int EventPerfLogCreate(EventPerfLog *);
104: EXTERN int EventPerfLogDestroy(EventPerfLog);
105: /* General functions */
106: EXTERN int EventPerfLogEnsureSize(EventPerfLog, int);
107: EXTERN int EventPerfInfoClear(EventPerfInfo *);
108: EXTERN int EventPerfInfoCopy(EventPerfInfo *, EventPerfInfo *);
109: /* Registration functions */
110: EXTERN int EventRegLogRegister(EventRegLog, const char [], int, int *);
111: /* Query functions */
112: EXTERN int EventPerfLogSetVisible(EventPerfLog, int, PetscTruth);
113: EXTERN int EventPerfLogGetVisible(EventPerfLog, int, PetscTruth *);
114: EXTERN int EventRegLogGetEvent(EventRegLog, int, int *);
115: /* Activaton functions */
116: EXTERN int EventPerfLogActivate(EventPerfLog, int);
117: EXTERN int EventPerfLogDeactivate(EventPerfLog, int);
118: EXTERN int EventPerfLogActivateClass(EventPerfLog, EventRegLog, int);
119: EXTERN int EventPerfLogDeactivateClass(EventPerfLog, EventRegLog, int);

121: /* Logging functions */
122: EXTERN int PetscLogEventBeginDefault(int, int, PetscObject, PetscObject, PetscObject, PetscObject);
123: EXTERN int PetscLogEventEndDefault(int, int, PetscObject, PetscObject, PetscObject, PetscObject);
124: EXTERN int PetscLogEventBeginComplete(int, int, PetscObject, PetscObject, PetscObject, PetscObject);
125: EXTERN int PetscLogEventEndComplete(int, int, PetscObject, PetscObject, PetscObject, PetscObject);
126: EXTERN int PetscLogEventBeginTrace(int, int, PetscObject, PetscObject, PetscObject, PetscObject);
127: EXTERN int PetscLogEventEndTrace(int, int, PetscObject, PetscObject, PetscObject, PetscObject);

129: /* Creation and destruction functions */
130: EXTERN int ClassRegLogCreate(ClassRegLog *);
131: EXTERN int ClassRegLogDestroy(ClassRegLog);
132: EXTERN int ClassPerfLogCreate(ClassPerfLog *);
133: EXTERN int ClassPerfLogDestroy(ClassPerfLog);
134: EXTERN int ClassRegInfoDestroy(ClassRegInfo *);
135: /* General functions */
136: EXTERN int ClassPerfLogEnsureSize(ClassPerfLog, int);
137: EXTERN int ClassPerfInfoClear(ClassPerfInfo *);
138: /* Registration functions */
139: EXTERN int ClassRegLogRegister(ClassRegLog, const char [], int *);
140: /* Query functions */
141: EXTERN int ClassRegLogGetClass(ClassRegLog, int, int *);
142: /* Logging functions */
143: EXTERN int PetscLogObjCreateDefault(PetscObject);
144: EXTERN int PetscLogObjDestroyDefault(PetscObject);

146: #endif /* PETSC_USE_LOG */