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