xref: /petsc/include/petsclog.h (revision f7765cec48af37dbfe327d22e68b1bee19f0dfa2)
1 /* $Id: plog.h,v 1.32 1995/12/02 19:23:22 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 #if defined (PETSC_LOG) && defined(HAVE_BLOCKSOLVE)
12 #define BSMAINLOG
13 #endif
14 
15 /*
16   If you add an event here, make sure you add to petsc/bin/petscview.cfg
17   and petsc/src/sys/src/plog.c!!
18 */
19 #define MAT_Mult                                0
20 #define MAT_AssemblyBegin                       1
21 #define MAT_AssemblyEnd                         2
22 #define MAT_GetReordering                       3
23 #define MAT_MultTrans                           4
24 #define MAT_MultAdd                             5
25 #define MAT_MultTransAdd                        6
26 #define MAT_LUFactor                            7
27 #define MAT_CholeskyFactor                      8
28 #define MAT_LUFactorSymbolic                    9
29 #define MAT_ILUFactorSymbolic                   10
30 #define MAT_CholeskyFactorSymbolic              11
31 #define MAT_IncompleteCholeskyFactorSymbolic    12
32 #define MAT_LUFactorNumeric                     13
33 #define MAT_CholeskyFactorNumeric               14
34 #define MAT_Relax                               15
35 #define MAT_Copy                                16
36 #define MAT_Convert                             17
37 #define MAT_Scale                               18
38 #define MAT_ZeroEntries                         19
39 #define MAT_Solve                               20
40 #define MAT_SolveAdd                            21
41 #define MAT_SolveTrans                          22
42 #define MAT_SolveTransAdd                       23
43 #define MAT_SetValues                           24
44 #define MAT_ForwardSolve                        25
45 #define MAT_BackwardSolve                       26
46 #define MAT_Load                                27
47 #define MAT_View                                28
48 #define MAT_ILUFactor                           29
49 #define MAT_GetSubMatrix                        30
50 #define MAT_GetSubMatrices                      31
51 #define MAT_GetValues                           32
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 
77 #define SLES_Solve                              70
78 #define SLES_SetUp                              71
79 
80 #define KSP_GMRESOrthogonalization              72
81 #define KSP_Solve                               73
82 
83 #define PC_SetUp                                75
84 #define PC_Apply                                76
85 
86 #define SNES_Solve                              80
87 #define SNES_LineSearch                         81
88 #define SNES_FunctionEval                       82
89 #define SNES_JacobianEval                       83
90 #define SNES_MinimizationFunctionEval           84
91 #define SNES_GradientEval                       85
92 #define SNES_HessianEval                        86
93 
94 
95 /*
96    Event numbers PLOG_USER_EVENT_LOW to PLOG_USER_EVENT_HIGH are reserved
97    for applications.  Make sure that src/sys/src/plog.c defines enough
98    entries in (*name)[] to go up to PLOG_USER_EVENT_HIGH.
99 */
100 #define PLOG_USER_EVENT_LOW                     120
101 #define PLOG_USER_EVENT_HIGH                    200
102 
103 /* Global flop counter */
104 extern double _TotalFlops;
105 #if defined(PETSC_LOG)
106 #define PLogFlops(n) {_TotalFlops += n;}
107 #else
108 #define PLogFlops(n)
109 #endif
110 
111 /*M
112    PLogFlops - Adds floating point operations to the global counter.
113 
114    Input Parameter:
115 .  f - flop counter
116 
117    Synopsis:
118    PLogFlops(int f)
119 
120    Notes:
121    A global counter logs all PETSc flop counts.  The user can use
122    PLogFlops() to increment this counter to include flops for the
123    application code.
124 
125    PETSc automatically logs library events if the code has been
126    compiled with -DPETSC_LOG (which is the default), and -log,
127    -log_summary, or -log_all are specified.  PLogFlops() is
128    intended for logging user flops to supplement this PETSc
129    information.
130 
131     Example of Usage:
132 $     #define USER_EVENT PLOG_USER_EVENT_LOW
133 $     PLogEventRegister(USER_EVENT,"User event");
134 $     PLogEventBegin(USER_EVENT,0,0,0,0);
135 $     [code segment to monitor]
136 $     PLogFlops(user_flops)
137 $     PLogEventEnd(USER_EVENT,0,0,0,0);
138 
139 .seealso:  PLogEventRegister(), PLogEventBegin(), PLogEventEnd()
140 
141 .keywords:  Petsc, log, flops, floating point operations
142 M*/
143 
144 extern int PLogPrint(MPI_Comm,FILE *);
145 extern int PLogBegin();
146 extern int PLogAllBegin();
147 extern int PLogDump(char*);
148 
149 #if defined(PETSC_LOG)
150 
151 extern int (*_PLB)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
152 extern int (*_PLE)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
153 extern int (*_PHC)(PetscObject);
154 extern int (*_PHD)(PetscObject);
155 extern int PLogEventRegister(int,char*);
156 
157 /*M
158    PLogEventBegin - Logs the beginning of a user event.
159 
160    Input Parameters:
161 .  e - integer associated with the event (PLOG_USER_EVENT_LOW <= e < PLOG_USER_EVENT_HIGH)
162 .  o1,o2,o3,o4 - objects associated with the event, or 0
163 
164    Synopsis:
165    PLogEventBegin(int e,PetscObject o1,PetscObject o2,PetscObject o3,
166                   PetscObject o4)
167 
168    Notes:
169    You should also register each integer event with the command
170    PLogRegisterEvent().  The source code must be compiled with
171    -DPETSC_LOG, which is the default.
172 
173    PETSc automatically logs library events if the code has been
174    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
175    specified.  PLogEventBegin() is intended for logging user events
176    to supplement this PETSc information.
177 
178     Example of Usage:
179 $     #define USER_EVENT PLOG_USER_EVENT_LOW
180 $     int user_event_flops;
181 $     PLogEventRegister(USER_EVENT,"User event");
182 $     PLogEventBegin(USER_EVENT,0,0,0,0);
183 $        [code segment to monitor]
184 $        PLogFlops(user_event_flops);
185 $     PLogEventEnd(USER_EVENT,0,0,0,0);
186 
187 .seealso: PLogEventRegister(), PLogEventEnd(), PLogFlops()
188 
189 .keywords: log, event, begin
190 M*/
191 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0;\
192           { _tacky++;if (_PLB) (*_PLB)(e,_tacky,(PetscObject)o1,\
193            (PetscObject)o2,(PetscObject)o3,(PetscObject)o4);};
194 
195 /*M
196    PLogEventEnd - Log the end of a user event.
197 
198    Input Parameters:
199 .  e - integer associated with the event (PLOG_USER_EVENT_LOW <= e < PLOG_USER_EVENT_HIGH)
200 .  o1,o2,o3,o4 - objects associated with the event, or 0
201 
202    Synopsis:
203    PLogEventEnd(int e,PetscObject o1,PetscObject o2,PetscObject o3,
204                 PetscObject o4)
205 
206    Notes:
207    You should also register each integer event with the command
208    PLogRegisterEvent(). Source code must be compiled with
209    -DPETSC_LOG, which is the default.
210 
211    PETSc automatically logs library events if the code has been
212    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
213    specified.  PLogEventEnd() is intended for logging user events
214    to supplement this PETSc information.
215 
216     Example of Usage:
217 $     #define USER_EVENT PLOG_EVENT_USER_LOW
218 $     int user_event_flops;
219 $     PLogEventRegister(USER_EVENT,"User event");
220 $     PLogEventBegin(USER_EVENT,0,0,0,0);
221 $        [code segment to monitor]
222 $        PLogFlops(user_event_flops);
223 $     PLogEventEnd(USER_EVENT,0,0,0,0);
224 
225 .seealso: PLogEventRegister(), PLogEventBegin(), PLogFlops()
226 
227 .keywords: log, event, end
228 M*/
229 #define PLogEventEnd(e,o1,o2,o3,o4) {if (_PLE) (*_PLE)(e,_tacky,(PetscObject)o1,\
230                                     (PetscObject)o2,(PetscObject)o3,(PetscObject)o4);}\
231                                     _tacky--;}
232 #define PLogObjectParent(p,c)       {PETSCVALIDHEADER((PetscObject)c); \
233                                      PETSCVALIDHEADER((PetscObject)p);\
234                                      ((PetscObject)(c))->parent = (PetscObject) p;}
235 #define PLogObjectParents(p,n,d)    {int _i; for ( _i=0; _i<n; _i++ ) \
236                                     PLogObjectParent(p,(d)[_i]);}
237 #define PLogObjectCreate(h)         {if (_PHC) (*_PHC)((PetscObject)h);}
238 #define PLogObjectDestroy(h)        {if (_PHD) (*_PHD)((PetscObject)h);}
239 #define PLogObjectMemory(p,m)       {PETSCVALIDHEADER((PetscObject)p);\
240                                     ((PetscObject)(p))->mem += (m);}
241 extern int PLogObjectState(PetscObject,char *,...);
242 extern int PLogInfo(PetscObject,char*,...);
243 extern int PLogDestroy();
244 extern int PLogStagePush(int);
245 extern int PLogStagePop();
246 extern int PLogStageName(int,char*);
247 
248 #else
249 
250 #define PLogObjectCreate(h)
251 #define PLogObjectDestroy(h)
252 #define PLogObjectMemory(p,m)
253 #define PLogEventBegin(e,o1,o2,o3,o4)
254 #define PLogEventEnd(e,o1,o2,o3,o4)
255 #define PLogObjectParent(p,c)
256 #define PLogObjectParents(p,n,c)
257 extern int PLogInfo(PetscObject,char*,...);
258 extern int PLogDestroy();
259 extern int PLogStagePush(int);
260 extern int PLogStagePop();
261 extern int PLogStageName(int,char*);
262 #endif
263 
264 #endif
265 
266