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