xref: /petsc/include/petsclog.h (revision 4e52e31164d3e894b0d0acb35191029f4220c3dc)
1 /* $Id: plog.h,v 1.25 1995/11/01 19:12:32 bsmith 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   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 /* event numbers 80 to 99 are reserved for applications */
89 
90 /* Global flop counter */
91 extern double _TotalFlops;
92 #if defined(PETSC_LOG)
93 #define PLogFlops(n) {_TotalFlops += n;}
94 #else
95 #define PLogFlops(n)
96 #endif
97 
98 /*M
99    PLogFlops - Adds floating point operations to the global counter.
100 
101    Input Parameter:
102 .  f - flop counter
103 
104    Synopsis:
105    PLogFlops(int f)
106 
107    Notes:
108    A global counter logs all PETSc flop counts.  The user can use
109    PLogFlops() to increment this counter to include flops for the
110    application code.
111 
112    PETSc automatically logs library events if the code has been
113    compiled with -DPETSC_LOG (which is the default), and -log,
114    -log_summary, or -log_all are specified.  PLogFlops() is
115    intended for logging user flops to supplement this PETSc
116    information.
117 
118     Example of Usage:
119 $     #define USER_EVENT 85
120 $     PLogEventRegister(USER_EVENT,"User event");
121 $     PLogEventBegin(USER_EVENT,0,0,0,0);
122 $     [code segment to monitor]
123 $     PLogFlops(user_flops)
124 $     PLogEventEnd(USER_EVENT,0,0,0,0);
125 
126 .seealso:  PLogEventRegister(), PLogEventBegin(), PLogEventEnd()
127 
128 .keywords:  Petsc, log, flops, floating point operations
129 M*/
130 
131 extern int PLogPrint(MPI_Comm,FILE *);
132 extern int PLogBegin();
133 extern int PLogAllBegin();
134 extern int PLogDump(char*);
135 
136 #if defined(PETSC_LOG)
137 
138 extern int (*_PLB)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
139 extern int (*_PLE)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
140 extern int (*_PHC)(PetscObject);
141 extern int (*_PHD)(PetscObject);
142 extern int PLogEventRegister(int,char*);
143 
144 /*M
145    PLogEventBegin - Logs the beginning of a user event.
146 
147    Input Parameters:
148 .  e - integer associated with the event (80 < e < 99)
149 .  o1,o2,o3,o4 - objects associated with the event, or 0
150 
151    Synopsis:
152    PLogEventBegin(int e,PetscObject o1,PetscObject o2,PetscObject o3,
153                   PetscObject o4)
154 
155    Notes:
156    You should also register each integer event with the command
157    PLogRegisterEvent().  The source code must be compiled with
158    -DPETSC_LOG, which is the default.
159 
160    PETSc automatically logs library events if the code has been
161    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
162    specified.  PLogEventBegin() is intended for logging user events
163    to supplement this PETSc information.
164 
165     Example of Usage:
166 $     #define USER_EVENT 85
167 $     int user_event_flops;
168 $     PLogEventRegister(USER_EVENT,"User event");
169 $     PLogEventBegin(USER_EVENT,0,0,0,0);
170 $        [code segment to monitor]
171 $        PLogFlops(user_event_flops);
172 $     PLogEventEnd(USER_EVENT,0,0,0,0);
173 
174 .seealso: PLogEventRegister(), PLogEventEnd(), PLogFlops()
175 
176 .keywords: log, event, begin
177 M*/
178 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0;\
179           { _tacky++;if (_PLB) (*_PLB)(e,_tacky,(PetscObject)o1,\
180            (PetscObject)o2,(PetscObject)o3,(PetscObject)o4);};
181 
182 /*M
183    PLogEventEnd - Log the end of a user event.
184 
185    Input Parameters:
186 .  e - integer associated with the event (80 < e < 99)
187 .  o1,o2,o3,o4 - objects associated with the event, or 0
188 
189    Synopsis:
190    PLogEventEnd(int e,PetscObject o1,PetscObject o2,PetscObject o3,
191                 PetscObject o4)
192 
193    Notes:
194    You should also register each integer event with the command
195    PLogRegisterEvent(). Source code must be compiled with
196    -DPETSC_LOG, which is the default.
197 
198    PETSc automatically logs library events if the code has been
199    compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are
200    specified.  PLogEventEnd() is intended for logging user events
201    to supplement this PETSc information.
202 
203     Example of Usage:
204 $     #define USER_EVENT 85
205 $     int user_event_flops;
206 $     PLogEventRegister(USER_EVENT,"User event");
207 $     PLogEventBegin(USER_EVENT,0,0,0,0);
208 $        [code segment to monitor]
209 $        PLogFlops(user_event_flops);
210 $     PLogEventEnd(USER_EVENT,0,0,0,0);
211 
212 .seealso: PLogEventRegister(), PLogEventBegin(), PLogFlops()
213 
214 .keywords: log, event, end
215 M*/
216 #define PLogEventEnd(e,o1,o2,o3,o4) {if (_PLE) (*_PLE)(e,_tacky,(PetscObject)o1,\
217                                     (PetscObject)o2,(PetscObject)o3,(PetscObject)o4);}\
218                                     _tacky--;}
219 #define PLogObjectParent(p,c)       {PETSCVALIDHEADER((PetscObject)c); \
220                                      PETSCVALIDHEADER((PetscObject)p);\
221                                      ((PetscObject)(c))->parent = (PetscObject) p;}
222 #define PLogObjectParents(p,n,d)    {int _i; for ( _i=0; _i<n; _i++ ) \
223                                     PLogObjectParent(p,(d)[_i]);}
224 #define PLogObjectCreate(h)         {if (_PHC) (*_PHC)((PetscObject)h);}
225 #define PLogObjectDestroy(h)        {if (_PHD) (*_PHD)((PetscObject)h);}
226 #define PLogObjectMemory(p,m)       {PETSCVALIDHEADER((PetscObject)p);\
227                                     ((PetscObject)(p))->mem += (m);}
228 extern int PLogObjectState(PetscObject,char *,...);
229 extern int PLogInfo(PetscObject,char*,...);
230 extern int PLogDestroy();
231 
232 #else
233 
234 #define PLogObjectCreate(h)
235 #define PLogObjectDestroy(h)
236 #define PLogObjectMemory(p,m)
237 #define PLogEventBegin(e,o1,o2,o3,o4)
238 #define PLogEventEnd(e,o1,o2,o3,o4)
239 #define PLogObjectParent(p,c)
240 #define PLogObjectParents(p,n,c)
241 extern int PLogInfo(PetscObject,char*,...);
242 #endif
243 
244 #endif
245