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