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