xref: /petsc/include/petsclog.h (revision bc5ccf886fc7b029025ea4de8c4047e1db2135de)
1 /* $Id: petsclog.h,v 1.125 1998/11/20 15:31:26 bsmith Exp bsmith $ */
2 
3 /*
4     Defines profile/logging in PETSc.
5 */
6 
7 #if !defined(__PLOG_H)
8 #define __PLOG_H
9 #include "petsc.h"
10 
11 /*
12   Lists all PETSc events that are logged/profiled.
13 
14   If you add an event here, make sure you add it to
15   petsc/bin/petscview.cfg,
16   petsc/bin/petscview,
17   petsc/src/plog/src/plog.c,
18   petsc/src/plog/src/plogmpe.c, and
19   petsc/include/finclude/petsclog.h!!!
20 */
21 #define MAT_Mult                                0
22 #define MAT_MatrixFreeMult                      1
23 #define MAT_AssemblyBegin                       2
24 #define MAT_AssemblyEnd                         3
25 #define MAT_GetReordering                       4
26 #define MAT_MultTrans                           5
27 #define MAT_MultAdd                             6
28 #define MAT_MultTransAdd                        7
29 #define MAT_LUFactor                            8
30 #define MAT_CholeskyFactor                      9
31 #define MAT_LUFactorSymbolic                    10
32 #define MAT_ILUFactorSymbolic                   11
33 #define MAT_CholeskyFactorSymbolic              12
34 #define MAT_IncompleteCholeskyFactorSymbolic    13
35 #define MAT_LUFactorNumeric                     14
36 #define MAT_CholeskyFactorNumeric               15
37 #define MAT_Relax                               16
38 #define MAT_Copy                                17
39 #define MAT_Convert                             18
40 #define MAT_Scale                               19
41 #define MAT_ZeroEntries                         20
42 #define MAT_Solve                               21
43 #define MAT_SolveAdd                            22
44 #define MAT_SolveTrans                          23
45 #define MAT_SolveTransAdd                       24
46 #define MAT_SetValues                           25
47 #define MAT_ForwardSolve                        26
48 #define MAT_BackwardSolve                       27
49 #define MAT_Load                                28
50 #define MAT_View                                29
51 #define MAT_ILUFactor                           30
52 #define MAT_GetColoring                         31
53 #define MAT_GetSubMatrices                      32
54 #define MAT_GetValues                           33
55 #define MAT_IncreaseOverlap                     34
56 #define MAT_GetRow                              35
57 #define MAT_Partitioning                        36
58 
59 #define VEC_ReduceArithmetic                    37
60 #define VEC_ReduceCommunication                 38
61 #define VEC_ScatterBarrier                      39
62 #define VEC_Dot                                 40
63 #define VEC_Norm                                41
64 #define VEC_Max                                 42
65 #define VEC_Min                                 43
66 #define VEC_TDot                                44
67 #define VEC_Scale                               45
68 #define VEC_Copy                                46
69 #define VEC_Set                                 47
70 #define VEC_AXPY                                48
71 #define VEC_AYPX                                49
72 #define VEC_Swap                                50
73 #define VEC_WAXPY                               51
74 #define VEC_AssemblyBegin                       52
75 #define VEC_AssemblyEnd                         53
76 #define VEC_MTDot                               54
77 #define VEC_MDot                                55
78 #define VEC_MAXPY                               56
79 #define VEC_PMult                               57
80 #define VEC_SetValues                           58
81 #define VEC_Load                                59
82 #define VEC_View                                60
83 #define VEC_ScatterBegin                        61
84 #define VEC_ScatterEnd                          62
85 #define VEC_SetRandom                           63
86 
87 #define VEC_NormBarrier                         64
88 #define VEC_NormComm                            65
89 #define VEC_DotBarrier                          66
90 #define VEC_DotComm                             67
91 #define VEC_MDotBarrier                         68
92 #define VEC_MDotComm                            69
93 
94 #define SLES_Solve                              70
95 #define SLES_SetUp                              71
96 
97 #define KSP_GMRESOrthogonalization              72
98 
99 #define PC_ModifySubMatrices                    74
100 #define PC_SetUp                                75
101 #define PC_SetUpOnBlocks                        76
102 #define PC_Apply                                77
103 #define PC_ApplySymmetricLeft                   78
104 #define PC_ApplySymmetricRight                  79
105 
106 #define SNES_Solve                              80
107 #define SNES_LineSearch                         81
108 #define SNES_FunctionEval                       82
109 #define SNES_JacobianEval                       83
110 #define SNES_MinimizationFunctionEval           84
111 #define SNES_GradientEval                       85
112 #define SNES_HessianEval                        86
113 
114 #define VEC_ReduceBarrier                       87
115 #define VEC_ReduceCommOnly                      88
116 
117 #define TS_Step                                 90
118 #define TS_PseudoComputeTimeStep                91
119 
120 #define Petsc_Barrier                           100
121 
122 #define EC_SetUp                                105
123 #define EC_Solve                                106
124 
125 #define DFVec_RefineVector                      110
126 #define DFVec_AssembleFullVector                111
127 #define DFVec_GetComponentVectors               112
128 #define DFVec_DrawContours                      113
129 
130 /*
131    Event numbers PLOG_USER_EVENT_LOW to PLOG_USER_EVENT_HIGH are reserved
132    for applications.  Make sure that src/plog/src/plog.c defines enough
133    entries in (*name)[] to go up to PLOG_USER_EVENT_HIGH.
134 */
135 #define PLOG_USER_EVENT_LOW_STATIC              120
136 #define PLOG_USER_EVENT_HIGH                    200
137 
138 /* Global flop counter */
139 extern PLogDouble _TotalFlops;
140 
141 /* General logging of information; different from event logging */
142 extern int PLogInfo(void*,const char[],...);
143 extern int PLogInfoDeactivateClass(int);
144 extern int PLogInfoActivateClass(int);
145 extern int PLogPrintInfo;  /* if 1, indicates PLogInfo() is turned on */
146 
147 #if defined(USE_PETSC_LOG)  /* --- Logging is turned on --------------------------------*/
148 
149 /*
150    Flop counting:  We count each arithmetic operation (e.g., addition, multiplication) separately.
151 
152    For the complex numbers version, note that
153        1 complex addition = 2 flops
154        1 complex multiplication = 6 flops,
155    where we define 1 flop as that for a double precision scalar.  We roughly approximate
156    flop counting for complex numbers by multiplying the total flops by 4; this corresponds
157    to the assumption that we're counting mostly additions and multiplications -- and
158    roughly the same number of each.  More accurate counting could be done by distinguishing
159    among the various arithmetic operations.
160  */
161 
162 #if defined(USE_PETSC_COMPLEX)
163 #define PLogFlops(n) {_TotalFlops += (4*n);}
164 #else
165 #define PLogFlops(n) {_TotalFlops += (n);}
166 #endif
167 
168 #if defined (HAVE_MPE)
169 #include "mpe.h"
170 #define MPEBEGIN    1000
171 extern int PLogMPEBegin(void);
172 extern int PLogMPEDump(const char[]);
173 extern int UseMPE,PLogEventMPEFlags[];
174 extern int PLogEventMPEActivate(int);
175 extern int PLogEventMPEDeactivate(int);
176 #else
177 #define PLogEventMPEActivate(a) 0
178 #define PLogEventMPEDeactivate(a) 0
179 #endif
180 
181 extern int PLogEventActivate(int);
182 extern int PLogEventDeactivate(int);
183 
184 extern int PLogEventActivateClass(int);
185 extern int PLogEventDeactivateClass(int);
186 
187 extern int PLogEventFlags[];
188 extern int (*_PLogPLB)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
189 extern int (*_PLogPLE)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
190 extern int (*_PLogPHC)(PetscObject);
191 extern int (*_PLogPHD)(PetscObject);
192 
193 #if defined(HAVE_MPE)
194 #define PLogEventBarrierBegin(e,o1,o2,o3,o4,cm) \
195   { \
196     if (_PLogPLB && PLogEventFlags[e]) {                           \
197       PLogEventBegin((e),o1,o2,o3,o4);                                   \
198       if (UseMPE && PLogEventMPEFlags[(e)])\
199         MPE_Log_event(MPEBEGIN+2*(e),0,"");\
200       MPI_Barrier(cm);                                             \
201       PLogEventEnd((e),o1,o2,o3,o4);                                     \
202       if (UseMPE && PLogEventMPEFlags[(e)])\
203         MPE_Log_event(MPEBEGIN+2*((e)+1),0,"");\
204     }                                                                \
205     PLogEventBegin(e+1,o1,o2,o3,o4);                                   \
206     if (UseMPE && PLogEventMPEFlags[(e)+1])\
207       MPE_Log_event(MPEBEGIN+2*((e)+1),0,"");\
208   }
209 #define PLogEventBegin(e,o1,o2,o3,o4)  \
210   {  \
211    if (_PLogPLB && PLogEventFlags[(e)]) \
212      (*_PLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
213    if (UseMPE && PLogEventMPEFlags[(e)])\
214      MPE_Log_event(MPEBEGIN+2*(e),0,"");\
215   }
216 #else
217 #define PLogEventBarrierBegin(e,o1,o2,o3,o4,cm) \
218   { \
219     if (_PLogPLB && PLogEventFlags[(e)]) {                           \
220       PLogEventBegin((e),o1,o2,o3,o4);                                   \
221       MPI_Barrier(cm);                                             \
222       PLogEventEnd((e),o1,o2,o3,o4);                                     \
223     }                                                                \
224     PLogEventBegin((e)+1,o1,o2,o3,o4);                                   \
225   }
226 #define PLogEventBegin(e,o1,o2,o3,o4)  \
227   {  \
228    if (_PLogPLB && PLogEventFlags[(e)]) \
229      (*_PLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
230   }
231 #endif
232 
233 #if defined(HAVE_MPE)
234 #define PLogEventBarrierEnd(e,o1,o2,o3,o4,cm) {\
235   if (_PLogPLE && PLogEventFlags[(e)+1]) \
236     (*_PLogPLE)((e)+1,0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
237   if (UseMPE && PLogEventMPEFlags[(e)+1])\
238      MPE_Log_event(MPEBEGIN+2*((e)+1)+1,0,"");\
239   }
240 #define PLogEventEnd(e,o1,o2,o3,o4) {\
241   if (_PLogPLE && PLogEventFlags[(e)]) \
242     (*_PLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
243   if (UseMPE && PLogEventMPEFlags[(e)])\
244      MPE_Log_event(MPEBEGIN+2*(e)+1,0,"");\
245   }
246 #else
247 #define PLogEventBarrierEnd(e,o1,o2,o3,o4,cm) {\
248   if (_PLogPLE && PLogEventFlags[(e)+1]) \
249     (*_PLogPLE)((e)+1,0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
250   }
251 #define PLogEventEnd(e,o1,o2,o3,o4) {\
252   if (_PLogPLE && PLogEventFlags[(e)]) \
253     (*_PLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
254   }
255 #endif
256 
257 
258 #define PLogObjectParent(p,c)       if (c) {PetscValidHeader((PetscObject)(c)); \
259                                      PetscValidHeader((PetscObject)(p));\
260                                      ((PetscObject)(c))->parent = (PetscObject) (p);\
261 				     ((PetscObject)(c))->parentid = ((PetscObject) p)->id;}
262 #define PLogObjectParents(p,n,d)    {int _i; for ( _i=0; _i<n; _i++ ) \
263                                     PLogObjectParent(p,(d)[_i]);}
264 #define PLogObjectCreate(h)         {if (_PLogPHC) (*_PLogPHC)((PetscObject)h);}
265 #define PLogObjectDestroy(h)        {if (_PLogPHD) (*_PLogPHD)((PetscObject)h);}
266 #define PLogObjectMemory(p,m)       {PetscValidHeader((PetscObject)p);\
267                                     ((PetscObject)(p))->mem += (m);}
268 extern int  PLogObjectState(PetscObject,const char[],...);
269 extern int  PLogDestroy(void);
270 extern int  PLogStagePush(int);
271 extern int  PLogStagePop(void);
272 extern int  PLogStageRegister(int,const char[]);
273 extern int  PLogPrintSummary(MPI_Comm,const char[]);
274 extern int  PLogBegin(void);
275 extern int  PLogTraceBegin(FILE *);
276 extern int  PLogAllBegin(void);
277 extern int  PLogSet(int (*)(int,int,PetscObject,PetscObject,PetscObject,PetscObject),
278                     int (*)(int,int,PetscObject,PetscObject,PetscObject,PetscObject));
279 extern int  PLogDump(const char[]);
280 extern int  PLogEventRegister(int*,const char[],const char[]);
281 extern int  PetscGetFlops(PLogDouble*);
282 
283 extern PLogDouble irecv_ct, isend_ct, wait_ct, wait_any_ct, recv_ct, send_ct;
284 extern PLogDouble irecv_len, isend_len, recv_len, send_len;
285 extern PLogDouble wait_all_ct,allreduce_ct,sum_of_waits_ct;
286 extern int        PETSC_DUMMY,PETSC_DUMMY_SIZE;
287 
288 /*
289      This does not work for MPI-Uni because our src/mpiuni/mpi.h file
290    uses macros to defined the MPI operations.
291 
292      It does not work correctly from HP-UX because it processes the
293    macros in a way that sometimes it double counts, hence
294    HAVE_BROKEN_RECURSIVE_MACRO
295 
296      It does not work with Windows NT because winmpich lacks MPI_Type_size()
297 */
298 #if !defined(USING_MPIUNI) && !defined(HAVE_BROKEN_RECURSIVE_MACRO)
299 /*
300    Logging of MPI activities
301 */
302 
303 #define TypeSize(buff,count,type)                                                \
304 (                                                                                \
305   MPI_Type_size(type,&PETSC_DUMMY_SIZE), buff += ((PLogDouble) ((count)*PETSC_DUMMY_SIZE)) \
306 )
307 
308 #define MPI_Irecv( buf, count,  datatype, source, tag, comm, request)        \
309 (                                                                            \
310   PETSC_DUMMY = MPI_Irecv( buf, count,  datatype, source, tag, comm, request),             \
311   irecv_ct++, TypeSize(irecv_len,count,datatype),PETSC_DUMMY                            \
312 )
313 
314 #define MPI_Isend( buf, count,  datatype, dest, tag, comm, request)          \
315 (                                                                            \
316   PETSC_DUMMY = MPI_Isend( buf, count,  datatype, dest, tag, comm, request),               \
317   isend_ct++,   TypeSize(isend_len,count,datatype),PETSC_DUMMY                          \
318 )
319 
320 #define MPI_Startall_irecv( count,number,requests)                                     \
321 (                                                                                      \
322   PETSC_DUMMY = MPI_Startall( number, requests),                                                     \
323   irecv_ct += (PLogDouble)(number), irecv_len += ((PLogDouble) (count*sizeof(Scalar))),PETSC_DUMMY \
324 )
325 
326 #define MPI_Startall_isend( count,number,requests)                                    \
327 (                                                                                     \
328   PETSC_DUMMY = MPI_Startall( number, requests),                                                    \
329   isend_ct += (PLogDouble)(number), isend_len += ((PLogDouble) (count*sizeof(Scalar))),PETSC_DUMMY \
330 )
331 
332 #define MPI_Start_isend(count,  requests)\
333 (\
334   PETSC_DUMMY = MPI_Start( requests),\
335   isend_ct++, isend_len += ((PLogDouble) (count*sizeof(Scalar))),PETSC_DUMMY\
336 )
337 
338 #define MPI_Recv( buf, count,  datatype, source, tag, comm, status)           \
339 (                                                                            \
340   PETSC_DUMMY = MPI_Recv( buf, count,  datatype, source, tag, comm, status),                \
341   recv_ct++, TypeSize(recv_len,count,datatype), PETSC_DUMMY                              \
342 )
343 
344 #define MPI_Send( buf, count,  datatype, dest, tag, comm)                     \
345 (                                                                             \
346   PETSC_DUMMY = MPI_Send( buf, count,  datatype, dest, tag, comm),                          \
347   send_ct++,  TypeSize(send_len,count,datatype),PETSC_DUMMY                              \
348 )
349 
350 #define MPI_Wait(request, status) \
351 (                                 \
352   wait_ct++, sum_of_waits_ct++,   \
353   MPI_Wait(request, status)       \
354 )
355 
356 #define MPI_Waitany(a, b, c, d)     \
357 (                                   \
358   wait_any_ct++, sum_of_waits_ct++, \
359   MPI_Waitany(a, b, c, d)           \
360 )
361 
362 #define MPI_Waitall(count, array_of_requests, array_of_statuses) \
363 (                                                                \
364   wait_all_ct++, sum_of_waits_ct += (PLogDouble) (count),        \
365   MPI_Waitall(count, array_of_requests, array_of_statuses)       \
366 )
367 
368 #define MPI_Allreduce( sendbuf,  recvbuf, count, datatype, op, comm) \
369     (allreduce_ct++,MPI_Allreduce( sendbuf,  recvbuf, count, datatype, op, comm))
370 
371 #else
372 
373 #define MPI_Startall_irecv( count,number,requests) \
374 (                                                  \
375   MPI_Startall( number, requests)                 \
376 )
377 
378 #define MPI_Startall_isend( count,number,requests) \
379 (                                                  \
380   MPI_Startall( number, requests)                 \
381 )
382 
383 #define MPI_Start_isend(count,  requests) \
384 (                                         \
385   MPI_Start( requests)                   \
386 )
387 
388 #endif /* !USING_MPIUNI && ! HAVE_BROKEN_RECURSIVE_MACRO */
389 
390 #else  /* ---Logging is turned off --------------------------------------------*/
391 
392 #define PLogFlops(n)
393 
394 /*
395      With logging turned off, then MPE has to be turned off
396 */
397 #define MPEBEGIN                  1000
398 #define PLogMPEBegin()
399 #define PLogMPEDump(a)
400 #define PLogEventMPEActivate(a)   0
401 #define PLogEventMPEDeactivate(a) 0
402 
403 #define PLogEventActivate(a)   0
404 #define PLogEventDeactivate(a) 0
405 
406 #define PLogEventActivateClass(a)   0
407 #define PLogEventDeactivateClass(a) 0
408 
409 #define _PLogPLB                        0
410 #define _PLogPLE                        0
411 #define _PLogPHC                        0
412 #define _PLogPHD                        0
413 #define PetscGetFlops(a)                (*(a) = 0.0,0)
414 #define PLogEventBegin(e,o1,o2,o3,o4)
415 #define PLogEventEnd(e,o1,o2,o3,o4)
416 #define PLogEventBarrierBegin(e,o1,o2,o3,o4,cm)
417 #define PLogEventBarrierEnd(e,o1,o2,o3,o4,cm)
418 #define PLogObjectParent(p,c)
419 #define PLogObjectParents(p,n,c)
420 #define PLogObjectCreate(h)
421 #define PLogObjectDestroy(h)
422 #define PLogObjectMemory(p,m)
423 #define PLogDestroy()
424 #define PLogStagePush(a)
425 #define PLogStagePop()
426 #define PLogStageRegister(a,b)
427 #define PLogPrintSummary(comm,file)
428 #define PLogBegin()
429 #define PLogTraceBegin(file)            0
430 #define PLogSet(lb,le)
431 #define PLogAllBegin()
432 #define PLogDump(c)
433 #define PLogEventRegister(a,b,c)        0
434 #define PLogMPEBegin()
435 #define PLogMPEDump(a)
436 extern int PLogObjectState(PetscObject,const char[],...);
437 
438 /* If USE_PETSC_LOG is NOT defined, these still need to be! */
439 #define MPI_Startall_irecv( count,number,requests) MPI_Startall( number, requests)
440 
441 #define MPI_Startall_isend( count,number,requests) MPI_Startall( number, requests)
442 
443 #define MPI_Start_isend(count,  requests) MPI_Start( requests)
444 
445 #endif   /* USE_PETSC_LOG */
446 
447 
448 #endif
449 
450 
451 
452 
453 
454 
455