1 /* $Id: petsclog.h,v 1.128 1999/03/17 23:25:44 bsmith Exp bsmith $ */ 2 3 /* 4 Defines profile/logging in PETSc. 5 */ 6 7 #if !defined(__PLOG_H) 8 #define __PLOG_H 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_GetOrdering 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 #define MAT_Partitioning 36 58 59 #define VEC_ReduceArithmetic 37 60 #define VEC_ReduceCommunication 38 61 #define VEC_ScatterBarrier 39 62 #define VEC_Dot 40 63 #define VEC_Norm 41 64 #define VEC_Max 42 65 #define VEC_Min 43 66 #define VEC_TDot 44 67 #define VEC_Scale 45 68 #define VEC_Copy 46 69 #define VEC_Set 47 70 #define VEC_AXPY 48 71 #define VEC_AYPX 49 72 #define VEC_Swap 50 73 #define VEC_WAXPY 51 74 #define VEC_AssemblyBegin 52 75 #define VEC_AssemblyEnd 53 76 #define VEC_MTDot 54 77 #define VEC_MDot 55 78 #define VEC_MAXPY 56 79 #define VEC_PMult 57 80 #define VEC_SetValues 58 81 #define VEC_Load 59 82 #define VEC_View 60 83 #define VEC_ScatterBegin 61 84 #define VEC_ScatterEnd 62 85 #define VEC_SetRandom 63 86 87 #define VEC_NormBarrier 64 88 #define VEC_NormComm 65 89 #define VEC_DotBarrier 66 90 #define VEC_DotComm 67 91 #define VEC_MDotBarrier 68 92 #define VEC_MDotComm 69 93 94 #define SLES_Solve 70 95 #define SLES_SetUp 71 96 97 #define KSP_GMRESOrthogonalization 72 98 99 #define PC_ModifySubMatrices 74 100 #define PC_SetUp 75 101 #define PC_SetUpOnBlocks 76 102 #define PC_Apply 77 103 #define PC_ApplySymmetricLeft 78 104 #define PC_ApplySymmetricRight 79 105 106 #define SNES_Solve 80 107 #define SNES_LineSearch 81 108 #define SNES_FunctionEval 82 109 #define SNES_JacobianEval 83 110 #define SNES_MinimizationFunctionEval 84 111 #define SNES_GradientEval 85 112 #define SNES_HessianEval 86 113 114 #define VEC_ReduceBarrier 87 115 #define VEC_ReduceCommOnly 88 116 117 #define TS_Step 90 118 #define TS_PseudoComputeTimeStep 91 119 120 #define Petsc_Barrier 100 121 122 #define EC_SetUp 105 123 #define EC_Solve 106 124 125 /* 126 Event numbers PLOG_USER_EVENT_LOW to PLOG_USER_EVENT_HIGH are reserved 127 for applications. Make sure that src/plog/src/plog.c defines enough 128 entries in (*name)[] to go up to PLOG_USER_EVENT_HIGH. 129 */ 130 #define PLOG_USER_EVENT_LOW_STATIC 120 131 #define PLOG_USER_EVENT_HIGH 200 132 133 /* Global flop counter */ 134 extern PLogDouble _TotalFlops; 135 136 /* General logging of information; different from event logging */ 137 extern int PLogInfo(void*,const char[],...); 138 extern int PLogInfoDeactivateClass(int); 139 extern int PLogInfoActivateClass(int); 140 extern int PLogPrintInfo; /* if 1, indicates PLogInfo() is turned on */ 141 142 #if defined(PETSC_USE_LOG) /* --- Logging is turned on --------------------------------*/ 143 144 /* 145 Flop counting: We count each arithmetic operation (e.g., addition, multiplication) separately. 146 147 For the complex numbers version, note that 148 1 complex addition = 2 flops 149 1 complex multiplication = 6 flops, 150 where we define 1 flop as that for a double precision scalar. We roughly approximate 151 flop counting for complex numbers by multiplying the total flops by 4; this corresponds 152 to the assumption that we're counting mostly additions and multiplications -- and 153 roughly the same number of each. More accurate counting could be done by distinguishing 154 among the various arithmetic operations. 155 */ 156 157 #if defined(PETSC_USE_COMPLEX) 158 #define PLogFlops(n) {_TotalFlops += (4*n);} 159 #else 160 #define PLogFlops(n) {_TotalFlops += (n);} 161 #endif 162 163 #if defined (PETSC_HAVE_MPE) 164 #include "mpe.h" 165 #define MPEBEGIN 1000 166 extern int PLogMPEBegin(void); 167 extern int PLogMPEDump(const char[]); 168 extern int UseMPE,PLogEventMPEFlags[]; 169 extern int PLogEventMPEActivate(int); 170 extern int PLogEventMPEDeactivate(int); 171 #else 172 #define PLogEventMPEActivate(a) 0 173 #define PLogEventMPEDeactivate(a) 0 174 #endif 175 176 extern int PLogEventActivate(int); 177 extern int PLogEventDeactivate(int); 178 179 extern int PLogEventActivateClass(int); 180 extern int PLogEventDeactivateClass(int); 181 182 extern int PLogEventFlags[]; 183 extern int (*_PLogPLB)(int,int,PetscObject,PetscObject,PetscObject,PetscObject); 184 extern int (*_PLogPLE)(int,int,PetscObject,PetscObject,PetscObject,PetscObject); 185 extern int (*_PLogPHC)(PetscObject); 186 extern int (*_PLogPHD)(PetscObject); 187 188 #if defined(PETSC_HAVE_MPE) 189 #define PLogEventBarrierBegin(e,o1,o2,o3,o4,cm) \ 190 { \ 191 if (_PLogPLB && PLogEventFlags[e]) { \ 192 PLogEventBegin((e),o1,o2,o3,o4); \ 193 if (UseMPE && PLogEventMPEFlags[(e)])\ 194 MPE_Log_event(MPEBEGIN+2*(e),0,"");\ 195 MPI_Barrier(cm); \ 196 PLogEventEnd((e),o1,o2,o3,o4); \ 197 if (UseMPE && PLogEventMPEFlags[(e)])\ 198 MPE_Log_event(MPEBEGIN+2*((e)+1),0,"");\ 199 } \ 200 PLogEventBegin(e+1,o1,o2,o3,o4); \ 201 if (UseMPE && PLogEventMPEFlags[(e)+1])\ 202 MPE_Log_event(MPEBEGIN+2*((e)+1),0,"");\ 203 } 204 #define PLogEventBegin(e,o1,o2,o3,o4) \ 205 { \ 206 if (_PLogPLB && PLogEventFlags[(e)]) \ 207 (*_PLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 208 if (UseMPE && PLogEventMPEFlags[(e)])\ 209 MPE_Log_event(MPEBEGIN+2*(e),0,"");\ 210 } 211 #else 212 #define PLogEventBarrierBegin(e,o1,o2,o3,o4,cm) \ 213 { \ 214 if (_PLogPLB && PLogEventFlags[(e)]) { \ 215 PLogEventBegin((e),o1,o2,o3,o4); \ 216 MPI_Barrier(cm); \ 217 PLogEventEnd((e),o1,o2,o3,o4); \ 218 } \ 219 PLogEventBegin((e)+1,o1,o2,o3,o4); \ 220 } 221 #define PLogEventBegin(e,o1,o2,o3,o4) \ 222 { \ 223 if (_PLogPLB && PLogEventFlags[(e)]) \ 224 (*_PLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 225 } 226 #endif 227 228 #if defined(PETSC_HAVE_MPE) 229 #define PLogEventBarrierEnd(e,o1,o2,o3,o4,cm) {\ 230 if (_PLogPLE && PLogEventFlags[(e)+1]) \ 231 (*_PLogPLE)((e)+1,0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 232 if (UseMPE && PLogEventMPEFlags[(e)+1])\ 233 MPE_Log_event(MPEBEGIN+2*((e)+1)+1,0,"");\ 234 } 235 #define PLogEventEnd(e,o1,o2,o3,o4) {\ 236 if (_PLogPLE && PLogEventFlags[(e)]) \ 237 (*_PLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 238 if (UseMPE && PLogEventMPEFlags[(e)])\ 239 MPE_Log_event(MPEBEGIN+2*(e)+1,0,"");\ 240 } 241 #else 242 #define PLogEventBarrierEnd(e,o1,o2,o3,o4,cm) {\ 243 if (_PLogPLE && PLogEventFlags[(e)+1]) \ 244 (*_PLogPLE)((e)+1,0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 245 } 246 #define PLogEventEnd(e,o1,o2,o3,o4) {\ 247 if (_PLogPLE && PLogEventFlags[(e)]) \ 248 (*_PLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 249 } 250 #endif 251 252 253 #define PLogObjectParent(p,c) if (c) {PetscValidHeader((PetscObject)(c)); \ 254 PetscValidHeader((PetscObject)(p));\ 255 ((PetscObject)(c))->parent = (PetscObject) (p);\ 256 ((PetscObject)(c))->parentid = ((PetscObject) p)->id;} 257 #define PLogObjectParents(p,n,d) {int _i; for ( _i=0; _i<n; _i++ ) \ 258 PLogObjectParent(p,(d)[_i]);} 259 #define PLogObjectCreate(h) {if (_PLogPHC) (*_PLogPHC)((PetscObject)h);} 260 #define PLogObjectDestroy(h) {if (_PLogPHD) (*_PLogPHD)((PetscObject)h);} 261 #define PLogObjectMemory(p,m) {PetscValidHeader((PetscObject)p);\ 262 ((PetscObject)(p))->mem += (m);} 263 extern int PLogObjectState(PetscObject,const char[],...); 264 extern int PLogDestroy(void); 265 extern int PLogStagePush(int); 266 extern int PLogStagePop(void); 267 extern int PLogStageRegister(int,const char[]); 268 extern int PLogPrintSummary(MPI_Comm,const char[]); 269 extern int PLogBegin(void); 270 extern int PLogTraceBegin(FILE *); 271 extern int PLogAllBegin(void); 272 extern int PLogSet(int (*)(int,int,PetscObject,PetscObject,PetscObject,PetscObject), 273 int (*)(int,int,PetscObject,PetscObject,PetscObject,PetscObject)); 274 extern int PLogDump(const char[]); 275 extern int PLogEventRegister(int*,const char[],const char[]); 276 extern int PetscGetFlops(PLogDouble*); 277 278 extern PLogDouble irecv_ct, isend_ct, wait_ct, wait_any_ct, recv_ct, send_ct; 279 extern PLogDouble irecv_len, isend_len, recv_len, send_len; 280 extern PLogDouble wait_all_ct,allreduce_ct,sum_of_waits_ct; 281 extern int PETSC_DUMMY,PETSC_DUMMY_SIZE; 282 283 /* 284 This does not work for MPI-Uni because our src/mpiuni/mpi.h file 285 uses macros to defined the MPI operations. 286 287 It does not work correctly from HP-UX because it processes the 288 macros in a way that sometimes it double counts, hence 289 PETSC_HAVE_BROKEN_RECURSIVE_MACRO 290 291 It does not work with Windows NT because winmpich lacks MPI_Type_size() 292 */ 293 #if !defined(USING_MPIUNI) && !defined(PETSC_HAVE_BROKEN_RECURSIVE_MACRO) 294 /* 295 Logging of MPI activities 296 */ 297 298 #define TypeSize(buff,count,type) \ 299 ( \ 300 MPI_Type_size(type,&PETSC_DUMMY_SIZE), buff += ((PLogDouble) ((count)*PETSC_DUMMY_SIZE)) \ 301 ) 302 303 #define MPI_Irecv( buf, count, datatype, source, tag, comm, request) \ 304 ( \ 305 PETSC_DUMMY = MPI_Irecv( buf, count, datatype, source, tag, comm, request), \ 306 irecv_ct++, TypeSize(irecv_len,count,datatype),PETSC_DUMMY \ 307 ) 308 309 #define MPI_Isend( buf, count, datatype, dest, tag, comm, request) \ 310 ( \ 311 PETSC_DUMMY = MPI_Isend( buf, count, datatype, dest, tag, comm, request), \ 312 isend_ct++, TypeSize(isend_len,count,datatype),PETSC_DUMMY \ 313 ) 314 315 #define MPI_Startall_irecv( count,number,requests) \ 316 ( \ 317 PETSC_DUMMY = MPI_Startall( number, requests), \ 318 irecv_ct += (PLogDouble)(number), irecv_len += ((PLogDouble) (count*sizeof(Scalar))),PETSC_DUMMY \ 319 ) 320 321 #define MPI_Startall_isend( count,number,requests) \ 322 ( \ 323 PETSC_DUMMY = MPI_Startall( number, requests), \ 324 isend_ct += (PLogDouble)(number), isend_len += ((PLogDouble) (count*sizeof(Scalar))),PETSC_DUMMY \ 325 ) 326 327 #define MPI_Start_isend(count, requests)\ 328 (\ 329 PETSC_DUMMY = MPI_Start( requests),\ 330 isend_ct++, isend_len += ((PLogDouble) (count*sizeof(Scalar))),PETSC_DUMMY\ 331 ) 332 333 #define MPI_Recv( buf, count, datatype, source, tag, comm, status) \ 334 ( \ 335 PETSC_DUMMY = MPI_Recv( buf, count, datatype, source, tag, comm, status), \ 336 recv_ct++, TypeSize(recv_len,count,datatype), PETSC_DUMMY \ 337 ) 338 339 #define MPI_Send( buf, count, datatype, dest, tag, comm) \ 340 ( \ 341 PETSC_DUMMY = MPI_Send( buf, count, datatype, dest, tag, comm), \ 342 send_ct++, TypeSize(send_len,count,datatype),PETSC_DUMMY \ 343 ) 344 345 #define MPI_Wait(request, status) \ 346 ( \ 347 wait_ct++, sum_of_waits_ct++, \ 348 MPI_Wait(request, status) \ 349 ) 350 351 #define MPI_Waitany(a, b, c, d) \ 352 ( \ 353 wait_any_ct++, sum_of_waits_ct++, \ 354 MPI_Waitany(a, b, c, d) \ 355 ) 356 357 #define MPI_Waitall(count, array_of_requests, array_of_statuses) \ 358 ( \ 359 wait_all_ct++, sum_of_waits_ct += (PLogDouble) (count), \ 360 MPI_Waitall(count, array_of_requests, array_of_statuses) \ 361 ) 362 363 #define MPI_Allreduce( sendbuf, recvbuf, count, datatype, op, comm) \ 364 (allreduce_ct++,MPI_Allreduce( sendbuf, recvbuf, count, datatype, op, comm)) 365 366 #else 367 368 #define MPI_Startall_irecv( count,number,requests) \ 369 ( \ 370 MPI_Startall( number, requests) \ 371 ) 372 373 #define MPI_Startall_isend( count,number,requests) \ 374 ( \ 375 MPI_Startall( number, requests) \ 376 ) 377 378 #define MPI_Start_isend(count, requests) \ 379 ( \ 380 MPI_Start( requests) \ 381 ) 382 383 #endif /* !USING_MPIUNI && ! PETSC_HAVE_BROKEN_RECURSIVE_MACRO */ 384 385 #else /* ---Logging is turned off --------------------------------------------*/ 386 387 #define PLogFlops(n) 388 389 /* 390 With logging turned off, then MPE has to be turned off 391 */ 392 #define MPEBEGIN 1000 393 #define PLogMPEBegin() 394 #define PLogMPEDump(a) 395 #define PLogEventMPEActivate(a) 0 396 #define PLogEventMPEDeactivate(a) 0 397 398 #define PLogEventActivate(a) 0 399 #define PLogEventDeactivate(a) 0 400 401 #define PLogEventActivateClass(a) 0 402 #define PLogEventDeactivateClass(a) 0 403 404 #define _PLogPLB 0 405 #define _PLogPLE 0 406 #define _PLogPHC 0 407 #define _PLogPHD 0 408 #define PetscGetFlops(a) (*(a) = 0.0,0) 409 #define PLogEventBegin(e,o1,o2,o3,o4) 410 #define PLogEventEnd(e,o1,o2,o3,o4) 411 #define PLogEventBarrierBegin(e,o1,o2,o3,o4,cm) 412 #define PLogEventBarrierEnd(e,o1,o2,o3,o4,cm) 413 #define PLogObjectParent(p,c) 414 #define PLogObjectParents(p,n,c) 415 #define PLogObjectCreate(h) 416 #define PLogObjectDestroy(h) 417 #define PLogObjectMemory(p,m) 418 #define PLogDestroy() 419 #define PLogStagePush(a) 420 #define PLogStagePop() 421 #define PLogStageRegister(a,b) 422 #define PLogPrintSummary(comm,file) 423 #define PLogBegin() 424 #define PLogTraceBegin(file) 0 425 #define PLogSet(lb,le) 426 #define PLogAllBegin() 427 #define PLogDump(c) 428 #define PLogEventRegister(a,b,c) 0 429 #define PLogMPEBegin() 430 #define PLogMPEDump(a) 431 extern int PLogObjectState(PetscObject,const char[],...); 432 433 /* If PETSC_USE_LOG is NOT defined, these still need to be! */ 434 #define MPI_Startall_irecv( count,number,requests) MPI_Startall( number, requests) 435 436 #define MPI_Startall_isend( count,number,requests) MPI_Startall( number, requests) 437 438 #define MPI_Start_isend(count, requests) MPI_Start( requests) 439 440 #endif /* PETSC_USE_LOG */ 441 442 443 #endif 444 445 446 447 448 449 450