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