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