xref: /petsc/include/petsclog.h (revision 7a052e47fbce8e12f90a08d18a07fc827a694db0)
197bb86f7SLois Curfman McInnes /*
27588ac45SBarry Smith     Defines profile/logging in PETSc.
397bb86f7SLois Curfman McInnes */
497bb86f7SLois Curfman McInnes 
5b0a32e0cSBarry Smith #if !defined(__PetscLog_H)
6b0a32e0cSBarry Smith #define __PetscLog_H
7aaa7dc30SBarry Smith #include <petscsys.h>
8958c4211Shannah_mairs #include <petsctime.h>
9c8d78d4dSSatish Balay 
10fa2bb9feSLisandro Dalcin /* General logging of information; different from event logging */
11fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscInfo_Private(const char[],void*,const char[],...);
12fa2bb9feSLisandro Dalcin #if defined(PETSC_USE_INFO)
13fa2bb9feSLisandro Dalcin #define PetscInfo(A,S)                       PetscInfo_Private(PETSC_FUNCTION_NAME,A,S)
14fa2bb9feSLisandro Dalcin #define PetscInfo1(A,S,a1)                   PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1)
15fa2bb9feSLisandro Dalcin #define PetscInfo2(A,S,a1,a2)                PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2)
16fa2bb9feSLisandro Dalcin #define PetscInfo3(A,S,a1,a2,a3)             PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2,a3)
17fa2bb9feSLisandro Dalcin #define PetscInfo4(A,S,a1,a2,a3,a4)          PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2,a3,a4)
18fa2bb9feSLisandro Dalcin #define PetscInfo5(A,S,a1,a2,a3,a4,a5)       PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2,a3,a4,a5)
19fa2bb9feSLisandro Dalcin #define PetscInfo6(A,S,a1,a2,a3,a4,a5,a6)    PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2,a3,a4,a5,a6)
20fa2bb9feSLisandro Dalcin #define PetscInfo7(A,S,a1,a2,a3,a4,a5,a6,a7) PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2,a3,a4,a5,a6,a7)
21fa2bb9feSLisandro Dalcin #else
22fa2bb9feSLisandro Dalcin #define PetscInfo(A,S)                       0
23fa2bb9feSLisandro Dalcin #define PetscInfo1(A,S,a1)                   0
24fa2bb9feSLisandro Dalcin #define PetscInfo2(A,S,a1,a2)                0
25fa2bb9feSLisandro Dalcin #define PetscInfo3(A,S,a1,a2,a3)             0
26fa2bb9feSLisandro Dalcin #define PetscInfo4(A,S,a1,a2,a3,a4)          0
27fa2bb9feSLisandro Dalcin #define PetscInfo5(A,S,a1,a2,a3,a4,a5)       0
28fa2bb9feSLisandro Dalcin #define PetscInfo6(A,S,a1,a2,a3,a4,a5,a6)    0
29fa2bb9feSLisandro Dalcin #define PetscInfo7(A,S,a1,a2,a3,a4,a5,a6,a7) 0
30fa2bb9feSLisandro Dalcin #endif
31fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscInfoDeactivateClass(PetscClassId);
32fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscInfoActivateClass(PetscClassId);
33fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscBool PetscLogPrintInfo;  /* if true, indicates PetscInfo() is turned on */
34fa2bb9feSLisandro Dalcin 
35b859824cSBarry Smith /*MC
36b859824cSBarry Smith     PetscLogEvent - id used to identify PETSc or user events which timed portions (blocks of executable)
37b859824cSBarry Smith      code.
38b859824cSBarry Smith 
39b859824cSBarry Smith     Level: intermediate
40b859824cSBarry Smith 
41b859824cSBarry Smith .seealso: PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd(), PetscLogStage
42b859824cSBarry Smith M*/
43b859824cSBarry Smith typedef int PetscLogEvent;
44b859824cSBarry Smith 
45b859824cSBarry Smith /*MC
46b859824cSBarry Smith     PetscLogStage - id used to identify user stages (phases, sections) of runs - for logging
47b859824cSBarry Smith 
48b859824cSBarry Smith     Level: intermediate
49b859824cSBarry Smith 
50522ce795SJed Brown .seealso: PetscLogStageRegister(), PetscLogStagePush(), PetscLogStagePop(), PetscLogEvent
51b859824cSBarry Smith M*/
52b859824cSBarry Smith typedef int PetscLogStage;
53b859824cSBarry Smith 
548ba1e511SMatthew Knepley #define PETSC_EVENT  1311311
55014dd563SJed Brown PETSC_EXTERN PetscLogEvent PETSC_LARGEST_EVENT;
5697bb86f7SLois Curfman McInnes 
5719b02663SBarry Smith /* Global flop counter */
58014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_TotalFlops;
59014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_tmp_flops;
6019b02663SBarry Smith 
61bec0b493Shannah_mairs /* Global GPU counters */
62bec0b493Shannah_mairs #if defined(PETSC_HAVE_VIENNACL) || defined(PETSC_HAVE_CUDA)
63bec0b493Shannah_mairs PETSC_EXTERN PetscLogDouble petsc_ctog_ct;
64bec0b493Shannah_mairs PETSC_EXTERN PetscLogDouble petsc_gtoc_ct;
65bec0b493Shannah_mairs PETSC_EXTERN PetscLogDouble petsc_ctog_sz;
66bec0b493Shannah_mairs PETSC_EXTERN PetscLogDouble petsc_gtoc_sz;
67958c4211Shannah_mairs PETSC_EXTERN PetscLogDouble petsc_gflops;
68958c4211Shannah_mairs PETSC_EXTERN PetscLogDouble petsc_gtime;
69bec0b493Shannah_mairs #endif
70bec0b493Shannah_mairs 
7131d06abdSBarry Smith /* We must make the following structures available to access the event
7231d06abdSBarry Smith      activation flags in the PetscLogEventBegin/End() macros. These are not part of the PETSc public
7331d06abdSBarry Smith      API and are not intended to be used by other parts of PETSc or by users.
74d49d4b11SBarry Smith 
75fa2bb9feSLisandro Dalcin      The code that manipulates these structures is in src/sys/logging/utils.
7631d06abdSBarry Smith */
77aa213bdcSJed Brown typedef struct _n_PetscIntStack *PetscIntStack;
786a6a9b46SSatish Balay 
79217044c2SLisandro Dalcin /* -----------------------------------------------------------------------------------------------------*/
80c60ec953SBarry Smith /*
81aa213bdcSJed Brown     PetscClassRegInfo, PetscClassPerfInfo - Each class has two data structures associated with it. The first has
82c60ec953SBarry Smith        static information about it, the second collects statistics on how many objects of the class are created,
83c60ec953SBarry Smith        how much memory they use, etc.
84c60ec953SBarry Smith 
85aa213bdcSJed Brown     PetscClassRegLog, PetscClassPerfLog - arrays of the PetscClassRegInfo and PetscClassPerfInfo for all classes.
86c60ec953SBarry Smith */
876a6a9b46SSatish Balay typedef struct  {
88c60ec953SBarry Smith   char           *name;   /* The class name */
89c60ec953SBarry Smith   PetscClassId   classid; /* The integer identifying this class */
90aa213bdcSJed Brown } PetscClassRegInfo;
916a6a9b46SSatish Balay 
926a6a9b46SSatish Balay typedef struct {
930700a824SBarry Smith   PetscClassId   id;           /* The integer identifying this class */
946a6a9b46SSatish Balay   int            creations;    /* The number of objects of this class created */
956a6a9b46SSatish Balay   int            destructions; /* The number of objects of this class destroyed */
966a6a9b46SSatish Balay   PetscLogDouble mem;          /* The total memory allocated by objects of this class */
976a6a9b46SSatish Balay   PetscLogDouble descMem;      /* The total memory allocated by descendents of these objects */
98aa213bdcSJed Brown } PetscClassPerfInfo;
996a6a9b46SSatish Balay 
100aa213bdcSJed Brown typedef struct _n_PetscClassRegLog *PetscClassRegLog;
101aa213bdcSJed Brown struct _n_PetscClassRegLog {
102c60ec953SBarry Smith   int               numClasses; /* The number of classes registered */
103c60ec953SBarry Smith   int               maxClasses; /* The maximum number of classes */
104aa213bdcSJed Brown   PetscClassRegInfo *classInfo; /* The structure for class information (classids are monotonicly increasing) */
105c60ec953SBarry Smith };
1066a6a9b46SSatish Balay 
107aa213bdcSJed Brown typedef struct _n_PetscClassPerfLog *PetscClassPerfLog;
108aa213bdcSJed Brown struct _n_PetscClassPerfLog {
109c60ec953SBarry Smith   int                numClasses; /* The number of logging classes */
110c60ec953SBarry Smith   int                maxClasses; /* The maximum number of classes */
111aa213bdcSJed Brown   PetscClassPerfInfo *classInfo; /* The structure for class information (classids are monotonicly increasing) */
112c60ec953SBarry Smith };
113c60ec953SBarry Smith /* -----------------------------------------------------------------------------------------------------*/
114c60ec953SBarry Smith /*
115aa213bdcSJed Brown     PetscEventRegInfo, PetscEventPerfInfo - Each event has two data structures associated with it. The first has
116c60ec953SBarry Smith        static information about it, the second collects statistics on how many times the event is used, how
117c60ec953SBarry Smith        much time it takes, etc.
118c60ec953SBarry Smith 
119aa213bdcSJed Brown     PetscEventRegLog, PetscEventPerfLog - an array of all PetscEventRegInfo and PetscEventPerfInfo for all events. There is one
120c60ec953SBarry Smith       of these for each stage.
121c60ec953SBarry Smith 
122c60ec953SBarry Smith */
1236a6a9b46SSatish Balay typedef struct {
1246a6a9b46SSatish Balay   char         *name;         /* The name of this event */
125c60ec953SBarry Smith   PetscClassId classid;       /* The class the event is associated with */
126217044c2SLisandro Dalcin   PetscBool    collective;    /* Flag this event as collective */
1276a6a9b46SSatish Balay #if defined (PETSC_HAVE_MPE)
1286a6a9b46SSatish Balay   int          mpe_id_begin;  /* MPE IDs that define the event */
1296a6a9b46SSatish Balay   int          mpe_id_end;
1306a6a9b46SSatish Balay #endif
131aa213bdcSJed Brown } PetscEventRegInfo;
1326a6a9b46SSatish Balay 
133c60ec953SBarry Smith typedef struct {
134c60ec953SBarry Smith   int            id;            /* The integer identifying this event */
135ace3abfcSBarry Smith   PetscBool      active;        /* The flag to activate logging */
136ace3abfcSBarry Smith   PetscBool      visible;       /* The flag to print info in summary */
137c60ec953SBarry Smith   int            depth;         /* The nesting depth of the event call */
138c60ec953SBarry Smith   int            count;         /* The number of times this event was executed */
139a42e5b54SMatthew G Knepley   PetscLogDouble flops, flops2, flopsTmp; /* The flops and flops^2 used in this event */
140a42e5b54SMatthew G Knepley   PetscLogDouble time, time2, timeTmp;    /* The time and time^2 taken for this event */
141217044c2SLisandro Dalcin   PetscLogDouble syncTime;                /* The synchronization barrier time */
142891e75beSMatthew G. Knepley   PetscLogDouble dof[8];        /* The number of degrees of freedom associated with this event */
1435d68e14cSMatthew G. Knepley   PetscLogDouble errors[8];     /* The errors (user-defined) associated with this event */
144c60ec953SBarry Smith   PetscLogDouble numMessages;   /* The number of messages in this event */
145c60ec953SBarry Smith   PetscLogDouble messageLength; /* The total message lengths in this event */
146c60ec953SBarry Smith   PetscLogDouble numReductions; /* The number of reductions in this event */
147e3ed9ee7SBarry Smith   PetscLogDouble memIncrease;   /* How much the resident memory has increased in this event */
148e3ed9ee7SBarry Smith   PetscLogDouble mallocIncrease;/* How much the maximum malloced space has increased in this event */
149e3ed9ee7SBarry Smith   PetscLogDouble mallocSpace;   /* How much the space was malloced and kept during this event */
150e3ed9ee7SBarry Smith   PetscLogDouble mallocIncreaseEvent;  /* Maximum of the high water mark with in event minus memory available at the end of the event */
151bec0b493Shannah_mairs   #if defined(PETSC_HAVE_VIENNACL) || defined(PETSC_HAVE_CUDA)
152bec0b493Shannah_mairs   PetscLogDouble CpuToGpuCount; /* The total number of CPU to GPU copies */
153bec0b493Shannah_mairs   PetscLogDouble GpuToCpuCount; /* The total number of GPU to CPU copies */
154bec0b493Shannah_mairs   PetscLogDouble CpuToGpuSize;  /* The total size of CPU to GPU copies */
155bec0b493Shannah_mairs   PetscLogDouble GpuToCpuSize;  /* The total size of GPU to CPU copies */
156958c4211Shannah_mairs   PetscLogDouble GpuFlops;      /* The flops done on a GPU in this event */
157958c4211Shannah_mairs   PetscLogDouble GpuTime;       /* The time spent on a GPU in this event */
158bec0b493Shannah_mairs   #endif
159aa213bdcSJed Brown } PetscEventPerfInfo;
160c60ec953SBarry Smith 
161aa213bdcSJed Brown typedef struct _n_PetscEventRegLog *PetscEventRegLog;
162aa213bdcSJed Brown struct _n_PetscEventRegLog {
1636a6a9b46SSatish Balay   int               numEvents;  /* The number of registered events */
1646a6a9b46SSatish Balay   int               maxEvents;  /* The maximum number of events */
165aa213bdcSJed Brown   PetscEventRegInfo *eventInfo; /* The registration information for each event */
1666a6a9b46SSatish Balay };
1676a6a9b46SSatish Balay 
168aa213bdcSJed Brown typedef struct _n_PetscEventPerfLog *PetscEventPerfLog;
169aa213bdcSJed Brown struct _n_PetscEventPerfLog {
1706a6a9b46SSatish Balay   int                numEvents;  /* The number of logging events */
1716a6a9b46SSatish Balay   int                maxEvents;  /* The maximum number of events */
172aa213bdcSJed Brown   PetscEventPerfInfo *eventInfo; /* The performance information for each event */
1736a6a9b46SSatish Balay };
174c60ec953SBarry Smith /* ------------------------------------------------------------------------------------------------------------*/
175c60ec953SBarry Smith /*
176aa213bdcSJed Brown    PetscStageInfo - Contains all the information about a particular stage.
1776a6a9b46SSatish Balay 
178aa213bdcSJed Brown    PetscStageLog - An array of PetscStageInfo for each registered stage. There is a single one of these in the code.
179c60ec953SBarry Smith */
180aa213bdcSJed Brown typedef struct _PetscStageInfo {
1816a6a9b46SSatish Balay   char               *name;     /* The stage name */
182ace3abfcSBarry Smith   PetscBool          used;      /* The stage was pushed on this processor */
183aa213bdcSJed Brown   PetscEventPerfInfo perfInfo;  /* The stage performance information */
184aa213bdcSJed Brown   PetscEventPerfLog  eventLog;  /* The event information for this stage */
185aa213bdcSJed Brown   PetscClassPerfLog  classLog;  /* The class information for this stage */
186aa213bdcSJed Brown } PetscStageInfo;
1876a6a9b46SSatish Balay 
188aa213bdcSJed Brown typedef struct _n_PetscStageLog *PetscStageLog;
189aa213bdcSJed Brown struct _n_PetscStageLog {
1906a6a9b46SSatish Balay   int              numStages;   /* The number of registered stages */
1916a6a9b46SSatish Balay   int              maxStages;   /* The maximum number of stages */
192aa213bdcSJed Brown   PetscIntStack    stack;       /* The stack for active stages */
193aa213bdcSJed Brown   int              curStage;    /* The current stage (only used in macros so we don't call PetscIntStackTop) */
194aa213bdcSJed Brown   PetscStageInfo   *stageInfo;  /* The information for each stage */
195aa213bdcSJed Brown   PetscEventRegLog eventLog;    /* The registered events */
196aa213bdcSJed Brown   PetscClassRegLog classLog;    /* The registered classes */
1976a6a9b46SSatish Balay };
198217044c2SLisandro Dalcin /* -----------------------------------------------------------------------------------------------------*/
199fee518ebSJed Brown 
2003bb1ff40SBarry Smith PETSC_EXTERN PetscErrorCode PetscLogObjectParent(PetscObject,PetscObject);
2013bb1ff40SBarry Smith PETSC_EXTERN PetscErrorCode PetscLogObjectMemory(PetscObject,PetscLogDouble);
2023bb1ff40SBarry Smith 
203aa482453SBarry Smith #if defined(PETSC_USE_LOG)  /* --- Logging is turned on --------------------------------*/
204aeeda9f6SJohn Fettig PETSC_EXTERN PetscStageLog petsc_stageLog;
205f5d6ab90SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogGetStageLog(PetscStageLog*);
206f5d6ab90SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscStageLogGetCurrent(PetscStageLog,int*);
207f5d6ab90SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscStageLogGetEventPerfLog(PetscStageLog,int,PetscEventPerfLog*);
208614700edSBarry Smith 
209da63de55SLois Curfman McInnes /*
210da63de55SLois Curfman McInnes    Flop counting:  We count each arithmetic operation (e.g., addition, multiplication) separately.
211da63de55SLois Curfman McInnes 
212da63de55SLois Curfman McInnes    For the complex numbers version, note that
213da63de55SLois Curfman McInnes        1 complex addition = 2 flops
214da63de55SLois Curfman McInnes        1 complex multiplication = 6 flops,
215da63de55SLois Curfman McInnes    where we define 1 flop as that for a double precision scalar.  We roughly approximate
216da63de55SLois Curfman McInnes    flop counting for complex numbers by multiplying the total flops by 4; this corresponds
217da63de55SLois Curfman McInnes    to the assumption that we're counting mostly additions and multiplications -- and
218da63de55SLois Curfman McInnes    roughly the same number of each.  More accurate counting could be done by distinguishing
219da63de55SLois Curfman McInnes    among the various arithmetic operations.
220da63de55SLois Curfman McInnes  */
221da63de55SLois Curfman McInnes 
222aa482453SBarry Smith #if defined(PETSC_USE_COMPLEX)
223542d4b3fSSatish Balay #define PETSC_FLOPS_PER_OP 4.0
224da63de55SLois Curfman McInnes #else
225542d4b3fSSatish Balay #define PETSC_FLOPS_PER_OP 1.0
226bf3909cdSBarry Smith #endif
227bf3909cdSBarry Smith 
228dd19b90bSBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscLogFlops(PetscLogDouble n)
229dd19b90bSBarry Smith {
230dd19b90bSBarry Smith   PetscFunctionBegin;
231bf3909cdSBarry Smith #if defined(PETSC_USE_DEBUG)
232dd19b90bSBarry Smith   if (n < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Cannot log negative flops");
233da63de55SLois Curfman McInnes #endif
234dd19b90bSBarry Smith   petsc_TotalFlops += PETSC_FLOPS_PER_OP*n;
235dd19b90bSBarry Smith   PetscFunctionReturn(0);
236dd19b90bSBarry Smith }
237fa2bb9feSLisandro Dalcin 
238bec0b493Shannah_mairs #if defined(PETSC_HAVE_VIENNACL) || defined(PETSC_HAVE_CUDA)
239bec0b493Shannah_mairs PETSC_STATIC_INLINE PetscErrorCode PetscLogCpuToGpu(PetscLogDouble size){
240958c4211Shannah_mairs   PetscFunctionBegin;
241bec0b493Shannah_mairs   petsc_ctog_ct += 1;
242bec0b493Shannah_mairs   petsc_ctog_sz += size;
243bec0b493Shannah_mairs   PetscFunctionReturn(0);
244bec0b493Shannah_mairs }
245bec0b493Shannah_mairs PETSC_STATIC_INLINE PetscErrorCode PetscLogGpuToCpu(PetscLogDouble size){
246958c4211Shannah_mairs   PetscFunctionBegin;
247bec0b493Shannah_mairs   petsc_gtoc_ct += 1;
248bec0b493Shannah_mairs   petsc_gtoc_sz += size;
249bec0b493Shannah_mairs   PetscFunctionReturn(0);
250bec0b493Shannah_mairs }
251958c4211Shannah_mairs PETSC_STATIC_INLINE PetscErrorCode PetscLogGpuFlops(PetscLogDouble n){
252958c4211Shannah_mairs   PetscFunctionBegin;
253958c4211Shannah_mairs #if defined(PETSC_USE_DEBUG)
254958c4211Shannah_mairs   if (n < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Cannot log negative flops");
255958c4211Shannah_mairs #endif
256958c4211Shannah_mairs   petsc_TotalFlops += PETSC_FLOPS_PER_OP*n;
257958c4211Shannah_mairs   petsc_gflops += PETSC_FLOPS_PER_OP*n;
258958c4211Shannah_mairs   PetscFunctionReturn(0);
259958c4211Shannah_mairs }
260*7a052e47Shannah_mairs PETSC_STATIC_INLINE PetscErrorCode PetscLogGpuTimeBegin(){
261958c4211Shannah_mairs   PetscErrorCode ierr;
262958c4211Shannah_mairs   PetscFunctionBegin;
263958c4211Shannah_mairs   ierr = PetscTimeSubtract(&petsc_gtime);CHKERRQ(ierr);
264958c4211Shannah_mairs   PetscFunctionReturn(0);
265958c4211Shannah_mairs }
266958c4211Shannah_mairs PETSC_STATIC_INLINE PetscErrorCode PetscLogGpuTimeEnd(){
267958c4211Shannah_mairs   PetscErrorCode ierr;
268958c4211Shannah_mairs   PetscFunctionBegin;
269958c4211Shannah_mairs   ierr = PetscTimeAdd(&petsc_gtime);CHKERRQ(ierr);
270958c4211Shannah_mairs   PetscFunctionReturn(0);
271958c4211Shannah_mairs }
272bec0b493Shannah_mairs #endif
273bec0b493Shannah_mairs 
274fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscGetFlops(PetscLogDouble *);
27577c4ece6SBarry Smith 
276aa482453SBarry Smith #if defined (PETSC_HAVE_MPE)
277014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogMPEBegin(void);
278014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogMPEDump(const char[]);
27977c4ece6SBarry Smith #endif
28077c4ece6SBarry Smith 
281014dd563SJed Brown PETSC_EXTERN PetscErrorCode (*PetscLogPLB)(PetscLogEvent,int,PetscObject,PetscObject,PetscObject,PetscObject);
282014dd563SJed Brown PETSC_EXTERN PetscErrorCode (*PetscLogPLE)(PetscLogEvent,int,PetscObject,PetscObject,PetscObject,PetscObject);
283014dd563SJed Brown PETSC_EXTERN PetscErrorCode (*PetscLogPHC)(PetscObject);
284014dd563SJed Brown PETSC_EXTERN PetscErrorCode (*PetscLogPHD)(PetscObject);
28577c4ece6SBarry Smith 
286e83a5d19SLisandro Dalcin #define PetscLogObjectParents(p,n,d)  0;do{int _i; for (_i=0; _i<(n); _i++) {ierr = PetscLogObjectParent((PetscObject)(p),(PetscObject)(d)[_i]);CHKERRQ(ierr);}}while(0)
287fa2bb9feSLisandro Dalcin #define PetscLogObjectCreate(h)      ((PetscLogPHC) ? (*PetscLogPHC)((PetscObject)(h)) : 0)
288fa2bb9feSLisandro Dalcin #define PetscLogObjectDestroy(h)     ((PetscLogPHD) ? (*PetscLogPHD)((PetscObject)(h)) : 0)
289fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogObjectState(PetscObject, const char[], ...);
290fa2bb9feSLisandro Dalcin 
2918ba1e511SMatthew Knepley /* Initialization functions */
292bb1d7374SBarry Smith PETSC_EXTERN PetscErrorCode PetscLogDefaultBegin(void);
293014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogAllBegin(void);
294bb1d7374SBarry Smith PETSC_EXTERN PetscErrorCode PetscLogNestedBegin(void);
295014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogTraceBegin(FILE *);
296014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogActions(PetscBool);
297014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogObjects(PetscBool);
298fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogSetThreshold(PetscLogDouble,PetscLogDouble*);
299014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogSet(PetscErrorCode (*)(int, int, PetscObject, PetscObject, PetscObject, PetscObject),
3006849ba73SBarry Smith                                         PetscErrorCode (*)(int, int, PetscObject, PetscObject, PetscObject, PetscObject));
301fa2bb9feSLisandro Dalcin 
3028ba1e511SMatthew Knepley /* Output functions */
303014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogView(PetscViewer);
304f14045dbSBarry Smith PETSC_EXTERN PetscErrorCode PetscLogViewFromOptions(void);
305014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogDump(const char[]);
30631d06abdSBarry Smith 
307fa2bb9feSLisandro Dalcin /* Stage functions */
308014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStageRegister(const char[],PetscLogStage*);
309014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStagePush(PetscLogStage);
310014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStagePop(void);
311014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStageSetActive(PetscLogStage,PetscBool);
312014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStageGetActive(PetscLogStage,PetscBool*);
313014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStageSetVisible(PetscLogStage,PetscBool);
314014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStageGetVisible(PetscLogStage,PetscBool*);
315014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStageGetId(const char[],PetscLogStage*);
316f5d6ab90SLisandro Dalcin 
3178ba1e511SMatthew Knepley /* Event functions */
318014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventRegister(const char[],PetscClassId,PetscLogEvent*);
319217044c2SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogEventSetCollective(PetscLogEvent,PetscBool);
320fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogEventIncludeClass(PetscClassId);
321fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogEventExcludeClass(PetscClassId);
322014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventActivate(PetscLogEvent);
323014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventDeactivate(PetscLogEvent);
324014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventSetActiveAll(PetscLogEvent,PetscBool);
325014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventActivateClass(PetscClassId);
326014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventDeactivateClass(PetscClassId);
3278c49a8d9SBarry Smith PETSC_EXTERN PetscErrorCode PetscLogEventGetId(const char[],PetscLogEvent*);
32813230571SMichael Lange PETSC_EXTERN PetscErrorCode PetscLogEventGetPerfInfo(int,PetscLogEvent,PetscEventPerfInfo*);
329891e75beSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLogEventSetDof(PetscLogEvent, PetscInt, PetscLogDouble);
3305d68e14cSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLogEventSetError(PetscLogEvent, PetscInt, PetscLogDouble);
3318ba1e511SMatthew Knepley 
3328ba1e511SMatthew Knepley /* Global counters */
333014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_irecv_ct;
334014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_isend_ct;
335014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_recv_ct;
336014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_send_ct;
337014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_irecv_len;
338014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_isend_len;
339014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_recv_len;
340014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_send_len;
341014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_allreduce_ct;
342014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_gather_ct;
343014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_scatter_ct;
344014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_wait_ct;
345014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_wait_any_ct;
346014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_wait_all_ct;
347014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_sum_of_waits_ct;
3488ba1e511SMatthew Knepley 
349e3ed9ee7SBarry Smith PETSC_EXTERN PetscBool      PetscLogMemory;
350e3ed9ee7SBarry Smith 
351fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscBool PetscLogSyncOn;  /* true if logging synchronization is enabled */
35262872c28SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogEventSynchronize(PetscLogEvent, MPI_Comm);
35362872c28SLisandro Dalcin 
35462872c28SLisandro Dalcin #define PetscLogEventSync(e,comm) \
35562872c28SLisandro Dalcin   (((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog->curStage].perfInfo.active && petsc_stageLog->stageInfo[petsc_stageLog->curStage].eventLog->eventInfo[e].active) ? \
35662872c28SLisandro Dalcin     PetscLogEventSynchronize((e),(comm)) : 0 ))
35777c4ece6SBarry Smith 
35852e6d16bSBarry Smith #define PetscLogEventBegin(e,o1,o2,o3,o4) \
3598b5db460SBarry Smith   (((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog->curStage].perfInfo.active && petsc_stageLog->stageInfo[petsc_stageLog->curStage].eventLog->eventInfo[e].active) ? \
360495fc317SBarry Smith     (*PetscLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4)) : 0 ))
361043328b6SSatish Balay 
36252e6d16bSBarry Smith #define PetscLogEventEnd(e,o1,o2,o3,o4) \
3638b5db460SBarry Smith   (((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog->curStage].perfInfo.active && petsc_stageLog->stageInfo[petsc_stageLog->curStage].eventLog->eventInfo[e].active) ? \
364495fc317SBarry Smith     (*PetscLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4)) : 0 ))
36577c4ece6SBarry Smith 
366014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventGetFlops(PetscLogEvent,PetscLogDouble*);
367014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventZeroFlops(PetscLogEvent);
368003131ecSBarry Smith 
369ce85283eSBarry Smith /*
370f621e05eSBarry Smith      These are used internally in the PETSc routines to keep a count of MPI messages and
371f621e05eSBarry Smith    their sizes.
372f621e05eSBarry Smith 
373af0996ceSBarry Smith      This does not work for MPI-Uni because our include/petsc/mpiuni/mpi.h file
374ce85283eSBarry Smith    uses macros to defined the MPI operations.
37515308354SBarry Smith 
37615308354SBarry Smith      It does not work correctly from HP-UX because it processes the
377bb4af37aSBarry Smith    macros in a way that sometimes it double counts, hence
378b6410449SSatish Balay    PETSC_HAVE_BROKEN_RECURSIVE_MACRO
3797c1e34a4SSatish Balay 
380f569fd43SBarry Smith      It does not work with Windows because winmpich lacks MPI_Type_size()
381ce85283eSBarry Smith */
382c8217ed5SSatish Balay #if !defined(__MPIUNI_H) && !defined(PETSC_HAVE_BROKEN_RECURSIVE_MACRO) && !defined (PETSC_HAVE_MPI_MISSING_TYPESIZE)
38377a39924SBarry Smith /*
38477a39924SBarry Smith    Logging of MPI activities
38577a39924SBarry Smith */
386ad39c06fSJed Brown PETSC_STATIC_INLINE PetscErrorCode PetscMPITypeSize(PetscLogDouble *buff,PetscMPIInt count,MPI_Datatype type)
387f95db71bSBarry Smith {
3887d30fa4aSBarry Smith   PetscMPIInt mysize;
3899c72ff1eSSatish Balay   PetscErrorCode _myierr;
3907d30fa4aSBarry Smith   if (type == MPI_DATATYPE_NULL) return 0;
3919c72ff1eSSatish Balay   _myierr = MPI_Type_size(type,&mysize);CHKERRQ(_myierr);
3929c72ff1eSSatish Balay   *buff += (PetscLogDouble) (count*mysize);
3939c72ff1eSSatish Balay   return 0;
394f95db71bSBarry Smith }
39577a39924SBarry Smith 
396ad39c06fSJed Brown PETSC_STATIC_INLINE PetscErrorCode PetscMPITypeSizeComm(MPI_Comm comm, PetscLogDouble *buff,PetscMPIInt *counts,MPI_Datatype type)
3973b9284c0SMatthew G Knepley {
3983b9284c0SMatthew G Knepley   PetscMPIInt mysize, commsize, p;
3993b9284c0SMatthew G Knepley   PetscErrorCode _myierr;
4003b9284c0SMatthew G Knepley 
4017d30fa4aSBarry Smith   if (type == MPI_DATATYPE_NULL) return 0;
4023b9284c0SMatthew G Knepley   _myierr = MPI_Comm_size(comm,&commsize);CHKERRQ(_myierr);
4033b9284c0SMatthew G Knepley   _myierr = MPI_Type_size(type,&mysize);CHKERRQ(_myierr);
4043b9284c0SMatthew G Knepley   for (p = 0; p < commsize; ++p) {
4053b9284c0SMatthew G Knepley     *buff += (PetscLogDouble) (counts[p]*mysize);
4063b9284c0SMatthew G Knepley   }
4073b9284c0SMatthew G Knepley   return 0;
4083b9284c0SMatthew G Knepley }
4093b9284c0SMatthew G Knepley 
41072b11a25SBarry Smith /*
41172b11a25SBarry Smith     Returns 1 if the communicator is parallel else zero
41272b11a25SBarry Smith */
41372b11a25SBarry Smith PETSC_STATIC_INLINE int PetscMPIParallelComm(MPI_Comm comm)
41472b11a25SBarry Smith {
41572b11a25SBarry Smith   PetscMPIInt size; MPI_Comm_size(comm,&size); return size > 1;
41672b11a25SBarry Smith }
41772b11a25SBarry Smith 
41877a39924SBarry Smith #define MPI_Irecv(buf,count,datatype,source,tag,comm,request) \
4195fa69175SJed Brown   ((petsc_irecv_ct++,0) || PetscMPITypeSize(&(petsc_irecv_len),(count),(datatype)) || MPI_Irecv((buf),(count),(datatype),(source),(tag),(comm),(request)))
42015308354SBarry Smith 
42177a39924SBarry Smith #define MPI_Isend(buf,count,datatype,dest,tag,comm,request) \
4225fa69175SJed Brown   ((petsc_isend_ct++,0) || PetscMPITypeSize(&(petsc_isend_len),(count),(datatype)) || MPI_Isend((buf),(count),(datatype),(dest),(tag),(comm),(request)))
42315308354SBarry Smith 
424457b14b1SJunchao Zhang #define MPI_Startall_irecv(count,datatype,number,requests) \
425ea1c87f7SJunchao Zhang   ((petsc_irecv_ct += (PetscLogDouble)(number),0) || PetscMPITypeSize(&(petsc_irecv_len),(count),(datatype)) || ((number) && MPI_Startall((number),(requests))))
4260d4b0b6cSBarry Smith 
427457b14b1SJunchao Zhang #define MPI_Startall_isend(count,datatype,number,requests) \
428ea1c87f7SJunchao Zhang   ((petsc_isend_ct += (PetscLogDouble)(number),0) || PetscMPITypeSize(&(petsc_isend_len),(count),(datatype)) || ((number) && MPI_Startall((number),(requests))))
4290d4b0b6cSBarry Smith 
430457b14b1SJunchao Zhang #define MPI_Start_isend(count,datatype,requests) \
431457b14b1SJunchao Zhang   ((petsc_isend_ct++,0) || PetscMPITypeSize((&petsc_isend_len),(count),(datatype)) || MPI_Start((requests)))
4320d4b0b6cSBarry Smith 
433ce85283eSBarry Smith #define MPI_Recv(buf,count,datatype,source,tag,comm,status) \
4345fa69175SJed Brown   ((petsc_recv_ct++,0) || PetscMPITypeSize((&petsc_recv_len),(count),(datatype)) || MPI_Recv((buf),(count),(datatype),(source),(tag),(comm),(status)))
43515308354SBarry Smith 
43677a39924SBarry Smith #define MPI_Send(buf,count,datatype,dest,tag,comm) \
4375fa69175SJed Brown   ((petsc_send_ct++,0) || PetscMPITypeSize((&petsc_send_len),(count),(datatype)) || MPI_Send((buf),(count),(datatype),(dest),(tag),(comm)))
43877a39924SBarry Smith 
43977a39924SBarry Smith #define MPI_Wait(request,status) \
4405fa69175SJed Brown   ((petsc_wait_ct++,petsc_sum_of_waits_ct++,0) || MPI_Wait((request),(status)))
44177a39924SBarry Smith 
44277a39924SBarry Smith #define MPI_Waitany(a,b,c,d) \
4435fa69175SJed Brown   ((petsc_wait_any_ct++,petsc_sum_of_waits_ct++,0) || MPI_Waitany((a),(b),(c),(d)))
44477a39924SBarry Smith 
44577a39924SBarry Smith #define MPI_Waitall(count,array_of_requests,array_of_statuses) \
4465fa69175SJed Brown   ((petsc_wait_all_ct++,petsc_sum_of_waits_ct += (PetscLogDouble) (count),0) || MPI_Waitall((count),(array_of_requests),(array_of_statuses)))
44777a39924SBarry Smith 
44877a39924SBarry Smith #define MPI_Allreduce(sendbuf,recvbuf,count,datatype,op,comm) \
4495fa69175SJed Brown   ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Allreduce((sendbuf),(recvbuf),(count),(datatype),(op),(comm)))
4503914022bSBarry Smith 
45154fe5c21SBarry Smith #define MPI_Bcast(buffer,count,datatype,root,comm) \
4525fa69175SJed Brown   ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Bcast((buffer),(count),(datatype),(root),(comm)))
45354fe5c21SBarry Smith 
454d6e4c47cSJed Brown #define MPI_Reduce_scatter_block(sendbuf,recvbuf,recvcount,datatype,op,comm) \
4555fa69175SJed Brown   ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Reduce_scatter_block((sendbuf),(recvbuf),(recvcount),(datatype),(op),(comm)))
456d6e4c47cSJed Brown 
4573b9284c0SMatthew G Knepley #define MPI_Alltoall(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype,comm) \
4585fa69175SJed Brown   ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || PetscMPITypeSize((&petsc_send_len),(sendcount),(sendtype)) || MPI_Alltoall((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(recvtype),(comm)))
4593b9284c0SMatthew G Knepley 
4603b9284c0SMatthew G Knepley #define MPI_Alltoallv(sendbuf,sendcnts,sdispls,sendtype,recvbuf,recvcnts,rdispls,recvtype,comm) \
4615fa69175SJed Brown   ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || PetscMPITypeSizeComm((comm),(&petsc_send_len),(sendcnts),(sendtype)) || MPI_Alltoallv((sendbuf),(sendcnts),(sdispls),(sendtype),(recvbuf),(recvcnts),(rdispls),(recvtype),(comm)))
4623b9284c0SMatthew G Knepley 
46301faf4e4SMatthew Knepley #define MPI_Allgather(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype,comm) \
4645fa69175SJed Brown   ((petsc_gather_ct += PetscMPIParallelComm((comm)),0) || MPI_Allgather((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(recvtype),(comm)))
46501faf4e4SMatthew Knepley 
46601faf4e4SMatthew Knepley #define MPI_Allgatherv(sendbuf,sendcount,sendtype,recvbuf,recvcount,displs,recvtype,comm) \
4675fa69175SJed Brown   ((petsc_gather_ct += PetscMPIParallelComm((comm)),0) || MPI_Allgatherv((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(displs),(recvtype),(comm)))
46801faf4e4SMatthew Knepley 
46901faf4e4SMatthew Knepley #define MPI_Gather(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype,root,comm) \
4705fa69175SJed Brown   ((petsc_gather_ct++,0) || PetscMPITypeSize((&petsc_send_len),(sendcount),(sendtype)) || MPI_Gather((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(recvtype),(root),(comm)))
47101faf4e4SMatthew Knepley 
47201faf4e4SMatthew Knepley #define MPI_Gatherv(sendbuf,sendcount,sendtype,recvbuf,recvcount,displs,recvtype,root,comm) \
4735fa69175SJed Brown   ((petsc_gather_ct++,0) || PetscMPITypeSize((&petsc_send_len),(sendcount),(sendtype)) || MPI_Gatherv((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(displs),(recvtype),(root),(comm)))
47401faf4e4SMatthew Knepley 
47501faf4e4SMatthew Knepley #define MPI_Scatter(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype,root,comm) \
4765fa69175SJed Brown   ((petsc_scatter_ct++,0) || PetscMPITypeSize((&petsc_recv_len),(recvcount),(recvtype)) || MPI_Scatter((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(recvtype),(root),(comm)))
47701faf4e4SMatthew Knepley 
47801faf4e4SMatthew Knepley #define MPI_Scatterv(sendbuf,sendcount,displs,sendtype,recvbuf,recvcount,recvtype,root,comm) \
4795fa69175SJed Brown   ((petsc_scatter_ct++,0) || PetscMPITypeSize((&petsc_recv_len),(recvcount),(recvtype)) || MPI_Scatterv((sendbuf),(sendcount),(displs),(sendtype),(recvbuf),(recvcount),(recvtype),(root),(comm)))
48001faf4e4SMatthew Knepley 
4810d4b0b6cSBarry Smith #else
4820d4b0b6cSBarry Smith 
483457b14b1SJunchao Zhang #define MPI_Startall_irecv(count,datatype,number,requests) \
484ea1c87f7SJunchao Zhang   ((number) && MPI_Startall((number),(requests)))
4850d4b0b6cSBarry Smith 
486457b14b1SJunchao Zhang #define MPI_Startall_isend(count,datatype,number,requests) \
487ea1c87f7SJunchao Zhang   ((number) && MPI_Startall((number),(requests)))
4880d4b0b6cSBarry Smith 
489457b14b1SJunchao Zhang #define MPI_Start_isend(count,datatype,requests) \
4905fa69175SJed Brown   (MPI_Start((requests)))
4910d4b0b6cSBarry Smith 
492c8217ed5SSatish Balay #endif /* !__MPIUNI_H && ! PETSC_HAVE_BROKEN_RECURSIVE_MACRO */
493614700edSBarry Smith 
494df8cf0b5SBarry Smith #else  /* ---Logging is turned off --------------------------------------------*/
495614700edSBarry Smith 
496e3ed9ee7SBarry Smith #define PetscLogMemory                     PETSC_FALSE
497e3ed9ee7SBarry Smith 
498b0a32e0cSBarry Smith #define PetscLogFlops(n)                   0
499fa2bb9feSLisandro Dalcin #define PetscGetFlops(a)                   (*(a) = 0.0,0)
500614700edSBarry Smith 
501fa2bb9feSLisandro Dalcin #define PetscLogStageRegister(a,b)         0
502fa2bb9feSLisandro Dalcin #define PetscLogStagePush(a)               0
503fa2bb9feSLisandro Dalcin #define PetscLogStagePop()                 0
504f5d6ab90SLisandro Dalcin #define PetscLogStageSetActive(a,b)        0
505f5d6ab90SLisandro Dalcin #define PetscLogStageGetActive(a,b)        0
506f5d6ab90SLisandro Dalcin #define PetscLogStageGetVisible(a,b)       0
507f5d6ab90SLisandro Dalcin #define PetscLogStageSetVisible(a,b)       0
508f5d6ab90SLisandro Dalcin #define PetscLogStageGetId(a,b)            (*(b)=0,0)
509f5d6ab90SLisandro Dalcin 
510fa2bb9feSLisandro Dalcin #define PetscLogEventRegister(a,b,c)       0
511fa2bb9feSLisandro Dalcin #define PetscLogEventSetCollective(a,b)    0
512fa2bb9feSLisandro Dalcin #define PetscLogEventIncludeClass(a)       0
513fa2bb9feSLisandro Dalcin #define PetscLogEventExcludeClass(a)       0
514b0a32e0cSBarry Smith #define PetscLogEventActivate(a)           0
515b0a32e0cSBarry Smith #define PetscLogEventDeactivate(a)         0
516b0a32e0cSBarry Smith #define PetscLogEventActivateClass(a)      0
517b0a32e0cSBarry Smith #define PetscLogEventDeactivateClass(a)    0
518e8e7597cSSatish Balay #define PetscLogEventSetActiveAll(a,b)     0
51946eb3cd7SSatish Balay #define PetscLogEventGetId(a,b)            (*(b)=0,0)
520561b2a67SSatish Balay #define PetscLogEventGetPerfInfo(a,b,c)    0
5219c702cfcSMatthew G. Knepley #define PetscLogEventSetDof(a,b,c)         0
5229c702cfcSMatthew G. Knepley #define PetscLogEventSetError(a,b,c)       0
52377c4ece6SBarry Smith 
5248b5db460SBarry Smith #define PetscLogPLB                        0
5258b5db460SBarry Smith #define PetscLogPLE                        0
5268b5db460SBarry Smith #define PetscLogPHC                        0
5278b5db460SBarry Smith #define PetscLogPHD                        0
528f5d6ab90SLisandro Dalcin 
529efee365bSSatish Balay #define PetscLogObjectParents(p,n,c)       0
53052e6d16bSBarry Smith #define PetscLogObjectCreate(h)            0
53152e6d16bSBarry Smith #define PetscLogObjectDestroy(h)           0
532fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogObjectState(PetscObject,const char[],...);
533fa2bb9feSLisandro Dalcin 
534bb1d7374SBarry Smith #define PetscLogDefaultBegin()             0
535b0a32e0cSBarry Smith #define PetscLogAllBegin()                 0
536bb1d7374SBarry Smith #define PetscLogNestedBegin()              0
537fa2bb9feSLisandro Dalcin #define PetscLogTraceBegin(file)           0
53873fda44aSBarry Smith #define PetscLogActions(a)                 0
539fa2bb9feSLisandro Dalcin #define PetscLogObjects(a)                 0
540fa2bb9feSLisandro Dalcin #define PetscLogSetThreshold(a,b)          0
541fa2bb9feSLisandro Dalcin #define PetscLogSet(lb,le)                 0
542fa2bb9feSLisandro Dalcin 
543fa2bb9feSLisandro Dalcin #define PetscLogView(viewer)               0
544fa2bb9feSLisandro Dalcin #define PetscLogViewFromOptions()          0
545fa2bb9feSLisandro Dalcin #define PetscLogDump(c)                    0
546fa2bb9feSLisandro Dalcin 
54762872c28SLisandro Dalcin #define PetscLogEventSync(e,comm)          0
548fa2bb9feSLisandro Dalcin #define PetscLogEventBegin(e,o1,o2,o3,o4)  0
549fa2bb9feSLisandro Dalcin #define PetscLogEventEnd(e,o1,o2,o3,o4)    0
550ce6058e1SBarry Smith 
551aa482453SBarry Smith /* If PETSC_USE_LOG is NOT defined, these still need to be! */
552ea1c87f7SJunchao Zhang #define MPI_Startall_irecv(count,datatype,number,requests) ((number) && MPI_Startall(number,requests))
553ea1c87f7SJunchao Zhang #define MPI_Startall_isend(count,datatype,number,requests) ((number) && MPI_Startall(number,requests))
554457b14b1SJunchao Zhang #define MPI_Start_isend(count,datatype,requests)           MPI_Start(requests)
555f141ce34SMatthew Knepley 
556aa482453SBarry Smith #endif   /* PETSC_USE_LOG */
5576daaf66cSBarry Smith 
558204a6943SJed Brown #define PetscPreLoadBegin(flag,name) \
559204a6943SJed Brown do {\
560204a6943SJed Brown   PetscBool      PetscPreLoading = flag;\
561204a6943SJed Brown   int            PetscPreLoadMax,PetscPreLoadIt;\
562166c7f25SBarry Smith   PetscLogStage  _stageNum;\
5638cbcd9ccSBarry Smith   PetscErrorCode _3_ierr; \
564c5929fdfSBarry Smith   _3_ierr = PetscOptionsGetBool(NULL,NULL,"-preload",&PetscPreLoading,NULL);CHKERRQ(_3_ierr); \
565204a6943SJed Brown   PetscPreLoadMax = (int)(PetscPreLoading);\
566204a6943SJed Brown   PetscPreLoadingUsed = PetscPreLoading ? PETSC_TRUE : PetscPreLoadingUsed;\
567204a6943SJed Brown   for (PetscPreLoadIt=0; PetscPreLoadIt<=PetscPreLoadMax; PetscPreLoadIt++) {\
568204a6943SJed Brown     PetscPreLoadingOn = PetscPreLoading;\
5690298fd71SBarry Smith     _3_ierr = PetscBarrier(NULL);CHKERRQ(_3_ierr);\
570204a6943SJed Brown     if (PetscPreLoadIt>0) {\
5718e58c17dSMatthew Knepley       _3_ierr = PetscLogStageGetId(name,&_stageNum);CHKERRQ(_3_ierr);\
5728e58c17dSMatthew Knepley     } else {\
573a3bc4eb9SBarry Smith       _3_ierr = PetscLogStageRegister(name,&_stageNum);CHKERRQ(_3_ierr); \
5748e58c17dSMatthew Knepley     }\
575204a6943SJed Brown     _3_ierr = PetscLogStageSetActive(_stageNum,(PetscBool)(!PetscPreLoadMax || PetscPreLoadIt));\
5768e58c17dSMatthew Knepley     _3_ierr = PetscLogStagePush(_stageNum);CHKERRQ(_3_ierr);
5778e58c17dSMatthew Knepley 
578204a6943SJed Brown #define PetscPreLoadEnd() \
579043328b6SSatish Balay     _3_ierr = PetscLogStagePop();CHKERRQ(_3_ierr);\
580204a6943SJed Brown     PetscPreLoading = PETSC_FALSE;\
581043328b6SSatish Balay   }\
582204a6943SJed Brown } while (0)
5838e58c17dSMatthew Knepley 
584204a6943SJed Brown #define PetscPreLoadStage(name) do {                                         \
585043328b6SSatish Balay     _3_ierr = PetscLogStagePop();CHKERRQ(_3_ierr);                      \
586204a6943SJed Brown     if (PetscPreLoadIt>0) {                                                  \
5878e58c17dSMatthew Knepley       _3_ierr = PetscLogStageGetId(name,&_stageNum);CHKERRQ(_3_ierr);   \
5888e58c17dSMatthew Knepley     } else {                                                            \
589a3bc4eb9SBarry Smith       _3_ierr = PetscLogStageRegister(name,&_stageNum);CHKERRQ(_3_ierr); \
5908e58c17dSMatthew Knepley     }                                                                   \
591204a6943SJed Brown     _3_ierr = PetscLogStageSetActive(_stageNum,(PetscBool)(!PetscPreLoadMax || PetscPreLoadIt)); \
592204a6943SJed Brown     _3_ierr = PetscLogStagePush(_stageNum);CHKERRQ(_3_ierr);            \
593204a6943SJed Brown   } while (0)
594e9fa29b7SSatish Balay 
595ad14c47eSJed Brown /* some vars for logging */
596ad14c47eSJed Brown PETSC_EXTERN PetscBool PetscPreLoadingUsed;       /* true if we are or have done preloading */
597ad14c47eSJed Brown PETSC_EXTERN PetscBool PetscPreLoadingOn;         /* true if we are currently in a preloading calculation */
598ad14c47eSJed Brown 
59997bb86f7SLois Curfman McInnes #endif
600