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