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