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