xref: /petsc/include/petsclog.h (revision 96d09e227e0e753a6888f217ccd1cd5469fdb59e)
1 /* $Id: petsclog.h,v 1.94 1996/12/09 16:17:25 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/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 
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 extern int PLogPrintInfo;  /* if 1, indicates PLogInfo() is turned on */
129 
130 #if defined(PETSC_LOG)  /* --------------------------------------------*/
131 
132 #define PLogFlops(n) {_TotalFlops += (n);}
133 
134 #if defined (HAVE_MPE)
135 #include "mpe.h"
136 #define MPEBEGIN    1000
137 extern int PLogMPEBegin();
138 extern int PLogMPEDump(char *);
139 extern int UseMPE,PLogEventMPEFlags[];
140 extern int PLogEventMPEActivate(int);
141 extern int PLogEventMPEDeactivate(int);
142 #else
143 #define PLogEventMPEActivate(a) 0
144 #define PLogEventMPEDeactivate(a) 0
145 #endif
146 
147 extern int PLogEventActivate(int);
148 extern int PLogEventDeactivate(int);
149 
150 extern int PLogEventActivateClass(int);
151 extern int PLogEventDeactivateClass(int);
152 
153 extern int PLogEventFlags[];
154 extern int (*_PLogPLB)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
155 extern int (*_PLogPLE)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
156 extern int (*_PLogPHC)(PetscObject);
157 extern int (*_PLogPHD)(PetscObject);
158 
159 #if defined(HAVE_MPE)
160 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0; \
161   { _tacky++; \
162    if (_PLogPLB && PLogEventFlags[e]) \
163      (*_PLogPLB)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
164    if (_tacky == 1 && UseMPE && PLogEventMPEFlags[e])\
165      MPE_Log_event(MPEBEGIN+2*e,0,"");\
166   }
167 #else
168 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0; \
169   { _tacky++; \
170    if (_PLogPLB && PLogEventFlags[e]) \
171      (*_PLogPLB)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
172   }
173 #endif
174 
175 #if defined(HAVE_MPE)
176 #define PLogEventEnd(e,o1,o2,o3,o4) {\
177   if (_PLogPLE && PLogEventFlags[e]) \
178     (*_PLogPLE)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
179   if (_tacky == 1 && UseMPE && PLogEventMPEFlags[e])\
180      MPE_Log_event(MPEBEGIN+2*e+1,0,"");\
181   }  _tacky--;}
182 #else
183 #define PLogEventEnd(e,o1,o2,o3,o4) {\
184   if (_PLogPLE && PLogEventFlags[e]) \
185     (*_PLogPLE)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
186   } _tacky--;}
187 #endif
188 
189 
190 #define PLogObjectParent(p,c)       {PetscValidHeader((PetscObject)c); \
191                                      PetscValidHeader((PetscObject)p);\
192                                      ((PetscObject)(c))->parent = (PetscObject) p;}
193 #define PLogObjectParents(p,n,d)    {int _i; for ( _i=0; _i<n; _i++ ) \
194                                     PLogObjectParent(p,(d)[_i]);}
195 #define PLogObjectCreate(h)         {if (_PLogPHC) (*_PLogPHC)((PetscObject)h);}
196 #define PLogObjectDestroy(h)        {if (_PLogPHD) (*_PLogPHD)((PetscObject)h);}
197 #define PLogObjectMemory(p,m)       {PetscValidHeader((PetscObject)p);\
198                                     ((PetscObject)(p))->mem += (m);}
199 extern int    PLogObjectState(PetscObject,char *,...);
200 extern int    PLogDestroy();
201 extern int    PLogStagePush(int);
202 extern int    PLogStagePop();
203 extern int    PLogStageRegister(int,char*);
204 extern int    PLogPrintSummary(MPI_Comm,FILE *);
205 extern int    PLogBegin();
206 extern int    PLogTraceBegin(FILE *);
207 extern int    PLogAllBegin();
208 extern int    PLogSet(int (*)(int,int,PetscObject,PetscObject,PetscObject,PetscObject),
209                       int (*)(int,int,PetscObject,PetscObject,PetscObject,PetscObject));
210 extern int    PLogDump(char*);
211 extern int    PLogEventRegister(int*,char*,char*);
212 extern double PetscGetFlops();
213 
214 extern double irecv_ct, isend_ct, wait_ct, wait_any_ct, recv_ct, send_ct;
215 extern double irecv_len, isend_len, recv_len, send_len;
216 extern double wait_all_ct,allreduce_ct,sum_of_waits_ct;
217 /*
218      This does not use for MPI-Uni because our src/mpiuni/mpi.h file
219    uses macros to defined the MPI operations.
220 
221      It does not work correctly from HP-UX because it processes the
222    macros in a way that sometimes it double counts.
223 */
224 #if !defined(PETSC_USING_MPIUNI) && !defined(PARCH_hpux)
225 /*
226    Logging of MPI activities
227 */
228 
229 #define TypeSize(buff,count,type) \
230 { \
231   if (type == MPIU_SCALAR) { \
232     buff += (double) ((count)*sizeof(Scalar)); \
233   } else if (type == MPI_INT) { \
234     buff += (double) ((count)*sizeof(int));  \
235   } else { \
236     int _size; MPI_Type_size(type,&_size); buff += (double) ((count)*_size); \
237   } \
238 }
239 
240 #define MPI_Irecv( buf, count,  datatype, source, tag, comm, request) \
241 { \
242   MPI_Irecv( buf, count,  datatype, source, tag, comm, request);\
243   irecv_ct++; TypeSize(irecv_len,count,datatype); \
244 }
245 
246 #define MPI_Isend( buf, count,  datatype, dest, tag, comm, request) \
247 { \
248   MPI_Isend( buf, count,  datatype, dest, tag, comm, request); \
249   isend_ct++;   TypeSize(isend_len,count,datatype); \
250 }
251 
252 #define MPI_Startall_irecv( count,number,requests) \
253 { \
254   MPI_Startall( number, requests);\
255   irecv_ct += (double)(number); irecv_len += (double) (count*sizeof(Scalar)); \
256 }
257 
258 #define MPI_Startall_isend( count,number,requests) \
259 { \
260   MPI_Startall( number, requests);\
261   isend_ct += (double)(number); isend_len += (double) (count*sizeof(Scalar)); \
262 }
263 
264 #define MPI_Start_isend(count,  requests) \
265 { \
266   MPI_Start( requests);\
267   isend_ct++; isend_len += (double) (count*sizeof(Scalar)); \
268 }
269 
270 #define MPI_Recv( buf, count,  datatype, source, tag, comm, status) \
271 { \
272   MPI_Recv( buf, count,  datatype, source, tag, comm, status); \
273   recv_ct++; TypeSize(recv_len,count,datatype); \
274 }
275 
276 #define MPI_Send( buf, count,  datatype, dest, tag, comm) \
277 { \
278   MPI_Send( buf, count,  datatype, dest, tag, comm); \
279   send_ct++;  TypeSize(send_len,count,datatype); \
280 }
281 
282 #define MPI_Wait(request, status) \
283 ( \
284   wait_ct++, sum_of_waits_ct++,\
285   MPI_Wait(request, status)  \
286 )
287 
288 #define MPI_Waitany(a, b, c, d) \
289 ( \
290   wait_any_ct++, sum_of_waits_ct++,  \
291   MPI_Waitany(a, b, c, d)\
292 )
293 
294 #define MPI_Waitall(count, array_of_requests, array_of_statuses) \
295 ( \
296   wait_all_ct++, sum_of_waits_ct += (double) (count),\
297   MPI_Waitall(count, array_of_requests, array_of_statuses) \
298 )
299 
300 #define MPI_Allreduce( sendbuf,  recvbuf, count, datatype, op, comm) \
301 ( \
302   allreduce_ct++, \
303   MPI_Allreduce( sendbuf,  recvbuf, count, datatype, op, comm) \
304 )
305 #else
306 
307 #define MPI_Startall_irecv( count,number,requests) \
308 { \
309   MPI_Startall( number, requests);\
310 }
311 
312 #define MPI_Startall_isend( count,number,requests) \
313 { \
314   MPI_Startall( number, requests);\
315 }
316 
317 #define MPI_Start_isend(count,  requests) \
318 { \
319   MPI_Start( requests);\
320 }
321 
322 #endif /* ! PETSC_USING_MPIUNI && ! PARCH_hpux */
323 
324 #else  /* ------------------------------------------------------------*/
325 
326 #define PLogFlops(n)
327 
328 #if defined (HAVE_MPE)
329 #define MPEBEGIN    1000
330 extern int PLogMPEBegin();
331 extern int PLogMPEDump(char *);
332 #else
333 #define PLogEventMPEActivate(a) 0
334 #define PLogEventMPEDeactivate(a) 0
335 #endif
336 
337 #define PLogEventActivate(a) 0
338 #define PLogEventDeactivate(a) 0
339 
340 #define PLogEventActivateClass(a) 0
341 #define PLogEventDeactivateClass(a) 0
342 
343 #define _PLogPLB                        0
344 #define _PLogPLE                        0
345 #define _PLogPHC                        0
346 #define _PLogPHD                        0
347 #define PetscGetFlops                 0.0
348 #define PLogEventBegin(e,o1,o2,o3,o4)
349 #define PLogEventEnd(e,o1,o2,o3,o4)
350 #define PLogObjectParent(p,c)
351 #define PLogObjectParents(p,n,c)
352 #define PLogObjectCreate(h)
353 #define PLogObjectDestroy(h)
354 #define PLogObjectMemory(p,m)
355 #define PLogDestroy()
356 #define PLogStagePush(a)
357 #define PLogStagePop()
358 #define PLogStageRegister(a,b)
359 #define PLogPrintSummary(comm,file)
360 #define PLogBegin()
361 #define PLogTraceBegin(file)
362 #define PLogSet(lb,le)
363 #define PLogAllBegin()
364 #define PLogDump(char)
365 #define PLogEventRegister(a,b,c) 0
366 #define PLogMPEBegin()
367 #define PLogMPEDump(a)
368 extern int PLogObjectState(PetscObject,char *,...);
369 
370 /* If PETSC_LOG is NOT defined, these still need to be! */
371 #define MPI_Startall_irecv( count,number,requests) \
372 { \
373   MPI_Startall( number, requests);\
374 }
375 
376 #define MPI_Startall_isend( count,number,requests) \
377 { \
378   MPI_Startall( number, requests);\
379 }
380 
381 #define MPI_Start_isend(count,  requests) \
382 { \
383   MPI_Start( requests);\
384 }
385 #endif   /* PETSC_LOG */
386 
387 /*MC
388    PLogFlops - Adds floating point operations to the global counter.
389 
390    Input Parameter:
391 .  f - flop counter
392 
393    Synopsis:
394    void PLogFlops(int f)
395 
396    Notes:
397    A global counter logs all PETSc flop counts.  The user can use
398    PLogFlops() to increment this counter to include flops for the
399    application code.
400 
401    PETSc automatically logs library events if the code has been
402    compiled with -DPETSC_LOG (which is the default), and -log,
403    -log_summary, or -log_all are specified.  PLogFlops() is
404    intended for logging user flops to supplement this PETSc
405    information.
406 
407     Example of Usage:
408 $     int USER_EVENT;
409 $     PLogEventRegister(&USER_EVENT,"User event","Color:");
410 $     PLogEventBegin(USER_EVENT,0,0,0,0);
411 $        [code segment to monitor]
412 $        PLogFlops(user_flops)
413 $     PLogEventEnd(USER_EVENT,0,0,0,0);
414 
415 .seealso: PLogEventRegister(), PLogEventBegin(), PLogEventEnd(), PetscGetFlops()
416 
417 .keywords: log, flops, floating point operations
418 M*/
419 
420 
421 /*MC
422    PLogEventBegin - Logs the beginning of a user event.
423 
424    Input Parameters:
425 .  e - integer associated with the event obtained from PLogEventRegister()
426 .  o1,o2,o3,o4 - objects associated with the event, or 0
427 
428    Synopsis:
429    void PLogEventBegin(int e,PetscObject o1,PetscObject o2,PetscObject o3,
430                   PetscObject o4)
431 
432    Notes:
433    You should also register each integer event with the command
434    PLogRegisterEvent().  The source code must be compiled with
435    -DPETSC_LOG, which is the default.
436 
437    PETSc automatically logs library events if the code has been
438    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
439    specified.  PLogEventBegin() is intended for logging user events
440    to supplement this PETSc information.
441 
442     Example of Usage:
443 $     int USER_EVENT;
444 $     int user_event_flops;
445 $     PLogEventRegister(&USER_EVENT,"User event","Color:");
446 $     PLogEventBegin(&USER_EVENT,0,0,0,0);
447 $        [code segment to monitor]
448 $        PLogFlops(user_event_flops);
449 $     PLogEventEnd(&USER_EVENT,0,0,0,0);
450 
451 .seealso: PLogEventRegister(), PLogEventEnd(), PLogFlops()
452 
453 .keywords: log, event, begin
454 M*/
455 
456 /*MC
457    PLogEventEnd - Log the end of a user event.
458 
459    Input Parameters:
460 .  e - integer associated with the event obtained with PLogEventRegister()
461 .  o1,o2,o3,o4 - objects associated with the event, or 0
462 
463    Synopsis:
464    void PLogEventEnd(int e,PetscObject o1,PetscObject o2,PetscObject o3,
465                 PetscObject o4)
466 
467    Notes:
468    You should also register each integer event with the command
469    PLogRegisterEvent(). Source code must be compiled with
470    -DPETSC_LOG, which is the default.
471 
472    PETSc automatically logs library events if the code has been
473    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
474    specified.  PLogEventEnd() is intended for logging user events
475    to supplement this PETSc information.
476 
477     Example of Usage:
478 $     int USER_EVENT;
479 $     int user_event_flops;
480 $     PLogEventRegister(&USER_EVENT,"User event","Color:");
481 $     PLogEventBegin(USER_EVENT,0,0,0,0);
482 $        [code segment to monitor]
483 $        PLogFlops(user_event_flops);
484 $     PLogEventEnd(USER_EVENT,0,0,0,0);
485 
486 .seealso: PLogEventRegister(), PLogEventBegin(), PLogFlops()
487 
488 .keywords: log, event, end
489 M*/
490 
491 
492 #endif
493 
494 
495 
496