xref: /petsc/include/petsclog.h (revision c16cb8f2de640b3af1673495cb6d811eff24116a)
1 /* $Id: plog.h,v 1.77 1996/07/28 16:07:13 bsmith Exp bsmith $ */
2 
3 /*
4     Defines high level logging in PETSc.
5 */
6 
7 #if !defined(__PLOG_PACKAGE)
8 #define __PLOG_PACKAGE
9 #include "petsc.h"
10 
11 /*
12   If you add an event here, make sure you add it to
13   petsc/bin/petscview.cfg,
14   petsc/bin/petscview,
15   petsc/src/plog/src/plog.c,
16   petsc/src/plog/src/plogmpe.c and
17   petsc/include/FINCLUDE/plog.h!!!
18 */
19 #define MAT_Mult                                0
20 #define MAT_MatrixFreeMult                      1
21 #define MAT_AssemblyBegin                       2
22 #define MAT_AssemblyEnd                         3
23 #define MAT_GetReordering                       4
24 #define MAT_MultTrans                           5
25 #define MAT_MultAdd                             6
26 #define MAT_MultTransAdd                        7
27 #define MAT_LUFactor                            8
28 #define MAT_CholeskyFactor                      9
29 #define MAT_LUFactorSymbolic                    10
30 #define MAT_ILUFactorSymbolic                   11
31 #define MAT_CholeskyFactorSymbolic              12
32 #define MAT_IncompleteCholeskyFactorSymbolic    13
33 #define MAT_LUFactorNumeric                     14
34 #define MAT_CholeskyFactorNumeric               15
35 #define MAT_Relax                               16
36 #define MAT_Copy                                17
37 #define MAT_Convert                             18
38 #define MAT_Scale                               19
39 #define MAT_ZeroEntries                         20
40 #define MAT_Solve                               21
41 #define MAT_SolveAdd                            22
42 #define MAT_SolveTrans                          23
43 #define MAT_SolveTransAdd                       24
44 #define MAT_SetValues                           25
45 #define MAT_ForwardSolve                        26
46 #define MAT_BackwardSolve                       27
47 #define MAT_Load                                28
48 #define MAT_View                                29
49 #define MAT_ILUFactor                           30
50 #define MAT_GetSubMatrix                        31
51 #define MAT_GetSubMatrices                      32
52 #define MAT_GetValues                           33
53 #define MAT_IncreaseOverlap                     34
54 #define MAT_GetRow                              35
55 
56 #define VEC_Dot                                 40
57 #define VEC_Norm                                41
58 #define VEC_Max                                 42
59 #define VEC_Min                                 43
60 #define VEC_TDot                                44
61 #define VEC_Scale                               45
62 #define VEC_Copy                                46
63 #define VEC_Set                                 47
64 #define VEC_AXPY                                48
65 #define VEC_AYPX                                49
66 #define VEC_Swap                                50
67 #define VEC_WAXPY                               51
68 #define VEC_AssemblyBegin                       52
69 #define VEC_AssemblyEnd                         53
70 #define VEC_MTDot                               54
71 #define VEC_MDot                                55
72 #define VEC_MAXPY                               56
73 #define VEC_PMult                               57
74 #define VEC_SetValues                           58
75 #define VEC_Load                                59
76 #define VEC_View                                60
77 #define VEC_ScatterBegin                        61
78 #define VEC_ScatterEnd                          62
79 #define VEC_SetRandom                           63
80 
81 #define SLES_Solve                              70
82 #define SLES_SetUp                              71
83 
84 #define KSP_GMRESOrthogonalization              72
85 
86 #define PC_SetUp                                75
87 #define PC_SetUpOnBlocks                        76
88 #define PC_Apply                                77
89 #define PC_ApplySymmetricLeft                   78
90 #define PC_ApplySymmetricRight                  79
91 
92 #define SNES_Solve                              80
93 #define SNES_LineSearch                         81
94 #define SNES_FunctionEval                       82
95 #define SNES_JacobianEval                       83
96 #define SNES_MinimizationFunctionEval           84
97 #define SNES_GradientEval                       85
98 #define SNES_HessianEval                        86
99 
100 #define TS_Step                                 90
101 
102 #define Petsc_Barrier                           100
103 
104 #define DFVec_RefineVector                      110
105 #define DFVec_AssembleFullVector                111
106 #define DFVec_GetComponentVectors               112
107 #define DFVec_DrawContours                      113
108 
109 /*
110    Event numbers PLOG_USER_EVENT_LOW to PLOG_USER_EVENT_HIGH are reserved
111    for applications.  Make sure that src/plog/src/plog.c defines enough
112    entries in (*name)[] to go up to PLOG_USER_EVENT_HIGH.
113 */
114 #define PLOG_USER_EVENT_LOW_STATIC              120
115 #define PLOG_USER_EVENT_HIGH                    200
116 
117 /* Global flop counter */
118 extern double _TotalFlops;
119 
120 /* General logging of information; different from event logging */
121 extern int PLogInfo(void*,char*,...);
122 extern int PLogInfoDeactivateClass(int);
123 extern int PLogInfoActivateClass(int);
124 
125 #if defined(PETSC_LOG)  /* --------------------------------------------*/
126 
127 #define PLogFlops(n) {_TotalFlops += (n);}
128 
129 #if defined (HAVE_MPE)
130 #include "mpe.h"
131 #define MPEBEGIN    1000
132 extern int PLogMPEBegin();
133 extern int PLogMPEDump(char *);
134 extern int UseMPE,PLogEventMPEFlags[];
135 extern int PLogEventMPEActivate(int);
136 extern int PLogEventMPEDeActivate(int);
137 #else
138 #define PLogEventMPEActivate(a)
139 #define PLogEventMPEDeActivate(a)
140 #endif
141 
142 extern int PLogEventActivate(int);
143 extern int PLogEventDeActivate(int);
144 
145 extern int PLogEventActivateClass();
146 extern int PLogEventDeActivateClass();
147 
148 extern int PLogEventFlags[];
149 extern int (*_PLB)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
150 extern int (*_PLE)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
151 extern int (*_PHC)(PetscObject);
152 extern int (*_PHD)(PetscObject);
153 
154 #if defined(HAVE_MPE)
155 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0; \
156   { _tacky++; \
157    if (_PLB && PLogEventFlags[e]) \
158      (*_PLB)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
159    if (_tacky == 1 && UseMPE && PLogEventMPEFlags[e])\
160      MPE_Log_event(MPEBEGIN+2*e,0,"");\
161   }
162 #else
163 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0; \
164   { _tacky++; \
165    if (_PLB && PLogEventFlags[e]) \
166      (*_PLB)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
167   }
168 #endif
169 
170 #if defined(HAVE_MPE)
171 #define PLogEventEnd(e,o1,o2,o3,o4) {\
172   if (_PLE && PLogEventFlags[e]) \
173     (*_PLE)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
174   if (_tacky == 1 && UseMPE && PLogEventMPEFlags[e])\
175      MPE_Log_event(MPEBEGIN+2*e+1,0,"");\
176   }  _tacky--;}
177 #else
178 #define PLogEventEnd(e,o1,o2,o3,o4) {\
179   if (_PLE && PLogEventFlags[e]) \
180     (*_PLE)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
181   } _tacky--;}
182 #endif
183 
184 
185 #define PLogObjectParent(p,c)       {PetscValidHeader((PetscObject)c); \
186                                      PetscValidHeader((PetscObject)p);\
187                                      ((PetscObject)(c))->parent = (PetscObject) p;}
188 #define PLogObjectParents(p,n,d)    {int _i; for ( _i=0; _i<n; _i++ ) \
189                                     PLogObjectParent(p,(d)[_i]);}
190 #define PLogObjectCreate(h)         {if (_PHC) (*_PHC)((PetscObject)h);}
191 #define PLogObjectDestroy(h)        {if (_PHD) (*_PHD)((PetscObject)h);}
192 #define PLogObjectMemory(p,m)       {PetscValidHeader((PetscObject)p);\
193                                     ((PetscObject)(p))->mem += (m);}
194 extern int PLogObjectState(PetscObject,char *,...);
195 extern int PLogDestroy();
196 extern int PLogStagePush(int);
197 extern int PLogStagePop();
198 extern int PLogStageRegister(int,char*);
199 extern int PLogPrintSummary(MPI_Comm,FILE *);
200 extern int PLogBegin();
201 extern int PLogAllBegin();
202 extern int PLogDump(char*);
203 extern int PLogEventRegister(int*,char*,char*);
204 extern double PetscGetFlops();
205 
206 /*
207      This does not use for MPI-Uni because our src/mpiuni/mpi.h file
208    uses macros to defined the MPI operations.
209 */
210 #if !defined(PETSC_USING_MPIUNI) && !defined(PARCH_hpux)
211 /*
212    Logging of MPI activities
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 #define TypeSize(buff,count,type) \
219 { \
220   if (type == MPIU_SCALAR) { \
221     buff += (double) ((count)*sizeof(Scalar)); \
222   } else if (type == MPI_INT) { \
223     buff += (double) ((count)*sizeof(int));  \
224   } else { \
225     int _size; MPI_Type_size(type,&_size); buff += (double) ((count)*_size); \
226   } \
227 }
228 
229 #if defined(PARCH_hpux)
230 /*
231     This is a tacky fix. The CPP on HP-UX scans the macros twice
232   thus it double counted the send/receive operations.
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 += .5; TypeSize(irecv_len,.5*count,datatype); \
238 }
239 #define MPI_Isend( buf, count,  datatype, dest, tag, comm, request) \
240 { \
241   MPI_Isend( buf, count,  datatype, dest, tag, comm, request); \
242   isend_ct += .5;   TypeSize(isend_len,.5*count,datatype); \
243 }
244 #define MPI_Recv( buf, count,  datatype, source, tag, comm, status) \
245 { \
246   MPI_Recv( buf, count,  datatype, source, tag, comm, status); \
247   recv_ct += .5; TypeSize(recv_len,.5*count,datatype); \
248 }
249 #define MPI_Send( buf, count,  datatype, dest, tag, comm) \
250 { \
251   MPI_Send( buf, count,  datatype, dest, tag, comm); \
252   send_ct += .5;  TypeSize(send_len,.5*count,datatype); \
253 }
254 #else
255 #define MPI_Irecv( buf, count,  datatype, source, tag, comm, request) \
256 { \
257   MPI_Irecv( buf, count,  datatype, source, tag, comm, request);\
258   irecv_ct++; TypeSize(irecv_len,count,datatype); \
259 }
260 #define MPI_Isend( buf, count,  datatype, dest, tag, comm, request) \
261 { \
262   MPI_Isend( buf, count,  datatype, dest, tag, comm, request); \
263   isend_ct++;   TypeSize(isend_len,count,datatype); \
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 #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 #endif
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 #endif /* ! PETSC_USING_MPIUNI */
301 
302 #else  /* ------------------------------------------------------------*/
303 
304 #define PLogFlops(n)
305 
306 #if defined (HAVE_MPE)
307 #define MPEBEGIN    1000
308 extern int PLogMPEBegin();
309 extern int PLogMPEDump(char *);
310 #else
311 #define PLogEventMPEActivate(a)
312 #define PLogEventMPEDeActivate(a)
313 #endif
314 
315 #define PLogEventActivate(a)
316 #define PLogEventDeActivate(a)
317 
318 #define PLogEventActivateClass()
319 #define PLogEventDeActivateClass()
320 
321 #define _PLB                          0
322 #define _PLE                          0
323 #define _PHC                          0
324 #define _PHD                          0
325 #define PetscGetFlops                 0.0
326 #define PLogEventBegin(e,o1,o2,o3,o4)
327 #define PLogEventEnd(e,o1,o2,o3,o4)
328 #define PLogObjectParent(p,c)
329 #define PLogObjectParents(p,n,c)
330 #define PLogObjectCreate(h)
331 #define PLogObjectDestroy(h)
332 #define PLogObjectMemory(p,m)
333 #define PLogDestroy()
334 #define PLogStagePush(int)
335 #define PLogStagePop()
336 #define PLogStageRegister(a,b)
337 #define PLogPrintSummary(comm,file)
338 #define PLogBegin()
339 #define PLogAllBegin()
340 #define PLogDump(char)
341 #define PLogEventRegister(a,b,c)
342 #define PLogMPEBegin()
343 #define PLogMPEDump(a)
344 extern int PLogObjectState(PetscObject,char *,...);
345 #endif
346 
347 /*MC
348    PLogFlops - Adds floating point operations to the global counter.
349 
350    Input Parameter:
351 .  f - flop counter
352 
353    Synopsis:
354    void PLogFlops(int f)
355 
356    Notes:
357    A global counter logs all PETSc flop counts.  The user can use
358    PLogFlops() to increment this counter to include flops for the
359    application code.
360 
361    PETSc automatically logs library events if the code has been
362    compiled with -DPETSC_LOG (which is the default), and -log,
363    -log_summary, or -log_all are specified.  PLogFlops() is
364    intended for logging user flops to supplement this PETSc
365    information.
366 
367     Example of Usage:
368 $     int USER_EVENT;
369 $     PLogEventRegister(&USER_EVENT,"User event","Color:");
370 $     PLogEventBegin(USER_EVENT,0,0,0,0);
371 $        [code segment to monitor]
372 $        PLogFlops(user_flops)
373 $     PLogEventEnd(USER_EVENT,0,0,0,0);
374 
375 .seealso: PLogEventRegister(), PLogEventBegin(), PLogEventEnd(), PetscGetFlops()
376 
377 .keywords: log, flops, floating point operations
378 M*/
379 
380 
381 /*MC
382    PLogEventBegin - Logs the beginning of a user event.
383 
384    Input Parameters:
385 .  e - integer associated with the event obtained from PLogEventRegister()
386 .  o1,o2,o3,o4 - objects associated with the event, or 0
387 
388    Synopsis:
389    void PLogEventBegin(int e,PetscObject o1,PetscObject o2,PetscObject o3,
390                   PetscObject o4)
391 
392    Notes:
393    You should also register each integer event with the command
394    PLogRegisterEvent().  The source code must be compiled with
395    -DPETSC_LOG, which is the default.
396 
397    PETSc automatically logs library events if the code has been
398    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
399    specified.  PLogEventBegin() is intended for logging user events
400    to supplement this PETSc information.
401 
402     Example of Usage:
403 $     int USER_EVENT;
404 $     int user_event_flops;
405 $     PLogEventRegister(&USER_EVENT,"User event","Color:");
406 $     PLogEventBegin(&USER_EVENT,0,0,0,0);
407 $        [code segment to monitor]
408 $        PLogFlops(user_event_flops);
409 $     PLogEventEnd(&USER_EVENT,0,0,0,0);
410 
411 .seealso: PLogEventRegister(), PLogEventEnd(), PLogFlops()
412 
413 .keywords: log, event, begin
414 M*/
415 
416 /*MC
417    PLogEventEnd - Log the end of a user event.
418 
419    Input Parameters:
420 .  e - integer associated with the event obtained with PLogEventRegister()
421 .  o1,o2,o3,o4 - objects associated with the event, or 0
422 
423    Synopsis:
424    void PLogEventEnd(int e,PetscObject o1,PetscObject o2,PetscObject o3,
425                 PetscObject o4)
426 
427    Notes:
428    You should also register each integer event with the command
429    PLogRegisterEvent(). Source code must be compiled with
430    -DPETSC_LOG, which is the default.
431 
432    PETSc automatically logs library events if the code has been
433    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
434    specified.  PLogEventEnd() is intended for logging user events
435    to supplement this PETSc information.
436 
437     Example of Usage:
438 $     int USER_EVENT;
439 $     int user_event_flops;
440 $     PLogEventRegister(&USER_EVENT,"User event","Color:");
441 $     PLogEventBegin(USER_EVENT,0,0,0,0);
442 $        [code segment to monitor]
443 $        PLogFlops(user_event_flops);
444 $     PLogEventEnd(USER_EVENT,0,0,0,0);
445 
446 .seealso: PLogEventRegister(), PLogEventBegin(), PLogFlops()
447 
448 .keywords: log, event, end
449 M*/
450 
451 
452 #endif
453 
454 
455 
456