1 /* $Id: plog.h,v 1.75 1996/07/12 22:29:29 bsmith Exp curfman $ */ 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 #if !defined(PETSC_USING_MPIUNI) 206 /* 207 Logging of MPI activities 208 */ 209 extern double irecv_ct,isend_ct,wait_ct,wait_any_ct; 210 extern double irecv_len,isend_len; 211 extern double wait_all_ct,allreduce_ct; 212 213 #define TypeSize(buff,count,type) \ 214 { \ 215 if (type == MPIU_SCALAR) { \ 216 buff += count*sizeof(Scalar); \ 217 } else if (type == MPI_INT) { \ 218 buff += count*sizeof(int); \ 219 } else { \ 220 int _size; MPI_Type_size(type,&_size); buff += count*_size; \ 221 } \ 222 } 223 224 225 #define MPI_Irecv( buf, count, datatype, source, tag, comm, request) \ 226 { \ 227 MPI_Irecv( buf, count, datatype, source, tag, comm, request); \ 228 irecv_ct++; TypeSize(irecv_len,count,datatype); \ 229 } 230 231 #define MPI_Recv( buf, count, datatype, source, tag, comm, status) \ 232 { \ 233 MPI_Recv( buf, count, datatype, source, tag, comm, status); \ 234 irecv_ct++; TypeSize(irecv_len,count,datatype); \ 235 } 236 237 #define MPI_Isend( buf, count, datatype, dest, tag, comm, request) \ 238 { \ 239 MPI_Isend( buf, count, datatype, dest, tag, comm, request); \ 240 isend_ct++; TypeSize(irecv_len,count,datatype); \ 241 } 242 243 #define MPI_Send( buf, count, datatype, dest, tag, comm) \ 244 { \ 245 MPI_Send( buf, count, datatype, dest, tag, comm); \ 246 isend_ct++; TypeSize(irecv_len,count,datatype); \ 247 } 248 249 250 #define MPI_Wait(request, status) \ 251 ( \ 252 wait_ct++, \ 253 MPI_Wait(request, status) \ 254 ) 255 256 #define MPI_Waitany(a, b, c, d) \ 257 ( \ 258 wait_any_ct++, \ 259 MPI_Waitany(a, b, c, d)\ 260 ) 261 262 #define MPI_Waitall(count, array_of_requests, array_of_statuses) \ 263 ( \ 264 wait_all_ct++, \ 265 MPI_Waitall(count, array_of_requests, array_of_statuses) \ 266 ) 267 268 #define MPI_Allreduce( sendbuf, recvbuf, count, datatype, op, comm) \ 269 ( \ 270 allreduce_ct++, \ 271 MPI_Allreduce( sendbuf, recvbuf, count, datatype, op, comm) \ 272 ) 273 #endif /* ! PETSC_USING_MPIUNI */ 274 275 #else /* ------------------------------------------------------------*/ 276 277 #define PLogFlops(n) 278 279 #if defined (HAVE_MPE) 280 #define MPEBEGIN 1000 281 extern int PLogMPEBegin(); 282 extern int PLogMPEDump(char *); 283 #else 284 #define PLogEventMPEActivate(a) 285 #define PLogEventMPEDeActivate(a) 286 #endif 287 288 #define PLogEventActivate(a) 289 #define PLogEventDeActivate(a) 290 291 #define PLogEventActivateClass() 292 #define PLogEventDeActivateClass() 293 294 #define _PLB 0 295 #define _PLE 0 296 #define _PHC 0 297 #define _PHD 0 298 #define PLogEventBegin(e,o1,o2,o3,o4) 299 #define PLogEventEnd(e,o1,o2,o3,o4) 300 #define PLogObjectParent(p,c) 301 #define PLogObjectParents(p,n,c) 302 #define PLogObjectCreate(h) 303 #define PLogObjectDestroy(h) 304 #define PLogObjectMemory(p,m) 305 #define PLogDestroy() 306 #define PLogStagePush(int) 307 #define PLogStagePop() 308 #define PLogStageRegister(a,b) 309 #define PLogPrintSummary(comm,file) 310 #define PLogBegin() 311 #define PLogAllBegin() 312 #define PLogDump(char) 313 #define PLogEventRegister(a,b,c) 314 #define PLogMPEBegin() 315 #define PLogMPEDump(a) 316 extern int PLogObjectState(PetscObject,char *,...); 317 318 #endif 319 320 /*MC 321 PLogFlops - Adds floating point operations to the global counter. 322 323 Input Parameter: 324 . f - flop counter 325 326 Synopsis: 327 void PLogFlops(int f) 328 329 Notes: 330 A global counter logs all PETSc flop counts. The user can use 331 PLogFlops() to increment this counter to include flops for the 332 application code. 333 334 PETSc automatically logs library events if the code has been 335 compiled with -DPETSC_LOG (which is the default), and -log, 336 -log_summary, or -log_all are specified. PLogFlops() is 337 intended for logging user flops to supplement this PETSc 338 information. 339 340 Example of Usage: 341 $ int USER_EVENT; 342 $ PLogEventRegister(&USER_EVENT,"User event","Color:"); 343 $ PLogEventBegin(USER_EVENT,0,0,0,0); 344 $ [code segment to monitor] 345 $ PLogFlops(user_flops) 346 $ PLogEventEnd(USER_EVENT,0,0,0,0); 347 348 .seealso: PLogEventRegister(), PLogEventBegin(), PLogEventEnd(), PetscGetFlops() 349 350 .keywords: log, flops, floating point operations 351 M*/ 352 353 354 /*MC 355 PLogEventBegin - Logs the beginning of a user event. 356 357 Input Parameters: 358 . e - integer associated with the event obtained from PLogEventRegister() 359 . o1,o2,o3,o4 - objects associated with the event, or 0 360 361 Synopsis: 362 void PLogEventBegin(int e,PetscObject o1,PetscObject o2,PetscObject o3, 363 PetscObject o4) 364 365 Notes: 366 You should also register each integer event with the command 367 PLogRegisterEvent(). The source code must be compiled with 368 -DPETSC_LOG, which is the default. 369 370 PETSc automatically logs library events if the code has been 371 compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are 372 specified. PLogEventBegin() is intended for logging user events 373 to supplement this PETSc information. 374 375 Example of Usage: 376 $ int USER_EVENT; 377 $ int user_event_flops; 378 $ PLogEventRegister(&USER_EVENT,"User event","Color:"); 379 $ PLogEventBegin(&USER_EVENT,0,0,0,0); 380 $ [code segment to monitor] 381 $ PLogFlops(user_event_flops); 382 $ PLogEventEnd(&USER_EVENT,0,0,0,0); 383 384 .seealso: PLogEventRegister(), PLogEventEnd(), PLogFlops() 385 386 .keywords: log, event, begin 387 M*/ 388 389 /*MC 390 PLogEventEnd - Log the end of a user event. 391 392 Input Parameters: 393 . e - integer associated with the event obtained with PLogEventRegister() 394 . o1,o2,o3,o4 - objects associated with the event, or 0 395 396 Synopsis: 397 void PLogEventEnd(int e,PetscObject o1,PetscObject o2,PetscObject o3, 398 PetscObject o4) 399 400 Notes: 401 You should also register each integer event with the command 402 PLogRegisterEvent(). Source code must be compiled with 403 -DPETSC_LOG, which is the default. 404 405 PETSc automatically logs library events if the code has been 406 compiled with -DPETSC_LOG, and -log, -log_summary, or -log_all are 407 specified. PLogEventEnd() is intended for logging user events 408 to supplement this PETSc information. 409 410 Example of Usage: 411 $ int USER_EVENT; 412 $ int user_event_flops; 413 $ PLogEventRegister(&USER_EVENT,"User event","Color:"); 414 $ PLogEventBegin(USER_EVENT,0,0,0,0); 415 $ [code segment to monitor] 416 $ PLogFlops(user_event_flops); 417 $ PLogEventEnd(USER_EVENT,0,0,0,0); 418 419 .seealso: PLogEventRegister(), PLogEventBegin(), PLogFlops() 420 421 .keywords: log, event, end 422 M*/ 423 424 #endif 425 426 427 428