1 /* $Id: petsclog.h,v 1.109 1997/08/06 22:32:13 bsmith Exp bsmith $ */ 2 3 /* 4 Defines profile/logging in PETSc. 5 */ 6 7 #if !defined(__PLOG_PACKAGE) 8 #define __PLOG_PACKAGE 9 #include "petsc.h" 10 11 /* 12 Lists all PETSc events that are logged/profiled. 13 14 If you add an event here, make sure you add it to 15 petsc/bin/petscview.cfg, 16 petsc/bin/petscview, 17 petsc/src/plog/src/plog.c, 18 petsc/src/plog/src/plogmpe.c, and 19 petsc/include/FINCLUDE/petsclog.h!!! 20 */ 21 #define MAT_Mult 0 22 #define MAT_MatrixFreeMult 1 23 #define MAT_AssemblyBegin 2 24 #define MAT_AssemblyEnd 3 25 #define MAT_GetReordering 4 26 #define MAT_MultTrans 5 27 #define MAT_MultAdd 6 28 #define MAT_MultTransAdd 7 29 #define MAT_LUFactor 8 30 #define MAT_CholeskyFactor 9 31 #define MAT_LUFactorSymbolic 10 32 #define MAT_ILUFactorSymbolic 11 33 #define MAT_CholeskyFactorSymbolic 12 34 #define MAT_IncompleteCholeskyFactorSymbolic 13 35 #define MAT_LUFactorNumeric 14 36 #define MAT_CholeskyFactorNumeric 15 37 #define MAT_Relax 16 38 #define MAT_Copy 17 39 #define MAT_Convert 18 40 #define MAT_Scale 19 41 #define MAT_ZeroEntries 20 42 #define MAT_Solve 21 43 #define MAT_SolveAdd 22 44 #define MAT_SolveTrans 23 45 #define MAT_SolveTransAdd 24 46 #define MAT_SetValues 25 47 #define MAT_ForwardSolve 26 48 #define MAT_BackwardSolve 27 49 #define MAT_Load 28 50 #define MAT_View 29 51 #define MAT_ILUFactor 30 52 #define MAT_GetColoring 31 53 #define MAT_GetSubMatrices 32 54 #define MAT_GetValues 33 55 #define MAT_IncreaseOverlap 34 56 #define MAT_GetRow 35 57 58 #define VEC_Dot 40 59 #define VEC_Norm 41 60 #define VEC_Max 42 61 #define VEC_Min 43 62 #define VEC_TDot 44 63 #define VEC_Scale 45 64 #define VEC_Copy 46 65 #define VEC_Set 47 66 #define VEC_AXPY 48 67 #define VEC_AYPX 49 68 #define VEC_Swap 50 69 #define VEC_WAXPY 51 70 #define VEC_AssemblyBegin 52 71 #define VEC_AssemblyEnd 53 72 #define VEC_MTDot 54 73 #define VEC_MDot 55 74 #define VEC_MAXPY 56 75 #define VEC_PMult 57 76 #define VEC_SetValues 58 77 #define VEC_Load 59 78 #define VEC_View 60 79 #define VEC_ScatterBegin 61 80 #define VEC_ScatterEnd 62 81 #define VEC_SetRandom 63 82 83 #define SLES_Solve 70 84 #define SLES_SetUp 71 85 86 #define KSP_GMRESOrthogonalization 72 87 88 #define PC_ModifySubMatrices 74 89 #define PC_SetUp 75 90 #define PC_SetUpOnBlocks 76 91 #define PC_Apply 77 92 #define PC_ApplySymmetricLeft 78 93 #define PC_ApplySymmetricRight 79 94 95 #define SNES_Solve 80 96 #define SNES_LineSearch 81 97 #define SNES_FunctionEval 82 98 #define SNES_JacobianEval 83 99 #define SNES_MinimizationFunctionEval 84 100 #define SNES_GradientEval 85 101 #define SNES_HessianEval 86 102 103 #define TS_Step 90 104 #define TS_PseudoComputeTimeStep 91 105 106 #define Petsc_Barrier 100 107 /* 108 Time spent by processors synchronousing for reduction 109 and then performing it. 110 */ 111 #define MPI_ReduceSync 101 112 #define MPI_ReduceComp 102 113 114 #define EC_SetUp 105 115 #define EC_Solve 106 116 117 #define DFVec_RefineVector 110 118 #define DFVec_AssembleFullVector 111 119 #define DFVec_GetComponentVectors 112 120 #define DFVec_DrawContours 113 121 122 /* 123 Event numbers PLOG_USER_EVENT_LOW to PLOG_USER_EVENT_HIGH are reserved 124 for applications. Make sure that src/plog/src/plog.c defines enough 125 entries in (*name)[] to go up to PLOG_USER_EVENT_HIGH. 126 */ 127 #define PLOG_USER_EVENT_LOW_STATIC 120 128 #define PLOG_USER_EVENT_HIGH 200 129 130 /* Global flop counter */ 131 extern PLogDouble _TotalFlops; 132 133 /* General logging of information; different from event logging */ 134 extern int PLogInfo(void*,char*,...); 135 extern int PLogInfoDeactivateClass(int); 136 extern int PLogInfoActivateClass(int); 137 extern int PLogPrintInfo; /* if 1, indicates PLogInfo() is turned on */ 138 139 #if defined(PETSC_LOG) /* --------------------------------------------*/ 140 141 #define PLogFlops(n) {_TotalFlops += (n);} 142 143 #if defined (HAVE_MPE) 144 #include "mpe.h" 145 #define MPEBEGIN 1000 146 extern int PLogMPEBegin(); 147 extern int PLogMPEDump(char *); 148 extern int UseMPE,PLogEventMPEFlags[]; 149 extern int PLogEventMPEActivate(int); 150 extern int PLogEventMPEDeactivate(int); 151 #else 152 #define PLogEventMPEActivate(a) 0 153 #define PLogEventMPEDeactivate(a) 0 154 #endif 155 156 extern int PLogEventActivate(int); 157 extern int PLogEventDeactivate(int); 158 159 extern int PLogEventActivateClass(int); 160 extern int PLogEventDeactivateClass(int); 161 162 extern int PLogEventFlags[]; 163 extern int (*_PLogPLB)(int,int,PetscObject,PetscObject,PetscObject,PetscObject); 164 extern int (*_PLogPLE)(int,int,PetscObject,PetscObject,PetscObject,PetscObject); 165 extern int (*_PLogPHC)(PetscObject); 166 extern int (*_PLogPHD)(PetscObject); 167 168 #if defined(HAVE_MPE) 169 #define PLogEventBegin(e,o1,o2,o3,o4) \ 170 { \ 171 if (_PLogPLB && PLogEventFlags[e]) \ 172 (*_PLogPLB)(e,0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 173 if (UseMPE && PLogEventMPEFlags[e])\ 174 MPE_Log_event(MPEBEGIN+2*e,0,"");\ 175 } 176 #else 177 #define PLogEventBegin(e,o1,o2,o3,o4) \ 178 { \ 179 if (_PLogPLB && PLogEventFlags[e]) \ 180 (*_PLogPLB)(e,0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 181 } 182 #endif 183 184 #if defined(HAVE_MPE) 185 #define PLogEventEnd(e,o1,o2,o3,o4) {\ 186 if (_PLogPLE && PLogEventFlags[e]) \ 187 (*_PLogPLE)(e,0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 188 if (UseMPE && PLogEventMPEFlags[e])\ 189 MPE_Log_event(MPEBEGIN+2*e+1,0,"");\ 190 } 191 #else 192 #define PLogEventEnd(e,o1,o2,o3,o4) {\ 193 if (_PLogPLE && PLogEventFlags[e]) \ 194 (*_PLogPLE)(e,0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 195 } 196 #endif 197 198 199 #define PLogObjectParent(p,c) {PetscValidHeader((PetscObject)c); \ 200 PetscValidHeader((PetscObject)p);\ 201 ((PetscObject)(c))->parent = (PetscObject) p;} 202 #define PLogObjectParents(p,n,d) {int _i; for ( _i=0; _i<n; _i++ ) \ 203 PLogObjectParent(p,(d)[_i]);} 204 #define PLogObjectCreate(h) {if (_PLogPHC) (*_PLogPHC)((PetscObject)h);} 205 #define PLogObjectDestroy(h) {if (_PLogPHD) (*_PLogPHD)((PetscObject)h);} 206 #define PLogObjectMemory(p,m) {PetscValidHeader((PetscObject)p);\ 207 ((PetscObject)(p))->mem += (m);} 208 extern int PLogObjectState(PetscObject,char *,...); 209 extern int PLogDestroy(); 210 extern int PLogStagePush(int); 211 extern int PLogStagePop(); 212 extern int PLogStageRegister(int,char*); 213 extern int PLogPrintSummary(MPI_Comm,char *); 214 extern int PLogBegin(); 215 extern int PLogTraceBegin(FILE *); 216 extern int PLogAllBegin(); 217 extern int PLogSet(int (*)(int,int,PetscObject,PetscObject,PetscObject,PetscObject), 218 int (*)(int,int,PetscObject,PetscObject,PetscObject,PetscObject)); 219 extern int PLogDump(char*); 220 extern int PLogEventRegister(int*,char*,char*); 221 extern PLogDouble PetscGetFlops(); 222 223 extern PLogDouble irecv_ct, isend_ct, wait_ct, wait_any_ct, recv_ct, send_ct; 224 extern PLogDouble irecv_len, isend_len, recv_len, send_len; 225 extern PLogDouble wait_all_ct,allreduce_ct,sum_of_waits_ct; 226 /* 227 This does not work for MPI-Uni because our src/mpiuni/mpi.h file 228 uses macros to defined the MPI operations. 229 230 It does not work correctly from HP-UX because it processes the 231 macros in a way that sometimes it double counts. 232 233 It does not work with Windows NT because winmpich lacks MPI_Type_size() 234 */ 235 #if !defined(PETSC_USING_MPIUNI) && !defined(PARCH_hpux) && !defined (PARCH_nt) 236 /* 237 Logging of MPI activities 238 */ 239 240 #define TypeSize(buff,count,type) \ 241 { \ 242 if (type == MPIU_SCALAR) { \ 243 buff += (PLogDouble) ((count)*sizeof(Scalar)); \ 244 } else if (type == MPI_INT) { \ 245 buff += (PLogDouble) ((count)*sizeof(int)); \ 246 } else { \ 247 int _size; MPI_Type_size(type,&_size); buff += (PLogDouble) ((count)*_size); \ 248 } \ 249 } 250 251 #define MPI_Irecv( buf, count, datatype, source, tag, comm, request) \ 252 { \ 253 MPI_Irecv( buf, count, datatype, source, tag, comm, request); \ 254 irecv_ct++; TypeSize(irecv_len,count,datatype); \ 255 } 256 257 #define MPI_Isend( buf, count, datatype, dest, tag, comm, request) \ 258 { \ 259 MPI_Isend( buf, count, datatype, dest, tag, comm, request); \ 260 isend_ct++; TypeSize(isend_len,count,datatype); \ 261 } 262 263 #define MPI_Startall_irecv( count,number,requests) \ 264 { \ 265 MPI_Startall( number, requests); \ 266 irecv_ct += (PLogDouble)(number); irecv_len += (PLogDouble) (count*sizeof(Scalar)); \ 267 } 268 269 #define MPI_Startall_isend( count,number,requests) \ 270 { \ 271 MPI_Startall( number, requests); \ 272 isend_ct += (PLogDouble)(number); isend_len += (PLogDouble) (count*sizeof(Scalar)); \ 273 } 274 275 #define MPI_Start_isend(count, requests) \ 276 { \ 277 MPI_Start( requests); \ 278 isend_ct++; isend_len += (PLogDouble) (count*sizeof(Scalar)); \ 279 } 280 281 #define MPI_Recv( buf, count, datatype, source, tag, comm, status) \ 282 { \ 283 MPI_Recv( buf, count, datatype, source, tag, comm, status); \ 284 recv_ct++; TypeSize(recv_len,count,datatype); \ 285 } 286 287 #define MPI_Send( buf, count, datatype, dest, tag, comm) \ 288 { \ 289 MPI_Send( buf, count, datatype, dest, tag, comm); \ 290 send_ct++; TypeSize(send_len,count,datatype); \ 291 } 292 293 #define MPI_Wait(request, status) \ 294 ( \ 295 wait_ct++, sum_of_waits_ct++, \ 296 MPI_Wait(request, status) \ 297 ) 298 299 #define MPI_Waitany(a, b, c, d) \ 300 ( \ 301 wait_any_ct++, sum_of_waits_ct++, \ 302 MPI_Waitany(a, b, c, d) \ 303 ) 304 305 #define MPI_Waitall(count, array_of_requests, array_of_statuses) \ 306 ( \ 307 wait_all_ct++, sum_of_waits_ct += (PLogDouble) (count), \ 308 MPI_Waitall(count, array_of_requests, array_of_statuses) \ 309 ) 310 311 /* 312 If logging is turned on for MPI_ReduceSync then this logs 313 the time to synchronous and then the time to do the reduction. 314 */ 315 extern int PETSC_DUMMY; 316 #define MPI_Allreduce( sendbuf, recvbuf, count, datatype, op, comm) \ 317 (PETSC_DUMMY = 0); { \ 318 if (_PLogPLB && PLogEventFlags[MPI_ReduceSync]) { \ 319 PLogEventBegin(MPI_ReduceSync,0,0,0,0); \ 320 MPI_Barrier(comm); \ 321 PLogEventEnd(MPI_ReduceSync,0,0,0,0); \ 322 } \ 323 PLogEventBegin(MPI_ReduceComp,0,0,0,0); \ 324 allreduce_ct++; \ 325 MPI_Allreduce( sendbuf, recvbuf, count, datatype, op, comm); \ 326 PLogEventEnd(MPI_ReduceComp,0,0,0,0); \ 327 } 328 329 #else 330 331 #define MPI_Startall_irecv( count,number,requests) \ 332 { \ 333 MPI_Startall( number, requests); \ 334 } 335 336 #define MPI_Startall_isend( count,number,requests) \ 337 { \ 338 MPI_Startall( number, requests); \ 339 } 340 341 #define MPI_Start_isend(count, requests) \ 342 { \ 343 MPI_Start( requests); \ 344 } 345 346 #endif /* ! PETSC_USING_MPIUNI && ! PARCH_hpux */ 347 348 #else /* ------------------------------------------------------------*/ 349 350 #define PLogFlops(n) 351 352 #if defined (HAVE_MPE) 353 #define MPEBEGIN 1000 354 extern int PLogMPEBegin(); 355 extern int PLogMPEDump(char *); 356 #else 357 #define PLogEventMPEActivate(a) 0 358 #define PLogEventMPEDeactivate(a) 0 359 #endif 360 361 #define PLogEventActivate(a) 0 362 #define PLogEventDeactivate(a) 0 363 364 #define PLogEventActivateClass(a) 0 365 #define PLogEventDeactivateClass(a) 0 366 367 #define _PLogPLB 0 368 #define _PLogPLE 0 369 #define _PLogPHC 0 370 #define _PLogPHD 0 371 #define PetscGetFlops() 0.0 372 #define PLogEventBegin(e,o1,o2,o3,o4) 373 #define PLogEventEnd(e,o1,o2,o3,o4) 374 #define PLogObjectParent(p,c) 375 #define PLogObjectParents(p,n,c) 376 #define PLogObjectCreate(h) 377 #define PLogObjectDestroy(h) 378 #define PLogObjectMemory(p,m) 379 #define PLogDestroy() 380 #define PLogStagePush(a) 381 #define PLogStagePop() 382 #define PLogStageRegister(a,b) 383 #define PLogPrintSummary(comm,file) 384 #define PLogBegin() 385 #define PLogTraceBegin(file) 0 386 #define PLogSet(lb,le) 387 #define PLogAllBegin() 388 #define PLogDump(char) 389 #define PLogEventRegister(a,b,c) 0 390 #define PLogMPEBegin() 391 #define PLogMPEDump(a) 392 extern int PLogObjectState(PetscObject,char *,...); 393 394 /* If PETSC_LOG is NOT defined, these still need to be! */ 395 #define MPI_Startall_irecv( count,number,requests) \ 396 { \ 397 MPI_Startall( number, requests); \ 398 } 399 400 #define MPI_Startall_isend( count,number,requests) \ 401 { \ 402 MPI_Startall( number, requests); \ 403 } 404 405 #define MPI_Start_isend(count, requests) \ 406 { \ 407 MPI_Start( requests); \ 408 } 409 #endif /* PETSC_LOG */ 410 411 /*MC 412 PLogFlops - Adds floating point operations to the global counter. 413 414 Input Parameter: 415 . f - flop counter 416 417 Synopsis: 418 void PLogFlops(int f) 419 420 Notes: 421 A global counter logs all PETSc flop counts. The user can use 422 PLogFlops() to increment this counter to include flops for the 423 application code. 424 425 PETSc automatically logs library events if the code has been 426 compiled with -DPETSC_LOG (which is the default), and -log, 427 -log_summary, or -log_all are specified. PLogFlops() is 428 intended for logging user flops to supplement this PETSc 429 information. 430 431 Example of Usage: 432 $ int USER_EVENT; 433 $ PLogEventRegister(&USER_EVENT,"User event","Color:"); 434 $ PLogEventBegin(USER_EVENT,0,0,0,0); 435 $ [code segment to monitor] 436 $ PLogFlops(user_flops) 437 $ PLogEventEnd(USER_EVENT,0,0,0,0); 438 439 .seealso: PLogEventRegister(), PLogEventBegin(), PLogEventEnd(), PetscGetFlops() 440 441 .keywords: log, flops, floating point operations 442 M*/ 443 444 445 /*MC 446 PLogEventBegin - Logs the beginning of a user event. 447 448 Input Parameters: 449 . e - integer associated with the event obtained from PLogEventRegister() 450 . o1,o2,o3,o4 - objects associated with the event, or 0 451 452 Synopsis: 453 void PLogEventBegin(int e,PetscObject o1,PetscObject o2,PetscObject o3, 454 PetscObject o4) 455 456 Notes: 457 You should also register each integer event with the command 458 PLogRegisterEvent(). The source code must be compiled with 459 -DPETSC_LOG, which is the default. 460 461 PETSc automatically logs library events if the code has been 462 compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are 463 specified. PLogEventBegin() is intended for logging user events 464 to supplement this PETSc information. 465 466 Example of Usage: 467 $ int USER_EVENT; 468 $ int user_event_flops; 469 $ PLogEventRegister(&USER_EVENT,"User event","Color:"); 470 $ PLogEventBegin(&USER_EVENT,0,0,0,0); 471 $ [code segment to monitor] 472 $ PLogFlops(user_event_flops); 473 $ PLogEventEnd(&USER_EVENT,0,0,0,0); 474 475 .seealso: PLogEventRegister(), PLogEventEnd(), PLogFlops() 476 477 .keywords: log, event, begin 478 M*/ 479 480 /*MC 481 PLogEventEnd - Log the end of a user event. 482 483 Input Parameters: 484 . e - integer associated with the event obtained with PLogEventRegister() 485 . o1,o2,o3,o4 - objects associated with the event, or 0 486 487 Synopsis: 488 void PLogEventEnd(int e,PetscObject o1,PetscObject o2,PetscObject o3, 489 PetscObject o4) 490 491 Notes: 492 You should also register each additional integer event with the command 493 PLogRegisterEvent(). Source code must be compiled with 494 -DPETSC_LOG, which is the default. 495 496 PETSc automatically logs library events if the code has been 497 compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are 498 specified. PLogEventEnd() is intended for logging user events 499 to supplement this PETSc information. 500 501 Example of Usage: 502 $ int USER_EVENT; 503 $ int user_event_flops; 504 $ PLogEventRegister(&USER_EVENT,"User event","Color:"); 505 $ PLogEventBegin(USER_EVENT,0,0,0,0); 506 $ [code segment to monitor] 507 $ PLogFlops(user_event_flops); 508 $ PLogEventEnd(USER_EVENT,0,0,0,0); 509 510 .seealso: PLogEventRegister(), PLogEventBegin(), PLogFlops() 511 512 .keywords: log, event, end 513 M*/ 514 515 516 #endif 517 518 519 520 521 522 523