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