Actual source code: petsclog.h
petsc-3.10.5 2019-03-28
1: /*
2: Defines profile/logging in PETSc.
3: */
7: #include <petscsys.h>
9: /* General logging of information; different from event logging */
10: PETSC_EXTERN PetscErrorCode PetscInfo_Private(const char[],void*,const char[],...);
11: #if defined(PETSC_USE_INFO)
12: #define PetscInfo(A,S) PetscInfo_Private(PETSC_FUNCTION_NAME,A,S)
13: #define PetscInfo1(A,S,a1) PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1)
14: #define PetscInfo2(A,S,a1,a2) PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2)
15: #define PetscInfo3(A,S,a1,a2,a3) PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2,a3)
16: #define PetscInfo4(A,S,a1,a2,a3,a4) PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2,a3,a4)
17: #define PetscInfo5(A,S,a1,a2,a3,a4,a5) PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2,a3,a4,a5)
18: #define PetscInfo6(A,S,a1,a2,a3,a4,a5,a6) PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2,a3,a4,a5,a6)
19: #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)
20: #else
21: #define PetscInfo(A,S) 0
22: #define PetscInfo1(A,S,a1) 0
23: #define PetscInfo2(A,S,a1,a2) 0
24: #define PetscInfo3(A,S,a1,a2,a3) 0
25: #define PetscInfo4(A,S,a1,a2,a3,a4) 0
26: #define PetscInfo5(A,S,a1,a2,a3,a4,a5) 0
27: #define PetscInfo6(A,S,a1,a2,a3,a4,a5,a6) 0
28: #define PetscInfo7(A,S,a1,a2,a3,a4,a5,a6,a7) 0
29: #endif
30: PETSC_EXTERN PetscErrorCode PetscInfoDeactivateClass(PetscClassId);
31: PETSC_EXTERN PetscErrorCode PetscInfoActivateClass(PetscClassId);
32: PETSC_EXTERN PetscBool PetscLogPrintInfo; /* if true, indicates PetscInfo() is turned on */
34: /*MC
35: PetscLogEvent - id used to identify PETSc or user events which timed portions (blocks of executable)
36: code.
38: Level: intermediate
40: .seealso: PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd(), PetscLogStage
41: M*/
42: typedef int PetscLogEvent;
44: /*MC
45: PetscLogStage - id used to identify user stages (phases, sections) of runs - for logging
47: Level: intermediate
49: .seealso: PetscLogStageRegister(), PetscLogStagePush(), PetscLogStagePop(), PetscLogEvent
50: M*/
51: typedef int PetscLogStage;
53: #define PETSC_EVENT 1311311
54: PETSC_EXTERN PetscLogEvent PETSC_LARGEST_EVENT;
56: /* Global flop counter */
57: PETSC_EXTERN PetscLogDouble petsc_TotalFlops;
58: PETSC_EXTERN PetscLogDouble petsc_tmp_flops;
60: /* We must make the following structures available to access the event
61: activation flags in the PetscLogEventBegin/End() macros. These are not part of the PETSc public
62: API and are not intended to be used by other parts of PETSc or by users.
64: The code that manipulates these structures is in src/sys/logging/utils.
65: */
66: typedef struct _n_PetscIntStack *PetscIntStack;
68: /* -----------------------------------------------------------------------------------------------------*/
69: /*
70: PetscClassRegInfo, PetscClassPerfInfo - Each class has two data structures associated with it. The first has
71: static information about it, the second collects statistics on how many objects of the class are created,
72: how much memory they use, etc.
74: PetscClassRegLog, PetscClassPerfLog - arrays of the PetscClassRegInfo and PetscClassPerfInfo for all classes.
75: */
76: typedef struct {
77: char *name; /* The class name */
78: PetscClassId classid; /* The integer identifying this class */
79: } PetscClassRegInfo;
81: typedef struct {
82: PetscClassId id; /* The integer identifying this class */
83: int creations; /* The number of objects of this class created */
84: int destructions; /* The number of objects of this class destroyed */
85: PetscLogDouble mem; /* The total memory allocated by objects of this class */
86: PetscLogDouble descMem; /* The total memory allocated by descendents of these objects */
87: } PetscClassPerfInfo;
89: typedef struct _n_PetscClassRegLog *PetscClassRegLog;
90: struct _n_PetscClassRegLog {
91: int numClasses; /* The number of classes registered */
92: int maxClasses; /* The maximum number of classes */
93: PetscClassRegInfo *classInfo; /* The structure for class information (classids are monotonicly increasing) */
94: };
96: typedef struct _n_PetscClassPerfLog *PetscClassPerfLog;
97: struct _n_PetscClassPerfLog {
98: int numClasses; /* The number of logging classes */
99: int maxClasses; /* The maximum number of classes */
100: PetscClassPerfInfo *classInfo; /* The structure for class information (classids are monotonicly increasing) */
101: };
102: /* -----------------------------------------------------------------------------------------------------*/
103: /*
104: PetscEventRegInfo, PetscEventPerfInfo - Each event has two data structures associated with it. The first has
105: static information about it, the second collects statistics on how many times the event is used, how
106: much time it takes, etc.
108: PetscEventRegLog, PetscEventPerfLog - an array of all PetscEventRegInfo and PetscEventPerfInfo for all events. There is one
109: of these for each stage.
111: */
112: typedef struct {
113: char *name; /* The name of this event */
114: PetscClassId classid; /* The class the event is associated with */
115: PetscBool collective; /* Flag this event as collective */
116: #if defined (PETSC_HAVE_MPE)
117: int mpe_id_begin; /* MPE IDs that define the event */
118: int mpe_id_end;
119: #endif
120: } PetscEventRegInfo;
122: typedef struct {
123: int id; /* The integer identifying this event */
124: PetscBool active; /* The flag to activate logging */
125: PetscBool visible; /* The flag to print info in summary */
126: int depth; /* The nesting depth of the event call */
127: int count; /* The number of times this event was executed */
128: PetscLogDouble flops, flops2, flopsTmp; /* The flops and flops^2 used in this event */
129: PetscLogDouble time, time2, timeTmp; /* The time and time^2 taken for this event */
130: PetscLogDouble syncTime; /* The synchronization barrier time */
131: PetscLogDouble numMessages; /* The number of messages in this event */
132: PetscLogDouble messageLength; /* The total message lengths in this event */
133: PetscLogDouble numReductions; /* The number of reductions in this event */
134: } PetscEventPerfInfo;
136: typedef struct _n_PetscEventRegLog *PetscEventRegLog;
137: struct _n_PetscEventRegLog {
138: int numEvents; /* The number of registered events */
139: int maxEvents; /* The maximum number of events */
140: PetscEventRegInfo *eventInfo; /* The registration information for each event */
141: };
143: typedef struct _n_PetscEventPerfLog *PetscEventPerfLog;
144: struct _n_PetscEventPerfLog {
145: int numEvents; /* The number of logging events */
146: int maxEvents; /* The maximum number of events */
147: PetscEventPerfInfo *eventInfo; /* The performance information for each event */
148: };
149: /* ------------------------------------------------------------------------------------------------------------*/
150: /*
151: PetscStageInfo - Contains all the information about a particular stage.
153: PetscStageLog - An array of PetscStageInfo for each registered stage. There is a single one of these in the code.
154: */
155: typedef struct _PetscStageInfo {
156: char *name; /* The stage name */
157: PetscBool used; /* The stage was pushed on this processor */
158: PetscEventPerfInfo perfInfo; /* The stage performance information */
159: PetscEventPerfLog eventLog; /* The event information for this stage */
160: PetscClassPerfLog classLog; /* The class information for this stage */
161: } PetscStageInfo;
163: typedef struct _n_PetscStageLog *PetscStageLog;
164: struct _n_PetscStageLog {
165: int numStages; /* The number of registered stages */
166: int maxStages; /* The maximum number of stages */
167: PetscIntStack stack; /* The stack for active stages */
168: int curStage; /* The current stage (only used in macros so we don't call PetscIntStackTop) */
169: PetscStageInfo *stageInfo; /* The information for each stage */
170: PetscEventRegLog eventLog; /* The registered events */
171: PetscClassRegLog classLog; /* The registered classes */
172: };
173: /* -----------------------------------------------------------------------------------------------------*/
175: PETSC_EXTERN PetscErrorCode PetscLogObjectParent(PetscObject,PetscObject);
176: PETSC_EXTERN PetscErrorCode PetscLogObjectMemory(PetscObject,PetscLogDouble);
179: #if defined(PETSC_USE_LOG) /* --- Logging is turned on --------------------------------*/
180: PETSC_EXTERN PetscStageLog petsc_stageLog;
181: PETSC_EXTERN PetscErrorCode PetscLogGetStageLog(PetscStageLog*);
182: PETSC_EXTERN PetscErrorCode PetscStageLogGetCurrent(PetscStageLog,int*);
183: PETSC_EXTERN PetscErrorCode PetscStageLogGetEventPerfLog(PetscStageLog,int,PetscEventPerfLog*);
185: /*
186: Flop counting: We count each arithmetic operation (e.g., addition, multiplication) separately.
188: For the complex numbers version, note that
189: 1 complex addition = 2 flops
190: 1 complex multiplication = 6 flops,
191: where we define 1 flop as that for a double precision scalar. We roughly approximate
192: flop counting for complex numbers by multiplying the total flops by 4; this corresponds
193: to the assumption that we're counting mostly additions and multiplications -- and
194: roughly the same number of each. More accurate counting could be done by distinguishing
195: among the various arithmetic operations.
196: */
198: #if defined(PETSC_USE_COMPLEX)
199: #define PETSC_FLOPS_PER_OP 4.0
200: #else
201: #define PETSC_FLOPS_PER_OP 1.0
202: #endif
204: PETSC_STATIC_INLINE PetscErrorCode PetscLogFlops(PetscLogDouble n)
205: {
207: #if defined(PETSC_USE_DEBUG)
208: if (n < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Cannot log negative flops");
209: #endif
210: petsc_TotalFlops += PETSC_FLOPS_PER_OP*n;
211: return(0);
212: }
214: PETSC_EXTERN PetscErrorCode PetscGetFlops(PetscLogDouble *);
216: #if defined (PETSC_HAVE_MPE)
217: PETSC_EXTERN PetscErrorCode PetscLogMPEBegin(void);
218: PETSC_EXTERN PetscErrorCode PetscLogMPEDump(const char[]);
219: #endif
221: PETSC_EXTERN PetscErrorCode (*PetscLogPLB)(PetscLogEvent,int,PetscObject,PetscObject,PetscObject,PetscObject);
222: PETSC_EXTERN PetscErrorCode (*PetscLogPLE)(PetscLogEvent,int,PetscObject,PetscObject,PetscObject,PetscObject);
223: PETSC_EXTERN PetscErrorCode (*PetscLogPHC)(PetscObject);
224: PETSC_EXTERN PetscErrorCode (*PetscLogPHD)(PetscObject);
226: #define PetscLogObjectParents(p,n,d) 0;{int _i; for (_i=0; _i<(n); _i++) {PetscLogObjectParent((PetscObject)(p),(PetscObject)(d)[_i]);}}
227: #define PetscLogObjectCreate(h) ((PetscLogPHC) ? (*PetscLogPHC)((PetscObject)(h)) : 0)
228: #define PetscLogObjectDestroy(h) ((PetscLogPHD) ? (*PetscLogPHD)((PetscObject)(h)) : 0)
229: PETSC_EXTERN PetscErrorCode PetscLogObjectState(PetscObject, const char[], ...);
231: /* Initialization functions */
232: PETSC_EXTERN PetscErrorCode PetscLogDefaultBegin(void);
233: PETSC_EXTERN PetscErrorCode PetscLogAllBegin(void);
234: PETSC_EXTERN PetscErrorCode PetscLogNestedBegin(void);
235: PETSC_EXTERN PetscErrorCode PetscLogTraceBegin(FILE *);
236: PETSC_EXTERN PetscErrorCode PetscLogActions(PetscBool);
237: PETSC_EXTERN PetscErrorCode PetscLogObjects(PetscBool);
238: PETSC_EXTERN PetscErrorCode PetscLogSetThreshold(PetscLogDouble,PetscLogDouble*);
239: PETSC_EXTERN PetscErrorCode PetscLogSet(PetscErrorCode (*)(int, int, PetscObject, PetscObject, PetscObject, PetscObject),
240: PetscErrorCode (*)(int, int, PetscObject, PetscObject, PetscObject, PetscObject));
242: /* Output functions */
243: PETSC_EXTERN PetscErrorCode PetscLogView(PetscViewer);
244: PETSC_EXTERN PetscErrorCode PetscLogViewFromOptions(void);
245: PETSC_EXTERN PetscErrorCode PetscLogDump(const char[]);
247: /* Stage functions */
248: PETSC_EXTERN PetscErrorCode PetscLogStageRegister(const char[],PetscLogStage*);
249: PETSC_EXTERN PetscErrorCode PetscLogStagePush(PetscLogStage);
250: PETSC_EXTERN PetscErrorCode PetscLogStagePop(void);
251: PETSC_EXTERN PetscErrorCode PetscLogStageSetActive(PetscLogStage,PetscBool);
252: PETSC_EXTERN PetscErrorCode PetscLogStageGetActive(PetscLogStage,PetscBool*);
253: PETSC_EXTERN PetscErrorCode PetscLogStageSetVisible(PetscLogStage,PetscBool);
254: PETSC_EXTERN PetscErrorCode PetscLogStageGetVisible(PetscLogStage,PetscBool*);
255: PETSC_EXTERN PetscErrorCode PetscLogStageGetId(const char[],PetscLogStage*);
257: /* Event functions */
258: PETSC_EXTERN PetscErrorCode PetscLogEventRegister(const char[],PetscClassId,PetscLogEvent*);
259: PETSC_EXTERN PetscErrorCode PetscLogEventSetCollective(PetscLogEvent,PetscBool);
260: PETSC_EXTERN PetscErrorCode PetscLogEventIncludeClass(PetscClassId);
261: PETSC_EXTERN PetscErrorCode PetscLogEventExcludeClass(PetscClassId);
262: PETSC_EXTERN PetscErrorCode PetscLogEventActivate(PetscLogEvent);
263: PETSC_EXTERN PetscErrorCode PetscLogEventDeactivate(PetscLogEvent);
264: PETSC_EXTERN PetscErrorCode PetscLogEventSetActiveAll(PetscLogEvent,PetscBool);
265: PETSC_EXTERN PetscErrorCode PetscLogEventActivateClass(PetscClassId);
266: PETSC_EXTERN PetscErrorCode PetscLogEventDeactivateClass(PetscClassId);
267: PETSC_EXTERN PetscErrorCode PetscLogEventGetId(const char[],PetscLogEvent*);
268: PETSC_EXTERN PetscErrorCode PetscLogEventGetPerfInfo(int,PetscLogEvent,PetscEventPerfInfo*);
270: /* Global counters */
271: PETSC_EXTERN PetscLogDouble petsc_irecv_ct;
272: PETSC_EXTERN PetscLogDouble petsc_isend_ct;
273: PETSC_EXTERN PetscLogDouble petsc_recv_ct;
274: PETSC_EXTERN PetscLogDouble petsc_send_ct;
275: PETSC_EXTERN PetscLogDouble petsc_irecv_len;
276: PETSC_EXTERN PetscLogDouble petsc_isend_len;
277: PETSC_EXTERN PetscLogDouble petsc_recv_len;
278: PETSC_EXTERN PetscLogDouble petsc_send_len;
279: PETSC_EXTERN PetscLogDouble petsc_allreduce_ct;
280: PETSC_EXTERN PetscLogDouble petsc_gather_ct;
281: PETSC_EXTERN PetscLogDouble petsc_scatter_ct;
282: PETSC_EXTERN PetscLogDouble petsc_wait_ct;
283: PETSC_EXTERN PetscLogDouble petsc_wait_any_ct;
284: PETSC_EXTERN PetscLogDouble petsc_wait_all_ct;
285: PETSC_EXTERN PetscLogDouble petsc_sum_of_waits_ct;
287: PETSC_EXTERN PetscBool PetscLogSyncOn; /* true if logging synchronization is enabled */
289: #define PetscLogEventBegin(e,o1,o2,o3,o4) \
290: (((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog->curStage].perfInfo.active && petsc_stageLog->stageInfo[petsc_stageLog->curStage].eventLog->eventInfo[e].active) ? \
291: (*PetscLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4)) : 0 ))
293: #define PetscLogEventEnd(e,o1,o2,o3,o4) \
294: (((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog->curStage].perfInfo.active && petsc_stageLog->stageInfo[petsc_stageLog->curStage].eventLog->eventInfo[e].active) ? \
295: (*PetscLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4)) : 0 ))
297: PETSC_EXTERN PetscErrorCode PetscLogEventGetFlops(PetscLogEvent,PetscLogDouble*);
298: PETSC_EXTERN PetscErrorCode PetscLogEventZeroFlops(PetscLogEvent);
300: /*
301: These are used internally in the PETSc routines to keep a count of MPI messages and
302: their sizes.
304: This does not work for MPI-Uni because our include/petsc/mpiuni/mpi.h file
305: uses macros to defined the MPI operations.
307: It does not work correctly from HP-UX because it processes the
308: macros in a way that sometimes it double counts, hence
309: PETSC_HAVE_BROKEN_RECURSIVE_MACRO
311: It does not work with Windows because winmpich lacks MPI_Type_size()
312: */
314: /*
315: Logging of MPI activities
316: */
317: PETSC_STATIC_INLINE PetscErrorCode PetscMPITypeSize(PetscLogDouble *buff,PetscMPIInt count,MPI_Datatype type)
318: {
319: PetscMPIInt mysize;
320: PetscErrorCode _myierr;
321: if (type == MPI_DATATYPE_NULL) return 0;
322: _myMPI_Type_size(type,&mysize);CHKERRQ(_myierr);
323: *buff += (PetscLogDouble) (count*mysize);
324: return 0;
325: }
327: PETSC_STATIC_INLINE PetscErrorCode PetscMPITypeSizeComm(MPI_Comm comm, PetscLogDouble *buff,PetscMPIInt *counts,MPI_Datatype type)
328: {
329: PetscMPIInt mysize, commsize, p;
330: PetscErrorCode _myierr;
332: if (type == MPI_DATATYPE_NULL) return 0;
333: _myMPI_Comm_size(comm,&commsize);CHKERRQ(_myierr);
334: _myMPI_Type_size(type,&mysize);CHKERRQ(_myierr);
335: for (p = 0; p < commsize; ++p) {
336: *buff += (PetscLogDouble) (counts[p]*mysize);
337: }
338: return 0;
339: }
341: /*
342: Returns 1 if the communicator is parallel else zero
343: */
344: PETSC_STATIC_INLINE int PetscMPIParallelComm(MPI_Comm comm)
345: {
346: PetscMPIInt size; MPI_Comm_size(comm,&size); return size > 1;
347: }
349: #define MPI_Irecv(buf,count,datatype,source,tag,comm,request) \
350: ((petsc_irecv_ct++,0) || PetscMPITypeSize(&(petsc_irecv_len),(count),(datatype)) || MPI_Irecv((buf),(count),(datatype),(source),(tag),(comm),(request)))
352: #define MPI_Isend(buf,count,datatype,dest,tag,comm,request) \
353: ((petsc_isend_ct++,0) || PetscMPITypeSize(&(petsc_isend_len),(count),(datatype)) || MPI_Isend((buf),(count),(datatype),(dest),(tag),(comm),(request)))
355: #define MPI_Startall_irecv(count,number,requests) \
356: ((petsc_irecv_ct += (PetscLogDouble)(number),0) || PetscMPITypeSize(&(petsc_irecv_len),(count),(MPIU_SCALAR)) || MPI_Startall((number),(requests)))
358: #define MPI_Startall_isend(count,number,requests) \
359: ((petsc_isend_ct += (PetscLogDouble)(number),0) || PetscMPITypeSize(&(petsc_isend_len),(count),(MPIU_SCALAR)) || MPI_Startall((number),(requests)))
361: #define MPI_Start_isend(count,requests) \
362: ((petsc_isend_ct++,0) || PetscMPITypeSize((&petsc_isend_len),(count),(MPIU_SCALAR)) || MPI_Start((requests)))
364: #define MPI_Recv(buf,count,datatype,source,tag,comm,status) \
365: ((petsc_recv_ct++,0) || PetscMPITypeSize((&petsc_recv_len),(count),(datatype)) || MPI_Recv((buf),(count),(datatype),(source),(tag),(comm),(status)))
367: #define MPI_Send(buf,count,datatype,dest,tag,comm) \
368: ((petsc_send_ct++,0) || PetscMPITypeSize((&petsc_send_len),(count),(datatype)) || MPI_Send((buf),(count),(datatype),(dest),(tag),(comm)))
370: #define MPI_Wait(request,status) \
371: ((petsc_wait_ct++,petsc_sum_of_waits_ct++,0) || MPI_Wait((request),(status)))
373: #define MPI_Waitany(a,b,c,d) \
374: ((petsc_wait_any_ct++,petsc_sum_of_waits_ct++,0) || MPI_Waitany((a),(b),(c),(d)))
376: #define MPI_Waitall(count,array_of_requests,array_of_statuses) \
377: ((petsc_wait_all_ct++,petsc_sum_of_waits_ct += (PetscLogDouble) (count),0) || MPI_Waitall((count),(array_of_requests),(array_of_statuses)))
379: #define MPI_Allreduce(sendbuf,recvbuf,count,datatype,op,comm) \
380: ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Allreduce((sendbuf),(recvbuf),(count),(datatype),(op),(comm)))
382: #define MPI_Bcast(buffer,count,datatype,root,comm) \
383: ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Bcast((buffer),(count),(datatype),(root),(comm)))
385: #define MPI_Reduce_scatter_block(sendbuf,recvbuf,recvcount,datatype,op,comm) \
386: ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Reduce_scatter_block((sendbuf),(recvbuf),(recvcount),(datatype),(op),(comm)))
388: #define MPI_Alltoall(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype,comm) \
389: ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || PetscMPITypeSize((&petsc_send_len),(sendcount),(sendtype)) || MPI_Alltoall((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(recvtype),(comm)))
391: #define MPI_Alltoallv(sendbuf,sendcnts,sdispls,sendtype,recvbuf,recvcnts,rdispls,recvtype,comm) \
392: ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || PetscMPITypeSizeComm((comm),(&petsc_send_len),(sendcnts),(sendtype)) || MPI_Alltoallv((sendbuf),(sendcnts),(sdispls),(sendtype),(recvbuf),(recvcnts),(rdispls),(recvtype),(comm)))
394: #define MPI_Allgather(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype,comm) \
395: ((petsc_gather_ct += PetscMPIParallelComm((comm)),0) || MPI_Allgather((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(recvtype),(comm)))
397: #define MPI_Allgatherv(sendbuf,sendcount,sendtype,recvbuf,recvcount,displs,recvtype,comm) \
398: ((petsc_gather_ct += PetscMPIParallelComm((comm)),0) || MPI_Allgatherv((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(displs),(recvtype),(comm)))
400: #define MPI_Gather(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype,root,comm) \
401: ((petsc_gather_ct++,0) || PetscMPITypeSize((&petsc_send_len),(sendcount),(sendtype)) || MPI_Gather((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(recvtype),(root),(comm)))
403: #define MPI_Gatherv(sendbuf,sendcount,sendtype,recvbuf,recvcount,displs,recvtype,root,comm) \
404: ((petsc_gather_ct++,0) || PetscMPITypeSize((&petsc_send_len),(sendcount),(sendtype)) || MPI_Gatherv((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(displs),(recvtype),(root),(comm)))
406: #define MPI_Scatter(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype,root,comm) \
407: ((petsc_scatter_ct++,0) || PetscMPITypeSize((&petsc_recv_len),(recvcount),(recvtype)) || MPI_Scatter((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(recvtype),(root),(comm)))
409: #define MPI_Scatterv(sendbuf,sendcount,displs,sendtype,recvbuf,recvcount,recvtype,root,comm) \
410: ((petsc_scatter_ct++,0) || PetscMPITypeSize((&petsc_recv_len),(recvcount),(recvtype)) || MPI_Scatterv((sendbuf),(sendcount),(displs),(sendtype),(recvbuf),(recvcount),(recvtype),(root),(comm)))
412: #else
414: #define MPI_Startall_irecv(count,number,requests) \
415: (MPI_Startall((number),(requests)))
417: #define MPI_Startall_isend(count,number,requests) \
418: (MPI_Startall((number),(requests)))
420: #define MPI_Start_isend(count,requests) \
421: (MPI_Start((requests)))
423: #endif /* !__MPIUNI_H && ! PETSC_HAVE_BROKEN_RECURSIVE_MACRO */
425: #else /* ---Logging is turned off --------------------------------------------*/
427: #define PetscLogFlops(n) 0
428: #define PetscGetFlops(a) (*(a) = 0.0,0)
430: #define PetscLogStageRegister(a,b) 0
431: #define PetscLogStagePush(a) 0
432: #define PetscLogStagePop() 0
433: #define PetscLogStageSetActive(a,b) 0
434: #define PetscLogStageGetActive(a,b) 0
435: #define PetscLogStageGetVisible(a,b) 0
436: #define PetscLogStageSetVisible(a,b) 0
437: #define PetscLogStageGetId(a,b) (*(b)=0,0)
439: #define PetscLogEventRegister(a,b,c) 0
440: #define PetscLogEventSetCollective(a,b) 0
441: #define PetscLogEventIncludeClass(a) 0
442: #define PetscLogEventExcludeClass(a) 0
443: #define PetscLogEventActivate(a) 0
444: #define PetscLogEventDeactivate(a) 0
445: #define PetscLogEventActivateClass(a) 0
446: #define PetscLogEventDeactivateClass(a) 0
447: #define PetscLogEventSetActiveAll(a,b) 0
448: #define PetscLogEventGetId(a,b) (*(b)=0,0)
449: #define PetscLogEventGetPerfInfo(a,b,c) 0
451: #define PetscLogPLB 0
452: #define PetscLogPLE 0
453: #define PetscLogPHC 0
454: #define PetscLogPHD 0
456: #define PetscLogObjectParents(p,n,c) 0
457: #define PetscLogObjectCreate(h) 0
458: #define PetscLogObjectDestroy(h) 0
459: PETSC_EXTERN PetscErrorCode PetscLogObjectState(PetscObject,const char[],...);
461: #define PetscLogDefaultBegin() 0
462: #define PetscLogAllBegin() 0
463: #define PetscLogNestedBegin() 0
464: #define PetscLogTraceBegin(file) 0
465: #define PetscLogActions(a) 0
466: #define PetscLogObjects(a) 0
467: #define PetscLogSetThreshold(a,b) 0
468: #define PetscLogSet(lb,le) 0
470: #define PetscLogView(viewer) 0
471: #define PetscLogViewFromOptions() 0
472: #define PetscLogDump(c) 0
474: #define PetscLogEventBegin(e,o1,o2,o3,o4) 0
475: #define PetscLogEventEnd(e,o1,o2,o3,o4) 0
477: /* If PETSC_USE_LOG is NOT defined, these still need to be! */
478: #define MPI_Startall_irecv(count,number,requests) MPI_Startall(number,requests)
479: #define MPI_Startall_isend(count,number,requests) MPI_Startall(number,requests)
480: #define MPI_Start_isend(count,requests) MPI_Start(requests)
482: #endif /* PETSC_USE_LOG */
484: #define PetscPreLoadBegin(flag,name) \
485: do {\
486: PetscBool PetscPreLoading = flag;\
487: int PetscPreLoadMax,PetscPreLoadIt;\
488: PetscLogStage _stageNum;\
489: PetscErrorCode _3_ierr; \
490: _3_PetscOptionsGetBool(NULL,NULL,"-preload",&PetscPreLoading,NULL);CHKERRQ(_3_ierr); \
491: PetscPreLoadMax = (int)(PetscPreLoading);\
492: PetscPreLoadingUsed = PetscPreLoading ? PETSC_TRUE : PetscPreLoadingUsed;\
493: for (PetscPreLoadIt=0; PetscPreLoadIt<=PetscPreLoadMax; PetscPreLoadIt++) {\
494: PetscPreLoadingOn = PetscPreLoading;\
495: _3_PetscBarrier(NULL);CHKERRQ(_3_ierr);\
496: if (PetscPreLoadIt>0) {\
497: _3_PetscLogStageGetId(name,&_stageNum);CHKERRQ(_3_ierr);\
498: } else {\
499: _3_PetscLogStageRegister(name,&_stageNum);CHKERRQ(_3_ierr); \
500: }\
501: _3_PetscLogStageSetActive(_stageNum,(PetscBool)(!PetscPreLoadMax || PetscPreLoadIt));\
502: _3_PetscLogStagePush(_stageNum);CHKERRQ(_3_ierr);
504: #define PetscPreLoadEnd() \
505: _3_PetscLogStagePop();CHKERRQ(_3_ierr);\
506: PetscPreLoading = PETSC_FALSE;\
507: }\
508: } while (0)
510: #define PetscPreLoadStage(name) do { \
511: _3_PetscLogStagePop();CHKERRQ(_3_ierr); \
512: if (PetscPreLoadIt>0) { \
513: _3_PetscLogStageGetId(name,&_stageNum);CHKERRQ(_3_ierr); \
514: } else { \
515: _3_PetscLogStageRegister(name,&_stageNum);CHKERRQ(_3_ierr); \
516: } \
517: _3_PetscLogStageSetActive(_stageNum,(PetscBool)(!PetscPreLoadMax || PetscPreLoadIt)); \
518: _3_PetscLogStagePush(_stageNum);CHKERRQ(_3_ierr); \
519: } while (0)
521: /* some vars for logging */
522: PETSC_EXTERN PetscBool PetscPreLoadingUsed; /* true if we are or have done preloading */
523: PETSC_EXTERN PetscBool PetscPreLoadingOn; /* true if we are currently in a preloading calculation */
525: #endif