xref: /petsc/include/petsclog.h (revision a2e5294746d31761ff9b1d6bc8f2ca5b61f69c89)
1 /* $Id: plog.h,v 1.52 1996/02/26 21:32:43 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 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 #define KSP_Solve                               73
83 
84 #define PC_SetUp                                75
85 #define PC_Apply                                76
86 #define PC_ApplySymmLeft                        77
87 #define PC_ApplySymmRight                       78
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 extern int PLogMPEBegin();
156 extern int PLogMPEDestroy();
157 extern int UseMPE,MPEFlags[];
158 #define MPEBEGIN    1000
159 #endif
160 
161 #if defined(PETSC_LOG)
162 
163 extern int (*_PLB)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
164 extern int (*_PLE)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
165 extern int (*_PHC)(PetscObject);
166 extern int (*_PHD)(PetscObject);
167 extern int PLogEventRegister(int*,char*);
168 
169 /*M
170    PLogEventBegin - Logs the beginning of a user event.
171 
172    Input Parameters:
173 .  e - integer associated with the event obtained from PLogEventRegister()
174 .  o1,o2,o3,o4 - objects associated with the event, or 0
175 
176    Synopsis:
177    PLogEventBegin(int e,PetscObject o1,PetscObject o2,PetscObject o3,
178                   PetscObject o4)
179 
180    Notes:
181    You should also register each integer event with the command
182    PLogRegisterEvent().  The source code must be compiled with
183    -DPETSC_LOG, which is the default.
184 
185    PETSc automatically logs library events if the code has been
186    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
187    specified.  PLogEventBegin() is intended for logging user events
188    to supplement this PETSc information.
189 
190     Example of Usage:
191 $     int USER_EVENT;
192 $     int user_event_flops;
193 $     PLogEventRegister(&USER_EVENT,"User event");
194 $     PLogEventBegin(&USER_EVENT,0,0,0,0);
195 $        [code segment to monitor]
196 $        PLogFlops(user_event_flops);
197 $     PLogEventEnd(&USER_EVENT,0,0,0,0);
198 
199 .seealso: PLogEventRegister(), PLogEventEnd(), PLogFlops()
200 
201 .keywords: log, event, begin
202 M*/
203 #if defined(HAVE_MPE)
204 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0; \
205   { _tacky++; \
206    if (_PLB) \
207      (*_PLB)(e,_tacky,(PetscObject)o1,(PetscObject)o2,(PetscObject)o3,(PetscObject)o4);\
208    if (_tacky == 1 && UseMPE && MPEFlags[e])\
209      MPE_Log_event(MPEBEGIN+2*e,0,"");\
210   }
211 #else
212 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0; \
213   { _tacky++; \
214    if (_PLB) \
215      (*_PLB)(e,_tacky,(PetscObject)o1,(PetscObject)o2,(PetscObject)o3,(PetscObject)o4);\
216   }
217 #endif
218 
219 /*M
220    PLogEventEnd - Log the end of a user event.
221 
222    Input Parameters:
223 .  e - integer associated with the event obtained with PLogEventRegister()
224 .  o1,o2,o3,o4 - objects associated with the event, or 0
225 
226    Synopsis:
227    PLogEventEnd(int e,PetscObject o1,PetscObject o2,PetscObject o3,
228                 PetscObject o4)
229 
230    Notes:
231    You should also register each integer event with the command
232    PLogRegisterEvent(). Source code must be compiled with
233    -DPETSC_LOG, which is the default.
234 
235    PETSc automatically logs library events if the code has been
236    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
237    specified.  PLogEventEnd() is intended for logging user events
238    to supplement this PETSc information.
239 
240     Example of Usage:
241 $     int USER_EVENT;
242 $     int user_event_flops;
243 $     PLogEventRegister(&USER_EVENT,"User event");
244 $     PLogEventBegin(USER_EVENT,0,0,0,0);
245 $        [code segment to monitor]
246 $        PLogFlops(user_event_flops);
247 $     PLogEventEnd(USER_EVENT,0,0,0,0);
248 
249 .seealso: PLogEventRegister(), PLogEventBegin(), PLogFlops()
250 
251 .keywords: log, event, end
252 M*/
253 #if defined(HAVE_MPE)
254 #define PLogEventEnd(e,o1,o2,o3,o4) {\
255   if (_PLE) \
256     (*_PLE)(e,_tacky,(PetscObject)o1,(PetscObject)o2,(PetscObject)o3,(PetscObject)o4);\
257   if (_tacky == 1 && UseMPE && MPEFlags[e])\
258      MPE_Log_event(MPEBEGIN+2*e+1,0,"");\
259   }  _tacky--;}
260 #else
261 #define PLogEventEnd(e,o1,o2,o3,o4) {\
262   if (_PLE) \
263     (*_PLE)(e,_tacky,(PetscObject)o1,(PetscObject)o2,(PetscObject)o3,(PetscObject)o4);\
264   } _tacky--;}
265 #endif
266 
267 
268 #define PLogObjectParent(p,c)       {PETSCVALIDHEADER((PetscObject)c); \
269                                      PETSCVALIDHEADER((PetscObject)p);\
270                                      ((PetscObject)(c))->parent = (PetscObject) p;}
271 #define PLogObjectParents(p,n,d)    {int _i; for ( _i=0; _i<n; _i++ ) \
272                                     PLogObjectParent(p,(d)[_i]);}
273 #define PLogObjectCreate(h)         {if (_PHC) (*_PHC)((PetscObject)h);}
274 #define PLogObjectDestroy(h)        {if (_PHD) (*_PHD)((PetscObject)h);}
275 #define PLogObjectMemory(p,m)       {PETSCVALIDHEADER((PetscObject)p);\
276                                     ((PetscObject)(p))->mem += (m);}
277 extern int PLogObjectState(PetscObject,char *,...);
278 extern int PLogInfo(PetscObject,char*,...);
279 extern int PLogDestroy();
280 extern int PLogStagePush(int);
281 extern int PLogStagePop();
282 extern int PLogStageRegister(int,char*);
283 
284 #else
285 
286 #define PLogObjectCreate(h)
287 #define PLogObjectDestroy(h)
288 #define PLogObjectMemory(p,m)
289 #define PLogEventBegin(e,o1,o2,o3,o4)
290 #define PLogEventEnd(e,o1,o2,o3,o4)
291 #define PLogObjectParent(p,c)
292 #define PLogObjectParents(p,n,c)
293 extern int PLogInfo(PetscObject,char*,...);
294 extern int PLogDestroy();
295 extern int PLogStagePush(int);
296 extern int PLogStagePop();
297 extern int PLogStageRegister(int,char*);
298 #endif
299 
300 #endif
301 
302