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