1 /* $Id: petsclog.h,v 1.135 2000/01/10 23:37:17 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/src/plog/src/plog.c, 16 petsc/src/plog/src/plogmpe.c, and 17 petsc/include/finclude/petsclog.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_GetOrdering 4 24 #define MAT_MultTranspose 5 25 #define MAT_MultAdd 6 26 #define MAT_MultTransposeAdd 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_SolveTranspose 23 43 #define MAT_SolveTransposeAdd 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_GetColoring 31 51 #define MAT_GetSubMatrices 32 52 #define MAT_GetValues 33 53 #define MAT_IncreaseOverlap 34 54 #define MAT_GetRow 35 55 #define MAT_Partitioning 36 56 57 #define VEC_ReduceArithmetic 37 58 #define VEC_ReduceCommunication 38 59 #define VEC_ScatterBarrier 39 60 #define VEC_Dot 40 61 #define VEC_Norm 41 62 #define VEC_Max 42 63 #define VEC_Min 43 64 #define VEC_TDot 44 65 #define VEC_Scale 45 66 #define VEC_Copy 46 67 #define VEC_Set 47 68 #define VEC_AXPY 48 69 #define VEC_AYPX 49 70 #define VEC_Swap 50 71 #define VEC_WAXPY 51 72 #define VEC_AssemblyBegin 52 73 #define VEC_AssemblyEnd 53 74 #define VEC_MTDot 54 75 #define VEC_MDot 55 76 #define VEC_MAXPY 56 77 #define VEC_PMult 57 78 #define VEC_SetValues 58 79 #define VEC_Load 59 80 #define VEC_View 60 81 #define VEC_ScatterBegin 61 82 #define VEC_ScatterEnd 62 83 #define VEC_SetRandom 63 84 85 #define VEC_NormBarrier 64 86 #define VEC_NormComm 65 87 #define VEC_DotBarrier 66 88 #define VEC_DotComm 67 89 #define VEC_MDotBarrier 68 90 #define VEC_MDotComm 69 91 92 #define SLES_Solve 70 93 #define SLES_SetUp 71 94 95 #define KSP_GMRESOrthogonalization 72 96 97 #define PC_ModifySubMatrices 74 98 #define PC_SetUp 75 99 #define PC_SetUpOnBlocks 76 100 #define PC_Apply 77 101 #define PC_ApplySymmetricLeft 78 102 #define PC_ApplySymmetricRight 79 103 104 #define SNES_Solve 80 105 #define SNES_LineSearch 81 106 #define SNES_FunctionEval 82 107 #define SNES_JacobianEval 83 108 #define SNES_MinimizationFunctionEval 84 109 #define SNES_GradientEval 85 110 #define SNES_HessianEval 86 111 112 #define VEC_ReduceBarrier 87 113 #define VEC_ReduceCommOnly 88 114 115 #define TS_Step 90 116 #define TS_PseudoComputeTimeStep 91 117 #define TS_FunctionEval 92 118 #define TS_JacobianEval 93 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 PetscTruth 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 extern PetscTruth PLogEventDepth[]; 189 190 #if defined(PETSC_HAVE_MPE) 191 #define PLogEventBarrierBegin(e,o1,o2,o3,o4,cm) \ 192 { \ 193 if (_PLogPLB && PLogEventFlags[e]) { \ 194 PLogEventBegin((e),o1,o2,o3,o4); \ 195 if (UseMPE && PLogEventMPEFlags[(e)])\ 196 MPE_Log_event(MPEBEGIN+2*(e),0,"");\ 197 MPI_Barrier(cm); \ 198 PLogEventEnd((e),o1,o2,o3,o4); \ 199 if (UseMPE && PLogEventMPEFlags[(e)])\ 200 MPE_Log_event(MPEBEGIN+2*((e)+1),0,"");\ 201 } \ 202 PLogEventBegin(e+1,o1,o2,o3,o4); \ 203 if (UseMPE && PLogEventMPEFlags[(e)+1])\ 204 MPE_Log_event(MPEBEGIN+2*((e)+1),0,"");\ 205 } 206 #define PLogEventBegin(e,o1,o2,o3,o4) \ 207 { \ 208 if (_PLogPLB && PLogEventFlags[(e)] && !PLogEventDepth[e]) {\ 209 PLogEventDepth[e] = PETSC_TRUE; \ 210 (*_PLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));}\ 211 if (UseMPE && PLogEventMPEFlags[(e)])\ 212 MPE_Log_event(MPEBEGIN+2*(e),0,"");\ 213 } 214 #else 215 #define PLogEventBarrierBegin(e,o1,o2,o3,o4,cm) \ 216 { \ 217 if (_PLogPLB && PLogEventFlags[(e)]) { \ 218 PLogEventBegin((e),o1,o2,o3,o4); \ 219 MPI_Barrier(cm); \ 220 PLogEventEnd((e),o1,o2,o3,o4); \ 221 } \ 222 PLogEventBegin((e)+1,o1,o2,o3,o4); \ 223 } 224 #define PLogEventBegin(e,o1,o2,o3,o4) \ 225 { \ 226 if (_PLogPLB && PLogEventFlags[(e)] && !PLogEventDepth[e]) {\ 227 PLogEventDepth[e] = PETSC_TRUE; \ 228 (*_PLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));}\ 229 } 230 #endif 231 232 #if defined(PETSC_HAVE_MPE) 233 #define PLogEventBarrierEnd(e,o1,o2,o3,o4,cm) {\ 234 if (_PLogPLE && PLogEventFlags[(e)+1]) {\ 235 (*_PLogPLE)((e)+1,0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 236 if (UseMPE && PLogEventMPEFlags[(e)+1])\ 237 MPE_Log_event(MPEBEGIN+2*((e)+1)+1,0,"");\ 238 } 239 #define PLogEventEnd(e,o1,o2,o3,o4) {\ 240 if (_PLogPLE && PLogEventFlags[(e)]) {\ 241 (*_PLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 242 PLogEventDepth[e] = PETSC_FALSE; }\ 243 if (UseMPE && PLogEventMPEFlags[(e)])\ 244 MPE_Log_event(MPEBEGIN+2*(e)+1,0,"");\ 245 } 246 #else 247 #define PLogEventBarrierEnd(e,o1,o2,o3,o4,cm) {\ 248 if (_PLogPLE && PLogEventFlags[(e)+1]) {\ 249 (*_PLogPLE)((e)+1,0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 250 } 251 #define PLogEventEnd(e,o1,o2,o3,o4) {\ 252 if (_PLogPLE && PLogEventFlags[(e)]) {\ 253 (*_PLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));\ 254 PLogEventDepth[e] = PETSC_FALSE; }\ 255 } 256 #endif 257 258 #define PLogObjectParent(p,c) if (c) {PetscValidHeader((PetscObject)(c)); \ 259 PetscValidHeader((PetscObject)(p));\ 260 ((PetscObject)(c))->parent = (PetscObject)(p);\ 261 ((PetscObject)(c))->parentid = ((PetscObject)p)->id;} 262 #define PLogObjectParents(p,n,d) {int _i; for (_i=0; _i<n; _i++) \ 263 PLogObjectParent(p,(d)[_i]);} 264 #define PLogObjectCreate(h) {if (_PLogPHC) (*_PLogPHC)((PetscObject)h);} 265 #define PLogObjectDestroy(h) {if (_PLogPHD) (*_PLogPHD)((PetscObject)h);} 266 #define PLogObjectMemory(p,m) {PetscValidHeader((PetscObject)p);\ 267 ((PetscObject)(p))->mem += (m);} 268 extern int PLogObjectState(PetscObject,const char[],...); 269 extern int PLogDestroy(void); 270 extern int PLogStagePush(int); 271 extern int PLogStagePop(void); 272 extern int PLogStageRegister(int,const char[]); 273 extern int PLogPrintSummary(MPI_Comm,const char[]); 274 extern int PLogBegin(void); 275 extern int PLogTraceBegin(FILE *); 276 extern int PLogAllBegin(void); 277 extern int PLogSet(int (*)(int,int,PetscObject,PetscObject,PetscObject,PetscObject), 278 int (*)(int,int,PetscObject,PetscObject,PetscObject,PetscObject)); 279 extern int PLogDump(const char[]); 280 extern int PLogEventRegister(int*,const char[],const char[]); 281 extern int PetscGetFlops(PLogDouble*); 282 283 extern PLogDouble irecv_ct,isend_ct,wait_ct,wait_any_ct,recv_ct,send_ct; 284 extern PLogDouble irecv_len,isend_len,recv_len,send_len; 285 extern PLogDouble wait_all_ct,allreduce_ct,sum_of_waits_ct; 286 extern int PETSC_DUMMY,PETSC_DUMMY_SIZE; 287 288 /* 289 This does not work for MPI-Uni because our src/mpiuni/mpi.h file 290 uses macros to defined the MPI operations. 291 292 It does not work correctly from HP-UX because it processes the 293 macros in a way that sometimes it double counts, hence 294 PETSC_HAVE_BROKEN_RECURSIVE_MACRO 295 296 It does not work with Windows NT because winmpich lacks MPI_Type_size() 297 */ 298 #if !defined(USING_MPIUNI) && !defined(PETSC_HAVE_BROKEN_RECURSIVE_MACRO) && !defined (PETSC_HAVE_MPI_MISSING_TYPESIZE) 299 /* 300 Logging of MPI activities 301 */ 302 303 #define TypeSize(buff,count,type) \ 304 (\ 305 MPI_Type_size(type,&PETSC_DUMMY_SIZE),buff += ((PLogDouble) ((count)*PETSC_DUMMY_SIZE)) \ 306 ) 307 308 #define MPI_Irecv(buf,count, datatype,source,tag,comm,request) \ 309 (\ 310 PETSC_DUMMY = MPI_Irecv(buf,count, datatype,source,tag,comm,request), \ 311 irecv_ct++,TypeSize(irecv_len,count,datatype),PETSC_DUMMY \ 312 ) 313 314 #define MPI_Isend(buf,count, datatype,dest,tag,comm,request) \ 315 (\ 316 PETSC_DUMMY = MPI_Isend(buf,count, datatype,dest,tag,comm,request), \ 317 isend_ct++, TypeSize(isend_len,count,datatype),PETSC_DUMMY \ 318 ) 319 320 #define MPI_Startall_irecv(count,number,requests) \ 321 (\ 322 PETSC_DUMMY = MPI_Startall(number,requests), \ 323 irecv_ct += (PLogDouble)(number),irecv_len += ((PLogDouble) (count*sizeof(Scalar))),PETSC_DUMMY \ 324 ) 325 326 #define MPI_Startall_isend(count,number,requests) \ 327 (\ 328 PETSC_DUMMY = MPI_Startall(number,requests), \ 329 isend_ct += (PLogDouble)(number),isend_len += ((PLogDouble) (count*sizeof(Scalar))),PETSC_DUMMY \ 330 ) 331 332 #define MPI_Start_isend(count, requests)\ 333 (\ 334 PETSC_DUMMY = MPI_Start(requests),\ 335 isend_ct++,isend_len += ((PLogDouble) (count*sizeof(Scalar))),PETSC_DUMMY\ 336 ) 337 338 #define MPI_Recv(buf,count, datatype,source,tag,comm,status) \ 339 (\ 340 PETSC_DUMMY = MPI_Recv(buf,count, datatype,source,tag,comm,status), \ 341 recv_ct++,TypeSize(recv_len,count,datatype),PETSC_DUMMY \ 342 ) 343 344 #define MPI_Send(buf,count, datatype,dest,tag,comm) \ 345 (\ 346 PETSC_DUMMY = MPI_Send(buf,count, datatype,dest,tag,comm), \ 347 send_ct++, TypeSize(send_len,count,datatype),PETSC_DUMMY \ 348 ) 349 350 #define MPI_Wait(request,status) \ 351 (\ 352 wait_ct++,sum_of_waits_ct++, \ 353 MPI_Wait(request,status) \ 354 ) 355 356 #define MPI_Waitany(a,b,c,d) \ 357 (\ 358 wait_any_ct++,sum_of_waits_ct++,\ 359 MPI_Waitany(a,b,c,d) \ 360 ) 361 362 #define MPI_Waitall(count,array_of_requests,array_of_statuses) \ 363 (\ 364 wait_all_ct++,sum_of_waits_ct += (PLogDouble) (count), \ 365 MPI_Waitall(count,array_of_requests,array_of_statuses) \ 366 ) 367 368 #define MPI_Allreduce(sendbuf, recvbuf,count,datatype,op,comm) \ 369 (\ 370 allreduce_ct++,MPI_Allreduce(sendbuf,recvbuf,count,datatype,op,comm)\ 371 ) 372 373 #else 374 375 #define MPI_Startall_irecv(count,number,requests) \ 376 (\ 377 MPI_Startall(number,requests) \ 378 ) 379 380 #define MPI_Startall_isend(count,number,requests) \ 381 (\ 382 MPI_Startall(number,requests) \ 383 ) 384 385 #define MPI_Start_isend(count, requests) \ 386 (\ 387 MPI_Start(requests) \ 388 ) 389 390 #endif /* !USING_MPIUNI && ! PETSC_HAVE_BROKEN_RECURSIVE_MACRO */ 391 392 #else /* ---Logging is turned off --------------------------------------------*/ 393 394 #define PLogFlops(n) 395 396 /* 397 With logging turned off, then MPE has to be turned off 398 */ 399 #define MPEBEGIN 1000 400 #define PLogMPEBegin() 401 #define PLogMPEDump(a) 0 402 #define PLogEventMPEActivate(a) 0 403 #define PLogEventMPEDeactivate(a) 0 404 405 #define PLogEventActivate(a) 0 406 #define PLogEventDeactivate(a) 0 407 408 #define PLogEventActivateClass(a) 0 409 #define PLogEventDeactivateClass(a) 0 410 411 #define _PLogPLB 0 412 #define _PLogPLE 0 413 #define _PLogPHC 0 414 #define _PLogPHD 0 415 #define PetscGetFlops(a) (*(a) = 0.0,0) 416 #define PLogEventBegin(e,o1,o2,o3,o4) 417 #define PLogEventEnd(e,o1,o2,o3,o4) 418 #define PLogEventBarrierBegin(e,o1,o2,o3,o4,cm) 419 #define PLogEventBarrierEnd(e,o1,o2,o3,o4,cm) 420 #define PLogObjectParent(p,c) 421 #define PLogObjectParents(p,n,c) 422 #define PLogObjectCreate(h) 423 #define PLogObjectDestroy(h) 424 #define PLogObjectMemory(p,m) 425 #define PLogDestroy() 0 426 #define PLogStagePush(a) 0 427 #define PLogStagePop() 0 428 #define PLogStageRegister(a,b) 0 429 #define PLogPrintSummary(comm,file) 0 430 #define PLogBegin() 0 431 #define PLogTraceBegin(file) 0 432 #define PLogSet(lb,le) 0 433 #define PLogAllBegin() 0 434 #define PLogDump(c) 0 435 #define PLogEventRegister(a,b,c) 0 436 extern int PLogObjectState(PetscObject,const char[],...); 437 438 /* If PETSC_USE_LOG is NOT defined, these still need to be! */ 439 #define MPI_Startall_irecv(count,number,requests) MPI_Startall(number,requests) 440 441 #define MPI_Startall_isend(count,number,requests) MPI_Startall(number,requests) 442 443 #define MPI_Start_isend(count,requests) MPI_Start(requests) 444 445 #endif /* PETSC_USE_LOG */ 446 447 448 #endif 449 450 451 452 453 454 455