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