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