xref: /petsc/include/petsclog.h (revision 421e10b8f79bbed49dcc4e803c884835d979c6ea)
1 /*
2     Defines profile/logging in PETSc.
3 */
4 
5 #if !defined(__PetscLog_H)
6 #define __PetscLog_H
7 #include "petsc.h"
8 PETSC_EXTERN_CXX_BEGIN
9 
10 #define PETSC_EVENT  1311311
11 extern PetscEvent PETSC_LARGEST_EVENT;
12 
13 /* Global flop counter */
14 extern PetscLogDouble PETSC_DLLEXPORT _TotalFlops;
15 
16 /* General logging of information; different from event logging */
17 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInfo_Private(const char[],void*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4);
18 #if defined(PETSC_USE_INFO)
19 #define PetscInfo(A,S)                       PetscInfo_Private(__FUNCT__,A,S)
20 #define PetscInfo1(A,S,a1)                   PetscInfo_Private(__FUNCT__,A,S,a1)
21 #define PetscInfo2(A,S,a1,a2)                PetscInfo_Private(__FUNCT__,A,S,a1,a2)
22 #define PetscInfo3(A,S,a1,a2,a3)             PetscInfo_Private(__FUNCT__,A,S,a1,a2,a3)
23 #define PetscInfo4(A,S,a1,a2,a3,a4)          PetscInfo_Private(__FUNCT__,A,S,a1,a2,a3,a4)
24 #define PetscInfo5(A,S,a1,a2,a3,a4,a5)       PetscInfo_Private(__FUNCT__,A,S,a1,a2,a3,a4,a5)
25 #define PetscInfo6(A,S,a1,a2,a3,a4,a5,a6)    PetscInfo_Private(__FUNCT__,A,S,a1,a2,a3,a4,a5,a6)
26 #define PetscInfo7(A,S,a1,a2,a3,a4,a5,a6,a7) PetscInfo_Private(__FUNCT__,A,S,a1,a2,a3,a4,a5,a6,a7)
27 #else
28 #define PetscInfo(A,S)                       0
29 #define PetscInfo1(A,S,a1)                   0
30 #define PetscInfo2(A,S,a1,a2)                0
31 #define PetscInfo3(A,S,a1,a2,a3)             0
32 #define PetscInfo4(A,S,a1,a2,a3,a4)          0
33 #define PetscInfo5(A,S,a1,a2,a3,a4,a5)       0
34 #define PetscInfo6(A,S,a1,a2,a3,a4,a5,a6)    0
35 #define PetscInfo7(A,S,a1,a2,a3,a4,a5,a6,a7) 0
36 #endif
37 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInfoDeactivateClass(PetscCookie);
38 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInfoActivateClass(PetscCookie);
39 extern PetscTruth     PETSC_DLLEXPORT PetscLogPrintInfo;  /* if true, indicates PetscInfo() is turned on */
40 
41 #if defined(PETSC_USE_LOG)  /* --- Logging is turned on --------------------------------*/
42 
43 /*
44    Flop counting:  We count each arithmetic operation (e.g., addition, multiplication) separately.
45 
46    For the complex numbers version, note that
47        1 complex addition = 2 flops
48        1 complex multiplication = 6 flops,
49    where we define 1 flop as that for a double precision scalar.  We roughly approximate
50    flop counting for complex numbers by multiplying the total flops by 4; this corresponds
51    to the assumption that we're counting mostly additions and multiplications -- and
52    roughly the same number of each.  More accurate counting could be done by distinguishing
53    among the various arithmetic operations.
54  */
55 
56 #if defined(PETSC_USE_COMPLEX)
57 #define PetscLogFlops(n) (_TotalFlops += (4*n),0)
58 #else
59 #define PetscLogFlops(n) (_TotalFlops += (n),0)
60 #endif
61 
62 #if defined (PETSC_HAVE_MPE)
63 #include "mpe.h"
64 EXTERN PetscErrorCode PETSC_DLLEXPORT        PetscLogMPEBegin(void);
65 EXTERN PetscErrorCode PETSC_DLLEXPORT        PetscLogMPEDump(const char[]);
66 extern PetscTruth UseMPE;
67 #define PETSC_LOG_EVENT_MPE_BEGIN(e) \
68   ((UseMPE && _stageLog->stageInfo[_stageLog->curStage].eventLog->eventInfo[e].active) ? \
69    MPE_Log_event(_stageLog->eventLog->eventInfo[e].mpe_id_begin,0,NULL) : 0)
70 
71 #define PETSC_LOG_EVENT_MPE_END(e) \
72   ((UseMPE && _stageLog->stageInfo[_stageLog->curStage].eventLog->eventInfo[e].active) ? \
73    MPE_Log_event(_stageLog->eventLog->eventInfo[e].mpe_id_end,0,NULL) : 0)
74 
75 #else
76 #define PETSC_LOG_EVENT_MPE_BEGIN(e) 0
77 #define PETSC_LOG_EVENT_MPE_END(e)   0
78 #endif
79 
80 EXTERN PETSC_DLLEXPORT PetscErrorCode (*_PetscLogPLB)(PetscEvent,int,PetscObject,PetscObject,PetscObject,PetscObject);
81 EXTERN PETSC_DLLEXPORT PetscErrorCode (*_PetscLogPLE)(PetscEvent,int,PetscObject,PetscObject,PetscObject,PetscObject);
82 EXTERN PETSC_DLLEXPORT PetscErrorCode (*_PetscLogPHC)(PetscObject);
83 EXTERN PETSC_DLLEXPORT PetscErrorCode (*_PetscLogPHD)(PetscObject);
84 
85 #define PetscLogObjectParent(p,c) \
86   ((c && p) ? ((PetscObject)(c))->parent = (PetscObject)(p),((PetscObject)(c))->parentid = ((PetscObject)p)->id : 0, 0)
87 
88 #define PetscLogObjectParents(p,n,d)  0;{int _i; for (_i=0; _i<n; _i++) {ierr = PetscLogObjectParent(p,(d)[_i]);CHKERRQ(ierr);}}
89 #define PetscLogObjectCreate(h)      ((_PetscLogPHC) ? (*_PetscLogPHC)((PetscObject)h) : 0)
90 #define PetscLogObjectDestroy(h)     ((_PetscLogPHD) ? (*_PetscLogPHD)((PetscObject)h) : 0)
91 #define PetscLogObjectMemory(p,m)    (((PetscObject)(p))->mem += (m),0)
92 /* Initialization functions */
93 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogBegin(void);
94 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogAllBegin(void);
95 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogTraceBegin(FILE *);
96 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogActions(PetscTruth);
97 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogObjects(PetscTruth);
98 /* General functions */
99 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogGetRGBColor(const char*[]);
100 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogDestroy(void);
101 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogSet(PetscErrorCode (*)(int, int, PetscObject, PetscObject, PetscObject, PetscObject),
102                    PetscErrorCode (*)(int, int, PetscObject, PetscObject, PetscObject, PetscObject));
103 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogObjectState(PetscObject, const char[], ...)  PETSC_PRINTF_FORMAT_CHECK(2,3);
104 /* Output functions */
105 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogPrintSummary(MPI_Comm, const char[]);
106 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogDump(const char[]);
107 /* Counter functions */
108 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetFlops(PetscLogDouble *);
109 /* Stage functions */
110 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStageRegister(int*, const char[]);
111 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStagePush(int);
112 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStagePop(void);
113 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStageSetActive(int, PetscTruth);
114 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStageGetActive(int, PetscTruth *);
115 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStageSetVisible(int, PetscTruth);
116 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStageGetVisible(int, PetscTruth *);
117 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStageGetId(const char [], int *);
118 /* Event functions */
119 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogEventRegister(PetscEvent*, const char[], PetscCookie);
120 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogEventActivate(PetscEvent);
121 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogEventDeactivate(PetscEvent);
122 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogEventSetActiveAll(PetscEvent, PetscTruth);
123 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogEventActivateClass(PetscCookie);
124 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogEventDeactivateClass(PetscCookie);
125 /* Class functions */
126 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogClassRegister(PetscCookie*, const char []);
127 
128 /* Global counters */
129 extern PETSC_DLLEXPORT PetscLogDouble irecv_ct;
130 extern PETSC_DLLEXPORT PetscLogDouble isend_ct;
131 extern PETSC_DLLEXPORT PetscLogDouble recv_ct;
132 extern PETSC_DLLEXPORT PetscLogDouble send_ct;
133 extern PETSC_DLLEXPORT PetscLogDouble irecv_len;
134 extern PETSC_DLLEXPORT PetscLogDouble isend_len;
135 extern PETSC_DLLEXPORT PetscLogDouble recv_len;
136 extern PETSC_DLLEXPORT PetscLogDouble send_len;
137 extern PETSC_DLLEXPORT PetscLogDouble allreduce_ct;
138 extern PETSC_DLLEXPORT PetscLogDouble wait_ct;
139 extern PETSC_DLLEXPORT PetscLogDouble wait_any_ct;
140 extern PETSC_DLLEXPORT PetscLogDouble wait_all_ct;
141 extern PETSC_DLLEXPORT PetscLogDouble sum_of_waits_ct;
142 extern PETSC_DLLEXPORT int            PETSC_DUMMY_SIZE;
143 extern PETSC_DLLEXPORT int            PETSC_DUMMY_COUNT;
144 
145 /* We must make these structures available if we are to access the event
146    activation flags in the PetscLogEventBegin/End() macros. If we forced a
147    function call each time, we could make these private.
148 */
149 /* Default log */
150 typedef struct _n_StageLog *StageLog;
151 extern PETSC_DLLEXPORT StageLog _stageLog;
152 
153 /* A simple stack (should replace) */
154 typedef struct _n_IntStack *IntStack;
155 
156 /* The structures for logging performance */
157 typedef struct _EventPerfInfo {
158   int            id;            /* The integer identifying this section */
159   PetscTruth     active;        /* The flag to activate logging */
160   PetscTruth     visible;       /* The flag to print info in summary */
161   int            depth;         /* The nesting depth of the event call */
162   int            count;         /* The number of times this section was executed */
163   PetscLogDouble flops;         /* The flops used in this section */
164   PetscLogDouble time;          /* The time taken for this section */
165   PetscLogDouble numMessages;   /* The number of messages in this section */
166   PetscLogDouble messageLength; /* The total message lengths in this section */
167   PetscLogDouble numReductions; /* The number of reductions in this section */
168 } EventPerfInfo;
169 
170 typedef struct _ClassPerfInfo {
171   int            id;           /* The integer identifying this class */
172   int            creations;    /* The number of objects of this class created */
173   int            destructions; /* The number of objects of this class destroyed */
174   PetscLogDouble mem;          /* The total memory allocated by objects of this class */
175   PetscLogDouble descMem;      /* The total memory allocated by descendents of these objects */
176 } ClassPerfInfo;
177 
178 /* The structures for logging registration */
179 typedef struct _ClassRegInfo {
180   char            *name;   /* The class name */
181   PetscCookie cookie; /* The integer identifying this class */
182 } ClassRegInfo;
183 
184 typedef struct _EventRegInfo {
185   char            *name;   /* The name of this event */
186   PetscCookie cookie; /* The class id for this event (should maybe give class ID instead) */
187 #if defined (PETSC_HAVE_MPE)
188   int             mpe_id_begin; /* MPE IDs that define the event */
189   int             mpe_id_end;
190 #endif
191 } EventRegInfo;
192 
193 typedef struct _n_EventRegLog *EventRegLog;
194 struct _n_EventRegLog {
195   int           numEvents; /* The number of registered events */
196   int           maxEvents; /* The maximum number of events */
197   EventRegInfo *eventInfo; /* The registration information for each event */
198 };
199 
200 typedef struct _n_EventPerfLog *EventPerfLog;
201 struct _n_EventPerfLog {
202   int            numEvents; /* The number of logging events */
203   int            maxEvents; /* The maximum number of events */
204   EventPerfInfo *eventInfo; /* The performance information for each event */
205 };
206 
207 /* The structure for logging class information */
208 typedef struct _n_ClassRegLog *ClassRegLog;
209 struct _n_ClassRegLog {
210   int           numClasses; /* The number of classes registered */
211   int           maxClasses; /* The maximum number of classes */
212   ClassRegInfo *classInfo;  /* The structure for class information (cookies are monotonicly increasing) */
213 };
214 
215 typedef struct _n_ClassPerfLog *ClassPerfLog;
216 struct _n_ClassPerfLog {
217   int            numClasses; /* The number of logging classes */
218   int            maxClasses; /* The maximum number of classes */
219   ClassPerfInfo *classInfo;  /* The structure for class information (cookies are monotonicly increasing) */
220 };
221 
222 /* The structures for logging in stages */
223 typedef struct _StageInfo {
224   char         *name;     /* The stage name */
225   PetscTruth    used;     /* The stage was pushed on this processor */
226   EventPerfInfo perfInfo; /* The stage performance information */
227   EventPerfLog  eventLog; /* The event information for this stage */
228   ClassPerfLog  classLog; /* The class information for this stage */
229 } StageInfo;
230 
231 struct _n_StageLog {
232   /* Size information */
233   int         numStages; /* The number of registered stages */
234   int         maxStages; /* The maximum number of stages */
235   /* Runtime information */
236   IntStack    stack;     /* The stack for active stages */
237   int         curStage;  /* The current stage (only used in macros so we don't call StackTop) */
238   /* Stage specific information */
239   StageInfo  *stageInfo; /* The information for each stage */
240   EventRegLog eventLog;  /* The registered events */
241   ClassRegLog classLog;  /* The registered classes */
242 };
243 
244 #define PetscLogEventBarrierBegin(e,o1,o2,o3,o4,cm) \
245   (((_PetscLogPLB && _stageLog->stageInfo[_stageLog->curStage].perfInfo.active &&  _stageLog->stageInfo[_stageLog->curStage].eventLog->eventInfo[e].active) ? \
246     (PetscLogEventBegin((e),o1,o2,o3,o4) || MPI_Barrier(cm) || PetscLogEventEnd((e),o1,o2,o3,o4)) : 0 ) || \
247    PetscLogEventBegin((e)+1,o1,o2,o3,o4))
248 
249 #define PetscLogEventBegin(e,o1,o2,o3,o4) \
250   (((_PetscLogPLB && _stageLog->stageInfo[_stageLog->curStage].perfInfo.active && _stageLog->stageInfo[_stageLog->curStage].eventLog->eventInfo[e].active) ? \
251     (*_PetscLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4)) : 0 ) || \
252   PETSC_LOG_EVENT_MPE_BEGIN(e))
253 
254 #define PetscLogEventBarrierEnd(e,o1,o2,o3,o4,cm) PetscLogEventEnd(e+1,o1,o2,o3,o4)
255 
256 #define PetscLogEventEnd(e,o1,o2,o3,o4) \
257   (((_PetscLogPLE && _stageLog->stageInfo[_stageLog->curStage].perfInfo.active && _stageLog->stageInfo[_stageLog->curStage].eventLog->eventInfo[e].active) ? \
258     (*_PetscLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4)) : 0 ) || \
259   PETSC_LOG_EVENT_MPE_END(e))
260 
261 /* Creation and destruction functions */
262 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogCreate(StageLog *);
263 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogDestroy(StageLog);
264 /* Registration functions */
265 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogRegister(StageLog, const char [], int *);
266 /* Runtime functions */
267 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogGetStageLog(StageLog *);
268 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogPush(StageLog, int);
269 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogPop(StageLog);
270 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetCurrent(StageLog, int *);
271 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogSetActive(StageLog, int, PetscTruth);
272 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetActive(StageLog, int, PetscTruth *);
273 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogSetVisible(StageLog, int, PetscTruth);
274 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetVisible(StageLog, int, PetscTruth *);
275 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetStage(StageLog, const char [], int *);
276 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetClassRegLog(StageLog, ClassRegLog *);
277 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetEventRegLog(StageLog, EventRegLog *);
278 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetClassPerfLog(StageLog, int, ClassPerfLog *);
279 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetEventPerfLog(StageLog, int, EventPerfLog *);
280 
281 /*
282      These are used internally in the PETSc routines to keep a count of MPI messages and
283    their sizes.
284 
285      This does not work for MPI-Uni because our include/mpiuni/mpi.h file
286    uses macros to defined the MPI operations.
287 
288      It does not work correctly from HP-UX because it processes the
289    macros in a way that sometimes it double counts, hence
290    PETSC_HAVE_BROKEN_RECURSIVE_MACRO
291 
292      It does not work with Windows because winmpich lacks MPI_Type_size()
293 */
294 #if !defined(_petsc_mpi_uni) && !defined(PETSC_HAVE_BROKEN_RECURSIVE_MACRO) && !defined (PETSC_HAVE_MPI_MISSING_TYPESIZE)
295 /*
296    Logging of MPI activities
297 */
298 #define TypeSize(buff,count,type) \
299  (MPI_Type_size(type,&PETSC_DUMMY_SIZE) || (buff += (PetscLogDouble) ((count)*PETSC_DUMMY_SIZE),0))
300 
301 #define MPI_Irecv(buf,count,datatype,source,tag,comm,request) \
302  ((PETSC_DUMMY_COUNT = count,irecv_ct++,0) || TypeSize(irecv_len,PETSC_DUMMY_COUNT,datatype) || MPI_Irecv(buf,PETSC_DUMMY_COUNT,datatype,source,tag,comm,request))
303 
304 #define MPI_Isend(buf,count,datatype,dest,tag,comm,request) \
305  ((PETSC_DUMMY_COUNT = count,isend_ct++,0) || TypeSize(isend_len,PETSC_DUMMY_COUNT,datatype) || MPI_Isend(buf,PETSC_DUMMY_COUNT,datatype,dest,tag,comm,request))
306 
307 #define MPI_Startall_irecv(count,number,requests) \
308  ((irecv_ct += (PetscLogDouble)(number),0) || TypeSize(irecv_len,count,MPIU_SCALAR) || MPI_Startall(number,requests))
309 
310 #define MPI_Startall_isend(count,number,requests) \
311  ((isend_ct += (PetscLogDouble)(number),0) || TypeSize(isend_len,count,MPIU_SCALAR) || MPI_Startall(number,requests))
312 
313 #define MPI_Start_isend(count,requests) \
314  ((isend_ct++,0) || TypeSize(isend_len,count,MPIU_SCALAR) || MPI_Start(requests))
315 
316 #define MPI_Recv(buf,count,datatype,source,tag,comm,status) \
317  ((PETSC_DUMMY_COUNT = count,recv_ct++,0) || TypeSize(recv_len,PETSC_DUMMY_COUNT,datatype) || MPI_Recv(buf,PETSC_DUMMY_COUNT,datatype,source,tag,comm,status))
318 
319 #define MPI_Send(buf,count,datatype,dest,tag,comm) \
320  ((PETSC_DUMMY_COUNT = count,send_ct++,0) || TypeSize(send_len,PETSC_DUMMY_COUNT,datatype) || MPI_Send(buf,PETSC_DUMMY_COUNT,datatype,dest,tag,comm))
321 
322 #define MPI_Wait(request,status) \
323  ((wait_ct++,sum_of_waits_ct++,0) || MPI_Wait(request,status))
324 
325 #define MPI_Waitany(a,b,c,d) \
326  ((wait_any_ct++,sum_of_waits_ct++,0) || MPI_Waitany(a,b,c,d))
327 
328 #define MPI_Waitall(count,array_of_requests,array_of_statuses) \
329  ((PETSC_DUMMY_COUNT = count,wait_all_ct++,sum_of_waits_ct += (PetscLogDouble) (PETSC_DUMMY_COUNT),0) || MPI_Waitall(PETSC_DUMMY_COUNT,array_of_requests,array_of_statuses))
330 
331 #define MPI_Allreduce(sendbuf,recvbuf,count,datatype,op,comm) \
332  ((allreduce_ct++,0) || MPI_Allreduce(sendbuf,recvbuf,count,datatype,op,comm))
333 
334 #else
335 
336 #define MPI_Startall_irecv(count,number,requests) \
337  (MPI_Startall(number,requests))
338 
339 #define MPI_Startall_isend(count,number,requests) \
340  (MPI_Startall(number,requests))
341 
342 #define MPI_Start_isend(count,requests) \
343  (MPI_Start(requests))
344 
345 #endif /* !_petsc_mpi_uni && ! PETSC_HAVE_BROKEN_RECURSIVE_MACRO */
346 
347 #else  /* ---Logging is turned off --------------------------------------------*/
348 
349 #define PetscLogFlops(n) 0
350 
351 /*
352      With logging turned off, then MPE has to be turned off
353 */
354 #define PetscLogMPEBegin()         0
355 #define PetscLogMPEDump(a)         0
356 
357 #define PetscLogEventActivate(a)   0
358 #define PetscLogEventDeactivate(a) 0
359 
360 #define PetscLogEventActivateClass(a)   0
361 #define PetscLogEventDeactivateClass(a) 0
362 #define PetscLogClassRegister(a,b)      PetscCookieRegister(a)
363 #define PetscLogEventSetActiveAll(a,b)  0
364 
365 #define _PetscLogPLB                        0
366 #define _PetscLogPLE                        0
367 #define _PetscLogPHC                        0
368 #define _PetscLogPHD                        0
369 #define PetscGetFlops(a)                (*(a) = 0.0,0)
370 #define PetscLogEventBegin(e,o1,o2,o3,o4)   0
371 #define PetscLogEventEnd(e,o1,o2,o3,o4)     0
372 #define PetscLogEventBarrierBegin(e,o1,o2,o3,o4,cm) 0
373 #define PetscLogEventBarrierEnd(e,o1,o2,o3,o4,cm)   0
374 #define PetscLogObjectParent(p,c)           0
375 #define PetscLogObjectParents(p,n,c)        0
376 #define PetscLogObjectCreate(h)             0
377 #define PetscLogObjectDestroy(h)            0
378 #define PetscLogObjectMemory(p,m)           0
379 #define PetscLogDestroy()                   0
380 #define PetscLogStagePush(a)                0
381 #define PetscLogStagePop()                  0
382 #define PetscLogStageRegister(a,b)          0
383 #define PetscLogStagePrint(a,flg)           0
384 #define PetscLogPrintSummary(comm,file)     0
385 #define PetscLogBegin()                     0
386 #define PetscLogTraceBegin(file)            0
387 #define PetscLogSet(lb,le)                  0
388 #define PetscLogAllBegin()                  0
389 #define PetscLogDump(c)                     0
390 #define PetscLogEventRegister(a,b,c)        0
391 #define PetscLogObjects(a)                  0
392 #define PetscLogActions(a)                  0
393 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogObjectState(PetscObject,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
394 
395 /* If PETSC_USE_LOG is NOT defined, these still need to be! */
396 #define MPI_Startall_irecv(count,number,requests) MPI_Startall(number,requests)
397 #define MPI_Startall_isend(count,number,requests) MPI_Startall(number,requests)
398 #define MPI_Start_isend(count,requests) MPI_Start(requests)
399 
400 /* Creation and destruction functions */
401 #define StageLogCreate(stageLog)                     0
402 #define StageLogDestroy(stageLog)                    0
403 /* Registration functions */
404 #define StageLogRegister(stageLog, name, stage)      0
405 /* Runtime functions */
406 #define PetscLogGetStageLog(stageLog)                0
407 #define StageLogPush(stageLog, stage)                0
408 #define StageLogPop(stageLog)                        0
409 #define StageLogGetCurrent(stageLog, stage)          0
410 #define StageLogSetActive(stageLog, stage, active)   0
411 #define StageLogGetActive(stageLog, stage, active)   0
412 #define StageLogSetVisible(stageLog, stage, visible) 0
413 #define StageLogGetVisible(stageLog, stage, visible) 0
414 #define StageLogGetStage(stageLog, name, stage)      0
415 #define PetscLogStageGetId(a,b)                      (*(b)=0,0)
416 #define PetscLogStageSetActive(a,b)                  0
417 
418 #endif   /* PETSC_USE_LOG */
419 
420 #define PreLoadBegin(flag,name) \
421 {\
422   PetscTruth PreLoading = flag;\
423   int        PreLoadMax,PreLoadIt,_stageNum,_3_ierr;\
424   _3_ierr = PetscOptionsGetTruth(PETSC_NULL,"-preload",&PreLoading,PETSC_NULL);CHKERRQ(_3_ierr);\
425   PreLoadMax = (int)(PreLoading);\
426   PetscPreLoadingUsed = PreLoading ? PETSC_TRUE : PetscPreLoadingUsed;\
427   for (PreLoadIt=0; PreLoadIt<=PreLoadMax; PreLoadIt++) {\
428     PetscPreLoadingOn = PreLoading;\
429     _3_ierr = PetscBarrier(PETSC_NULL);CHKERRQ(_3_ierr);\
430     if (PreLoadIt>0) {\
431       _3_ierr = PetscLogStageGetId(name,&_stageNum);CHKERRQ(_3_ierr);\
432     } else {\
433       _3_ierr = PetscLogStageRegister(&_stageNum,name);CHKERRQ(_3_ierr);\
434     }\
435     _3_ierr = PetscLogStageSetActive(_stageNum,(PetscTruth)(!PreLoadMax || PreLoadIt));\
436     _3_ierr = PetscLogStagePush(_stageNum);CHKERRQ(_3_ierr);
437 
438 #define PreLoadEnd() \
439     _3_ierr = PetscLogStagePop();CHKERRQ(_3_ierr);\
440     PreLoading = PETSC_FALSE;\
441   }\
442 }
443 
444 #define PreLoadStage(name) \
445   _3_ierr = PetscLogStagePop();CHKERRQ(_3_ierr);\
446   if (PreLoadIt>0) {\
447     _3_ierr = PetscLogStageGetId(name,&_stageNum);CHKERRQ(_3_ierr);\
448   } else {\
449     _3_ierr = PetscLogStageRegister(&_stageNum,name);CHKERRQ(_3_ierr);\
450   }\
451   _3_ierr = PetscLogStageSetActive(_stageNum,(PetscTruth)(!PreLoadMax || PreLoadIt));\
452   _3_ierr = PetscLogStagePush(_stageNum);CHKERRQ(_3_ierr);
453 
454 PETSC_EXTERN_CXX_END
455 #endif
456