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