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