xref: /petsc/include/petsclog.h (revision c912cb8372f694ea9f4f9c5ac2b710bfac8f04da)
1 /* $Id: plog.h,v 1.56 1996/02/26 23:14:07 balay 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 to petsc/bin/petscview.cfg,
13   petsc/bin/petscview, petsc/src/sys/src/plog.c, and
14   petsc/src/sys/src/plogmpe.c!!!
15 */
16 #define MAT_Mult                                0
17 #define MAT_MatrixFreeMult                      1
18 #define MAT_AssemblyBegin                       2
19 #define MAT_AssemblyEnd                         3
20 #define MAT_GetReordering                       4
21 #define MAT_MultTrans                           5
22 #define MAT_MultAdd                             6
23 #define MAT_MultTransAdd                        7
24 #define MAT_LUFactor                            8
25 #define MAT_CholeskyFactor                      9
26 #define MAT_LUFactorSymbolic                    10
27 #define MAT_ILUFactorSymbolic                   11
28 #define MAT_CholeskyFactorSymbolic              12
29 #define MAT_IncompleteCholeskyFactorSymbolic    13
30 #define MAT_LUFactorNumeric                     14
31 #define MAT_CholeskyFactorNumeric               15
32 #define MAT_Relax                               16
33 #define MAT_Copy                                17
34 #define MAT_Convert                             18
35 #define MAT_Scale                               19
36 #define MAT_ZeroEntries                         20
37 #define MAT_Solve                               21
38 #define MAT_SolveAdd                            22
39 #define MAT_SolveTrans                          23
40 #define MAT_SolveTransAdd                       24
41 #define MAT_SetValues                           25
42 #define MAT_ForwardSolve                        26
43 #define MAT_BackwardSolve                       27
44 #define MAT_Load                                28
45 #define MAT_View                                29
46 #define MAT_ILUFactor                           30
47 #define MAT_GetSubMatrix                        31
48 #define MAT_GetSubMatrices                      32
49 #define MAT_GetValues                           33
50 #define MAT_IncreaseOverlap                     34
51 #define MAT_GetRow                              35
52 
53 #define VEC_Dot                                 40
54 #define VEC_Norm                                41
55 #define VEC_Max                                 42
56 #define VEC_Min                                 43
57 #define VEC_TDot                                44
58 #define VEC_Scale                               45
59 #define VEC_Copy                                46
60 #define VEC_Set                                 47
61 #define VEC_AXPY                                48
62 #define VEC_AYPX                                49
63 #define VEC_Swap                                50
64 #define VEC_WAXPY                               51
65 #define VEC_AssemblyBegin                       52
66 #define VEC_AssemblyEnd                         53
67 #define VEC_MTDot                               54
68 #define VEC_MDot                                55
69 #define VEC_MAXPY                               56
70 #define VEC_PMult                               57
71 #define VEC_SetValues                           58
72 #define VEC_Load                                59
73 #define VEC_View                                60
74 #define VEC_ScatterBegin                        61
75 #define VEC_ScatterEnd                          62
76 #define VEC_SetRandom                           63
77 
78 #define SLES_Solve                              70
79 #define SLES_SetUp                              71
80 
81 #define KSP_GMRESOrthogonalization              72
82 
83 #define PC_SetUp                                75
84 #define PC_SetUpOnBlocks                        76
85 #define PC_Apply                                77
86 #define PC_ApplySymmLeft                        78
87 #define PC_ApplySymmRight                       79
88 
89 #define SNES_Solve                              80
90 #define SNES_LineSearch                         81
91 #define SNES_FunctionEval                       82
92 #define SNES_JacobianEval                       83
93 #define SNES_MinimizationFunctionEval           84
94 #define SNES_GradientEval                       85
95 #define SNES_HessianEval                        86
96 
97 #define TS_Step                                 90
98 /*
99    Event numbers PLOG_USER_EVENT_LOW to PLOG_USER_EVENT_HIGH are reserved
100    for applications.  Make sure that src/sys/src/plog.c defines enough
101    entries in (*name)[] to go up to PLOG_USER_EVENT_HIGH.
102 */
103 #define PLOG_USER_EVENT_LOW_STATIC              120
104 #define PLOG_USER_EVENT_HIGH                    200
105 
106 /* Global flop counter */
107 extern double _TotalFlops;
108 #if defined(PETSC_LOG)
109 #define PLogFlops(n) {_TotalFlops += n;}
110 #else
111 #define PLogFlops(n)
112 #endif
113 
114 
115 /*M
116    PLogFlops - Adds floating point operations to the global counter.
117                You must include "plog.h" to use this function.
118 
119    Input Parameter:
120 .  f - flop counter
121 
122    Synopsis:
123    PLogFlops(int f)
124 
125    Notes:
126    A global counter logs all PETSc flop counts.  The user can use
127    PLogFlops() to increment this counter to include flops for the
128    application code.
129 
130    PETSc automatically logs library events if the code has been
131    compiled with -DPETSC_LOG (which is the default), and -log,
132    -log_summary, or -log_all are specified.  PLogFlops() is
133    intended for logging user flops to supplement this PETSc
134    information.
135 
136     Example of Usage:
137 $     int USER_EVENT;
138 $     PLogEventRegister(&USER_EVENT,"User event");
139 $     PLogEventBegin(USER_EVENT,0,0,0,0);
140 $     [code segment to monitor]
141 $     PLogFlops(user_flops)
142 $     PLogEventEnd(USER_EVENT,0,0,0,0);
143 
144 .seealso:  PLogEventRegister(), PLogEventBegin(), PLogEventEnd()
145 
146 .keywords:  Petsc, log, flops, floating point operations
147 M*/
148 
149 extern int PLogPrintSummary(MPI_Comm,FILE *);
150 extern int PLogBegin();
151 extern int PLogAllBegin();
152 extern int PLogDump(char*);
153 
154 #if defined (HAVE_MPE)
155 #include "mpe.h"
156 extern int PLogMPEBegin();
157 extern int PLogMPEDump(char *);
158 extern int UseMPE,MPEFlags[];
159 #define MPEBEGIN    1000
160 #endif
161 
162 #if defined(PETSC_LOG)
163 
164 extern int (*_PLB)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
165 extern int (*_PLE)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
166 extern int (*_PHC)(PetscObject);
167 extern int (*_PHD)(PetscObject);
168 extern int PLogEventRegister(int*,char*);
169 
170 /*M
171    PLogEventBegin - Logs the beginning of a user event.
172 
173    Input Parameters:
174 .  e - integer associated with the event obtained from PLogEventRegister()
175 .  o1,o2,o3,o4 - objects associated with the event, or 0
176 
177    Synopsis:
178    PLogEventBegin(int e,PetscObject o1,PetscObject o2,PetscObject o3,
179                   PetscObject o4)
180 
181    Notes:
182    You should also register each integer event with the command
183    PLogRegisterEvent().  The source code must be compiled with
184    -DPETSC_LOG, which is the default.
185 
186    PETSc automatically logs library events if the code has been
187    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
188    specified.  PLogEventBegin() is intended for logging user events
189    to supplement this PETSc information.
190 
191     Example of Usage:
192 $     int USER_EVENT;
193 $     int user_event_flops;
194 $     PLogEventRegister(&USER_EVENT,"User event");
195 $     PLogEventBegin(&USER_EVENT,0,0,0,0);
196 $        [code segment to monitor]
197 $        PLogFlops(user_event_flops);
198 $     PLogEventEnd(&USER_EVENT,0,0,0,0);
199 
200 .seealso: PLogEventRegister(), PLogEventEnd(), PLogFlops()
201 
202 .keywords: log, event, begin
203 M*/
204 #if defined(HAVE_MPE)
205 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0; \
206   { _tacky++; \
207    if (_PLB) \
208      (*_PLB)(e,_tacky,(PetscObject)o1,(PetscObject)o2,(PetscObject)o3,(PetscObject)o4);\
209    if (_tacky == 1 && UseMPE && MPEFlags[e])\
210      MPE_Log_event(MPEBEGIN+2*e,0,"");\
211   }
212 #else
213 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0; \
214   { _tacky++; \
215    if (_PLB) \
216      (*_PLB)(e,_tacky,(PetscObject)o1,(PetscObject)o2,(PetscObject)o3,(PetscObject)o4);\
217   }
218 #endif
219 
220 /*M
221    PLogEventEnd - Log the end of a user event.
222 
223    Input Parameters:
224 .  e - integer associated with the event obtained with PLogEventRegister()
225 .  o1,o2,o3,o4 - objects associated with the event, or 0
226 
227    Synopsis:
228    PLogEventEnd(int e,PetscObject o1,PetscObject o2,PetscObject o3,
229                 PetscObject o4)
230 
231    Notes:
232    You should also register each integer event with the command
233    PLogRegisterEvent(). Source code must be compiled with
234    -DPETSC_LOG, which is the default.
235 
236    PETSc automatically logs library events if the code has been
237    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
238    specified.  PLogEventEnd() is intended for logging user events
239    to supplement this PETSc information.
240 
241     Example of Usage:
242 $     int USER_EVENT;
243 $     int user_event_flops;
244 $     PLogEventRegister(&USER_EVENT,"User event");
245 $     PLogEventBegin(USER_EVENT,0,0,0,0);
246 $        [code segment to monitor]
247 $        PLogFlops(user_event_flops);
248 $     PLogEventEnd(USER_EVENT,0,0,0,0);
249 
250 .seealso: PLogEventRegister(), PLogEventBegin(), PLogFlops()
251 
252 .keywords: log, event, end
253 M*/
254 #if defined(HAVE_MPE)
255 #define PLogEventEnd(e,o1,o2,o3,o4) {\
256   if (_PLE) \
257     (*_PLE)(e,_tacky,(PetscObject)o1,(PetscObject)o2,(PetscObject)o3,(PetscObject)o4);\
258   if (_tacky == 1 && UseMPE && MPEFlags[e])\
259      MPE_Log_event(MPEBEGIN+2*e+1,0,"");\
260   }  _tacky--;}
261 #else
262 #define PLogEventEnd(e,o1,o2,o3,o4) {\
263   if (_PLE) \
264     (*_PLE)(e,_tacky,(PetscObject)o1,(PetscObject)o2,(PetscObject)o3,(PetscObject)o4);\
265   } _tacky--;}
266 #endif
267 
268 
269 #define PLogObjectParent(p,c)       {PETSCVALIDHEADER((PetscObject)c); \
270                                      PETSCVALIDHEADER((PetscObject)p);\
271                                      ((PetscObject)(c))->parent = (PetscObject) p;}
272 #define PLogObjectParents(p,n,d)    {int _i; for ( _i=0; _i<n; _i++ ) \
273                                     PLogObjectParent(p,(d)[_i]);}
274 #define PLogObjectCreate(h)         {if (_PHC) (*_PHC)((PetscObject)h);}
275 #define PLogObjectDestroy(h)        {if (_PHD) (*_PHD)((PetscObject)h);}
276 #define PLogObjectMemory(p,m)       {PETSCVALIDHEADER((PetscObject)p);\
277                                     ((PetscObject)(p))->mem += (m);}
278 extern int PLogObjectState(PetscObject,char *,...);
279 extern int PLogInfo(PetscObject,char*,...);
280 extern int PLogDestroy();
281 extern int PLogStagePush(int);
282 extern int PLogStagePop();
283 extern int PLogStageRegister(int,char*);
284 
285 #else
286 
287 #define PLogObjectCreate(h)
288 #define PLogObjectDestroy(h)
289 #define PLogObjectMemory(p,m)
290 #define PLogEventBegin(e,o1,o2,o3,o4)
291 #define PLogEventEnd(e,o1,o2,o3,o4)
292 #define PLogObjectParent(p,c)
293 #define PLogObjectParents(p,n,c)
294 extern int PLogInfo(PetscObject,char*,...);
295 extern int PLogDestroy();
296 extern int PLogStagePush(int);
297 extern int PLogStagePop();
298 extern int PLogStageRegister(int,char*);
299 #endif
300 
301 #endif
302 
303