1 /* $Id: plog.h,v 1.73 1996/07/02 18:09:25 bsmith Exp balay $ */ 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 it to 13 petsc/bin/petscview.cfg, 14 petsc/bin/petscview, 15 petsc/src/plog/src/plog.c, 16 petsc/src/plog/src/plogmpe.c and 17 petsc/include/FINCLUDE/plog.h!!! 18 */ 19 #define MAT_Mult 0 20 #define MAT_MatrixFreeMult 1 21 #define MAT_AssemblyBegin 2 22 #define MAT_AssemblyEnd 3 23 #define MAT_GetReordering 4 24 #define MAT_MultTrans 5 25 #define MAT_MultAdd 6 26 #define MAT_MultTransAdd 7 27 #define MAT_LUFactor 8 28 #define MAT_CholeskyFactor 9 29 #define MAT_LUFactorSymbolic 10 30 #define MAT_ILUFactorSymbolic 11 31 #define MAT_CholeskyFactorSymbolic 12 32 #define MAT_IncompleteCholeskyFactorSymbolic 13 33 #define MAT_LUFactorNumeric 14 34 #define MAT_CholeskyFactorNumeric 15 35 #define MAT_Relax 16 36 #define MAT_Copy 17 37 #define MAT_Convert 18 38 #define MAT_Scale 19 39 #define MAT_ZeroEntries 20 40 #define MAT_Solve 21 41 #define MAT_SolveAdd 22 42 #define MAT_SolveTrans 23 43 #define MAT_SolveTransAdd 24 44 #define MAT_SetValues 25 45 #define MAT_ForwardSolve 26 46 #define MAT_BackwardSolve 27 47 #define MAT_Load 28 48 #define MAT_View 29 49 #define MAT_ILUFactor 30 50 #define MAT_GetSubMatrix 31 51 #define MAT_GetSubMatrices 32 52 #define MAT_GetValues 33 53 #define MAT_IncreaseOverlap 34 54 #define MAT_GetRow 35 55 56 #define VEC_Dot 40 57 #define VEC_Norm 41 58 #define VEC_Max 42 59 #define VEC_Min 43 60 #define VEC_TDot 44 61 #define VEC_Scale 45 62 #define VEC_Copy 46 63 #define VEC_Set 47 64 #define VEC_AXPY 48 65 #define VEC_AYPX 49 66 #define VEC_Swap 50 67 #define VEC_WAXPY 51 68 #define VEC_AssemblyBegin 52 69 #define VEC_AssemblyEnd 53 70 #define VEC_MTDot 54 71 #define VEC_MDot 55 72 #define VEC_MAXPY 56 73 #define VEC_PMult 57 74 #define VEC_SetValues 58 75 #define VEC_Load 59 76 #define VEC_View 60 77 #define VEC_ScatterBegin 61 78 #define VEC_ScatterEnd 62 79 #define VEC_SetRandom 63 80 81 #define SLES_Solve 70 82 #define SLES_SetUp 71 83 84 #define KSP_GMRESOrthogonalization 72 85 86 #define PC_SetUp 75 87 #define PC_SetUpOnBlocks 76 88 #define PC_Apply 77 89 #define PC_ApplySymmetricLeft 78 90 #define PC_ApplySymmetricRight 79 91 92 #define SNES_Solve 80 93 #define SNES_LineSearch 81 94 #define SNES_FunctionEval 82 95 #define SNES_JacobianEval 83 96 #define SNES_MinimizationFunctionEval 84 97 #define SNES_GradientEval 85 98 #define SNES_HessianEval 86 99 100 #define TS_Step 90 101 102 #define Petsc_Barrier 100 103 104 #define DFVec_RefineVector 110 105 #define DFVec_AssembleFullVector 111 106 #define DFVec_GetComponentVectors 112 107 #define DFVec_DrawContours 113 108 109 /* 110 Event numbers PLOG_USER_EVENT_LOW to PLOG_USER_EVENT_HIGH are reserved 111 for applications. Make sure that src/plog/src/plog.c defines enough 112 entries in (*name)[] to go up to PLOG_USER_EVENT_HIGH. 113 */ 114 #define PLOG_USER_EVENT_LOW_STATIC 120 115 #define PLOG_USER_EVENT_HIGH 200 116 117 /* Global flop counter */ 118 extern double _TotalFlops; 119 120 /* General logging of information; different from event logging */ 121 extern int PLogInfo(void*,char*,...); 122 extern int PLogInfoDeactivateClass(int); 123 extern int PLogInfoActivateClass(int); 124 125 #if defined(PETSC_LOG) /* --------------------------------------------*/ 126 127 #define PLogFlops(n) {_TotalFlops += (n);} 128 129 #if defined (HAVE_MPE) 130 #include "mpe.h" 131 #define MPEBEGIN 1000 132 extern int PLogMPEBegin(); 133 extern int PLogMPEDump(char *); 134 extern int UseMPE,PLogEventMPEFlags[]; 135 extern int PLogEventMPEActivate(int); 136 extern int PLogEventMPEDeActivate(int); 137 #else 138 #define PLogEventMPEActivate(a) 139 #define PLogEventMPEDeActivate(a) 140 #endif 141 142 extern int PLogEventActivate(int); 143 extern int PLogEventDeActivate(int); 144 145 extern int PLogEventActivateClass(); 146 extern int PLogEventDeActivateClass(); 147 148 extern int PLogEventFlags[]; 149 extern int (*_PLB)(int,int,PetscObject,PetscObject,PetscObject,PetscObject); 150 extern int (*_PLE)(int,int,PetscObject,PetscObject,PetscObject,PetscObject); 151 extern int (*_PHC)(PetscObject); 152 extern int (*_PHD)(PetscObject); 153 154 #if defined(HAVE_MPE) 155 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0; \ 156 { _tacky++; \ 157 if (_PLB && PLogEventFlags[e]) \ 158 (*_PLB)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 159 if (_tacky == 1 && UseMPE && PLogEventMPEFlags[e])\ 160 MPE_Log_event(MPEBEGIN+2*e,0,"");\ 161 } 162 #else 163 #define PLogEventBegin(e,o1,o2,o3,o4) {static int _tacky = 0; \ 164 { _tacky++; \ 165 if (_PLB && PLogEventFlags[e]) \ 166 (*_PLB)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 167 } 168 #endif 169 170 #if defined(HAVE_MPE) 171 #define PLogEventEnd(e,o1,o2,o3,o4) {\ 172 if (_PLE && PLogEventFlags[e]) \ 173 (*_PLE)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 174 if (_tacky == 1 && UseMPE && PLogEventMPEFlags[e])\ 175 MPE_Log_event(MPEBEGIN+2*e+1,0,"");\ 176 } _tacky--;} 177 #else 178 #define PLogEventEnd(e,o1,o2,o3,o4) {\ 179 if (_PLE && PLogEventFlags[e]) \ 180 (*_PLE)(e,_tacky,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 181 } _tacky--;} 182 #endif 183 184 185 #define PLogObjectParent(p,c) {PetscValidHeader((PetscObject)c); \ 186 PetscValidHeader((PetscObject)p);\ 187 ((PetscObject)(c))->parent = (PetscObject) p;} 188 #define PLogObjectParents(p,n,d) {int _i; for ( _i=0; _i<n; _i++ ) \ 189 PLogObjectParent(p,(d)[_i]);} 190 #define PLogObjectCreate(h) {if (_PHC) (*_PHC)((PetscObject)h);} 191 #define PLogObjectDestroy(h) {if (_PHD) (*_PHD)((PetscObject)h);} 192 #define PLogObjectMemory(p,m) {PetscValidHeader((PetscObject)p);\ 193 ((PetscObject)(p))->mem += (m);} 194 extern int PLogObjectState(PetscObject,char *,...); 195 extern int PLogDestroy(); 196 extern int PLogStagePush(int); 197 extern int PLogStagePop(); 198 extern int PLogStageRegister(int,char*); 199 extern int PLogPrintSummary(MPI_Comm,FILE *); 200 extern int PLogBegin(); 201 extern int PLogAllBegin(); 202 extern int PLogDump(char*); 203 extern int PLogEventRegister(int*,char*,char*); 204 205 206 #else /* ------------------------------------------------------------*/ 207 208 #define PLogFlops(n) 209 210 #if defined (HAVE_MPE) 211 #define MPEBEGIN 1000 212 extern int PLogMPEBegin(); 213 extern int PLogMPEDump(char *); 214 #else 215 #define PLogEventMPEActivate(a) 216 #define PLogEventMPEDeActivate(a) 217 #endif 218 219 #define PLogEventActivate(a) 220 #define PLogEventDeActivate(a) 221 222 #define PLogEventActivateClass() 223 #define PLogEventDeActivateClass() 224 225 #define _PLB 0 226 #define _PLE 0 227 #define _PHC 0 228 #define _PHD 0 229 #define PLogEventBegin(e,o1,o2,o3,o4) 230 #define PLogEventEnd(e,o1,o2,o3,o4) 231 #define PLogObjectParent(p,c) 232 #define PLogObjectParents(p,n,c) 233 #define PLogObjectCreate(h) 234 #define PLogObjectDestroy(h) 235 #define PLogObjectMemory(p,m) 236 #define PLogDestroy() 237 #define PLogStagePush(int) 238 #define PLogStagePop() 239 #define PLogStageRegister(a,b) 240 #define PLogPrintSummary(comm,file) 241 #define PLogBegin() 242 #define PLogAllBegin() 243 #define PLogDump(char) 244 #define PLogEventRegister(a,b,c) 245 #define PLogMPEBegin() 246 #define PLogMPEDump(a) 247 extern int PLogObjectState(PetscObject,char *,...); 248 249 #endif 250 251 /*MC 252 PLogFlops - Adds floating point operations to the global counter. 253 254 Input Parameter: 255 . f - flop counter 256 257 Synopsis: 258 void PLogFlops(int f) 259 260 Notes: 261 A global counter logs all PETSc flop counts. The user can use 262 PLogFlops() to increment this counter to include flops for the 263 application code. 264 265 PETSc automatically logs library events if the code has been 266 compiled with -DPETSC_LOG (which is the default), and -log, 267 -log_summary, or -log_all are specified. PLogFlops() is 268 intended for logging user flops to supplement this PETSc 269 information. 270 271 Example of Usage: 272 $ int USER_EVENT; 273 $ PLogEventRegister(&USER_EVENT,"User event","Color:"); 274 $ PLogEventBegin(USER_EVENT,0,0,0,0); 275 $ [code segment to monitor] 276 $ PLogFlops(user_flops) 277 $ PLogEventEnd(USER_EVENT,0,0,0,0); 278 279 .seealso: PLogEventRegister(), PLogEventBegin(), PLogEventEnd(), PetscGetFlops() 280 281 .keywords: log, flops, floating point operations 282 M*/ 283 284 285 /*MC 286 PLogEventBegin - Logs the beginning of a user event. 287 288 Input Parameters: 289 . e - integer associated with the event obtained from PLogEventRegister() 290 . o1,o2,o3,o4 - objects associated with the event, or 0 291 292 Synopsis: 293 void PLogEventBegin(int e,PetscObject o1,PetscObject o2,PetscObject o3, 294 PetscObject o4) 295 296 Notes: 297 You should also register each integer event with the command 298 PLogRegisterEvent(). The source code must be compiled with 299 -DPETSC_LOG, which is the default. 300 301 PETSc automatically logs library events if the code has been 302 compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are 303 specified. PLogEventBegin() is intended for logging user events 304 to supplement this PETSc information. 305 306 Example of Usage: 307 $ int USER_EVENT; 308 $ int user_event_flops; 309 $ PLogEventRegister(&USER_EVENT,"User event","Color:"); 310 $ PLogEventBegin(&USER_EVENT,0,0,0,0); 311 $ [code segment to monitor] 312 $ PLogFlops(user_event_flops); 313 $ PLogEventEnd(&USER_EVENT,0,0,0,0); 314 315 .seealso: PLogEventRegister(), PLogEventEnd(), PLogFlops() 316 317 .keywords: log, event, begin 318 M*/ 319 320 /*MC 321 PLogEventEnd - Log the end of a user event. 322 323 Input Parameters: 324 . e - integer associated with the event obtained with PLogEventRegister() 325 . o1,o2,o3,o4 - objects associated with the event, or 0 326 327 Synopsis: 328 void PLogEventEnd(int e,PetscObject o1,PetscObject o2,PetscObject o3, 329 PetscObject o4) 330 331 Notes: 332 You should also register each integer event with the command 333 PLogRegisterEvent(). Source code must be compiled with 334 -DPETSC_LOG, which is the default. 335 336 PETSc automatically logs library events if the code has been 337 compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are 338 specified. PLogEventEnd() is intended for logging user events 339 to supplement this PETSc information. 340 341 Example of Usage: 342 $ int USER_EVENT; 343 $ int user_event_flops; 344 $ PLogEventRegister(&USER_EVENT,"User event","Color:"); 345 $ PLogEventBegin(USER_EVENT,0,0,0,0); 346 $ [code segment to monitor] 347 $ PLogFlops(user_event_flops); 348 $ PLogEventEnd(USER_EVENT,0,0,0,0); 349 350 .seealso: PLogEventRegister(), PLogEventBegin(), PLogFlops() 351 352 .keywords: log, event, end 353 M*/ 354 355 #if defined(PETSC_MPI_LOG) 356 357 extern int irecv_ct,isend_ct,wait_ct,wait_any_ct,get_count_ct,wait_all_ct,allreduce_ct; 358 359 #define MPI_Irecv( buf, count, datatype, source, tag, comm, request) \ 360 { \ 361 PMPI_Irecv( buf, count, datatype, source, tag, comm, request); \ 362 irecv_ct++; \ 363 } 364 365 #define MPI_Isend( buf, count, datatype, dest, tag, comm, request) \ 366 { \ 367 PMPI_Isend( buf, count, datatype, dest, tag, comm, request); \ 368 isend_ct++; \ 369 } 370 371 #define MPI_Wait(request, status) \ 372 { \ 373 PMPI_Wait(request, status) ; \ 374 wait_ct++; \ 375 } 376 #define MPI_Waitany(a, b, c, d) \ 377 { \ 378 PMPI_Waitany(a, b, c, d);\ 379 wait_any_ct++; \ 380 } 381 382 #define MPI_Get_count(status, datatype, count) \ 383 { \ 384 PMPI_Get_count(status, datatype, count);\ 385 get_count_ct++; \ 386 } 387 388 #define MPI_Waitall(count, array_of_requests, array_of_statuses) \ 389 { \ 390 PMPI_Waitall(count, array_of_requests, array_of_statuses); \ 391 wait_all_ct++; \ 392 } 393 394 #define MPI_Allreduce( sendbuf, recvbuf, count, datatype, op, comm) \ 395 { \ 396 PMPI_Allreduce( sendbuf, recvbuf, count, datatype, op, comm); \ 397 allreduce_ct++; \ 398 } 399 400 #endif 401 402 #endif 403 404 405 406