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 /* Events for the Petsc standard library */ 14 extern PetscEvent PETSC_DLLEXPORT PETSC_Barrier; 15 16 /* Global flop counter */ 17 extern PetscLogDouble PETSC_DLLEXPORT _TotalFlops; 18 19 /* General logging of information; different from event logging */ 20 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscVerboseInfo_Private(void*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 21 #if defined(PETSC_USE_VERBOSE) 22 #define PetscVerboseInfo(A) PetscVerboseInfo_Private A 23 #else 24 #define PetscVerboseInfo(A) 0 25 #endif 26 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscVerboseInfoDeactivateClass(PetscCookie); 27 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscVerboseInfoActivateClass(PetscCookie); 28 extern PetscTruth PETSC_DLLEXPORT PetscLogPrintInfo; /* if true, indicates PetscVerboseInfo() is turned on */ 29 30 #if defined(PETSC_USE_LOG) /* --- Logging is turned on --------------------------------*/ 31 32 /* 33 Flop counting: We count each arithmetic operation (e.g., addition, multiplication) separately. 34 35 For the complex numbers version, note that 36 1 complex addition = 2 flops 37 1 complex multiplication = 6 flops, 38 where we define 1 flop as that for a double precision scalar. We roughly approximate 39 flop counting for complex numbers by multiplying the total flops by 4; this corresponds 40 to the assumption that we're counting mostly additions and multiplications -- and 41 roughly the same number of each. More accurate counting could be done by distinguishing 42 among the various arithmetic operations. 43 */ 44 45 #if defined(PETSC_USE_COMPLEX) 46 #define PetscLogFlops(n) (_TotalFlops += (4*n),0) 47 #else 48 #define PetscLogFlops(n) (_TotalFlops += (n),0) 49 #endif 50 51 #if defined (PETSC_HAVE_MPE) 52 #include "mpe.h" 53 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogMPEBegin(void); 54 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogMPEDump(const char[]); 55 extern PetscTruth UseMPE; 56 #define PETSC_LOG_EVENT_MPE_BEGIN(e) \ 57 ((UseMPE && _stageLog->stageInfo[_stageLog->curStage].eventLog->eventInfo[e].active) ? \ 58 MPE_Log_event(_stageLog->eventLog->eventInfo[e].mpe_id_begin,0,NULL) : 0) 59 60 #define PETSC_LOG_EVENT_MPE_END(e) \ 61 ((UseMPE && _stageLog->stageInfo[_stageLog->curStage].eventLog->eventInfo[e].active) ? \ 62 MPE_Log_event(_stageLog->eventLog->eventInfo[e].mpe_id_end,0,NULL) : 0) 63 64 #else 65 #define PETSC_LOG_EVENT_MPE_BEGIN(e) 0 66 #define PETSC_LOG_EVENT_MPE_END(e) 0 67 #endif 68 69 EXTERN PETSC_DLLEXPORT PetscErrorCode (*_PetscLogPLB)(PetscEvent,int,PetscObject,PetscObject,PetscObject,PetscObject); 70 EXTERN PETSC_DLLEXPORT PetscErrorCode (*_PetscLogPLE)(PetscEvent,int,PetscObject,PetscObject,PetscObject,PetscObject); 71 EXTERN PETSC_DLLEXPORT PetscErrorCode (*_PetscLogPHC)(PetscObject); 72 EXTERN PETSC_DLLEXPORT PetscErrorCode (*_PetscLogPHD)(PetscObject); 73 74 #define PetscLogObjectParent(p,c) \ 75 ((c && p) ? ((PetscObject)(c))->parent = (PetscObject)(p),((PetscObject)(c))->parentid = ((PetscObject)p)->id : 0, 0) 76 77 #define PetscLogObjectParents(p,n,d) 0;{int _i; for (_i=0; _i<n; _i++) {ierr = PetscLogObjectParent(p,(d)[_i]);CHKERRQ(ierr);}} 78 #define PetscLogObjectCreate(h) ((_PetscLogPHC) ? (*_PetscLogPHC)((PetscObject)h) : 0) 79 #define PetscLogObjectDestroy(h) ((_PetscLogPHD) ? (*_PetscLogPHD)((PetscObject)h) : 0) 80 #define PetscLogObjectMemory(p,m) (((PetscObject)(p))->mem += (m),0) 81 /* Initialization functions */ 82 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogBegin(void); 83 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogAllBegin(void); 84 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogTraceBegin(FILE *); 85 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogActions(PetscTruth); 86 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogObjects(PetscTruth); 87 /* General functions */ 88 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogGetRGBColor(const char*[]); 89 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogDestroy(void); 90 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogSet(PetscErrorCode (*)(int, int, PetscObject, PetscObject, PetscObject, PetscObject), 91 PetscErrorCode (*)(int, int, PetscObject, PetscObject, PetscObject, PetscObject)); 92 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogObjectState(PetscObject, const char[], ...) PETSC_PRINTF_FORMAT_CHECK(2,3); 93 /* Output functions */ 94 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogPrintSummary(MPI_Comm, const char[]); 95 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogDump(const char[]); 96 /* Counter functions */ 97 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetFlops(PetscLogDouble *); 98 /* Stage functions */ 99 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStageRegister(int*, const char[]); 100 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStagePush(int); 101 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStagePop(void); 102 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStageSetActive(int, PetscTruth); 103 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStageGetActive(int, PetscTruth *); 104 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStageSetVisible(int, PetscTruth); 105 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStageGetVisible(int, PetscTruth *); 106 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogStageGetId(const char [], int *); 107 /* Event functions */ 108 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogEventRegister(PetscEvent*, const char[], PetscCookie); 109 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogEventActivate(PetscEvent); 110 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogEventDeactivate(PetscEvent); 111 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogEventSetActiveAll(PetscEvent, PetscTruth); 112 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogEventActivateClass(PetscCookie); 113 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogEventDeactivateClass(PetscCookie); 114 /* Class functions */ 115 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogClassRegister(PetscCookie*, const char []); 116 117 /* Global counters */ 118 extern PETSC_DLLEXPORT PetscLogDouble irecv_ct; 119 extern PETSC_DLLEXPORT PetscLogDouble isend_ct; 120 extern PETSC_DLLEXPORT PetscLogDouble recv_ct; 121 extern PETSC_DLLEXPORT PetscLogDouble send_ct; 122 extern PETSC_DLLEXPORT PetscLogDouble irecv_len; 123 extern PETSC_DLLEXPORT PetscLogDouble isend_len; 124 extern PETSC_DLLEXPORT PetscLogDouble recv_len; 125 extern PETSC_DLLEXPORT PetscLogDouble send_len; 126 extern PETSC_DLLEXPORT PetscLogDouble allreduce_ct; 127 extern PETSC_DLLEXPORT PetscLogDouble wait_ct; 128 extern PETSC_DLLEXPORT PetscLogDouble wait_any_ct; 129 extern PETSC_DLLEXPORT PetscLogDouble wait_all_ct; 130 extern PETSC_DLLEXPORT PetscLogDouble sum_of_waits_ct; 131 extern PETSC_DLLEXPORT int PETSC_DUMMY_SIZE; 132 extern PETSC_DLLEXPORT int PETSC_DUMMY_COUNT; 133 134 /* We must make these structures available if we are to access the event 135 activation flags in the PetscLogEventBegin/End() macros. If we forced a 136 function call each time, we could leave these structures in plog.h 137 */ 138 /* Default log */ 139 typedef struct _n_StageLog *StageLog; 140 extern PETSC_DLLEXPORT StageLog _stageLog; 141 142 /* A simple stack (should replace) */ 143 typedef struct _n_IntStack *IntStack; 144 145 /* The structures for logging performance */ 146 typedef struct _EventPerfInfo { 147 int id; /* The integer identifying this section */ 148 PetscTruth active; /* The flag to activate logging */ 149 PetscTruth visible; /* The flag to print info in summary */ 150 int depth; /* The nesting depth of the event call */ 151 int count; /* The number of times this section was executed */ 152 PetscLogDouble flops; /* The flops used in this section */ 153 PetscLogDouble time; /* The time taken for this section */ 154 PetscLogDouble numMessages; /* The number of messages in this section */ 155 PetscLogDouble messageLength; /* The total message lengths in this section */ 156 PetscLogDouble numReductions; /* The number of reductions in this section */ 157 } EventPerfInfo; 158 159 typedef struct _ClassPerfInfo { 160 int id; /* The integer identifying this class */ 161 int creations; /* The number of objects of this class created */ 162 int destructions; /* The number of objects of this class destroyed */ 163 PetscLogDouble mem; /* The total memory allocated by objects of this class */ 164 PetscLogDouble descMem; /* The total memory allocated by descendents of these objects */ 165 } ClassPerfInfo; 166 167 /* The structures for logging registration */ 168 typedef struct _ClassRegInfo { 169 char *name; /* The class name */ 170 PetscCookie cookie; /* The integer identifying this class */ 171 } ClassRegInfo; 172 173 typedef struct _EventRegInfo { 174 char *name; /* The name of this event */ 175 PetscCookie cookie; /* The class id for this event (should maybe give class ID instead) */ 176 #if defined (PETSC_HAVE_MPE) 177 int mpe_id_begin; /* MPE IDs that define the event */ 178 int mpe_id_end; 179 #endif 180 } EventRegInfo; 181 182 typedef struct _n_EventRegLog *EventRegLog; 183 struct _n_EventRegLog { 184 int numEvents; /* The number of registered events */ 185 int maxEvents; /* The maximum number of events */ 186 EventRegInfo *eventInfo; /* The registration information for each event */ 187 }; 188 189 typedef struct _n_EventPerfLog *EventPerfLog; 190 struct _n_EventPerfLog { 191 int numEvents; /* The number of logging events */ 192 int maxEvents; /* The maximum number of events */ 193 EventPerfInfo *eventInfo; /* The performance information for each event */ 194 }; 195 196 /* The structure for logging class information */ 197 typedef struct _n_ClassRegLog *ClassRegLog; 198 struct _n_ClassRegLog { 199 int numClasses; /* The number of classes registered */ 200 int maxClasses; /* The maximum number of classes */ 201 ClassRegInfo *classInfo; /* The structure for class information (cookies are monotonicly increasing) */ 202 }; 203 204 typedef struct _n_ClassPerfLog *ClassPerfLog; 205 struct _n_ClassPerfLog { 206 int numClasses; /* The number of logging classes */ 207 int maxClasses; /* The maximum number of classes */ 208 ClassPerfInfo *classInfo; /* The structure for class information (cookies are monotonicly increasing) */ 209 }; 210 211 /* The structures for logging in stages */ 212 typedef struct _StageInfo { 213 char *name; /* The stage name */ 214 PetscTruth used; /* The stage was pushed on this processor */ 215 EventPerfInfo perfInfo; /* The stage performance information */ 216 EventPerfLog eventLog; /* The event information for this stage */ 217 ClassPerfLog classLog; /* The class information for this stage */ 218 } StageInfo; 219 220 struct _n_StageLog { 221 /* Size information */ 222 int numStages; /* The number of registered stages */ 223 int maxStages; /* The maximum number of stages */ 224 /* Runtime information */ 225 IntStack stack; /* The stack for active stages */ 226 int curStage; /* The current stage (only used in macros so we don't call StackTop) */ 227 /* Stage specific information */ 228 StageInfo *stageInfo; /* The information for each stage */ 229 EventRegLog eventLog; /* The registered events */ 230 ClassRegLog classLog; /* The registered classes */ 231 }; 232 233 #define PetscLogEventBarrierBegin(e,o1,o2,o3,o4,cm) \ 234 (((_PetscLogPLB && _stageLog->stageInfo[_stageLog->curStage].perfInfo.active && _stageLog->stageInfo[_stageLog->curStage].eventLog->eventInfo[e].active) ? \ 235 (PetscLogEventBegin((e),o1,o2,o3,o4) || MPI_Barrier(cm) || PetscLogEventEnd((e),o1,o2,o3,o4)) : 0 ) || \ 236 PetscLogEventBegin((e)+1,o1,o2,o3,o4)) 237 238 #define PetscLogEventBegin(e,o1,o2,o3,o4) \ 239 (((_PetscLogPLB && _stageLog->stageInfo[_stageLog->curStage].perfInfo.active && _stageLog->stageInfo[_stageLog->curStage].eventLog->eventInfo[e].active) ? \ 240 (*_PetscLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4)) : 0 ) || \ 241 PETSC_LOG_EVENT_MPE_BEGIN(e)) 242 243 #define PetscLogEventBarrierEnd(e,o1,o2,o3,o4,cm) PetscLogEventEnd(e+1,o1,o2,o3,o4) 244 245 #define PetscLogEventEnd(e,o1,o2,o3,o4) \ 246 (((_PetscLogPLE && _stageLog->stageInfo[_stageLog->curStage].perfInfo.active && _stageLog->stageInfo[_stageLog->curStage].eventLog->eventInfo[e].active) ? \ 247 (*_PetscLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4)) : 0 ) || \ 248 PETSC_LOG_EVENT_MPE_END(e)) 249 250 /* Creation and destruction functions */ 251 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogCreate(StageLog *); 252 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogDestroy(StageLog); 253 /* Registration functions */ 254 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogRegister(StageLog, const char [], int *); 255 /* Runtime functions */ 256 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLogGetStageLog(StageLog *); 257 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogPush(StageLog, int); 258 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogPop(StageLog); 259 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetCurrent(StageLog, int *); 260 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogSetActive(StageLog, int, PetscTruth); 261 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetActive(StageLog, int, PetscTruth *); 262 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogSetVisible(StageLog, int, PetscTruth); 263 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetVisible(StageLog, int, PetscTruth *); 264 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetStage(StageLog, const char [], int *); 265 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetClassRegLog(StageLog, ClassRegLog *); 266 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetEventRegLog(StageLog, EventRegLog *); 267 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetClassPerfLog(StageLog, int, ClassPerfLog *); 268 EXTERN PetscErrorCode PETSC_DLLEXPORT StageLogGetEventPerfLog(StageLog, int, EventPerfLog *); 269 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