xref: /petsc/include/petsclog.h (revision 53fde1fefa21c060fa81e4e25e00b5f55bdbe18f)
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"
1097bb86f7SLois Curfman McInnes 
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 */
2895f075fdSBarry Smith EXTERN int        PetscLogInfo(void*,const char[],...) __ATTRIBUTE__ ((format (printf, 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"
56614700edSBarry Smith #define MPEBEGIN    1000
57b0a32e0cSBarry Smith EXTERN int        PetscLogMPEBegin(void);
58b0a32e0cSBarry Smith EXTERN int        PetscLogMPEDump(const char[]);
5935d8aa7fSBarry Smith extern PetscTruth UseMPE;
60b0a32e0cSBarry Smith extern int        PetscLogEventMPEFlags[];
61b0a32e0cSBarry Smith EXTERN int        PetscLogEventMPEActivate(int);
62b0a32e0cSBarry Smith EXTERN int        PetscLogEventMPEDeactivate(int);
63614700edSBarry Smith #else
64b0a32e0cSBarry Smith #define PetscLogEventMPEActivate(a) 0
65b0a32e0cSBarry Smith #define PetscLogEventMPEDeactivate(a) 0
6677c4ece6SBarry Smith #endif
6777c4ece6SBarry Smith 
68b0a32e0cSBarry Smith EXTERN int (*_PetscLogPLB)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
69b0a32e0cSBarry Smith EXTERN int (*_PetscLogPLE)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
70b0a32e0cSBarry Smith EXTERN int (*_PetscLogPHC)(PetscObject);
71b0a32e0cSBarry Smith EXTERN int (*_PetscLogPHD)(PetscObject);
7277c4ece6SBarry Smith 
738ba1e511SMatthew Knepley #define PetscLogObjectParent(p,c)       if (c) {PetscValidHeader((PetscObject)(c)); \
748ba1e511SMatthew Knepley                                                 PetscValidHeader((PetscObject)(p));\
758ba1e511SMatthew Knepley                                                 ((PetscObject)(c))->parent = (PetscObject)(p);\
768ba1e511SMatthew Knepley 				                ((PetscObject)(c))->parentid = ((PetscObject)p)->id;}
778ba1e511SMatthew Knepley #define PetscLogObjectParents(p,n,d)    {int _i; for (_i=0; _i<n; _i++) \
788ba1e511SMatthew Knepley                                          PetscLogObjectParent(p,(d)[_i]);}
798ba1e511SMatthew Knepley #define PetscLogObjectCreate(h)         {if (_PetscLogPHC) (*_PetscLogPHC)((PetscObject)h);}
808ba1e511SMatthew Knepley #define PetscLogObjectDestroy(h)        {if (_PetscLogPHD) (*_PetscLogPHD)((PetscObject)h);}
818ba1e511SMatthew Knepley #define PetscLogObjectMemory(p,m)       {PetscValidHeader((PetscObject)p);\
828ba1e511SMatthew Knepley                                          ((PetscObject)(p))->mem += (m);}
838ba1e511SMatthew Knepley /* Initialization functions */
848ba1e511SMatthew Knepley EXTERN int PetscLogBegin(void);
858ba1e511SMatthew Knepley EXTERN int PetscLogAllBegin(void);
868ba1e511SMatthew Knepley EXTERN int PetscLogTraceBegin(FILE *);
878ba1e511SMatthew Knepley /* General functions */
888ba1e511SMatthew Knepley EXTERN int PetscLogDestroy(void);
898ba1e511SMatthew Knepley EXTERN int PetscLogSet(int (*)(int, int, PetscObject, PetscObject, PetscObject, PetscObject),
908ba1e511SMatthew Knepley                    int (*)(int, int, PetscObject, PetscObject, PetscObject, PetscObject));
9195f075fdSBarry Smith EXTERN int PetscLogObjectState(PetscObject, const char[], ...) __ATTRIBUTE__ ((format (printf, 2,3)));
928ba1e511SMatthew Knepley /* Output functions */
938ba1e511SMatthew Knepley EXTERN int PetscLogPrintSummary(MPI_Comm, const char[]);
948ba1e511SMatthew Knepley EXTERN int PetscLogDump(const char[]);
958ba1e511SMatthew Knepley /* Counter functions */
968ba1e511SMatthew Knepley EXTERN int PetscGetFlops(PetscLogDouble *);
978ba1e511SMatthew Knepley /* Stage functions */
988ba1e511SMatthew Knepley EXTERN int PetscLogStageRegister(int *, const char[]);
998ba1e511SMatthew Knepley EXTERN int PetscLogStagePush(int);
1008ba1e511SMatthew Knepley EXTERN int PetscLogStagePop(void);
1018ba1e511SMatthew Knepley EXTERN int PetscLogStageSetVisible(int, PetscTruth);
1028ba1e511SMatthew Knepley EXTERN int PetscLogStageGetVisible(int, PetscTruth *);
1038e58c17dSMatthew Knepley EXTERN int PetscLogStageGetId(const char [], int *);
1048ba1e511SMatthew Knepley /* Event functions */
1058ba1e511SMatthew Knepley EXTERN int PetscLogEventRegister(int *, const char[], const char[], int);
1068ba1e511SMatthew Knepley EXTERN int PetscLogEventActivate(int);
1078ba1e511SMatthew Knepley EXTERN int PetscLogEventDeactivate(int);
1088ba1e511SMatthew Knepley EXTERN int PetscLogEventActivateClass(int);
1098ba1e511SMatthew Knepley EXTERN int PetscLogEventDeactivateClass(int);
1108ba1e511SMatthew Knepley /* Class functions */
1118ba1e511SMatthew Knepley EXTERN int PetscLogClassRegister(int *, const char []);
1128ba1e511SMatthew Knepley 
1138ba1e511SMatthew Knepley /* Default log */
1148ba1e511SMatthew Knepley typedef struct _StageLog *StageLog;
1158ba1e511SMatthew Knepley extern StageLog _stageLog;
1168ba1e511SMatthew Knepley 
1178ba1e511SMatthew Knepley /* Global counters */
1188ba1e511SMatthew Knepley extern PetscLogDouble irecv_ct,  isend_ct,  recv_ct,  send_ct;
1198ba1e511SMatthew Knepley extern PetscLogDouble irecv_len, isend_len, recv_len, send_len;
1208ba1e511SMatthew Knepley extern PetscLogDouble allreduce_ct;
1218ba1e511SMatthew Knepley extern PetscLogDouble wait_ct, wait_any_ct, wait_all_ct, sum_of_waits_ct;
1228ba1e511SMatthew Knepley extern int            PETSC_DUMMY, PETSC_DUMMY_SIZE;
1238ba1e511SMatthew Knepley 
1248ba1e511SMatthew Knepley /* We must make these structures available if we are to access the event
1258ba1e511SMatthew Knepley    activation flags in the PetscLogEventBegin/End() macros. If we forced a
1268ba1e511SMatthew Knepley    function call each time, we could leave these structures in plog.h
1278ba1e511SMatthew Knepley */
1288ba1e511SMatthew Knepley /* The structure for logging performance */
1298ba1e511SMatthew Knepley typedef struct _PerfInfo {
1308ba1e511SMatthew Knepley   char          *name;          /* The name of this section */
1318ba1e511SMatthew Knepley   char          *color;         /* The color of this section */
1328ba1e511SMatthew Knepley   int            id;            /* The integer identifying this event */
1338ba1e511SMatthew Knepley   int            cookie;        /* The class id for this section */
134800883a5SMatthew Knepley   PetscTruth     active;        /* The flag to activate logging */
135800883a5SMatthew Knepley   PetscTruth     visible;       /* The flag to print info in summary */
1368ba1e511SMatthew Knepley   int            depth;         /* The nesting depth of the event call */
1378ba1e511SMatthew Knepley   int            count;         /* The number of times this section was executed */
1388ba1e511SMatthew Knepley   PetscLogDouble flops;         /* The flops used in this section */
1398ba1e511SMatthew Knepley   PetscLogDouble time;          /* The time taken for this section */
1408ba1e511SMatthew Knepley   PetscLogDouble numMessages;   /* The number of messages in this section */
1418ba1e511SMatthew Knepley   PetscLogDouble messageLength; /* The total message lengths in this section */
1428ba1e511SMatthew Knepley   PetscLogDouble numReductions; /* The number of reductions in this section */
1438ba1e511SMatthew Knepley } PerfInfo;
1448ba1e511SMatthew Knepley 
1458ba1e511SMatthew Knepley /* The structure for logging events */
1468ba1e511SMatthew Knepley typedef struct _EventLog *EventLog;
1478ba1e511SMatthew Knepley struct _EventLog {
1488ba1e511SMatthew Knepley   int       numEvents;   /* The number of registered events */
1498ba1e511SMatthew Knepley   int       maxEvents;   /* The maximum number of events */
1508ba1e511SMatthew Knepley   PerfInfo *eventInfo;   /* The performance information for each event */
1518ba1e511SMatthew Knepley };
152*53fde1feSMatthew Knepley typedef int PetscEvent;
1538ba1e511SMatthew Knepley 
1548ba1e511SMatthew Knepley /* The structure for logging class information */
1558ba1e511SMatthew Knepley typedef struct _ClassInfo {
1568ba1e511SMatthew Knepley   char          *name;          /* The class name */
1578ba1e511SMatthew Knepley   int            cookie;        /* 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 */
1628ba1e511SMatthew Knepley } ClassInfo;
1638ba1e511SMatthew Knepley 
1648ba1e511SMatthew Knepley typedef struct _ClassLog *ClassLog;
1658ba1e511SMatthew Knepley struct _ClassLog {
1668ba1e511SMatthew Knepley   int        numClasses; /* The number of classes registered */
1678ba1e511SMatthew Knepley   int        maxClasses; /* The maximum number of classes */
1688ba1e511SMatthew Knepley   ClassInfo *classInfo;  /* The structure for classs information (cookies are monotonicly increasing) */
1698ba1e511SMatthew Knepley };
1708ba1e511SMatthew Knepley 
1718ba1e511SMatthew Knepley /* A simple stack (should replace) */
1728ba1e511SMatthew Knepley typedef struct _IntStack *IntStack;
1738ba1e511SMatthew Knepley 
1748ba1e511SMatthew Knepley /* The structure for logging in stages */
1758ba1e511SMatthew Knepley struct _StageLog {
1768ba1e511SMatthew Knepley   /* Size information */
1778ba1e511SMatthew Knepley   int         numStages;    /* The number of registered stages */
1788ba1e511SMatthew Knepley   int         maxStages;    /* The maximum number of stages */
1798ba1e511SMatthew Knepley   /* Runtime information */
1808ba1e511SMatthew Knepley   IntStack    stack;        /* The stack for active stages */
1818ba1e511SMatthew Knepley   int         curStage;     /* The current stage (only used in macros so we don't call StackTop) */
1828ba1e511SMatthew Knepley   /* Stage specific information */
1838ba1e511SMatthew Knepley   PerfInfo   *stageInfo;    /* The performance information for each stage */
1848ba1e511SMatthew Knepley   EventLog   *eventLog;     /* The event log for each stage */
1858ba1e511SMatthew Knepley   ClassLog   *classLog;     /* The class information for each stage */
1868ba1e511SMatthew Knepley };
1878ba1e511SMatthew Knepley 
188aa482453SBarry Smith #if defined(PETSC_HAVE_MPE)
189b0a32e0cSBarry Smith #define PetscLogEventBarrierBegin(e,o1,o2,o3,o4,cm) \
190*53fde1feSMatthew Knepley   0; { int _1_ierr; \
191*53fde1feSMatthew Knepley     if (_PetscLogPLB && _stageLog->eventLog[_stageLog->curStage]->eventInfo[e].active) { \
1926e491fe6SBarry Smith       _1_ierr = PetscLogEventBegin((e),o1,o2,o3,o4);CHKERRQ(_1_ierr);  \
193b0a32e0cSBarry Smith       if (UseMPE && PetscLogEventMPEFlags[(e)])                      \
194005c665bSBarry Smith         MPE_Log_event(MPEBEGIN+2*(e),0,"");                      \
1956e491fe6SBarry Smith       _1_ierr = MPI_Barrier(cm);CHKERRQ(_1_ierr);                  \
1966e491fe6SBarry Smith       _1_ierr = PetscLogEventEnd((e),o1,o2,o3,o4);CHKERRQ(_1_ierr);    \
197b0a32e0cSBarry Smith       if (UseMPE && PetscLogEventMPEFlags[(e)])                      \
198005c665bSBarry Smith         MPE_Log_event(MPEBEGIN+2*((e)+1),0,"");                  \
199005c665bSBarry Smith     }                                                            \
2006e491fe6SBarry Smith     _1_ierr = PetscLogEventBegin(e+1,o1,o2,o3,o4);CHKERRQ(_1_ierr);    \
201b0a32e0cSBarry Smith     if (UseMPE && PetscLogEventMPEFlags[(e)+1])                      \
202005c665bSBarry Smith       MPE_Log_event(MPEBEGIN+2*((e)+1),0,"");                    \
203005c665bSBarry Smith   }
204b0a32e0cSBarry Smith #define PetscLogEventBegin(e,o1,o2,o3,o4)  \
205*53fde1feSMatthew Knepley   0; { \
206*53fde1feSMatthew Knepley    if (_PetscLogPLB && _stageLog->eventLog[_stageLog->curStage]->eventInfo[e].active) {\
207b0a32e0cSBarry Smith      (*_PetscLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));}\
208b0a32e0cSBarry Smith    if (UseMPE && PetscLogEventMPEFlags[(e)])\
209005c665bSBarry Smith      MPE_Log_event(MPEBEGIN+2*(e),0,"");\
21077c4ece6SBarry Smith   }
21177c4ece6SBarry Smith #else
212b0a32e0cSBarry Smith #define PetscLogEventBarrierBegin(e,o1,o2,o3,o4,cm) \
213*53fde1feSMatthew Knepley   0; { int _2_ierr;\
214*53fde1feSMatthew Knepley     if (_PetscLogPLB && _stageLog->eventLog[_stageLog->curStage]->eventInfo[e].active) { \
2156e491fe6SBarry Smith       _2_ierr = PetscLogEventBegin((e),o1,o2,o3,o4);CHKERRQ(_2_ierr);    \
2166e491fe6SBarry Smith       _2_ierr = MPI_Barrier(cm);CHKERRQ(_2_ierr);                    \
2176e491fe6SBarry Smith       _2_ierr = PetscLogEventEnd((e),o1,o2,o3,o4);CHKERRQ(_2_ierr);      \
218005c665bSBarry Smith     }                                                              \
2196e491fe6SBarry Smith     _2_ierr = PetscLogEventBegin((e)+1,o1,o2,o3,o4);CHKERRQ(_2_ierr);    \
220005c665bSBarry Smith   }
221b0a32e0cSBarry Smith #define PetscLogEventBegin(e,o1,o2,o3,o4)  \
222*53fde1feSMatthew Knepley   0; { \
223*53fde1feSMatthew Knepley    if (_PetscLogPLB && _stageLog->eventLog[_stageLog->curStage]->eventInfo[e].active) {\
224b0a32e0cSBarry Smith      (*_PetscLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));}\
22577c4ece6SBarry Smith   }
22677c4ece6SBarry Smith #endif
22777c4ece6SBarry Smith 
228aa482453SBarry Smith #if defined(PETSC_HAVE_MPE)
229b0a32e0cSBarry Smith #define PetscLogEventBarrierEnd(e,o1,o2,o3,o4,cm) PetscLogEventEnd(e+1,o1,o2,o3,o4)
230b0a32e0cSBarry Smith #define PetscLogEventEnd(e,o1,o2,o3,o4) \
231*53fde1feSMatthew Knepley   0; { \
232*53fde1feSMatthew Knepley   if (_PetscLogPLE && _stageLog->eventLog[_stageLog->curStage]->eventInfo[e].active) {\
233b0a32e0cSBarry Smith     (*_PetscLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));}\
234b0a32e0cSBarry Smith   if (UseMPE && PetscLogEventMPEFlags[(e)])\
235005c665bSBarry Smith      MPE_Log_event(MPEBEGIN+2*(e)+1,0,"");\
236a1b5d808SSatish Balay   }
23777c4ece6SBarry Smith #else
238b0a32e0cSBarry Smith #define PetscLogEventBarrierEnd(e,o1,o2,o3,o4,cm) PetscLogEventEnd(e+1,o1,o2,o3,o4)
239b0a32e0cSBarry Smith #define PetscLogEventEnd(e,o1,o2,o3,o4) \
240*53fde1feSMatthew Knepley   0; { \
241*53fde1feSMatthew Knepley   if (_PetscLogPLE && _stageLog->eventLog[_stageLog->curStage]->eventInfo[e].active) {\
242b0a32e0cSBarry Smith     (*_PetscLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));}\
243a1b5d808SSatish Balay   }
24477c4ece6SBarry Smith #endif
24577c4ece6SBarry Smith 
246ce85283eSBarry Smith /*
24784cb2905SBarry Smith      This does not work for MPI-Uni because our src/mpiuni/mpi.h file
248ce85283eSBarry Smith    uses macros to defined the MPI operations.
24915308354SBarry Smith 
25015308354SBarry Smith      It does not work correctly from HP-UX because it processes the
251bb4af37aSBarry Smith    macros in a way that sometimes it double counts, hence
252b932d42aSSatish Balay    HAVE_BROKEN_RECURSIVE_MACRO
2537c1e34a4SSatish Balay 
2547c1e34a4SSatish Balay      It does not work with Windows NT because winmpich lacks MPI_Type_size()
255ce85283eSBarry Smith */
256b932d42aSSatish Balay #if !defined(PETSC_HAVE_MPI_UNI) && !defined(HAVE_BROKEN_RECURSIVE_MACRO) && !defined (PETSC_HAVE_MPI_MISSING_TYPESIZE)
25777a39924SBarry Smith /*
25877a39924SBarry Smith    Logging of MPI activities
25977a39924SBarry Smith */
26077a39924SBarry Smith 
26177a39924SBarry Smith #define TypeSize(buff,count,type)                                                \
262ca161407SBarry Smith (\
263b0a32e0cSBarry Smith   MPI_Type_size(type,&PETSC_DUMMY_SIZE),buff += ((PetscLogDouble) ((count)*PETSC_DUMMY_SIZE)) \
264ca161407SBarry Smith )
26577a39924SBarry Smith 
26677a39924SBarry Smith #define MPI_Irecv(buf,count, datatype,source,tag,comm,request)        \
267ca161407SBarry Smith (\
268ca161407SBarry Smith   PETSC_DUMMY = MPI_Irecv(buf,count, datatype,source,tag,comm,request),            \
269ca161407SBarry Smith   irecv_ct++,TypeSize(irecv_len,count,datatype),PETSC_DUMMY                            \
270ca161407SBarry Smith )
27115308354SBarry Smith 
27277a39924SBarry Smith #define MPI_Isend(buf,count, datatype,dest,tag,comm,request)          \
273ca161407SBarry Smith (\
274ca161407SBarry Smith   PETSC_DUMMY = MPI_Isend(buf,count, datatype,dest,tag,comm,request),              \
275ca161407SBarry Smith   isend_ct++,  TypeSize(isend_len,count,datatype),PETSC_DUMMY                          \
276ca161407SBarry Smith )
27715308354SBarry Smith 
2780d4b0b6cSBarry Smith #define MPI_Startall_irecv(count,number,requests)                                     \
279ca161407SBarry Smith (\
280ca161407SBarry Smith   PETSC_DUMMY = MPI_Startall(number,requests),                                                    \
28187828ca2SBarry Smith   irecv_ct += (PetscLogDouble)(number),irecv_len += ((PetscLogDouble) ((count)*sizeof(PetscScalar))),PETSC_DUMMY \
282ca161407SBarry Smith )
2830d4b0b6cSBarry Smith 
2840d4b0b6cSBarry Smith #define MPI_Startall_isend(count,number,requests)                                    \
285ca161407SBarry Smith (\
286ca161407SBarry Smith   PETSC_DUMMY = MPI_Startall(number,requests),                                                   \
28787828ca2SBarry Smith   isend_ct += (PetscLogDouble)(number),isend_len += ((PetscLogDouble) ((count)*sizeof(PetscScalar))),PETSC_DUMMY \
288ca161407SBarry Smith )
2890d4b0b6cSBarry Smith 
2900d4b0b6cSBarry Smith #define MPI_Start_isend(count, requests)\
291ca161407SBarry Smith (\
292ca161407SBarry Smith   PETSC_DUMMY = MPI_Start(requests),\
29387828ca2SBarry Smith   isend_ct++,isend_len += ((PetscLogDouble) ((count)*sizeof(PetscScalar))),PETSC_DUMMY\
294ca161407SBarry Smith )
2950d4b0b6cSBarry Smith 
296ce85283eSBarry Smith #define MPI_Recv(buf,count, datatype,source,tag,comm,status)           \
297ca161407SBarry Smith (\
298ca161407SBarry Smith   PETSC_DUMMY = MPI_Recv(buf,count, datatype,source,tag,comm,status),               \
299ca161407SBarry Smith   recv_ct++,TypeSize(recv_len,count,datatype),PETSC_DUMMY                              \
300ca161407SBarry Smith )
30115308354SBarry Smith 
30277a39924SBarry Smith #define MPI_Send(buf,count, datatype,dest,tag,comm)                     \
303ca161407SBarry Smith (\
304ca161407SBarry Smith   PETSC_DUMMY = MPI_Send(buf,count, datatype,dest,tag,comm),                         \
305ca161407SBarry Smith   send_ct++, TypeSize(send_len,count,datatype),PETSC_DUMMY                              \
306ca161407SBarry Smith )
30777a39924SBarry Smith 
30877a39924SBarry Smith #define MPI_Wait(request,status) \
30977a39924SBarry Smith (\
310e0937024SBarry Smith   wait_ct++,sum_of_waits_ct++,  \
31177a39924SBarry Smith   MPI_Wait(request,status)       \
31277a39924SBarry Smith )
31377a39924SBarry Smith 
31477a39924SBarry Smith #define MPI_Waitany(a,b,c,d)     \
31577a39924SBarry Smith (\
316e0937024SBarry Smith   wait_any_ct++,sum_of_waits_ct++,\
31777a39924SBarry Smith   MPI_Waitany(a,b,c,d)           \
31877a39924SBarry Smith )
31977a39924SBarry Smith 
32077a39924SBarry Smith #define MPI_Waitall(count,array_of_requests,array_of_statuses) \
32177a39924SBarry Smith (\
322b0a32e0cSBarry Smith   wait_all_ct++,sum_of_waits_ct += (PetscLogDouble) (count),       \
32377a39924SBarry Smith   MPI_Waitall(count,array_of_requests,array_of_statuses)       \
32477a39924SBarry Smith )
32577a39924SBarry Smith 
32677a39924SBarry Smith #define MPI_Allreduce(sendbuf, recvbuf,count,datatype,op,comm) \
3270743b949SBarry Smith (\
3280743b949SBarry Smith   allreduce_ct++,MPI_Allreduce(sendbuf,recvbuf,count,datatype,op,comm)\
3290743b949SBarry Smith )
3303914022bSBarry Smith 
3310d4b0b6cSBarry Smith #else
3320d4b0b6cSBarry Smith 
3330d4b0b6cSBarry Smith #define MPI_Startall_irecv(count,number,requests) \
334ca161407SBarry Smith (\
335ca161407SBarry Smith   MPI_Startall(number,requests)                 \
336ca161407SBarry Smith )
3370d4b0b6cSBarry Smith 
3380d4b0b6cSBarry Smith #define MPI_Startall_isend(count,number,requests) \
339ca161407SBarry Smith (\
340ca161407SBarry Smith   MPI_Startall(number,requests)                 \
341ca161407SBarry Smith )
3420d4b0b6cSBarry Smith 
3430d4b0b6cSBarry Smith #define MPI_Start_isend(count, requests) \
344ca161407SBarry Smith (\
345ca161407SBarry Smith   MPI_Start(requests)                   \
346ca161407SBarry Smith )
3470d4b0b6cSBarry Smith 
348b932d42aSSatish Balay #endif /* !PETSC_HAVE_MPI_UNI && ! HAVE_BROKEN_RECURSIVE_MACRO */
349614700edSBarry Smith 
350df8cf0b5SBarry Smith #else  /* ---Logging is turned off --------------------------------------------*/
351614700edSBarry Smith 
352b0a32e0cSBarry Smith #define PetscLogFlops(n) 0
353614700edSBarry Smith 
354df8cf0b5SBarry Smith /*
355df8cf0b5SBarry Smith      With logging turned off, then MPE has to be turned off
356df8cf0b5SBarry Smith */
357614700edSBarry Smith #define MPEBEGIN                  1000
358b0a32e0cSBarry Smith #define PetscLogMPEBegin()            0
359b0a32e0cSBarry Smith #define PetscLogMPEDump(a)            0
360b0a32e0cSBarry Smith #define PetscLogEventMPEActivate(a)   0
361b0a32e0cSBarry Smith #define PetscLogEventMPEDeactivate(a) 0
362614700edSBarry Smith 
363b0a32e0cSBarry Smith #define PetscLogEventActivate(a)   0
364b0a32e0cSBarry Smith #define PetscLogEventDeactivate(a) 0
365614700edSBarry Smith 
366b0a32e0cSBarry Smith #define PetscLogEventActivateClass(a)   0
367b0a32e0cSBarry Smith #define PetscLogEventDeactivateClass(a) 0
36877c4ece6SBarry Smith 
369b0a32e0cSBarry Smith #define _PetscLogPLB                        0
370b0a32e0cSBarry Smith #define _PetscLogPLE                        0
371b0a32e0cSBarry Smith #define _PetscLogPHC                        0
372b0a32e0cSBarry Smith #define _PetscLogPHD                        0
37399de4ba8SSatish Balay #define PetscGetFlops(a)                (*(a) = 0.0,0)
374b0a32e0cSBarry Smith #define PetscLogEventBegin(e,o1,o2,o3,o4)   0
375b0a32e0cSBarry Smith #define PetscLogEventEnd(e,o1,o2,o3,o4)     0
376b0a32e0cSBarry Smith #define PetscLogEventBarrierBegin(e,o1,o2,o3,o4,cm) 0
377b0a32e0cSBarry Smith #define PetscLogEventBarrierEnd(e,o1,o2,o3,o4,cm)   0
378b0a32e0cSBarry Smith #define PetscLogObjectParent(p,c)
379b0a32e0cSBarry Smith #define PetscLogObjectParents(p,n,c)
380b0a32e0cSBarry Smith #define PetscLogObjectCreate(h)
381b0a32e0cSBarry Smith #define PetscLogObjectDestroy(h)
382b0a32e0cSBarry Smith #define PetscLogObjectMemory(p,m)
383b0a32e0cSBarry Smith #define PetscLogDestroy()                   0
384b0a32e0cSBarry Smith #define PetscLogStagePush(a)                0
385b0a32e0cSBarry Smith #define PetscLogStagePop()                  0
386b0a32e0cSBarry Smith #define PetscLogStageRegister(a,b)          0
387b0a32e0cSBarry Smith #define PetscLogStagePrint(a,flg)           0
388b0a32e0cSBarry Smith #define PetscLogPrintSummary(comm,file)     0
389b0a32e0cSBarry Smith #define PetscLogBegin()                     0
390b0a32e0cSBarry Smith #define PetscLogTraceBegin(file)            0
391b0a32e0cSBarry Smith #define PetscLogSet(lb,le)                  0
392b0a32e0cSBarry Smith #define PetscLogAllBegin()                  0
393b0a32e0cSBarry Smith #define PetscLogDump(c)                     0
3945291dbe9SBarry Smith #define PetscLogEventRegister(a,b,c,d)      0
39595f075fdSBarry Smith EXTERN int PetscLogObjectState(PetscObject,const char[],...) __ATTRIBUTE__ ((format (printf, 2,3)));
396ce6058e1SBarry Smith 
397aa482453SBarry Smith /* If PETSC_USE_LOG is NOT defined, these still need to be! */
398ca161407SBarry Smith #define MPI_Startall_irecv(count,number,requests) MPI_Startall(number,requests)
399ce6058e1SBarry Smith 
400ca161407SBarry Smith #define MPI_Startall_isend(count,number,requests) MPI_Startall(number,requests)
401ce6058e1SBarry Smith 
402ca161407SBarry Smith #define MPI_Start_isend(count,requests) MPI_Start(requests)
403ca161407SBarry Smith 
404aa482453SBarry Smith #endif   /* PETSC_USE_LOG */
4056daaf66cSBarry Smith 
406435da068SBarry Smith extern PetscTruth PetscPreLoadingUsed;       /* true if we are or have done preloading */
407435da068SBarry Smith extern PetscTruth PetscPreLoadingOn;         /* true if we are currently in a preloading calculation */
4081d1367b7SBarry Smith 
4098e58c17dSMatthew Knepley #define PreLoadBegin(flag,name) {PetscTruth PreLoading = flag; \
4108e58c17dSMatthew Knepley                                  int        PreLoadMax,PreLoadIt,_stageNum,_3_ierr;\
4116e491fe6SBarry Smith                                  _3_ierr = PetscOptionsGetLogical(PETSC_NULL,"-preload",&PreLoading,PETSC_NULL);CHKERRQ(_3_ierr);\
4121d1367b7SBarry Smith                                  PreLoadMax = (int)(PreLoading);PetscPreLoadingUsed = PreLoading ? PETSC_TRUE : PetscPreLoadingUsed;\
413e7592fafSBarry Smith                                  for (PreLoadIt=0; PreLoadIt<=PreLoadMax; PreLoadIt++) {\
414435da068SBarry Smith                                    PetscPreLoadingOn = PreLoading;\
4156e491fe6SBarry Smith                                    _3_ierr = PetscBarrier(PETSC_NULL);CHKERRQ(_3_ierr);\
4168e58c17dSMatthew Knepley                                    if (PreLoadIt>0) {\
4178e58c17dSMatthew Knepley                                      _3_ierr = PetscLogStageGetId(name,&_stageNum);CHKERRQ(_3_ierr);\
4188e58c17dSMatthew Knepley                                    } else {\
4198e58c17dSMatthew Knepley                                      _3_ierr = PetscLogStageRegister(&_stageNum,name);CHKERRQ(_3_ierr);\
4208e58c17dSMatthew Knepley                                      _3_ierr = PetscLogStageSetVisible(_stageNum,(PetscTruth)(!PreLoadMax || PreLoadIt));\
4218e58c17dSMatthew Knepley                                    }\
4228e58c17dSMatthew Knepley                                    _3_ierr = PetscLogStagePush(_stageNum);CHKERRQ(_3_ierr);
4238e58c17dSMatthew Knepley 
4246e491fe6SBarry Smith #define PreLoadEnd()               _3_ierr = PetscLogStagePop();CHKERRQ(_3_ierr);PreLoading = PETSC_FALSE;}}
4258e58c17dSMatthew Knepley 
4266e491fe6SBarry Smith #define PreLoadStage(name)         _3_ierr = PetscLogStagePop();CHKERRQ(_3_ierr);\
4278e58c17dSMatthew Knepley                                    if (PreLoadIt>0) {\
4288e58c17dSMatthew Knepley                                      _3_ierr = PetscLogStageGetId(name,&_stageNum);CHKERRQ(_3_ierr);\
4298e58c17dSMatthew Knepley                                    } else {\
4308e58c17dSMatthew Knepley                                      _3_ierr = PetscLogStageRegister(&_stageNum,name);CHKERRQ(_3_ierr);\
4318e58c17dSMatthew Knepley                                      _3_ierr = PetscLogStageSetVisible(_stageNum,(PetscTruth)(!PreLoadMax || PreLoadIt));\
4328e58c17dSMatthew Knepley                                    }\
4338e58c17dSMatthew Knepley                                    _3_ierr = PetscLogStagePush(_stageNum);CHKERRQ(_3_ierr);
43497bb86f7SLois Curfman McInnes #endif
435