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