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