173f4d377SMatthew Knepley /* $Id: petsclog.h,v 1.155 2001/09/06 14:51:20 bsmith Exp $ */ 297bb86f7SLois Curfman McInnes 397bb86f7SLois Curfman McInnes /* 47588ac45SBarry Smith Defines profile/logging in PETSc. 597bb86f7SLois Curfman McInnes */ 697bb86f7SLois Curfman McInnes 7b0a32e0cSBarry Smith #if !defined(__PetscLog_H) 8b0a32e0cSBarry Smith #define __PetscLog_H 997bb86f7SLois Curfman McInnes #include "petsc.h" 10*e9fa29b7SSatish Balay PETSC_EXTERN_CXX_BEGIN 1197bb86f7SLois Curfman McInnes /* 128ba1e511SMatthew Knepley Each PETSc object class has it's own cookie (internal integer in the 138ba1e511SMatthew Knepley data structure used for error checking). These are all defined by an offset 148ba1e511SMatthew Knepley from the lowest one, PETSC_COOKIE. 1597bb86f7SLois Curfman McInnes */ 168ba1e511SMatthew Knepley #define PETSC_COOKIE 1211211 178ba1e511SMatthew Knepley extern int PETSC_LARGEST_COOKIE; 188ba1e511SMatthew Knepley #define PETSC_EVENT 1311311 198ba1e511SMatthew Knepley extern int PETSC_LARGEST_EVENT; 2097bb86f7SLois Curfman McInnes 218ba1e511SMatthew Knepley /* Events for the Petsc standard library */ 22d5ba7fb7SMatthew Knepley extern int PETSC_Barrier; 2397bb86f7SLois Curfman McInnes 2419b02663SBarry Smith /* Global flop counter */ 25b0a32e0cSBarry Smith extern PetscLogDouble _TotalFlops; 2619b02663SBarry Smith 27edde42fcSLois Curfman McInnes /* General logging of information; different from event logging */ 28f80b7eb0SBarry Smith EXTERN int PetscLogInfo(void*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 29b0a32e0cSBarry Smith EXTERN int PetscLogInfoDeactivateClass(int); 30b0a32e0cSBarry Smith EXTERN int PetscLogInfoActivateClass(int); 31b0a32e0cSBarry Smith extern PetscTruth PetscLogPrintInfo; /* if true, indicates PetscLogInfo() is turned on */ 32614700edSBarry Smith 33aa482453SBarry Smith #if defined(PETSC_USE_LOG) /* --- Logging is turned on --------------------------------*/ 34614700edSBarry Smith 35da63de55SLois Curfman McInnes /* 36da63de55SLois Curfman McInnes Flop counting: We count each arithmetic operation (e.g., addition, multiplication) separately. 37da63de55SLois Curfman McInnes 38da63de55SLois Curfman McInnes For the complex numbers version, note that 39da63de55SLois Curfman McInnes 1 complex addition = 2 flops 40da63de55SLois Curfman McInnes 1 complex multiplication = 6 flops, 41da63de55SLois Curfman McInnes where we define 1 flop as that for a double precision scalar. We roughly approximate 42da63de55SLois Curfman McInnes flop counting for complex numbers by multiplying the total flops by 4; this corresponds 43da63de55SLois Curfman McInnes to the assumption that we're counting mostly additions and multiplications -- and 44da63de55SLois Curfman McInnes roughly the same number of each. More accurate counting could be done by distinguishing 45da63de55SLois Curfman McInnes among the various arithmetic operations. 46da63de55SLois Curfman McInnes */ 47da63de55SLois Curfman McInnes 48aa482453SBarry Smith #if defined(PETSC_USE_COMPLEX) 49b0a32e0cSBarry Smith #define PetscLogFlops(n) (_TotalFlops += (4*n),0) 50da63de55SLois Curfman McInnes #else 51b0a32e0cSBarry Smith #define PetscLogFlops(n) (_TotalFlops += (n),0) 52da63de55SLois Curfman McInnes #endif 5377c4ece6SBarry Smith 54aa482453SBarry Smith #if defined (PETSC_HAVE_MPE) 5577c4ece6SBarry Smith #include "mpe.h" 56b0a32e0cSBarry Smith EXTERN int PetscLogMPEBegin(void); 57b0a32e0cSBarry Smith EXTERN int PetscLogMPEDump(const char[]); 5835d8aa7fSBarry Smith extern PetscTruth UseMPE; 59043328b6SSatish Balay #define PETSC_LOG_EVENT_MPE_BEGIN(e) \ 6074968b1dSMatthew Knepley if(UseMPE && _stageLog->stageInfo[_stageLog->curStage].eventLog->eventInfo[e].active) \ 6144451550SSatish Balay MPE_Log_event(_stageLog->eventLog->eventInfo[e].mpe_id_begin,0,""); 62043328b6SSatish Balay 63043328b6SSatish Balay #define PETSC_LOG_EVENT_MPE_END(e) \ 6474968b1dSMatthew Knepley if(UseMPE && _stageLog->stageInfo[_stageLog->curStage].eventLog->eventInfo[e].active) \ 6544451550SSatish Balay MPE_Log_event(_stageLog->eventLog->eventInfo[e].mpe_id_end,0,""); 66043328b6SSatish Balay 67614700edSBarry Smith #else 68043328b6SSatish Balay #define PETSC_LOG_EVENT_MPE_BEGIN(e) 69043328b6SSatish Balay #define PETSC_LOG_EVENT_MPE_END(e) 7077c4ece6SBarry Smith #endif 7177c4ece6SBarry Smith 72b0a32e0cSBarry Smith EXTERN int (*_PetscLogPLB)(int,int,PetscObject,PetscObject,PetscObject,PetscObject); 73b0a32e0cSBarry Smith EXTERN int (*_PetscLogPLE)(int,int,PetscObject,PetscObject,PetscObject,PetscObject); 74b0a32e0cSBarry Smith EXTERN int (*_PetscLogPHC)(PetscObject); 75b0a32e0cSBarry Smith EXTERN int (*_PetscLogPHD)(PetscObject); 7677c4ece6SBarry Smith 77043328b6SSatish Balay #define PetscLogObjectParent(p,c) \ 78043328b6SSatish Balay if (c) {\ 79043328b6SSatish Balay PetscValidHeader((PetscObject)(c));\ 808ba1e511SMatthew Knepley PetscValidHeader((PetscObject)(p));\ 818ba1e511SMatthew Knepley ((PetscObject)(c))->parent = (PetscObject)(p);\ 82043328b6SSatish Balay ((PetscObject)(c))->parentid = ((PetscObject)p)->id;\ 83043328b6SSatish Balay } 84043328b6SSatish Balay #define PetscLogObjectParents(p,n,d) {int _i; for (_i=0; _i<n; _i++) PetscLogObjectParent(p,(d)[_i]);} 858ba1e511SMatthew Knepley #define PetscLogObjectCreate(h) {if (_PetscLogPHC) (*_PetscLogPHC)((PetscObject)h);} 868ba1e511SMatthew Knepley #define PetscLogObjectDestroy(h) {if (_PetscLogPHD) (*_PetscLogPHD)((PetscObject)h);} 87043328b6SSatish Balay #define PetscLogObjectMemory(p,m) {PetscValidHeader((PetscObject)p);((PetscObject)(p))->mem += (m);} 888ba1e511SMatthew Knepley /* Initialization functions */ 898ba1e511SMatthew Knepley EXTERN int PetscLogBegin(void); 908ba1e511SMatthew Knepley EXTERN int PetscLogAllBegin(void); 918ba1e511SMatthew Knepley EXTERN int PetscLogTraceBegin(FILE *); 929c7ebac3SMatthew Knepley EXTERN int PetscLogActions(PetscTruth); 939c7ebac3SMatthew Knepley EXTERN int PetscLogObjects(PetscTruth); 948ba1e511SMatthew Knepley /* General functions */ 95043328b6SSatish Balay EXTERN int PetscLogGetRGBColor(char **); 968ba1e511SMatthew Knepley EXTERN int PetscLogDestroy(void); 978ba1e511SMatthew Knepley EXTERN int PetscLogSet(int (*)(int, int, PetscObject, PetscObject, PetscObject, PetscObject), 988ba1e511SMatthew Knepley int (*)(int, int, PetscObject, PetscObject, PetscObject, PetscObject)); 99f80b7eb0SBarry Smith EXTERN int PetscLogObjectState(PetscObject, const char[], ...) PETSC_PRINTF_FORMAT_CHECK(2,3); 1008ba1e511SMatthew Knepley /* Output functions */ 1018ba1e511SMatthew Knepley EXTERN int PetscLogPrintSummary(MPI_Comm, const char[]); 1028ba1e511SMatthew Knepley EXTERN int PetscLogDump(const char[]); 1038ba1e511SMatthew Knepley /* Counter functions */ 1048ba1e511SMatthew Knepley EXTERN int PetscGetFlops(PetscLogDouble *); 1058ba1e511SMatthew Knepley /* Stage functions */ 1068ba1e511SMatthew Knepley EXTERN int PetscLogStageRegister(int *, const char[]); 1078ba1e511SMatthew Knepley EXTERN int PetscLogStagePush(int); 1088ba1e511SMatthew Knepley EXTERN int PetscLogStagePop(void); 109773a6509SMatthew Knepley EXTERN int PetscLogStageSetActive(int, PetscTruth); 110773a6509SMatthew Knepley EXTERN int PetscLogStageGetActive(int, PetscTruth *); 1118ba1e511SMatthew Knepley EXTERN int PetscLogStageSetVisible(int, PetscTruth); 1128ba1e511SMatthew Knepley EXTERN int PetscLogStageGetVisible(int, PetscTruth *); 1138e58c17dSMatthew Knepley EXTERN int PetscLogStageGetId(const char [], int *); 1148ba1e511SMatthew Knepley /* Event functions */ 115043328b6SSatish Balay EXTERN int PetscLogEventRegister(int *, const char[], int); 1168ba1e511SMatthew Knepley EXTERN int PetscLogEventActivate(int); 1178ba1e511SMatthew Knepley EXTERN int PetscLogEventDeactivate(int); 118cda78268SMatthew Knepley EXTERN int PetscLogEventSetActiveAll(int, PetscTruth); 1198ba1e511SMatthew Knepley EXTERN int PetscLogEventActivateClass(int); 1208ba1e511SMatthew Knepley EXTERN int PetscLogEventDeactivateClass(int); 1218ba1e511SMatthew Knepley /* Class functions */ 1228ba1e511SMatthew Knepley EXTERN int PetscLogClassRegister(int *, const char []); 1238ba1e511SMatthew Knepley 1248ba1e511SMatthew Knepley /* Global counters */ 1258ba1e511SMatthew Knepley extern PetscLogDouble irecv_ct, isend_ct, recv_ct, send_ct; 1268ba1e511SMatthew Knepley extern PetscLogDouble irecv_len, isend_len, recv_len, send_len; 1278ba1e511SMatthew Knepley extern PetscLogDouble allreduce_ct; 1288ba1e511SMatthew Knepley extern PetscLogDouble wait_ct, wait_any_ct, wait_all_ct, sum_of_waits_ct; 1298ba1e511SMatthew Knepley extern int PETSC_DUMMY, PETSC_DUMMY_SIZE; 1308ba1e511SMatthew Knepley 1318ba1e511SMatthew Knepley /* We must make these structures available if we are to access the event 1328ba1e511SMatthew Knepley activation flags in the PetscLogEventBegin/End() macros. If we forced a 1338ba1e511SMatthew Knepley function call each time, we could leave these structures in plog.h 1348ba1e511SMatthew Knepley */ 135e855f6f8SMatthew Knepley /* Default log */ 136e855f6f8SMatthew Knepley typedef struct _StageLog *StageLog; 137e855f6f8SMatthew Knepley extern StageLog _stageLog; 138e855f6f8SMatthew Knepley 139e855f6f8SMatthew Knepley /* A simple stack (should replace) */ 140e855f6f8SMatthew Knepley typedef struct _IntStack *IntStack; 141e855f6f8SMatthew Knepley 142e855f6f8SMatthew Knepley /* The structures for logging performance */ 143af80a1fbSMatthew Knepley typedef struct _EventPerfInfo { 144e855f6f8SMatthew Knepley int id; /* The integer identifying this section */ 145800883a5SMatthew Knepley PetscTruth active; /* The flag to activate logging */ 146800883a5SMatthew Knepley PetscTruth visible; /* The flag to print info in summary */ 1478ba1e511SMatthew Knepley int depth; /* The nesting depth of the event call */ 1488ba1e511SMatthew Knepley int count; /* The number of times this section was executed */ 1498ba1e511SMatthew Knepley PetscLogDouble flops; /* The flops used in this section */ 1508ba1e511SMatthew Knepley PetscLogDouble time; /* The time taken for this section */ 1518ba1e511SMatthew Knepley PetscLogDouble numMessages; /* The number of messages in this section */ 1528ba1e511SMatthew Knepley PetscLogDouble messageLength; /* The total message lengths in this section */ 1538ba1e511SMatthew Knepley PetscLogDouble numReductions; /* The number of reductions in this section */ 154af80a1fbSMatthew Knepley } EventPerfInfo; 1558ba1e511SMatthew Knepley 156e855f6f8SMatthew Knepley typedef struct _ClassPerfInfo { 157e855f6f8SMatthew Knepley int id; /* The integer identifying this class */ 1588ba1e511SMatthew Knepley int creations; /* The number of objects of this class created */ 1598ba1e511SMatthew Knepley int destructions; /* The number of objects of this class destroyed */ 1608ba1e511SMatthew Knepley PetscLogDouble mem; /* The total memory allocated by objects of this class */ 1618ba1e511SMatthew Knepley PetscLogDouble descMem; /* The total memory allocated by descendents of these objects */ 162e855f6f8SMatthew Knepley } ClassPerfInfo; 1638ba1e511SMatthew Knepley 164e855f6f8SMatthew Knepley /* The structures for logging registration */ 165e855f6f8SMatthew Knepley typedef struct _ClassRegInfo { 166e855f6f8SMatthew Knepley char *name; /* The class name */ 167e855f6f8SMatthew Knepley int cookie; /* The integer identifying this class */ 168e855f6f8SMatthew Knepley } ClassRegInfo; 169e855f6f8SMatthew Knepley 170e855f6f8SMatthew Knepley typedef struct _EventRegInfo { 171e855f6f8SMatthew Knepley char *name; /* The name of this event */ 172e855f6f8SMatthew Knepley int cookie; /* The class id for this event (should maybe give class ID instead) */ 17344451550SSatish Balay #if defined (PETSC_HAVE_MPE) 17444451550SSatish Balay int mpe_id_begin; /* MPE IDs that define the event */ 17544451550SSatish Balay int mpe_id_end; 17644451550SSatish Balay #endif 177e855f6f8SMatthew Knepley } EventRegInfo; 178e855f6f8SMatthew Knepley 179e855f6f8SMatthew Knepley /* The structure for logging events */ 180e855f6f8SMatthew Knepley typedef int PetscEvent; 181e855f6f8SMatthew Knepley 182e855f6f8SMatthew Knepley typedef struct _EventRegLog *EventRegLog; 183e855f6f8SMatthew Knepley struct _EventRegLog { 184e855f6f8SMatthew Knepley int numEvents; /* The number of registered events */ 185e855f6f8SMatthew Knepley int maxEvents; /* The maximum number of events */ 186e855f6f8SMatthew Knepley EventRegInfo *eventInfo; /* The registration information for each event */ 1878ba1e511SMatthew Knepley }; 1888ba1e511SMatthew Knepley 189e855f6f8SMatthew Knepley typedef struct _EventPerfLog *EventPerfLog; 190e855f6f8SMatthew Knepley struct _EventPerfLog { 191e855f6f8SMatthew Knepley int numEvents; /* The number of logging events */ 192e855f6f8SMatthew Knepley int maxEvents; /* The maximum number of events */ 193af80a1fbSMatthew Knepley EventPerfInfo *eventInfo; /* The performance information for each event */ 194e855f6f8SMatthew Knepley }; 1958ba1e511SMatthew Knepley 196e855f6f8SMatthew Knepley /* The structure for logging class information */ 197e855f6f8SMatthew Knepley typedef struct _ClassRegLog *ClassRegLog; 198e855f6f8SMatthew Knepley struct _ClassRegLog { 199e855f6f8SMatthew Knepley int numClasses; /* The number of classes registered */ 200e855f6f8SMatthew Knepley int maxClasses; /* The maximum number of classes */ 201e855f6f8SMatthew Knepley ClassRegInfo *classInfo; /* The structure for class information (cookies are monotonicly increasing) */ 202e855f6f8SMatthew Knepley }; 203e855f6f8SMatthew Knepley 204e855f6f8SMatthew Knepley typedef struct _ClassPerfLog *ClassPerfLog; 205e855f6f8SMatthew Knepley struct _ClassPerfLog { 206e855f6f8SMatthew Knepley int numClasses; /* The number of logging classes */ 207e855f6f8SMatthew Knepley int maxClasses; /* The maximum number of classes */ 208e855f6f8SMatthew Knepley ClassPerfInfo *classInfo; /* The structure for class information (cookies are monotonicly increasing) */ 209e855f6f8SMatthew Knepley }; 210e855f6f8SMatthew Knepley 211e855f6f8SMatthew Knepley /* The structures for logging in stages */ 212e855f6f8SMatthew Knepley typedef struct _StageInfo { 213e855f6f8SMatthew Knepley char *name; /* The stage name */ 214773a6509SMatthew Knepley PetscTruth used; /* The stage was pushed on this processor */ 215af80a1fbSMatthew Knepley EventPerfInfo perfInfo; /* The stage performance information */ 216e855f6f8SMatthew Knepley EventPerfLog eventLog; /* The event information for this stage */ 217e855f6f8SMatthew Knepley ClassPerfLog classLog; /* The class information for this stage */ 218e855f6f8SMatthew Knepley } StageInfo; 219e855f6f8SMatthew Knepley 2208ba1e511SMatthew Knepley struct _StageLog { 2218ba1e511SMatthew Knepley /* Size information */ 2228ba1e511SMatthew Knepley int numStages; /* The number of registered stages */ 2238ba1e511SMatthew Knepley int maxStages; /* The maximum number of stages */ 2248ba1e511SMatthew Knepley /* Runtime information */ 2258ba1e511SMatthew Knepley IntStack stack; /* The stack for active stages */ 2268ba1e511SMatthew Knepley int curStage; /* The current stage (only used in macros so we don't call StackTop) */ 2278ba1e511SMatthew Knepley /* Stage specific information */ 228e855f6f8SMatthew Knepley StageInfo *stageInfo; /* The information for each stage */ 229e855f6f8SMatthew Knepley EventRegLog eventLog; /* The registered events */ 230e855f6f8SMatthew Knepley ClassRegLog classLog; /* The registered classes */ 2318ba1e511SMatthew Knepley }; 2328ba1e511SMatthew Knepley 233043328b6SSatish Balay #define PetscLogEventBarrierBegin(e,o1,o2,o3,o4,cm) 0; \ 234043328b6SSatish Balay {\ 235043328b6SSatish Balay int _2_ierr;\ 236773a6509SMatthew Knepley if (_PetscLogPLB && \ 237773a6509SMatthew Knepley _stageLog->stageInfo[_stageLog->curStage].perfInfo.active && \ 238773a6509SMatthew Knepley _stageLog->stageInfo[_stageLog->curStage].eventLog->eventInfo[e].active) {\ 2396e491fe6SBarry Smith _2_ierr = PetscLogEventBegin((e),o1,o2,o3,o4);CHKERRQ(_2_ierr);\ 2406e491fe6SBarry Smith _2_ierr = MPI_Barrier(cm);CHKERRQ(_2_ierr);\ 2416e491fe6SBarry Smith _2_ierr = PetscLogEventEnd((e),o1,o2,o3,o4);CHKERRQ(_2_ierr);\ 242005c665bSBarry Smith }\ 2436e491fe6SBarry Smith _2_ierr = PetscLogEventBegin((e)+1,o1,o2,o3,o4);CHKERRQ(_2_ierr);\ 244005c665bSBarry Smith } 24577c4ece6SBarry Smith 246043328b6SSatish Balay #define PetscLogEventBegin(e,o1,o2,o3,o4) 0; \ 247043328b6SSatish Balay {\ 248773a6509SMatthew Knepley if (_PetscLogPLB && \ 249773a6509SMatthew Knepley _stageLog->stageInfo[_stageLog->curStage].perfInfo.active && \ 250773a6509SMatthew Knepley _stageLog->stageInfo[_stageLog->curStage].eventLog->eventInfo[e].active) {\ 251043328b6SSatish Balay (*_PetscLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 252043328b6SSatish Balay }\ 253043328b6SSatish Balay PETSC_LOG_EVENT_MPE_BEGIN(e); \ 254a1b5d808SSatish Balay } 255043328b6SSatish Balay 256b0a32e0cSBarry Smith #define PetscLogEventBarrierEnd(e,o1,o2,o3,o4,cm) PetscLogEventEnd(e+1,o1,o2,o3,o4) 257043328b6SSatish Balay 258043328b6SSatish Balay #define PetscLogEventEnd(e,o1,o2,o3,o4) 0; \ 259043328b6SSatish Balay {\ 260773a6509SMatthew Knepley if (_PetscLogPLE && \ 261773a6509SMatthew Knepley _stageLog->stageInfo[_stageLog->curStage].perfInfo.active && \ 262773a6509SMatthew Knepley _stageLog->stageInfo[_stageLog->curStage].eventLog->eventInfo[e].active) {\ 263043328b6SSatish Balay (*_PetscLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 264043328b6SSatish Balay }\ 265043328b6SSatish Balay PETSC_LOG_EVENT_MPE_END(e); \ 266a1b5d808SSatish Balay } 26777c4ece6SBarry Smith 268f141ce34SMatthew Knepley /* Creation and destruction functions */ 269f141ce34SMatthew Knepley EXTERN int StageLogCreate(StageLog *); 270f141ce34SMatthew Knepley EXTERN int StageLogDestroy(StageLog); 271f141ce34SMatthew Knepley /* Registration functions */ 272f141ce34SMatthew Knepley EXTERN int StageLogRegister(StageLog, const char [], int *); 273f141ce34SMatthew Knepley /* Runtime functions */ 274f141ce34SMatthew Knepley EXTERN int PetscLogGetStageLog(StageLog *); 275f141ce34SMatthew Knepley EXTERN int StageLogPush(StageLog, int); 276f141ce34SMatthew Knepley EXTERN int StageLogPop(StageLog); 277f141ce34SMatthew Knepley EXTERN int StageLogGetCurrent(StageLog, int *); 278f141ce34SMatthew Knepley EXTERN int StageLogSetActive(StageLog, int, PetscTruth); 279f141ce34SMatthew Knepley EXTERN int StageLogGetActive(StageLog, int, PetscTruth *); 280f141ce34SMatthew Knepley EXTERN int StageLogSetVisible(StageLog, int, PetscTruth); 281f141ce34SMatthew Knepley EXTERN int StageLogGetVisible(StageLog, int, PetscTruth *); 282f141ce34SMatthew Knepley EXTERN int StageLogGetStage(StageLog, const char [], int *); 283f141ce34SMatthew Knepley 284ce85283eSBarry Smith /* 28584cb2905SBarry Smith This does not work for MPI-Uni because our src/mpiuni/mpi.h file 286ce85283eSBarry Smith uses macros to defined the MPI operations. 28715308354SBarry Smith 28815308354SBarry Smith It does not work correctly from HP-UX because it processes the 289bb4af37aSBarry Smith macros in a way that sometimes it double counts, hence 290b6410449SSatish Balay PETSC_HAVE_BROKEN_RECURSIVE_MACRO 2917c1e34a4SSatish Balay 2927c1e34a4SSatish Balay It does not work with Windows NT because winmpich lacks MPI_Type_size() 293ce85283eSBarry Smith */ 294f35a08a5SSatish Balay #if !defined(_petsc_mpi_uni) && !defined(PETSC_HAVE_BROKEN_RECURSIVE_MACRO) && !defined (PETSC_HAVE_MPI_MISSING_TYPESIZE) 29577a39924SBarry Smith /* 29677a39924SBarry Smith Logging of MPI activities 29777a39924SBarry Smith */ 29877a39924SBarry Smith 29977a39924SBarry Smith #define TypeSize(buff,count,type) \ 300ca161407SBarry Smith (\ 301b0a32e0cSBarry Smith MPI_Type_size(type,&PETSC_DUMMY_SIZE),buff += ((PetscLogDouble) ((count)*PETSC_DUMMY_SIZE))\ 302ca161407SBarry Smith ) 30377a39924SBarry Smith 30477a39924SBarry Smith #define MPI_Irecv(buf,count, datatype,source,tag,comm,request) \ 305ca161407SBarry Smith (\ 306ca161407SBarry Smith PETSC_DUMMY = MPI_Irecv(buf,count, datatype,source,tag,comm,request),\ 307ca161407SBarry Smith irecv_ct++,TypeSize(irecv_len,count,datatype),PETSC_DUMMY\ 308ca161407SBarry Smith ) 30915308354SBarry Smith 31077a39924SBarry Smith #define MPI_Isend(buf,count, datatype,dest,tag,comm,request) \ 311ca161407SBarry Smith (\ 312ca161407SBarry Smith PETSC_DUMMY = MPI_Isend(buf,count, datatype,dest,tag,comm,request),\ 313ca161407SBarry Smith isend_ct++, TypeSize(isend_len,count,datatype),PETSC_DUMMY\ 314ca161407SBarry Smith ) 31515308354SBarry Smith 3160d4b0b6cSBarry Smith #define MPI_Startall_irecv(count,number,requests) \ 317ca161407SBarry Smith (\ 318ca161407SBarry Smith PETSC_DUMMY = MPI_Startall(number,requests),\ 31987828ca2SBarry Smith irecv_ct += (PetscLogDouble)(number),irecv_len += ((PetscLogDouble) ((count)*sizeof(PetscScalar))),PETSC_DUMMY\ 320ca161407SBarry Smith ) 3210d4b0b6cSBarry Smith 3220d4b0b6cSBarry Smith #define MPI_Startall_isend(count,number,requests) \ 323ca161407SBarry Smith (\ 324ca161407SBarry Smith PETSC_DUMMY = MPI_Startall(number,requests),\ 32587828ca2SBarry Smith isend_ct += (PetscLogDouble)(number),isend_len += ((PetscLogDouble) ((count)*sizeof(PetscScalar))),PETSC_DUMMY\ 326ca161407SBarry Smith ) 3270d4b0b6cSBarry Smith 3280d4b0b6cSBarry Smith #define MPI_Start_isend(count, requests) \ 329ca161407SBarry Smith (\ 330ca161407SBarry Smith PETSC_DUMMY = MPI_Start(requests),\ 33187828ca2SBarry Smith isend_ct++,isend_len += ((PetscLogDouble) ((count)*sizeof(PetscScalar))),PETSC_DUMMY\ 332ca161407SBarry Smith ) 3330d4b0b6cSBarry Smith 334ce85283eSBarry Smith #define MPI_Recv(buf,count, datatype,source,tag,comm,status) \ 335ca161407SBarry Smith (\ 336ca161407SBarry Smith PETSC_DUMMY = MPI_Recv(buf,count, datatype,source,tag,comm,status),\ 337ca161407SBarry Smith recv_ct++,TypeSize(recv_len,count,datatype),PETSC_DUMMY\ 338ca161407SBarry Smith ) 33915308354SBarry Smith 34077a39924SBarry Smith #define MPI_Send(buf,count, datatype,dest,tag,comm) \ 341ca161407SBarry Smith (\ 342ca161407SBarry Smith PETSC_DUMMY = MPI_Send(buf,count, datatype,dest,tag,comm),\ 343ca161407SBarry Smith send_ct++, TypeSize(send_len,count,datatype),PETSC_DUMMY\ 344ca161407SBarry Smith ) 34577a39924SBarry Smith 34677a39924SBarry Smith #define MPI_Wait(request,status) \ 34777a39924SBarry Smith (\ 348e0937024SBarry Smith wait_ct++,sum_of_waits_ct++,\ 34977a39924SBarry Smith MPI_Wait(request,status)\ 35077a39924SBarry Smith ) 35177a39924SBarry Smith 35277a39924SBarry Smith #define MPI_Waitany(a,b,c,d) \ 35377a39924SBarry Smith (\ 354e0937024SBarry Smith wait_any_ct++,sum_of_waits_ct++,\ 35577a39924SBarry Smith MPI_Waitany(a,b,c,d)\ 35677a39924SBarry Smith ) 35777a39924SBarry Smith 35877a39924SBarry Smith #define MPI_Waitall(count,array_of_requests,array_of_statuses) \ 35977a39924SBarry Smith (\ 360b0a32e0cSBarry Smith wait_all_ct++,sum_of_waits_ct += (PetscLogDouble) (count),\ 36177a39924SBarry Smith MPI_Waitall(count,array_of_requests,array_of_statuses)\ 36277a39924SBarry Smith ) 36377a39924SBarry Smith 36477a39924SBarry Smith #define MPI_Allreduce(sendbuf, recvbuf,count,datatype,op,comm) \ 3650743b949SBarry Smith (\ 3660743b949SBarry Smith allreduce_ct++,MPI_Allreduce(sendbuf,recvbuf,count,datatype,op,comm)\ 3670743b949SBarry Smith ) 3683914022bSBarry Smith 3690d4b0b6cSBarry Smith #else 3700d4b0b6cSBarry Smith 3710d4b0b6cSBarry Smith #define MPI_Startall_irecv(count,number,requests) \ 372ca161407SBarry Smith (\ 373ca161407SBarry Smith MPI_Startall(number,requests)\ 374ca161407SBarry Smith ) 3750d4b0b6cSBarry Smith 3760d4b0b6cSBarry Smith #define MPI_Startall_isend(count,number,requests) \ 377ca161407SBarry Smith (\ 378ca161407SBarry Smith MPI_Startall(number,requests)\ 379ca161407SBarry Smith ) 3800d4b0b6cSBarry Smith 3810d4b0b6cSBarry Smith #define MPI_Start_isend(count, requests) \ 382ca161407SBarry Smith (\ 383ca161407SBarry Smith MPI_Start(requests)\ 384ca161407SBarry Smith ) 3850d4b0b6cSBarry Smith 386f35a08a5SSatish Balay #endif /* !_petsc_mpi_uni && ! PETSC_HAVE_BROKEN_RECURSIVE_MACRO */ 387614700edSBarry Smith 388df8cf0b5SBarry Smith #else /* ---Logging is turned off --------------------------------------------*/ 389614700edSBarry Smith 390b0a32e0cSBarry Smith #define PetscLogFlops(n) 0 391614700edSBarry Smith 392df8cf0b5SBarry Smith /* 393df8cf0b5SBarry Smith With logging turned off, then MPE has to be turned off 394df8cf0b5SBarry Smith */ 395b0a32e0cSBarry Smith #define PetscLogMPEBegin() 0 396b0a32e0cSBarry Smith #define PetscLogMPEDump(a) 0 397614700edSBarry Smith 398b0a32e0cSBarry Smith #define PetscLogEventActivate(a) 0 399b0a32e0cSBarry Smith #define PetscLogEventDeactivate(a) 0 400614700edSBarry Smith 401b0a32e0cSBarry Smith #define PetscLogEventActivateClass(a) 0 402b0a32e0cSBarry Smith #define PetscLogEventDeactivateClass(a) 0 40377c4ece6SBarry Smith 404b0a32e0cSBarry Smith #define _PetscLogPLB 0 405b0a32e0cSBarry Smith #define _PetscLogPLE 0 406b0a32e0cSBarry Smith #define _PetscLogPHC 0 407b0a32e0cSBarry Smith #define _PetscLogPHD 0 40899de4ba8SSatish Balay #define PetscGetFlops(a) (*(a) = 0.0,0) 409b0a32e0cSBarry Smith #define PetscLogEventBegin(e,o1,o2,o3,o4) 0 410b0a32e0cSBarry Smith #define PetscLogEventEnd(e,o1,o2,o3,o4) 0 411b0a32e0cSBarry Smith #define PetscLogEventBarrierBegin(e,o1,o2,o3,o4,cm) 0 412b0a32e0cSBarry Smith #define PetscLogEventBarrierEnd(e,o1,o2,o3,o4,cm) 0 413b0a32e0cSBarry Smith #define PetscLogObjectParent(p,c) 414b0a32e0cSBarry Smith #define PetscLogObjectParents(p,n,c) 415b0a32e0cSBarry Smith #define PetscLogObjectCreate(h) 416b0a32e0cSBarry Smith #define PetscLogObjectDestroy(h) 417b0a32e0cSBarry Smith #define PetscLogObjectMemory(p,m) 418b0a32e0cSBarry Smith #define PetscLogDestroy() 0 419b0a32e0cSBarry Smith #define PetscLogStagePush(a) 0 420b0a32e0cSBarry Smith #define PetscLogStagePop() 0 421b0a32e0cSBarry Smith #define PetscLogStageRegister(a,b) 0 422b0a32e0cSBarry Smith #define PetscLogStagePrint(a,flg) 0 423b0a32e0cSBarry Smith #define PetscLogPrintSummary(comm,file) 0 424b0a32e0cSBarry Smith #define PetscLogBegin() 0 425b0a32e0cSBarry Smith #define PetscLogTraceBegin(file) 0 426b0a32e0cSBarry Smith #define PetscLogSet(lb,le) 0 427b0a32e0cSBarry Smith #define PetscLogAllBegin() 0 428b0a32e0cSBarry Smith #define PetscLogDump(c) 0 429043328b6SSatish Balay #define PetscLogEventRegister(a,b,c) 0 43073fda44aSBarry Smith #define PetscLogObjects(a) 0 43173fda44aSBarry Smith #define PetscLogActions(a) 0 432f80b7eb0SBarry Smith EXTERN int PetscLogObjectState(PetscObject,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 433ce6058e1SBarry Smith 434aa482453SBarry Smith /* If PETSC_USE_LOG is NOT defined, these still need to be! */ 435ca161407SBarry Smith #define MPI_Startall_irecv(count,number,requests) MPI_Startall(number,requests) 436ca161407SBarry Smith #define MPI_Startall_isend(count,number,requests) MPI_Startall(number,requests) 437ca161407SBarry Smith #define MPI_Start_isend(count,requests) MPI_Start(requests) 438ca161407SBarry Smith 439f141ce34SMatthew Knepley /* Creation and destruction functions */ 440f141ce34SMatthew Knepley #define StageLogCreate(stageLog) 0 441f141ce34SMatthew Knepley #define StageLogDestroy(stageLog) 0 442f141ce34SMatthew Knepley /* Registration functions */ 443f141ce34SMatthew Knepley #define StageLogRegister(stageLog, name, stage) 0 444f141ce34SMatthew Knepley /* Runtime functions */ 445f141ce34SMatthew Knepley #define PetscLogGetStageLog(stageLog) 0 446f141ce34SMatthew Knepley #define StageLogPush(stageLog, stage) 0 447f141ce34SMatthew Knepley #define StageLogPop(stageLog) 0 448f141ce34SMatthew Knepley #define StageLogGetCurrent(stageLog, stage) 0 449f141ce34SMatthew Knepley #define StageLogSetActive(stageLog, stage, active) 0 450f141ce34SMatthew Knepley #define StageLogGetActive(stageLog, stage, active) 0 451f141ce34SMatthew Knepley #define StageLogSetVisible(stageLog, stage, visible) 0 452f141ce34SMatthew Knepley #define StageLogGetVisible(stageLog, stage, visible) 0 453f141ce34SMatthew Knepley #define StageLogGetStage(stageLog, name, stage) 0 454f141ce34SMatthew Knepley 455aa482453SBarry Smith #endif /* PETSC_USE_LOG */ 4566daaf66cSBarry Smith 457435da068SBarry Smith extern PetscTruth PetscPreLoadingUsed; /* true if we are or have done preloading */ 458435da068SBarry Smith extern PetscTruth PetscPreLoadingOn; /* true if we are currently in a preloading calculation */ 4591d1367b7SBarry Smith 460043328b6SSatish Balay #define PreLoadBegin(flag,name) \ 461043328b6SSatish Balay {\ 462043328b6SSatish Balay PetscTruth PreLoading = flag;\ 4638e58c17dSMatthew Knepley int PreLoadMax,PreLoadIt,_stageNum,_3_ierr;\ 4646e491fe6SBarry Smith _3_ierr = PetscOptionsGetLogical(PETSC_NULL,"-preload",&PreLoading,PETSC_NULL);CHKERRQ(_3_ierr);\ 465043328b6SSatish Balay PreLoadMax = (int)(PreLoading);\ 466043328b6SSatish Balay PetscPreLoadingUsed = PreLoading ? PETSC_TRUE : PetscPreLoadingUsed;\ 467e7592fafSBarry Smith for (PreLoadIt=0; PreLoadIt<=PreLoadMax; PreLoadIt++) {\ 468435da068SBarry Smith PetscPreLoadingOn = PreLoading;\ 4696e491fe6SBarry Smith _3_ierr = PetscBarrier(PETSC_NULL);CHKERRQ(_3_ierr);\ 4708e58c17dSMatthew Knepley if (PreLoadIt>0) {\ 4718e58c17dSMatthew Knepley _3_ierr = PetscLogStageGetId(name,&_stageNum);CHKERRQ(_3_ierr);\ 4728e58c17dSMatthew Knepley } else {\ 4738e58c17dSMatthew Knepley _3_ierr = PetscLogStageRegister(&_stageNum,name);CHKERRQ(_3_ierr);\ 4748e58c17dSMatthew Knepley }\ 475773a6509SMatthew Knepley _3_ierr = PetscLogStageSetActive(_stageNum,(PetscTruth)(!PreLoadMax || PreLoadIt));\ 4768e58c17dSMatthew Knepley _3_ierr = PetscLogStagePush(_stageNum);CHKERRQ(_3_ierr); 4778e58c17dSMatthew Knepley 478043328b6SSatish Balay #define PreLoadEnd() \ 479043328b6SSatish Balay _3_ierr = PetscLogStagePop();CHKERRQ(_3_ierr);\ 480043328b6SSatish Balay PreLoading = PETSC_FALSE;\ 481043328b6SSatish Balay }\ 482043328b6SSatish Balay } 4838e58c17dSMatthew Knepley 484043328b6SSatish Balay #define PreLoadStage(name) \ 485043328b6SSatish Balay _3_ierr = PetscLogStagePop();CHKERRQ(_3_ierr);\ 4868e58c17dSMatthew Knepley if (PreLoadIt>0) {\ 4878e58c17dSMatthew Knepley _3_ierr = PetscLogStageGetId(name,&_stageNum);CHKERRQ(_3_ierr);\ 4888e58c17dSMatthew Knepley } else {\ 4898e58c17dSMatthew Knepley _3_ierr = PetscLogStageRegister(&_stageNum,name);CHKERRQ(_3_ierr);\ 4908e58c17dSMatthew Knepley }\ 491773a6509SMatthew Knepley _3_ierr = PetscLogStageSetActive(_stageNum,(PetscTruth)(!PreLoadMax || PreLoadIt));\ 4928e58c17dSMatthew Knepley _3_ierr = PetscLogStagePush(_stageNum);CHKERRQ(_3_ierr); 493*e9fa29b7SSatish Balay 494*e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END 49597bb86f7SLois Curfman McInnes #endif 496