xref: /petsc/include/petsclog.h (revision edde42fc28bac63dd53b0b8d6cb07b743919f096)
1 /* $Id: plog.h,v 1.63 1996/03/22 19:56:40 curfman Exp curfman $ */
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 #define Petsc_Barrier                           100
100 /*
101    Event numbers PLOG_USER_EVENT_LOW to PLOG_USER_EVENT_HIGH are reserved
102    for applications.  Make sure that src/plog/src/plog.c defines enough
103    entries in (*name)[] to go up to PLOG_USER_EVENT_HIGH.
104 */
105 #define PLOG_USER_EVENT_LOW_STATIC              120
106 #define PLOG_USER_EVENT_HIGH                    200
107 
108 /* Global flop counter */
109 extern double _TotalFlops;
110 #if defined(PETSC_LOG)
111 #define PLogFlops(n) {_TotalFlops += n;}
112 #else
113 #define PLogFlops(n)
114 #endif
115 
116 /* General logging of information; different from event logging */
117 extern int PLogInfo(PetscObject,char*,...);
118 
119 #if defined (HAVE_MPE)
120 #include "mpe.h"
121 extern int PLogMPEBegin();
122 extern int PLogMPEDump(char *);
123 extern int UseMPE,MPEFlags[];
124 #define MPEBEGIN    1000
125 #endif
126 
127 #if defined(PETSC_LOG)
128 extern int (*_PLB)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
129 extern int (*_PLE)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
130 extern int (*_PHC)(PetscObject);
131 extern int (*_PHD)(PetscObject);
132 
133 #if defined(HAVE_MPE)
134 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0; \
135   { _tacky++; \
136    if (_PLB) \
137      (*_PLB)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
138    if (_tacky == 1 && UseMPE && MPEFlags[e])\
139      MPE_Log_event(MPEBEGIN+2*e,0,"");\
140   }
141 #else
142 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0; \
143   { _tacky++; \
144    if (_PLB) \
145      (*_PLB)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
146   }
147 #endif
148 
149 #if defined(HAVE_MPE)
150 #define PLogEventEnd(e,o1,o2,o3,o4) {\
151   if (_PLE) \
152     (*_PLE)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
153   if (_tacky == 1 && UseMPE && MPEFlags[e])\
154      MPE_Log_event(MPEBEGIN+2*e+1,0,"");\
155   }  _tacky--;}
156 #else
157 #define PLogEventEnd(e,o1,o2,o3,o4) {\
158   if (_PLE) \
159     (*_PLE)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\
160   } _tacky--;}
161 #endif
162 
163 
164 #define PLogObjectParent(p,c)       {PetscValidHeader((PetscObject)c); \
165                                      PetscValidHeader((PetscObject)p);\
166                                      ((PetscObject)(c))->parent = (PetscObject) p;}
167 #define PLogObjectParents(p,n,d)    {int _i; for ( _i=0; _i<n; _i++ ) \
168                                     PLogObjectParent(p,(d)[_i]);}
169 #define PLogObjectCreate(h)         {if (_PHC) (*_PHC)((PetscObject)h);}
170 #define PLogObjectDestroy(h)        {if (_PHD) (*_PHD)((PetscObject)h);}
171 #define PLogObjectMemory(p,m)       {PetscValidHeader((PetscObject)p);\
172                                     ((PetscObject)(p))->mem += (m);}
173 extern int PLogObjectState(PetscObject,char *,...);
174 extern int PLogDestroy();
175 extern int PLogStagePush(int);
176 extern int PLogStagePop();
177 extern int PLogStageRegister(int,char*);
178 extern int PLogPrintSummary(MPI_Comm,FILE *);
179 extern int PLogBegin();
180 extern int PLogAllBegin();
181 extern int PLogDump(char*);
182 extern int PLogEventRegister(int*,char*,char*);
183 
184 #else
185 
186 #define PLogEventBegin(e,o1,o2,o3,o4)
187 #define PLogEventEnd(e,o1,o2,o3,o4)
188 #define PLogObjectParent(p,c)
189 #define PLogObjectParents(p,n,c)
190 #define PLogObjectCreate(h)
191 #define PLogObjectDestroy(h)
192 #define PLogObjectMemory(p,m)
193 /* #define PLogObjectState(a,b,...) */
194 #define PLogDestroy()
195 #define PLogStagePush(int)
196 #define PLogStagePop()
197 #define PLogStageRegister(a,b)
198 #define PLogPrintSummary(comm,file)
199 #define PLogBegin()
200 #define PLogAllBegin()
201 #define PLogDump(char)
202 #define PLogEventRegister(a,b,c)
203 #define PLogMPEBegin()
204 #define PLogMPEDump(a)
205 
206 #endif
207 
208 /*M
209    PLogFlops - Adds floating point operations to the global counter.
210 
211    Input Parameter:
212 .  f - flop counter
213 
214    Synopsis:
215    void PLogFlops(int f)
216 
217    Notes:
218    A global counter logs all PETSc flop counts.  The user can use
219    PLogFlops() to increment this counter to include flops for the
220    application code.
221 
222    PETSc automatically logs library events if the code has been
223    compiled with -DPETSC_LOG (which is the default), and -log,
224    -log_summary, or -log_all are specified.  PLogFlops() is
225    intended for logging user flops to supplement this PETSc
226    information.
227 
228     Example of Usage:
229 $     int USER_EVENT;
230 $     PLogEventRegister(&USER_EVENT,"User event","Color:");
231 $     PLogEventBegin(USER_EVENT,0,0,0,0);
232 $        [code segment to monitor]
233 $        PLogFlops(user_flops)
234 $     PLogEventEnd(USER_EVENT,0,0,0,0);
235 
236 .seealso: PLogEventRegister(), PLogEventBegin(), PLogEventEnd()
237 
238 .keywords: log, flops, floating point operations
239 M*/
240 
241 
242 /*M
243    PLogEventBegin - Logs the beginning of a user event.
244 
245    Input Parameters:
246 .  e - integer associated with the event obtained from PLogEventRegister()
247 .  o1,o2,o3,o4 - objects associated with the event, or 0
248 
249    Synopsis:
250    void PLogEventBegin(int e,PetscObject o1,PetscObject o2,PetscObject o3,
251                   PetscObject o4)
252 
253    Notes:
254    You should also register each integer event with the command
255    PLogRegisterEvent().  The source code must be compiled with
256    -DPETSC_LOG, which is the default.
257 
258    PETSc automatically logs library events if the code has been
259    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
260    specified.  PLogEventBegin() is intended for logging user events
261    to supplement this PETSc information.
262 
263     Example of Usage:
264 $     int USER_EVENT;
265 $     int user_event_flops;
266 $     PLogEventRegister(&USER_EVENT,"User event","Color:");
267 $     PLogEventBegin(&USER_EVENT,0,0,0,0);
268 $        [code segment to monitor]
269 $        PLogFlops(user_event_flops);
270 $     PLogEventEnd(&USER_EVENT,0,0,0,0);
271 
272 .seealso: PLogEventRegister(), PLogEventEnd(), PLogFlops()
273 
274 .keywords: log, event, begin
275 M*/
276 
277 /*M
278    PLogEventEnd - Log the end of a user event.
279 
280    Input Parameters:
281 .  e - integer associated with the event obtained with PLogEventRegister()
282 .  o1,o2,o3,o4 - objects associated with the event, or 0
283 
284    Synopsis:
285    void PLogEventEnd(int e,PetscObject o1,PetscObject o2,PetscObject o3,
286                 PetscObject o4)
287 
288    Notes:
289    You should also register each integer event with the command
290    PLogRegisterEvent(). Source code must be compiled with
291    -DPETSC_LOG, which is the default.
292 
293    PETSc automatically logs library events if the code has been
294    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
295    specified.  PLogEventEnd() is intended for logging user events
296    to supplement this PETSc information.
297 
298     Example of Usage:
299 $     int USER_EVENT;
300 $     int user_event_flops;
301 $     PLogEventRegister(&USER_EVENT,"User event","Color:");
302 $     PLogEventBegin(USER_EVENT,0,0,0,0);
303 $        [code segment to monitor]
304 $        PLogFlops(user_event_flops);
305 $     PLogEventEnd(USER_EVENT,0,0,0,0);
306 
307 .seealso: PLogEventRegister(), PLogEventBegin(), PLogFlops()
308 
309 .keywords: log, event, end
310 M*/
311 
312 #endif
313 
314 
315 
316