xref: /petsc/include/petsclog.h (revision 90f02eec332fcca4c33b4e7b21cabed76bf0614e)
1 /* $Id: plog.h,v 1.90 1996/10/11 15:11:49 balay Exp bsmith $ */
2 
3 /*
4     Defines profile/logging in PETSc.
5 */
6 
7 #if !defined(__PLOG_PACKAGE)
8 #define __PLOG_PACKAGE
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/plog.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 
58 #define VEC_Dot                                 40
59 #define VEC_Norm                                41
60 #define VEC_Max                                 42
61 #define VEC_Min                                 43
62 #define VEC_TDot                                44
63 #define VEC_Scale                               45
64 #define VEC_Copy                                46
65 #define VEC_Set                                 47
66 #define VEC_AXPY                                48
67 #define VEC_AYPX                                49
68 #define VEC_Swap                                50
69 #define VEC_WAXPY                               51
70 #define VEC_AssemblyBegin                       52
71 #define VEC_AssemblyEnd                         53
72 #define VEC_MTDot                               54
73 #define VEC_MDot                                55
74 #define VEC_MAXPY                               56
75 #define VEC_PMult                               57
76 #define VEC_SetValues                           58
77 #define VEC_Load                                59
78 #define VEC_View                                60
79 #define VEC_ScatterBegin                        61
80 #define VEC_ScatterEnd                          62
81 #define VEC_SetRandom                           63
82 
83 #define SLES_Solve                              70
84 #define SLES_SetUp                              71
85 
86 #define KSP_GMRESOrthogonalization              72
87 
88 #define PC_ModifySubMatrices                    74
89 #define PC_SetUp                                75
90 #define PC_SetUpOnBlocks                        76
91 #define PC_Apply                                77
92 #define PC_ApplySymmetricLeft                   78
93 #define PC_ApplySymmetricRight                  79
94 
95 #define SNES_Solve                              80
96 #define SNES_LineSearch                         81
97 #define SNES_FunctionEval                       82
98 #define SNES_JacobianEval                       83
99 #define SNES_MinimizationFunctionEval           84
100 #define SNES_GradientEval                       85
101 #define SNES_HessianEval                        86
102 
103 #define TS_Step                                 90
104 #define TS_PseudoComputeTimeStep                91
105 
106 #define Petsc_Barrier                           100
107 
108 #define DFVec_RefineVector                      110
109 #define DFVec_AssembleFullVector                111
110 #define DFVec_GetComponentVectors               112
111 #define DFVec_DrawContours                      113
112 
113 /*
114    Event numbers PLOG_USER_EVENT_LOW to PLOG_USER_EVENT_HIGH are reserved
115    for applications.  Make sure that src/plog/src/plog.c defines enough
116    entries in (*name)[] to go up to PLOG_USER_EVENT_HIGH.
117 */
118 #define PLOG_USER_EVENT_LOW_STATIC              120
119 #define PLOG_USER_EVENT_HIGH                    200
120 
121 /* Global flop counter */
122 extern double _TotalFlops;
123 
124 /* General logging of information; different from event logging */
125 extern int PLogInfo(void*,char*,...);
126 extern int PLogInfoDeactivateClass(int);
127 extern int PLogInfoActivateClass(int);
128 
129 #if defined(PETSC_LOG)  /* --------------------------------------------*/
130 
131 #define PLogFlops(n) {_TotalFlops += (n);}
132 
133 #if defined (HAVE_MPE)
134 #include "mpe.h"
135 #define MPEBEGIN    1000
136 extern int PLogMPEBegin();
137 extern int PLogMPEDump(char *);
138 extern int UseMPE,PLogEventMPEFlags[];
139 extern int PLogEventMPEActivate(int);
140 extern int PLogEventMPEDeactivate(int);
141 #else
142 #define PLogEventMPEActivate(a) 0
143 #define PLogEventMPEDeactivate(a) 0
144 #endif
145 
146 extern int PLogEventActivate(int);
147 extern int PLogEventDeactivate(int);
148 
149 extern int PLogEventActivateClass(int);
150 extern int PLogEventDeactivateClass(int);
151 
152 extern int PLogEventFlags[];
153 extern int (*_PLB)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
154 extern int (*_PLE)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
155 extern int (*_PHC)(PetscObject);
156 extern int (*_PHD)(PetscObject);
157 
158 #if defined(HAVE_MPE)
159 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0; \
160   { _tacky++; \
161    if (_PLB && PLogEventFlags[e]) \
162      (*_PLB)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
163    if (_tacky == 1 && UseMPE && PLogEventMPEFlags[e])\
164      MPE_Log_event(MPEBEGIN+2*e,0,"");\
165   }
166 #else
167 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0; \
168   { _tacky++; \
169    if (_PLB && PLogEventFlags[e]) \
170      (*_PLB)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
171   }
172 #endif
173 
174 #if defined(HAVE_MPE)
175 #define PLogEventEnd(e,o1,o2,o3,o4) {\
176   if (_PLE && PLogEventFlags[e]) \
177     (*_PLE)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
178   if (_tacky == 1 && UseMPE && PLogEventMPEFlags[e])\
179      MPE_Log_event(MPEBEGIN+2*e+1,0,"");\
180   }  _tacky--;}
181 #else
182 #define PLogEventEnd(e,o1,o2,o3,o4) {\
183   if (_PLE && PLogEventFlags[e]) \
184     (*_PLE)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
185   } _tacky--;}
186 #endif
187 
188 
189 #define PLogObjectParent(p,c)       {PetscValidHeader((PetscObject)c); \
190                                      PetscValidHeader((PetscObject)p);\
191                                      ((PetscObject)(c))->parent = (PetscObject) p;}
192 #define PLogObjectParents(p,n,d)    {int _i; for ( _i=0; _i<n; _i++ ) \
193                                     PLogObjectParent(p,(d)[_i]);}
194 #define PLogObjectCreate(h)         {if (_PHC) (*_PHC)((PetscObject)h);}
195 #define PLogObjectDestroy(h)        {if (_PHD) (*_PHD)((PetscObject)h);}
196 #define PLogObjectMemory(p,m)       {PetscValidHeader((PetscObject)p);\
197                                     ((PetscObject)(p))->mem += (m);}
198 extern int    PLogObjectState(PetscObject,char *,...);
199 extern int    PLogDestroy();
200 extern int    PLogStagePush(int);
201 extern int    PLogStagePop();
202 extern int    PLogStageRegister(int,char*);
203 extern int    PLogPrintSummary(MPI_Comm,FILE *);
204 extern int    PLogBegin();
205 extern int    PLogTraceBegin(FILE *);
206 extern int    PLogAllBegin();
207 extern int    PLogSet(int (*)(int,int,PetscObject,PetscObject,PetscObject,PetscObject),
208                       int (*)(int,int,PetscObject,PetscObject,PetscObject,PetscObject));
209 extern int    PLogDump(char*);
210 extern int    PLogEventRegister(int*,char*,char*);
211 extern double PetscGetFlops();
212 
213 extern double irecv_ct, isend_ct, wait_ct, wait_any_ct, recv_ct, send_ct;
214 extern double irecv_len, isend_len, recv_len, send_len;
215 extern double wait_all_ct,allreduce_ct,sum_of_waits_ct;
216 /*
217      This does not use for MPI-Uni because our src/mpiuni/mpi.h file
218    uses macros to defined the MPI operations.
219 
220      It does not work correctly from HP-UX because it processes the
221    macros in a way that sometimes it double counts.
222 */
223 #if !defined(PETSC_USING_MPIUNI) && !defined(PARCH_hpux)
224 /*
225    Logging of MPI activities
226 */
227 
228 #define TypeSize(buff,count,type) \
229 { \
230   if (type == MPIU_SCALAR) { \
231     buff += (double) ((count)*sizeof(Scalar)); \
232   } else if (type == MPI_INT) { \
233     buff += (double) ((count)*sizeof(int));  \
234   } else { \
235     int _size; MPI_Type_size(type,&_size); buff += (double) ((count)*_size); \
236   } \
237 }
238 
239 #define MPI_Irecv( buf, count,  datatype, source, tag, comm, request) \
240 { \
241   MPI_Irecv( buf, count,  datatype, source, tag, comm, request);\
242   irecv_ct++; TypeSize(irecv_len,count,datatype); \
243 }
244 
245 #define MPI_Isend( buf, count,  datatype, dest, tag, comm, request) \
246 { \
247   MPI_Isend( buf, count,  datatype, dest, tag, comm, request); \
248   isend_ct++;   TypeSize(isend_len,count,datatype); \
249 }
250 
251 #define MPI_Startall_irecv( count,number,requests) \
252 { \
253   MPI_Startall( number, requests);\
254   irecv_ct += (double)(number); irecv_len += (double) (count*sizeof(Scalar)); \
255 }
256 
257 #define MPI_Startall_isend( count,number,requests) \
258 { \
259   MPI_Startall( number, requests);\
260   isend_ct += (double)(number); isend_len += (double) (count*sizeof(Scalar)); \
261 }
262 
263 #define MPI_Start_isend(count,  requests) \
264 { \
265   MPI_Start( requests);\
266   isend_ct++; isend_len += (double) (count*sizeof(Scalar)); \
267 }
268 
269 #define MPI_Recv( buf, count,  datatype, source, tag, comm, status) \
270 { \
271   MPI_Recv( buf, count,  datatype, source, tag, comm, status); \
272   recv_ct++; TypeSize(recv_len,count,datatype); \
273 }
274 
275 #define MPI_Send( buf, count,  datatype, dest, tag, comm) \
276 { \
277   MPI_Send( buf, count,  datatype, dest, tag, comm); \
278   send_ct++;  TypeSize(send_len,count,datatype); \
279 }
280 
281 #define MPI_Wait(request, status) \
282 ( \
283   wait_ct++, sum_of_waits_ct++,\
284   MPI_Wait(request, status)  \
285 )
286 
287 #define MPI_Waitany(a, b, c, d) \
288 ( \
289   wait_any_ct++, sum_of_waits_ct++,  \
290   MPI_Waitany(a, b, c, d)\
291 )
292 
293 #define MPI_Waitall(count, array_of_requests, array_of_statuses) \
294 ( \
295   wait_all_ct++, sum_of_waits_ct += (double) (count),\
296   MPI_Waitall(count, array_of_requests, array_of_statuses) \
297 )
298 
299 #define MPI_Allreduce( sendbuf,  recvbuf, count, datatype, op, comm) \
300 ( \
301   allreduce_ct++, \
302   MPI_Allreduce( sendbuf,  recvbuf, count, datatype, op, comm) \
303 )
304 #else
305 
306 #define MPI_Startall_irecv( count,number,requests) \
307 { \
308   MPI_Startall( number, requests);\
309 }
310 
311 #define MPI_Startall_isend( count,number,requests) \
312 { \
313   MPI_Startall( number, requests);\
314 }
315 
316 #define MPI_Start_isend(count,  requests) \
317 { \
318   MPI_Start( requests);\
319 }
320 
321 #endif /* ! PETSC_USING_MPIUNI && ! PARCH_hpux */
322 
323 #else  /* ------------------------------------------------------------*/
324 
325 #define PLogFlops(n)
326 
327 #if defined (HAVE_MPE)
328 #define MPEBEGIN    1000
329 extern int PLogMPEBegin();
330 extern int PLogMPEDump(char *);
331 #else
332 #define PLogEventMPEActivate(a) 0
333 #define PLogEventMPEDeactivate(a) 0
334 #endif
335 
336 #define PLogEventActivate(a) 0
337 #define PLogEventDeactivate(a) 0
338 
339 #define PLogEventActivateClass(a) 0
340 #define PLogEventDeactivateClass(a) 0
341 
342 #define _PLB                          0
343 #define _PLE                          0
344 #define _PHC                          0
345 #define _PHD                          0
346 #define PetscGetFlops                 0.0
347 #define PLogEventBegin(e,o1,o2,o3,o4)
348 #define PLogEventEnd(e,o1,o2,o3,o4)
349 #define PLogObjectParent(p,c)
350 #define PLogObjectParents(p,n,c)
351 #define PLogObjectCreate(h)
352 #define PLogObjectDestroy(h)
353 #define PLogObjectMemory(p,m)
354 #define PLogDestroy()
355 #define PLogStagePush(a)
356 #define PLogStagePop()
357 #define PLogStageRegister(a,b)
358 #define PLogPrintSummary(comm,file)
359 #define PLogBegin()
360 #define PLogTraceBegin(file)
361 #define PLogSet(lb,le)
362 #define PLogAllBegin()
363 #define PLogDump(char)
364 #define PLogEventRegister(a,b,c)
365 #define PLogMPEBegin()
366 #define PLogMPEDump(a)
367 extern int PLogObjectState(PetscObject,char *,...);
368 
369 /* If PETSC_LOG is NOT defined, these still need to be! */
370 #define MPI_Startall_irecv( count,number,requests) \
371 { \
372   MPI_Startall( number, requests);\
373 }
374 
375 #define MPI_Startall_isend( count,number,requests) \
376 { \
377   MPI_Startall( number, requests);\
378 }
379 
380 #define MPI_Start_isend(count,  requests) \
381 { \
382   MPI_Start( requests);\
383 }
384 #endif   /* PETSC_LOG */
385 
386 /*MC
387    PLogFlops - Adds floating point operations to the global counter.
388 
389    Input Parameter:
390 .  f - flop counter
391 
392    Synopsis:
393    void PLogFlops(int f)
394 
395    Notes:
396    A global counter logs all PETSc flop counts.  The user can use
397    PLogFlops() to increment this counter to include flops for the
398    application code.
399 
400    PETSc automatically logs library events if the code has been
401    compiled with -DPETSC_LOG (which is the default), and -log,
402    -log_summary, or -log_all are specified.  PLogFlops() is
403    intended for logging user flops to supplement this PETSc
404    information.
405 
406     Example of Usage:
407 $     int USER_EVENT;
408 $     PLogEventRegister(&USER_EVENT,"User event","Color:");
409 $     PLogEventBegin(USER_EVENT,0,0,0,0);
410 $        [code segment to monitor]
411 $        PLogFlops(user_flops)
412 $     PLogEventEnd(USER_EVENT,0,0,0,0);
413 
414 .seealso: PLogEventRegister(), PLogEventBegin(), PLogEventEnd(), PetscGetFlops()
415 
416 .keywords: log, flops, floating point operations
417 M*/
418 
419 
420 /*MC
421    PLogEventBegin - Logs the beginning of a user event.
422 
423    Input Parameters:
424 .  e - integer associated with the event obtained from PLogEventRegister()
425 .  o1,o2,o3,o4 - objects associated with the event, or 0
426 
427    Synopsis:
428    void PLogEventBegin(int e,PetscObject o1,PetscObject o2,PetscObject o3,
429                   PetscObject o4)
430 
431    Notes:
432    You should also register each integer event with the command
433    PLogRegisterEvent().  The source code must be compiled with
434    -DPETSC_LOG, which is the default.
435 
436    PETSc automatically logs library events if the code has been
437    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
438    specified.  PLogEventBegin() is intended for logging user events
439    to supplement this PETSc information.
440 
441     Example of Usage:
442 $     int USER_EVENT;
443 $     int user_event_flops;
444 $     PLogEventRegister(&USER_EVENT,"User event","Color:");
445 $     PLogEventBegin(&USER_EVENT,0,0,0,0);
446 $        [code segment to monitor]
447 $        PLogFlops(user_event_flops);
448 $     PLogEventEnd(&USER_EVENT,0,0,0,0);
449 
450 .seealso: PLogEventRegister(), PLogEventEnd(), PLogFlops()
451 
452 .keywords: log, event, begin
453 M*/
454 
455 /*MC
456    PLogEventEnd - Log the end of a user event.
457 
458    Input Parameters:
459 .  e - integer associated with the event obtained with PLogEventRegister()
460 .  o1,o2,o3,o4 - objects associated with the event, or 0
461 
462    Synopsis:
463    void PLogEventEnd(int e,PetscObject o1,PetscObject o2,PetscObject o3,
464                 PetscObject o4)
465 
466    Notes:
467    You should also register each integer event with the command
468    PLogRegisterEvent(). Source code must be compiled with
469    -DPETSC_LOG, which is the default.
470 
471    PETSc automatically logs library events if the code has been
472    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
473    specified.  PLogEventEnd() is intended for logging user events
474    to supplement this PETSc information.
475 
476     Example of Usage:
477 $     int USER_EVENT;
478 $     int user_event_flops;
479 $     PLogEventRegister(&USER_EVENT,"User event","Color:");
480 $     PLogEventBegin(USER_EVENT,0,0,0,0);
481 $        [code segment to monitor]
482 $        PLogFlops(user_event_flops);
483 $     PLogEventEnd(USER_EVENT,0,0,0,0);
484 
485 .seealso: PLogEventRegister(), PLogEventBegin(), PLogFlops()
486 
487 .keywords: log, event, end
488 M*/
489 
490 
491 #endif
492 
493 
494 
495