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