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