197bb86f7SLois Curfman McInnes /* 27588ac45SBarry Smith Defines profile/logging in PETSc. 397bb86f7SLois Curfman McInnes */ 497bb86f7SLois Curfman McInnes 5b0a32e0cSBarry Smith #if !defined(__PetscLog_H) 6b0a32e0cSBarry Smith #define __PetscLog_H 7aaa7dc30SBarry Smith #include <petscsys.h> 8c8d78d4dSSatish Balay 9fa2bb9feSLisandro Dalcin /* General logging of information; different from event logging */ 10fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscInfo_Private(const char[],void*,const char[],...); 11fa2bb9feSLisandro Dalcin #if defined(PETSC_USE_INFO) 12fa2bb9feSLisandro Dalcin #define PetscInfo(A,S) PetscInfo_Private(PETSC_FUNCTION_NAME,A,S) 13fa2bb9feSLisandro Dalcin #define PetscInfo1(A,S,a1) PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1) 14fa2bb9feSLisandro Dalcin #define PetscInfo2(A,S,a1,a2) PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2) 15fa2bb9feSLisandro Dalcin #define PetscInfo3(A,S,a1,a2,a3) PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2,a3) 16fa2bb9feSLisandro Dalcin #define PetscInfo4(A,S,a1,a2,a3,a4) PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2,a3,a4) 17fa2bb9feSLisandro Dalcin #define PetscInfo5(A,S,a1,a2,a3,a4,a5) PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2,a3,a4,a5) 18fa2bb9feSLisandro Dalcin #define PetscInfo6(A,S,a1,a2,a3,a4,a5,a6) PetscInfo_Private(PETSC_FUNCTION_NAME,A,S,a1,a2,a3,a4,a5,a6) 19fa2bb9feSLisandro Dalcin #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) 20fa2bb9feSLisandro Dalcin #else 21fa2bb9feSLisandro Dalcin #define PetscInfo(A,S) 0 22fa2bb9feSLisandro Dalcin #define PetscInfo1(A,S,a1) 0 23fa2bb9feSLisandro Dalcin #define PetscInfo2(A,S,a1,a2) 0 24fa2bb9feSLisandro Dalcin #define PetscInfo3(A,S,a1,a2,a3) 0 25fa2bb9feSLisandro Dalcin #define PetscInfo4(A,S,a1,a2,a3,a4) 0 26fa2bb9feSLisandro Dalcin #define PetscInfo5(A,S,a1,a2,a3,a4,a5) 0 27fa2bb9feSLisandro Dalcin #define PetscInfo6(A,S,a1,a2,a3,a4,a5,a6) 0 28fa2bb9feSLisandro Dalcin #define PetscInfo7(A,S,a1,a2,a3,a4,a5,a6,a7) 0 29fa2bb9feSLisandro Dalcin #endif 30fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscInfoDeactivateClass(PetscClassId); 31fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscInfoActivateClass(PetscClassId); 32fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscBool PetscLogPrintInfo; /* if true, indicates PetscInfo() is turned on */ 33fa2bb9feSLisandro Dalcin 34b859824cSBarry Smith /*MC 35b859824cSBarry Smith PetscLogEvent - id used to identify PETSc or user events which timed portions (blocks of executable) 36b859824cSBarry Smith code. 37b859824cSBarry Smith 38b859824cSBarry Smith Level: intermediate 39b859824cSBarry Smith 40b859824cSBarry Smith .seealso: PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd(), PetscLogStage 41b859824cSBarry Smith M*/ 42b859824cSBarry Smith typedef int PetscLogEvent; 43b859824cSBarry Smith 44b859824cSBarry Smith /*MC 45b859824cSBarry Smith PetscLogStage - id used to identify user stages (phases, sections) of runs - for logging 46b859824cSBarry Smith 47b859824cSBarry Smith Level: intermediate 48b859824cSBarry Smith 49522ce795SJed Brown .seealso: PetscLogStageRegister(), PetscLogStagePush(), PetscLogStagePop(), PetscLogEvent 50b859824cSBarry Smith M*/ 51b859824cSBarry Smith typedef int PetscLogStage; 52b859824cSBarry Smith 538ba1e511SMatthew Knepley #define PETSC_EVENT 1311311 54014dd563SJed Brown PETSC_EXTERN PetscLogEvent PETSC_LARGEST_EVENT; 5597bb86f7SLois Curfman McInnes 5619b02663SBarry Smith /* Global flop counter */ 57014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_TotalFlops; 58014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_tmp_flops; 5919b02663SBarry Smith 60*bec0b493Shannah_mairs /* Global GPU counters */ 61*bec0b493Shannah_mairs #if defined(PETSC_HAVE_VIENNACL) || defined(PETSC_HAVE_CUDA) 62*bec0b493Shannah_mairs PETSC_EXTERN PetscLogDouble petsc_ctog_ct; 63*bec0b493Shannah_mairs PETSC_EXTERN PetscLogDouble petsc_gtoc_ct; 64*bec0b493Shannah_mairs PETSC_EXTERN PetscLogDouble petsc_ctog_sz; 65*bec0b493Shannah_mairs PETSC_EXTERN PetscLogDouble petsc_gtoc_sz; 66*bec0b493Shannah_mairs #endif 67*bec0b493Shannah_mairs 6831d06abdSBarry Smith /* We must make the following structures available to access the event 6931d06abdSBarry Smith activation flags in the PetscLogEventBegin/End() macros. These are not part of the PETSc public 7031d06abdSBarry Smith API and are not intended to be used by other parts of PETSc or by users. 71d49d4b11SBarry Smith 72fa2bb9feSLisandro Dalcin The code that manipulates these structures is in src/sys/logging/utils. 7331d06abdSBarry Smith */ 74aa213bdcSJed Brown typedef struct _n_PetscIntStack *PetscIntStack; 756a6a9b46SSatish Balay 76217044c2SLisandro Dalcin /* -----------------------------------------------------------------------------------------------------*/ 77c60ec953SBarry Smith /* 78aa213bdcSJed Brown PetscClassRegInfo, PetscClassPerfInfo - Each class has two data structures associated with it. The first has 79c60ec953SBarry Smith static information about it, the second collects statistics on how many objects of the class are created, 80c60ec953SBarry Smith how much memory they use, etc. 81c60ec953SBarry Smith 82aa213bdcSJed Brown PetscClassRegLog, PetscClassPerfLog - arrays of the PetscClassRegInfo and PetscClassPerfInfo for all classes. 83c60ec953SBarry Smith */ 846a6a9b46SSatish Balay typedef struct { 85c60ec953SBarry Smith char *name; /* The class name */ 86c60ec953SBarry Smith PetscClassId classid; /* The integer identifying this class */ 87aa213bdcSJed Brown } PetscClassRegInfo; 886a6a9b46SSatish Balay 896a6a9b46SSatish Balay typedef struct { 900700a824SBarry Smith PetscClassId id; /* The integer identifying this class */ 916a6a9b46SSatish Balay int creations; /* The number of objects of this class created */ 926a6a9b46SSatish Balay int destructions; /* The number of objects of this class destroyed */ 936a6a9b46SSatish Balay PetscLogDouble mem; /* The total memory allocated by objects of this class */ 946a6a9b46SSatish Balay PetscLogDouble descMem; /* The total memory allocated by descendents of these objects */ 95aa213bdcSJed Brown } PetscClassPerfInfo; 966a6a9b46SSatish Balay 97aa213bdcSJed Brown typedef struct _n_PetscClassRegLog *PetscClassRegLog; 98aa213bdcSJed Brown struct _n_PetscClassRegLog { 99c60ec953SBarry Smith int numClasses; /* The number of classes registered */ 100c60ec953SBarry Smith int maxClasses; /* The maximum number of classes */ 101aa213bdcSJed Brown PetscClassRegInfo *classInfo; /* The structure for class information (classids are monotonicly increasing) */ 102c60ec953SBarry Smith }; 1036a6a9b46SSatish Balay 104aa213bdcSJed Brown typedef struct _n_PetscClassPerfLog *PetscClassPerfLog; 105aa213bdcSJed Brown struct _n_PetscClassPerfLog { 106c60ec953SBarry Smith int numClasses; /* The number of logging classes */ 107c60ec953SBarry Smith int maxClasses; /* The maximum number of classes */ 108aa213bdcSJed Brown PetscClassPerfInfo *classInfo; /* The structure for class information (classids are monotonicly increasing) */ 109c60ec953SBarry Smith }; 110c60ec953SBarry Smith /* -----------------------------------------------------------------------------------------------------*/ 111c60ec953SBarry Smith /* 112aa213bdcSJed Brown PetscEventRegInfo, PetscEventPerfInfo - Each event has two data structures associated with it. The first has 113c60ec953SBarry Smith static information about it, the second collects statistics on how many times the event is used, how 114c60ec953SBarry Smith much time it takes, etc. 115c60ec953SBarry Smith 116aa213bdcSJed Brown PetscEventRegLog, PetscEventPerfLog - an array of all PetscEventRegInfo and PetscEventPerfInfo for all events. There is one 117c60ec953SBarry Smith of these for each stage. 118c60ec953SBarry Smith 119c60ec953SBarry Smith */ 1206a6a9b46SSatish Balay typedef struct { 1216a6a9b46SSatish Balay char *name; /* The name of this event */ 122c60ec953SBarry Smith PetscClassId classid; /* The class the event is associated with */ 123217044c2SLisandro Dalcin PetscBool collective; /* Flag this event as collective */ 1246a6a9b46SSatish Balay #if defined (PETSC_HAVE_MPE) 1256a6a9b46SSatish Balay int mpe_id_begin; /* MPE IDs that define the event */ 1266a6a9b46SSatish Balay int mpe_id_end; 1276a6a9b46SSatish Balay #endif 128aa213bdcSJed Brown } PetscEventRegInfo; 1296a6a9b46SSatish Balay 130c60ec953SBarry Smith typedef struct { 131c60ec953SBarry Smith int id; /* The integer identifying this event */ 132ace3abfcSBarry Smith PetscBool active; /* The flag to activate logging */ 133ace3abfcSBarry Smith PetscBool visible; /* The flag to print info in summary */ 134c60ec953SBarry Smith int depth; /* The nesting depth of the event call */ 135c60ec953SBarry Smith int count; /* The number of times this event was executed */ 136a42e5b54SMatthew G Knepley PetscLogDouble flops, flops2, flopsTmp; /* The flops and flops^2 used in this event */ 137a42e5b54SMatthew G Knepley PetscLogDouble time, time2, timeTmp; /* The time and time^2 taken for this event */ 138217044c2SLisandro Dalcin PetscLogDouble syncTime; /* The synchronization barrier time */ 139891e75beSMatthew G. Knepley PetscLogDouble dof[8]; /* The number of degrees of freedom associated with this event */ 1405d68e14cSMatthew G. Knepley PetscLogDouble errors[8]; /* The errors (user-defined) associated with this event */ 141c60ec953SBarry Smith PetscLogDouble numMessages; /* The number of messages in this event */ 142c60ec953SBarry Smith PetscLogDouble messageLength; /* The total message lengths in this event */ 143c60ec953SBarry Smith PetscLogDouble numReductions; /* The number of reductions in this event */ 144e3ed9ee7SBarry Smith PetscLogDouble memIncrease; /* How much the resident memory has increased in this event */ 145e3ed9ee7SBarry Smith PetscLogDouble mallocIncrease;/* How much the maximum malloced space has increased in this event */ 146e3ed9ee7SBarry Smith PetscLogDouble mallocSpace; /* How much the space was malloced and kept during this event */ 147e3ed9ee7SBarry Smith PetscLogDouble mallocIncreaseEvent; /* Maximum of the high water mark with in event minus memory available at the end of the event */ 148*bec0b493Shannah_mairs #if defined(PETSC_HAVE_VIENNACL) || defined(PETSC_HAVE_CUDA) 149*bec0b493Shannah_mairs PetscLogDouble CpuToGpuCount; /* The total number of CPU to GPU copies */ 150*bec0b493Shannah_mairs PetscLogDouble GpuToCpuCount; /* The total number of GPU to CPU copies */ 151*bec0b493Shannah_mairs PetscLogDouble CpuToGpuSize; /* The total size of CPU to GPU copies */ 152*bec0b493Shannah_mairs PetscLogDouble GpuToCpuSize; /* The total size of GPU to CPU copies */ 153*bec0b493Shannah_mairs #endif 154aa213bdcSJed Brown } PetscEventPerfInfo; 155c60ec953SBarry Smith 156aa213bdcSJed Brown typedef struct _n_PetscEventRegLog *PetscEventRegLog; 157aa213bdcSJed Brown struct _n_PetscEventRegLog { 1586a6a9b46SSatish Balay int numEvents; /* The number of registered events */ 1596a6a9b46SSatish Balay int maxEvents; /* The maximum number of events */ 160aa213bdcSJed Brown PetscEventRegInfo *eventInfo; /* The registration information for each event */ 1616a6a9b46SSatish Balay }; 1626a6a9b46SSatish Balay 163aa213bdcSJed Brown typedef struct _n_PetscEventPerfLog *PetscEventPerfLog; 164aa213bdcSJed Brown struct _n_PetscEventPerfLog { 1656a6a9b46SSatish Balay int numEvents; /* The number of logging events */ 1666a6a9b46SSatish Balay int maxEvents; /* The maximum number of events */ 167aa213bdcSJed Brown PetscEventPerfInfo *eventInfo; /* The performance information for each event */ 1686a6a9b46SSatish Balay }; 169c60ec953SBarry Smith /* ------------------------------------------------------------------------------------------------------------*/ 170c60ec953SBarry Smith /* 171aa213bdcSJed Brown PetscStageInfo - Contains all the information about a particular stage. 1726a6a9b46SSatish Balay 173aa213bdcSJed Brown PetscStageLog - An array of PetscStageInfo for each registered stage. There is a single one of these in the code. 174c60ec953SBarry Smith */ 175aa213bdcSJed Brown typedef struct _PetscStageInfo { 1766a6a9b46SSatish Balay char *name; /* The stage name */ 177ace3abfcSBarry Smith PetscBool used; /* The stage was pushed on this processor */ 178aa213bdcSJed Brown PetscEventPerfInfo perfInfo; /* The stage performance information */ 179aa213bdcSJed Brown PetscEventPerfLog eventLog; /* The event information for this stage */ 180aa213bdcSJed Brown PetscClassPerfLog classLog; /* The class information for this stage */ 181aa213bdcSJed Brown } PetscStageInfo; 1826a6a9b46SSatish Balay 183aa213bdcSJed Brown typedef struct _n_PetscStageLog *PetscStageLog; 184aa213bdcSJed Brown struct _n_PetscStageLog { 1856a6a9b46SSatish Balay int numStages; /* The number of registered stages */ 1866a6a9b46SSatish Balay int maxStages; /* The maximum number of stages */ 187aa213bdcSJed Brown PetscIntStack stack; /* The stack for active stages */ 188aa213bdcSJed Brown int curStage; /* The current stage (only used in macros so we don't call PetscIntStackTop) */ 189aa213bdcSJed Brown PetscStageInfo *stageInfo; /* The information for each stage */ 190aa213bdcSJed Brown PetscEventRegLog eventLog; /* The registered events */ 191aa213bdcSJed Brown PetscClassRegLog classLog; /* The registered classes */ 1926a6a9b46SSatish Balay }; 193217044c2SLisandro Dalcin /* -----------------------------------------------------------------------------------------------------*/ 194fee518ebSJed Brown 1953bb1ff40SBarry Smith PETSC_EXTERN PetscErrorCode PetscLogObjectParent(PetscObject,PetscObject); 1963bb1ff40SBarry Smith PETSC_EXTERN PetscErrorCode PetscLogObjectMemory(PetscObject,PetscLogDouble); 1973bb1ff40SBarry Smith 198aa482453SBarry Smith #if defined(PETSC_USE_LOG) /* --- Logging is turned on --------------------------------*/ 199aeeda9f6SJohn Fettig PETSC_EXTERN PetscStageLog petsc_stageLog; 200f5d6ab90SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogGetStageLog(PetscStageLog*); 201f5d6ab90SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscStageLogGetCurrent(PetscStageLog,int*); 202f5d6ab90SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscStageLogGetEventPerfLog(PetscStageLog,int,PetscEventPerfLog*); 203614700edSBarry Smith 204da63de55SLois Curfman McInnes /* 205da63de55SLois Curfman McInnes Flop counting: We count each arithmetic operation (e.g., addition, multiplication) separately. 206da63de55SLois Curfman McInnes 207da63de55SLois Curfman McInnes For the complex numbers version, note that 208da63de55SLois Curfman McInnes 1 complex addition = 2 flops 209da63de55SLois Curfman McInnes 1 complex multiplication = 6 flops, 210da63de55SLois Curfman McInnes where we define 1 flop as that for a double precision scalar. We roughly approximate 211da63de55SLois Curfman McInnes flop counting for complex numbers by multiplying the total flops by 4; this corresponds 212da63de55SLois Curfman McInnes to the assumption that we're counting mostly additions and multiplications -- and 213da63de55SLois Curfman McInnes roughly the same number of each. More accurate counting could be done by distinguishing 214da63de55SLois Curfman McInnes among the various arithmetic operations. 215da63de55SLois Curfman McInnes */ 216da63de55SLois Curfman McInnes 217aa482453SBarry Smith #if defined(PETSC_USE_COMPLEX) 218542d4b3fSSatish Balay #define PETSC_FLOPS_PER_OP 4.0 219da63de55SLois Curfman McInnes #else 220542d4b3fSSatish Balay #define PETSC_FLOPS_PER_OP 1.0 221bf3909cdSBarry Smith #endif 222bf3909cdSBarry Smith 223dd19b90bSBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscLogFlops(PetscLogDouble n) 224dd19b90bSBarry Smith { 225dd19b90bSBarry Smith PetscFunctionBegin; 226bf3909cdSBarry Smith #if defined(PETSC_USE_DEBUG) 227dd19b90bSBarry Smith if (n < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Cannot log negative flops"); 228da63de55SLois Curfman McInnes #endif 229dd19b90bSBarry Smith petsc_TotalFlops += PETSC_FLOPS_PER_OP*n; 230dd19b90bSBarry Smith PetscFunctionReturn(0); 231dd19b90bSBarry Smith } 232fa2bb9feSLisandro Dalcin 233*bec0b493Shannah_mairs #if defined(PETSC_HAVE_VIENNACL) || defined(PETSC_HAVE_CUDA) 234*bec0b493Shannah_mairs PETSC_STATIC_INLINE PetscErrorCode PetscLogCpuToGpu(PetscLogDouble size){ 235*bec0b493Shannah_mairs petsc_ctog_ct += 1; 236*bec0b493Shannah_mairs petsc_ctog_sz += size; 237*bec0b493Shannah_mairs PetscFunctionReturn(0); 238*bec0b493Shannah_mairs } 239*bec0b493Shannah_mairs PETSC_STATIC_INLINE PetscErrorCode PetscLogGpuToCpu(PetscLogDouble size){ 240*bec0b493Shannah_mairs petsc_gtoc_ct += 1; 241*bec0b493Shannah_mairs petsc_gtoc_sz += size; 242*bec0b493Shannah_mairs PetscFunctionReturn(0); 243*bec0b493Shannah_mairs } 244*bec0b493Shannah_mairs #endif 245*bec0b493Shannah_mairs 246fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscGetFlops(PetscLogDouble *); 24777c4ece6SBarry Smith 248aa482453SBarry Smith #if defined (PETSC_HAVE_MPE) 249014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogMPEBegin(void); 250014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogMPEDump(const char[]); 25177c4ece6SBarry Smith #endif 25277c4ece6SBarry Smith 253014dd563SJed Brown PETSC_EXTERN PetscErrorCode (*PetscLogPLB)(PetscLogEvent,int,PetscObject,PetscObject,PetscObject,PetscObject); 254014dd563SJed Brown PETSC_EXTERN PetscErrorCode (*PetscLogPLE)(PetscLogEvent,int,PetscObject,PetscObject,PetscObject,PetscObject); 255014dd563SJed Brown PETSC_EXTERN PetscErrorCode (*PetscLogPHC)(PetscObject); 256014dd563SJed Brown PETSC_EXTERN PetscErrorCode (*PetscLogPHD)(PetscObject); 25777c4ece6SBarry Smith 258e83a5d19SLisandro Dalcin #define PetscLogObjectParents(p,n,d) 0;do{int _i; for (_i=0; _i<(n); _i++) {ierr = PetscLogObjectParent((PetscObject)(p),(PetscObject)(d)[_i]);CHKERRQ(ierr);}}while(0) 259fa2bb9feSLisandro Dalcin #define PetscLogObjectCreate(h) ((PetscLogPHC) ? (*PetscLogPHC)((PetscObject)(h)) : 0) 260fa2bb9feSLisandro Dalcin #define PetscLogObjectDestroy(h) ((PetscLogPHD) ? (*PetscLogPHD)((PetscObject)(h)) : 0) 261fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogObjectState(PetscObject, const char[], ...); 262fa2bb9feSLisandro Dalcin 2638ba1e511SMatthew Knepley /* Initialization functions */ 264bb1d7374SBarry Smith PETSC_EXTERN PetscErrorCode PetscLogDefaultBegin(void); 265014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogAllBegin(void); 266bb1d7374SBarry Smith PETSC_EXTERN PetscErrorCode PetscLogNestedBegin(void); 267014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogTraceBegin(FILE *); 268014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogActions(PetscBool); 269014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogObjects(PetscBool); 270fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogSetThreshold(PetscLogDouble,PetscLogDouble*); 271014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogSet(PetscErrorCode (*)(int, int, PetscObject, PetscObject, PetscObject, PetscObject), 2726849ba73SBarry Smith PetscErrorCode (*)(int, int, PetscObject, PetscObject, PetscObject, PetscObject)); 273fa2bb9feSLisandro Dalcin 2748ba1e511SMatthew Knepley /* Output functions */ 275014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogView(PetscViewer); 276f14045dbSBarry Smith PETSC_EXTERN PetscErrorCode PetscLogViewFromOptions(void); 277014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogDump(const char[]); 27831d06abdSBarry Smith 279fa2bb9feSLisandro Dalcin /* Stage functions */ 280014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStageRegister(const char[],PetscLogStage*); 281014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStagePush(PetscLogStage); 282014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStagePop(void); 283014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStageSetActive(PetscLogStage,PetscBool); 284014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStageGetActive(PetscLogStage,PetscBool*); 285014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStageSetVisible(PetscLogStage,PetscBool); 286014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStageGetVisible(PetscLogStage,PetscBool*); 287014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogStageGetId(const char[],PetscLogStage*); 288f5d6ab90SLisandro Dalcin 2898ba1e511SMatthew Knepley /* Event functions */ 290014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventRegister(const char[],PetscClassId,PetscLogEvent*); 291217044c2SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogEventSetCollective(PetscLogEvent,PetscBool); 292fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogEventIncludeClass(PetscClassId); 293fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogEventExcludeClass(PetscClassId); 294014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventActivate(PetscLogEvent); 295014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventDeactivate(PetscLogEvent); 296014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventSetActiveAll(PetscLogEvent,PetscBool); 297014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventActivateClass(PetscClassId); 298014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventDeactivateClass(PetscClassId); 2998c49a8d9SBarry Smith PETSC_EXTERN PetscErrorCode PetscLogEventGetId(const char[],PetscLogEvent*); 30013230571SMichael Lange PETSC_EXTERN PetscErrorCode PetscLogEventGetPerfInfo(int,PetscLogEvent,PetscEventPerfInfo*); 301891e75beSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLogEventSetDof(PetscLogEvent, PetscInt, PetscLogDouble); 3025d68e14cSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLogEventSetError(PetscLogEvent, PetscInt, PetscLogDouble); 3038ba1e511SMatthew Knepley 3048ba1e511SMatthew Knepley /* Global counters */ 305014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_irecv_ct; 306014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_isend_ct; 307014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_recv_ct; 308014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_send_ct; 309014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_irecv_len; 310014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_isend_len; 311014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_recv_len; 312014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_send_len; 313014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_allreduce_ct; 314014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_gather_ct; 315014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_scatter_ct; 316014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_wait_ct; 317014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_wait_any_ct; 318014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_wait_all_ct; 319014dd563SJed Brown PETSC_EXTERN PetscLogDouble petsc_sum_of_waits_ct; 3208ba1e511SMatthew Knepley 321e3ed9ee7SBarry Smith PETSC_EXTERN PetscBool PetscLogMemory; 322e3ed9ee7SBarry Smith 323fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscBool PetscLogSyncOn; /* true if logging synchronization is enabled */ 32462872c28SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogEventSynchronize(PetscLogEvent, MPI_Comm); 32562872c28SLisandro Dalcin 32662872c28SLisandro Dalcin #define PetscLogEventSync(e,comm) \ 32762872c28SLisandro Dalcin (((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog->curStage].perfInfo.active && petsc_stageLog->stageInfo[petsc_stageLog->curStage].eventLog->eventInfo[e].active) ? \ 32862872c28SLisandro Dalcin PetscLogEventSynchronize((e),(comm)) : 0 )) 32977c4ece6SBarry Smith 33052e6d16bSBarry Smith #define PetscLogEventBegin(e,o1,o2,o3,o4) \ 3318b5db460SBarry Smith (((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog->curStage].perfInfo.active && petsc_stageLog->stageInfo[petsc_stageLog->curStage].eventLog->eventInfo[e].active) ? \ 332495fc317SBarry Smith (*PetscLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4)) : 0 )) 333043328b6SSatish Balay 33452e6d16bSBarry Smith #define PetscLogEventEnd(e,o1,o2,o3,o4) \ 3358b5db460SBarry Smith (((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog->curStage].perfInfo.active && petsc_stageLog->stageInfo[petsc_stageLog->curStage].eventLog->eventInfo[e].active) ? \ 336495fc317SBarry Smith (*PetscLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4)) : 0 )) 33777c4ece6SBarry Smith 338014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventGetFlops(PetscLogEvent,PetscLogDouble*); 339014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscLogEventZeroFlops(PetscLogEvent); 340003131ecSBarry Smith 341ce85283eSBarry Smith /* 342f621e05eSBarry Smith These are used internally in the PETSc routines to keep a count of MPI messages and 343f621e05eSBarry Smith their sizes. 344f621e05eSBarry Smith 345af0996ceSBarry Smith This does not work for MPI-Uni because our include/petsc/mpiuni/mpi.h file 346ce85283eSBarry Smith uses macros to defined the MPI operations. 34715308354SBarry Smith 34815308354SBarry Smith It does not work correctly from HP-UX because it processes the 349bb4af37aSBarry Smith macros in a way that sometimes it double counts, hence 350b6410449SSatish Balay PETSC_HAVE_BROKEN_RECURSIVE_MACRO 3517c1e34a4SSatish Balay 352f569fd43SBarry Smith It does not work with Windows because winmpich lacks MPI_Type_size() 353ce85283eSBarry Smith */ 354c8217ed5SSatish Balay #if !defined(__MPIUNI_H) && !defined(PETSC_HAVE_BROKEN_RECURSIVE_MACRO) && !defined (PETSC_HAVE_MPI_MISSING_TYPESIZE) 35577a39924SBarry Smith /* 35677a39924SBarry Smith Logging of MPI activities 35777a39924SBarry Smith */ 358ad39c06fSJed Brown PETSC_STATIC_INLINE PetscErrorCode PetscMPITypeSize(PetscLogDouble *buff,PetscMPIInt count,MPI_Datatype type) 359f95db71bSBarry Smith { 3607d30fa4aSBarry Smith PetscMPIInt mysize; 3619c72ff1eSSatish Balay PetscErrorCode _myierr; 3627d30fa4aSBarry Smith if (type == MPI_DATATYPE_NULL) return 0; 3639c72ff1eSSatish Balay _myierr = MPI_Type_size(type,&mysize);CHKERRQ(_myierr); 3649c72ff1eSSatish Balay *buff += (PetscLogDouble) (count*mysize); 3659c72ff1eSSatish Balay return 0; 366f95db71bSBarry Smith } 36777a39924SBarry Smith 368ad39c06fSJed Brown PETSC_STATIC_INLINE PetscErrorCode PetscMPITypeSizeComm(MPI_Comm comm, PetscLogDouble *buff,PetscMPIInt *counts,MPI_Datatype type) 3693b9284c0SMatthew G Knepley { 3703b9284c0SMatthew G Knepley PetscMPIInt mysize, commsize, p; 3713b9284c0SMatthew G Knepley PetscErrorCode _myierr; 3723b9284c0SMatthew G Knepley 3737d30fa4aSBarry Smith if (type == MPI_DATATYPE_NULL) return 0; 3743b9284c0SMatthew G Knepley _myierr = MPI_Comm_size(comm,&commsize);CHKERRQ(_myierr); 3753b9284c0SMatthew G Knepley _myierr = MPI_Type_size(type,&mysize);CHKERRQ(_myierr); 3763b9284c0SMatthew G Knepley for (p = 0; p < commsize; ++p) { 3773b9284c0SMatthew G Knepley *buff += (PetscLogDouble) (counts[p]*mysize); 3783b9284c0SMatthew G Knepley } 3793b9284c0SMatthew G Knepley return 0; 3803b9284c0SMatthew G Knepley } 3813b9284c0SMatthew G Knepley 38272b11a25SBarry Smith /* 38372b11a25SBarry Smith Returns 1 if the communicator is parallel else zero 38472b11a25SBarry Smith */ 38572b11a25SBarry Smith PETSC_STATIC_INLINE int PetscMPIParallelComm(MPI_Comm comm) 38672b11a25SBarry Smith { 38772b11a25SBarry Smith PetscMPIInt size; MPI_Comm_size(comm,&size); return size > 1; 38872b11a25SBarry Smith } 38972b11a25SBarry Smith 39077a39924SBarry Smith #define MPI_Irecv(buf,count,datatype,source,tag,comm,request) \ 3915fa69175SJed Brown ((petsc_irecv_ct++,0) || PetscMPITypeSize(&(petsc_irecv_len),(count),(datatype)) || MPI_Irecv((buf),(count),(datatype),(source),(tag),(comm),(request))) 39215308354SBarry Smith 39377a39924SBarry Smith #define MPI_Isend(buf,count,datatype,dest,tag,comm,request) \ 3945fa69175SJed Brown ((petsc_isend_ct++,0) || PetscMPITypeSize(&(petsc_isend_len),(count),(datatype)) || MPI_Isend((buf),(count),(datatype),(dest),(tag),(comm),(request))) 39515308354SBarry Smith 396457b14b1SJunchao Zhang #define MPI_Startall_irecv(count,datatype,number,requests) \ 397ea1c87f7SJunchao Zhang ((petsc_irecv_ct += (PetscLogDouble)(number),0) || PetscMPITypeSize(&(petsc_irecv_len),(count),(datatype)) || ((number) && MPI_Startall((number),(requests)))) 3980d4b0b6cSBarry Smith 399457b14b1SJunchao Zhang #define MPI_Startall_isend(count,datatype,number,requests) \ 400ea1c87f7SJunchao Zhang ((petsc_isend_ct += (PetscLogDouble)(number),0) || PetscMPITypeSize(&(petsc_isend_len),(count),(datatype)) || ((number) && MPI_Startall((number),(requests)))) 4010d4b0b6cSBarry Smith 402457b14b1SJunchao Zhang #define MPI_Start_isend(count,datatype,requests) \ 403457b14b1SJunchao Zhang ((petsc_isend_ct++,0) || PetscMPITypeSize((&petsc_isend_len),(count),(datatype)) || MPI_Start((requests))) 4040d4b0b6cSBarry Smith 405ce85283eSBarry Smith #define MPI_Recv(buf,count,datatype,source,tag,comm,status) \ 4065fa69175SJed Brown ((petsc_recv_ct++,0) || PetscMPITypeSize((&petsc_recv_len),(count),(datatype)) || MPI_Recv((buf),(count),(datatype),(source),(tag),(comm),(status))) 40715308354SBarry Smith 40877a39924SBarry Smith #define MPI_Send(buf,count,datatype,dest,tag,comm) \ 4095fa69175SJed Brown ((petsc_send_ct++,0) || PetscMPITypeSize((&petsc_send_len),(count),(datatype)) || MPI_Send((buf),(count),(datatype),(dest),(tag),(comm))) 41077a39924SBarry Smith 41177a39924SBarry Smith #define MPI_Wait(request,status) \ 4125fa69175SJed Brown ((petsc_wait_ct++,petsc_sum_of_waits_ct++,0) || MPI_Wait((request),(status))) 41377a39924SBarry Smith 41477a39924SBarry Smith #define MPI_Waitany(a,b,c,d) \ 4155fa69175SJed Brown ((petsc_wait_any_ct++,petsc_sum_of_waits_ct++,0) || MPI_Waitany((a),(b),(c),(d))) 41677a39924SBarry Smith 41777a39924SBarry Smith #define MPI_Waitall(count,array_of_requests,array_of_statuses) \ 4185fa69175SJed Brown ((petsc_wait_all_ct++,petsc_sum_of_waits_ct += (PetscLogDouble) (count),0) || MPI_Waitall((count),(array_of_requests),(array_of_statuses))) 41977a39924SBarry Smith 42077a39924SBarry Smith #define MPI_Allreduce(sendbuf,recvbuf,count,datatype,op,comm) \ 4215fa69175SJed Brown ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Allreduce((sendbuf),(recvbuf),(count),(datatype),(op),(comm))) 4223914022bSBarry Smith 42354fe5c21SBarry Smith #define MPI_Bcast(buffer,count,datatype,root,comm) \ 4245fa69175SJed Brown ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Bcast((buffer),(count),(datatype),(root),(comm))) 42554fe5c21SBarry Smith 426d6e4c47cSJed Brown #define MPI_Reduce_scatter_block(sendbuf,recvbuf,recvcount,datatype,op,comm) \ 4275fa69175SJed Brown ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Reduce_scatter_block((sendbuf),(recvbuf),(recvcount),(datatype),(op),(comm))) 428d6e4c47cSJed Brown 4293b9284c0SMatthew G Knepley #define MPI_Alltoall(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype,comm) \ 4305fa69175SJed Brown ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || PetscMPITypeSize((&petsc_send_len),(sendcount),(sendtype)) || MPI_Alltoall((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(recvtype),(comm))) 4313b9284c0SMatthew G Knepley 4323b9284c0SMatthew G Knepley #define MPI_Alltoallv(sendbuf,sendcnts,sdispls,sendtype,recvbuf,recvcnts,rdispls,recvtype,comm) \ 4335fa69175SJed Brown ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || PetscMPITypeSizeComm((comm),(&petsc_send_len),(sendcnts),(sendtype)) || MPI_Alltoallv((sendbuf),(sendcnts),(sdispls),(sendtype),(recvbuf),(recvcnts),(rdispls),(recvtype),(comm))) 4343b9284c0SMatthew G Knepley 43501faf4e4SMatthew Knepley #define MPI_Allgather(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype,comm) \ 4365fa69175SJed Brown ((petsc_gather_ct += PetscMPIParallelComm((comm)),0) || MPI_Allgather((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(recvtype),(comm))) 43701faf4e4SMatthew Knepley 43801faf4e4SMatthew Knepley #define MPI_Allgatherv(sendbuf,sendcount,sendtype,recvbuf,recvcount,displs,recvtype,comm) \ 4395fa69175SJed Brown ((petsc_gather_ct += PetscMPIParallelComm((comm)),0) || MPI_Allgatherv((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(displs),(recvtype),(comm))) 44001faf4e4SMatthew Knepley 44101faf4e4SMatthew Knepley #define MPI_Gather(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype,root,comm) \ 4425fa69175SJed Brown ((petsc_gather_ct++,0) || PetscMPITypeSize((&petsc_send_len),(sendcount),(sendtype)) || MPI_Gather((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(recvtype),(root),(comm))) 44301faf4e4SMatthew Knepley 44401faf4e4SMatthew Knepley #define MPI_Gatherv(sendbuf,sendcount,sendtype,recvbuf,recvcount,displs,recvtype,root,comm) \ 4455fa69175SJed Brown ((petsc_gather_ct++,0) || PetscMPITypeSize((&petsc_send_len),(sendcount),(sendtype)) || MPI_Gatherv((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(displs),(recvtype),(root),(comm))) 44601faf4e4SMatthew Knepley 44701faf4e4SMatthew Knepley #define MPI_Scatter(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype,root,comm) \ 4485fa69175SJed Brown ((petsc_scatter_ct++,0) || PetscMPITypeSize((&petsc_recv_len),(recvcount),(recvtype)) || MPI_Scatter((sendbuf),(sendcount),(sendtype),(recvbuf),(recvcount),(recvtype),(root),(comm))) 44901faf4e4SMatthew Knepley 45001faf4e4SMatthew Knepley #define MPI_Scatterv(sendbuf,sendcount,displs,sendtype,recvbuf,recvcount,recvtype,root,comm) \ 4515fa69175SJed Brown ((petsc_scatter_ct++,0) || PetscMPITypeSize((&petsc_recv_len),(recvcount),(recvtype)) || MPI_Scatterv((sendbuf),(sendcount),(displs),(sendtype),(recvbuf),(recvcount),(recvtype),(root),(comm))) 45201faf4e4SMatthew Knepley 4530d4b0b6cSBarry Smith #else 4540d4b0b6cSBarry Smith 455457b14b1SJunchao Zhang #define MPI_Startall_irecv(count,datatype,number,requests) \ 456ea1c87f7SJunchao Zhang ((number) && MPI_Startall((number),(requests))) 4570d4b0b6cSBarry Smith 458457b14b1SJunchao Zhang #define MPI_Startall_isend(count,datatype,number,requests) \ 459ea1c87f7SJunchao Zhang ((number) && MPI_Startall((number),(requests))) 4600d4b0b6cSBarry Smith 461457b14b1SJunchao Zhang #define MPI_Start_isend(count,datatype,requests) \ 4625fa69175SJed Brown (MPI_Start((requests))) 4630d4b0b6cSBarry Smith 464c8217ed5SSatish Balay #endif /* !__MPIUNI_H && ! PETSC_HAVE_BROKEN_RECURSIVE_MACRO */ 465614700edSBarry Smith 466df8cf0b5SBarry Smith #else /* ---Logging is turned off --------------------------------------------*/ 467614700edSBarry Smith 468e3ed9ee7SBarry Smith #define PetscLogMemory PETSC_FALSE 469e3ed9ee7SBarry Smith 470b0a32e0cSBarry Smith #define PetscLogFlops(n) 0 471fa2bb9feSLisandro Dalcin #define PetscGetFlops(a) (*(a) = 0.0,0) 472614700edSBarry Smith 473fa2bb9feSLisandro Dalcin #define PetscLogStageRegister(a,b) 0 474fa2bb9feSLisandro Dalcin #define PetscLogStagePush(a) 0 475fa2bb9feSLisandro Dalcin #define PetscLogStagePop() 0 476f5d6ab90SLisandro Dalcin #define PetscLogStageSetActive(a,b) 0 477f5d6ab90SLisandro Dalcin #define PetscLogStageGetActive(a,b) 0 478f5d6ab90SLisandro Dalcin #define PetscLogStageGetVisible(a,b) 0 479f5d6ab90SLisandro Dalcin #define PetscLogStageSetVisible(a,b) 0 480f5d6ab90SLisandro Dalcin #define PetscLogStageGetId(a,b) (*(b)=0,0) 481f5d6ab90SLisandro Dalcin 482fa2bb9feSLisandro Dalcin #define PetscLogEventRegister(a,b,c) 0 483fa2bb9feSLisandro Dalcin #define PetscLogEventSetCollective(a,b) 0 484fa2bb9feSLisandro Dalcin #define PetscLogEventIncludeClass(a) 0 485fa2bb9feSLisandro Dalcin #define PetscLogEventExcludeClass(a) 0 486b0a32e0cSBarry Smith #define PetscLogEventActivate(a) 0 487b0a32e0cSBarry Smith #define PetscLogEventDeactivate(a) 0 488b0a32e0cSBarry Smith #define PetscLogEventActivateClass(a) 0 489b0a32e0cSBarry Smith #define PetscLogEventDeactivateClass(a) 0 490e8e7597cSSatish Balay #define PetscLogEventSetActiveAll(a,b) 0 49146eb3cd7SSatish Balay #define PetscLogEventGetId(a,b) (*(b)=0,0) 492561b2a67SSatish Balay #define PetscLogEventGetPerfInfo(a,b,c) 0 4939c702cfcSMatthew G. Knepley #define PetscLogEventSetDof(a,b,c) 0 4949c702cfcSMatthew G. Knepley #define PetscLogEventSetError(a,b,c) 0 49577c4ece6SBarry Smith 4968b5db460SBarry Smith #define PetscLogPLB 0 4978b5db460SBarry Smith #define PetscLogPLE 0 4988b5db460SBarry Smith #define PetscLogPHC 0 4998b5db460SBarry Smith #define PetscLogPHD 0 500f5d6ab90SLisandro Dalcin 501efee365bSSatish Balay #define PetscLogObjectParents(p,n,c) 0 50252e6d16bSBarry Smith #define PetscLogObjectCreate(h) 0 50352e6d16bSBarry Smith #define PetscLogObjectDestroy(h) 0 504fa2bb9feSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscLogObjectState(PetscObject,const char[],...); 505fa2bb9feSLisandro Dalcin 506bb1d7374SBarry Smith #define PetscLogDefaultBegin() 0 507b0a32e0cSBarry Smith #define PetscLogAllBegin() 0 508bb1d7374SBarry Smith #define PetscLogNestedBegin() 0 509fa2bb9feSLisandro Dalcin #define PetscLogTraceBegin(file) 0 51073fda44aSBarry Smith #define PetscLogActions(a) 0 511fa2bb9feSLisandro Dalcin #define PetscLogObjects(a) 0 512fa2bb9feSLisandro Dalcin #define PetscLogSetThreshold(a,b) 0 513fa2bb9feSLisandro Dalcin #define PetscLogSet(lb,le) 0 514fa2bb9feSLisandro Dalcin 515fa2bb9feSLisandro Dalcin #define PetscLogView(viewer) 0 516fa2bb9feSLisandro Dalcin #define PetscLogViewFromOptions() 0 517fa2bb9feSLisandro Dalcin #define PetscLogDump(c) 0 518fa2bb9feSLisandro Dalcin 51962872c28SLisandro Dalcin #define PetscLogEventSync(e,comm) 0 520fa2bb9feSLisandro Dalcin #define PetscLogEventBegin(e,o1,o2,o3,o4) 0 521fa2bb9feSLisandro Dalcin #define PetscLogEventEnd(e,o1,o2,o3,o4) 0 522ce6058e1SBarry Smith 523aa482453SBarry Smith /* If PETSC_USE_LOG is NOT defined, these still need to be! */ 524ea1c87f7SJunchao Zhang #define MPI_Startall_irecv(count,datatype,number,requests) ((number) && MPI_Startall(number,requests)) 525ea1c87f7SJunchao Zhang #define MPI_Startall_isend(count,datatype,number,requests) ((number) && MPI_Startall(number,requests)) 526457b14b1SJunchao Zhang #define MPI_Start_isend(count,datatype,requests) MPI_Start(requests) 527f141ce34SMatthew Knepley 528aa482453SBarry Smith #endif /* PETSC_USE_LOG */ 5296daaf66cSBarry Smith 530204a6943SJed Brown #define PetscPreLoadBegin(flag,name) \ 531204a6943SJed Brown do {\ 532204a6943SJed Brown PetscBool PetscPreLoading = flag;\ 533204a6943SJed Brown int PetscPreLoadMax,PetscPreLoadIt;\ 534166c7f25SBarry Smith PetscLogStage _stageNum;\ 5358cbcd9ccSBarry Smith PetscErrorCode _3_ierr; \ 536c5929fdfSBarry Smith _3_ierr = PetscOptionsGetBool(NULL,NULL,"-preload",&PetscPreLoading,NULL);CHKERRQ(_3_ierr); \ 537204a6943SJed Brown PetscPreLoadMax = (int)(PetscPreLoading);\ 538204a6943SJed Brown PetscPreLoadingUsed = PetscPreLoading ? PETSC_TRUE : PetscPreLoadingUsed;\ 539204a6943SJed Brown for (PetscPreLoadIt=0; PetscPreLoadIt<=PetscPreLoadMax; PetscPreLoadIt++) {\ 540204a6943SJed Brown PetscPreLoadingOn = PetscPreLoading;\ 5410298fd71SBarry Smith _3_ierr = PetscBarrier(NULL);CHKERRQ(_3_ierr);\ 542204a6943SJed Brown if (PetscPreLoadIt>0) {\ 5438e58c17dSMatthew Knepley _3_ierr = PetscLogStageGetId(name,&_stageNum);CHKERRQ(_3_ierr);\ 5448e58c17dSMatthew Knepley } else {\ 545a3bc4eb9SBarry Smith _3_ierr = PetscLogStageRegister(name,&_stageNum);CHKERRQ(_3_ierr); \ 5468e58c17dSMatthew Knepley }\ 547204a6943SJed Brown _3_ierr = PetscLogStageSetActive(_stageNum,(PetscBool)(!PetscPreLoadMax || PetscPreLoadIt));\ 5488e58c17dSMatthew Knepley _3_ierr = PetscLogStagePush(_stageNum);CHKERRQ(_3_ierr); 5498e58c17dSMatthew Knepley 550204a6943SJed Brown #define PetscPreLoadEnd() \ 551043328b6SSatish Balay _3_ierr = PetscLogStagePop();CHKERRQ(_3_ierr);\ 552204a6943SJed Brown PetscPreLoading = PETSC_FALSE;\ 553043328b6SSatish Balay }\ 554204a6943SJed Brown } while (0) 5558e58c17dSMatthew Knepley 556204a6943SJed Brown #define PetscPreLoadStage(name) do { \ 557043328b6SSatish Balay _3_ierr = PetscLogStagePop();CHKERRQ(_3_ierr); \ 558204a6943SJed Brown if (PetscPreLoadIt>0) { \ 5598e58c17dSMatthew Knepley _3_ierr = PetscLogStageGetId(name,&_stageNum);CHKERRQ(_3_ierr); \ 5608e58c17dSMatthew Knepley } else { \ 561a3bc4eb9SBarry Smith _3_ierr = PetscLogStageRegister(name,&_stageNum);CHKERRQ(_3_ierr); \ 5628e58c17dSMatthew Knepley } \ 563204a6943SJed Brown _3_ierr = PetscLogStageSetActive(_stageNum,(PetscBool)(!PetscPreLoadMax || PetscPreLoadIt)); \ 564204a6943SJed Brown _3_ierr = PetscLogStagePush(_stageNum);CHKERRQ(_3_ierr); \ 565204a6943SJed Brown } while (0) 566e9fa29b7SSatish Balay 567ad14c47eSJed Brown /* some vars for logging */ 568ad14c47eSJed Brown PETSC_EXTERN PetscBool PetscPreLoadingUsed; /* true if we are or have done preloading */ 569ad14c47eSJed Brown PETSC_EXTERN PetscBool PetscPreLoadingOn; /* true if we are currently in a preloading calculation */ 570ad14c47eSJed Brown 57197bb86f7SLois Curfman McInnes #endif 572