Actual source code: petsclog.h
1: /* $Id: petsclog.h,v 1.153 2001/04/10 22:34:32 balay Exp $ */
3: /*
4: Defines profile/logging in PETSc.
5: */
9: #include "petsc.h"
11: /*
12: Lists all PETSc events that are logged/profiled.
14: If you add an event here, make sure you add it to
15: petsc/src/PetscLog/src/PetscLog.c,
16: petsc/src/PetscLog/src/PetscLogmpe.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_ICCFactorSymbolic 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
57: #define MAT_FDColoringApply 38
58: #define MAT_FDColoringCreate 41
60: #define VEC_ReduceArithmetic 37
62: #define VEC_View 39
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_MAXPY 56
78: #define VEC_PMult 57
79: #define VEC_SetValues 58
80: #define VEC_Load 59
81: #define VEC_ScatterBarrier 60
82: #define VEC_ScatterBegin 61
83: #define VEC_ScatterEnd 62
84: #define VEC_SetRandom 63
86: #define VEC_NormBarrier 64
87: #define VEC_Norm 65
88: #define VEC_DotBarrier 66
89: #define VEC_Dot 67
90: #define VEC_MDotBarrier 68
91: #define VEC_MDot 69
93: #define SLES_Solve 70
94: #define SLES_SetUp 71
96: #define KSP_GMRESOrthogonalization 72
98: #define PC_ApplyCoarse 73
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
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
114: #define VEC_ReduceBarrier 87
115: #define VEC_ReduceComm 88
117: #define TS_Step 90
118: #define TS_PseudoComputeTimeStep 91
119: #define TS_FunctionEval 92
120: #define TS_JacobianEval 93
122: #define Petsc_Barrier 100
124: #define EC_SetUp 105
125: #define EC_Solve 106
127: /*
128: Event numbers PETSC_LOG_USER_EVENT_LOW to PETSC_LOG_USER_EVENT_HIGH are reserved
129: for applications. Make sure that src/PetscLog/src/PetscLog.c defines enough
130: entries in (*name)[] to go up to PETSC_LOG_USER_EVENT_HIGH.
131: */
132: #define PETSC_LOG_USER_EVENT_LOW_STATIC 120
133: #define PETSC_LOG_USER_EVENT_HIGH 200
135: /* Global flop counter */
136: extern PetscLogDouble _TotalFlops;
138: /* General logging of information; different from event logging */
139: EXTERN int PetscLogInfo(void*,const char[],...);
140: EXTERN int PetscLogInfoDeactivateClass(int);
141: EXTERN int PetscLogInfoActivateClass(int);
142: extern PetscTruth PetscLogPrintInfo; /* if true, indicates PetscLogInfo() is turned on */
144: #if defined(PETSC_USE_LOG) /* --- Logging is turned on --------------------------------*/
146: /*
147: Flop counting: We count each arithmetic operation (e.g., addition, multiplication) separately.
149: For the complex numbers version, note that
150: 1 complex addition = 2 flops
151: 1 complex multiplication = 6 flops,
152: where we define 1 flop as that for a double precision scalar. We roughly approximate
153: flop counting for complex numbers by multiplying the total flops by 4; this corresponds
154: to the assumption that we're counting mostly additions and multiplications -- and
155: roughly the same number of each. More accurate counting could be done by distinguishing
156: among the various arithmetic operations.
157: */
159: #if defined(PETSC_USE_COMPLEX)
160: #define PetscLogFlops(n) (_TotalFlops += (4*n),0)
161: #else
162: #define PetscLogFlops(n) (_TotalFlops += (n),0)
163: #endif
165: #if defined (PETSC_HAVE_MPE)
166: #include "mpe.h"
167: #define MPEBEGIN 1000
168: EXTERN int PetscLogMPEBegin(void);
169: EXTERN int PetscLogMPEDump(const char[]);
170: extern PetscTruth UseMPE;
171: extern int PetscLogEventMPEFlags[];
172: EXTERN int PetscLogEventMPEActivate(int);
173: EXTERN int PetscLogEventMPEDeactivate(int);
174: #else
175: #define PetscLogEventMPEActivate(a) 0
176: #define PetscLogEventMPEDeactivate(a) 0
177: #endif
179: EXTERN int PetscLogEventActivate(int);
180: EXTERN int PetscLogEventDeactivate(int);
182: EXTERN int PetscLogEventActivateClass(int);
183: EXTERN int PetscLogEventDeactivateClass(int);
185: extern PetscTruth PetscLogEventFlags[];
186: EXTERN int (*_PetscLogPLB)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
187: EXTERN int (*_PetscLogPLE)(int,int,PetscObject,PetscObject,PetscObject,PetscObject);
188: EXTERN int (*_PetscLogPHC)(PetscObject);
189: EXTERN int (*_PetscLogPHD)(PetscObject);
191: extern int PetscLogEventDepth[];
193: #if defined(PETSC_HAVE_MPE)
194: #define PetscLogEventBarrierBegin(e,o1,o2,o3,o4,cm)
195: 0; { int __ierr;
196: if (_PetscLogPLB && PetscLogEventFlags[e]) {
197: __PetscLogEventBegin((e),o1,o2,o3,o4);CHKERRQ(__ierr);
198: if (UseMPE && PetscLogEventMPEFlags[(e)])
199: MPE_Log_event(MPEBEGIN+2*(e),0,"");
200: __MPI_Barrier(cm);CHKERRQ(__ierr);
201: __PetscLogEventEnd((e),o1,o2,o3,o4);CHKERRQ(__ierr);
202: if (UseMPE && PetscLogEventMPEFlags[(e)])
203: MPE_Log_event(MPEBEGIN+2*((e)+1),0,"");
204: }
205: __PetscLogEventBegin(e+1,o1,o2,o3,o4);CHKERRQ(__ierr);
206: if (UseMPE && PetscLogEventMPEFlags[(e)+1])
207: MPE_Log_event(MPEBEGIN+2*((e)+1),0,"");
208: }
209: #define PetscLogEventBegin(e,o1,o2,o3,o4)
210: 0; {
211: if (_PetscLogPLB && PetscLogEventFlags[(e)] && !PetscLogEventDepth[e]++) {
212: (*_PetscLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));}
213: if (UseMPE && PetscLogEventMPEFlags[(e)])
214: MPE_Log_event(MPEBEGIN+2*(e),0,"");
215: }
216: #else
217: #define PetscLogEventBarrierBegin(e,o1,o2,o3,o4,cm)
218: 0; { int __ierr;
219: if (_PetscLogPLB && PetscLogEventFlags[(e)]) {
220: __PetscLogEventBegin((e),o1,o2,o3,o4);CHKERRQ(__ierr);
221: __MPI_Barrier(cm);CHKERRQ(__ierr);
222: __PetscLogEventEnd((e),o1,o2,o3,o4);CHKERRQ(__ierr);
223: }
224: __PetscLogEventBegin((e)+1,o1,o2,o3,o4);CHKERRQ(__ierr);
225: }
226: #define PetscLogEventBegin(e,o1,o2,o3,o4)
227: 0; {
228: if (_PetscLogPLB && PetscLogEventFlags[(e)] && !PetscLogEventDepth[e]++) {
229: (*_PetscLogPLB)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));}
230: }
231: #endif
233: #if defined(PETSC_HAVE_MPE)
234: #define PetscLogEventBarrierEnd(e,o1,o2,o3,o4,cm) PetscLogEventEnd(e+1,o1,o2,o3,o4)
235: #define PetscLogEventEnd(e,o1,o2,o3,o4)
236: 0; {
237: if (_PetscLogPLE && PetscLogEventFlags[(e)] && !--PetscLogEventDepth[e]) {
238: (*_PetscLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));}
239: if (UseMPE && PetscLogEventMPEFlags[(e)])
240: MPE_Log_event(MPEBEGIN+2*(e)+1,0,"");
241: }
242: #else
243: #define PetscLogEventBarrierEnd(e,o1,o2,o3,o4,cm) PetscLogEventEnd(e+1,o1,o2,o3,o4)
244: #define PetscLogEventEnd(e,o1,o2,o3,o4)
245: 0; {
246: if (_PetscLogPLE && PetscLogEventFlags[(e)] && !--PetscLogEventDepth[e]) {
247: (*_PetscLogPLE)((e),0,(PetscObject)(o1),(PetscObject)(o2),(PetscObject)(o3),(PetscObject)(o4));}
248: }
249: #endif
253: ((PetscObject)(c))->parent = (PetscObject)(p);
254: ((PetscObject)(c))->parentid = ((PetscObject)p)->id;}
255: #define PetscLogObjectParents(p,n,d) {int _i; for (_i=0; _i<n; _i++)
256: PetscLogObjectParent(p,(d)[_i]);}
257: #define PetscLogObjectCreate(h) {if (_PetscLogPHC) (*_PetscLogPHC)((PetscObject)h);}
258: #define PetscLogObjectDestroy(h) {if (_PetscLogPHD) (*_PetscLogPHD)((PetscObject)h);}
260: ((PetscObject)(p))->mem += (m);}
261: EXTERN int PetscLogObjectState(PetscObject,const char[],...);
262: EXTERN int PetscLogDestroy(void);
263: EXTERN int PetscLogStagePush(int);
264: EXTERN int PetscLogStagePop(void);
265: EXTERN int PetscLogStageRegister(int,const char[]);
266: EXTERN int PetscLogStagePrint(int,PetscTruth);
267: EXTERN int PetscLogPrintSummary(MPI_Comm,const char[]);
268: EXTERN int PetscLogBegin(void);
269: EXTERN int PetscLogTraceBegin(FILE *);
270: EXTERN int PetscLogAllBegin(void);
271: EXTERN int PetscLogSet(int (*)(int,int,PetscObject,PetscObject,PetscObject,PetscObject),
272: int (*)(int,int,PetscObject,PetscObject,PetscObject,PetscObject));
273: EXTERN int PetscLogDump(const char[]);
274: EXTERN int PetscLogEventRegister(int*,const char[],const char[]);
275: EXTERN int PetscGetFlops(PetscLogDouble*);
277: extern PetscLogDouble irecv_ct,isend_ct,wait_ct,wait_any_ct,recv_ct,send_ct;
278: extern PetscLogDouble irecv_len,isend_len,recv_len,send_len;
279: extern PetscLogDouble wait_all_ct,allreduce_ct,sum_of_waits_ct;
280: extern int PETSC_DUMMY,PETSC_DUMMY_SIZE;
282: /*
283: This does not work for MPI-Uni because our src/mpiuni/mpi.h file
284: uses macros to defined the MPI operations.
286: It does not work correctly from HP-UX because it processes the
287: macros in a way that sometimes it double counts, hence
288: PETSC_HAVE_BROKEN_RECURSIVE_MACRO
290: It does not work with Windows NT because winmpich lacks MPI_Type_size()
291: */
292: #if !defined(USING_MPIUNI) && !defined(PETSC_HAVE_BROKEN_RECURSIVE_MACRO) && !defined (PETSC_HAVE_MPI_MISSING_TYPESIZE)
293: /*
294: Logging of MPI activities
295: */
297: #define TypeSize(buff,count,type)
298: (
299: MPI_Type_size(type,&PETSC_DUMMY_SIZE),buff += ((PetscLogDouble) ((count)*PETSC_DUMMY_SIZE))
300: )
302: #define MPI_Irecv(buf,count, datatype,source,tag,comm,request)
303: (
304: PETSC_DUMMY = MPI_Irecv(buf,count, datatype,source,tag,comm,request),
305: irecv_ct++,TypeSize(irecv_len,count,datatype),PETSC_DUMMY
306: )
308: #define MPI_Isend(buf,count, datatype,dest,tag,comm,request)
309: (
310: PETSC_DUMMY = MPI_Isend(buf,count, datatype,dest,tag,comm,request),
311: isend_ct++, TypeSize(isend_len,count,datatype),PETSC_DUMMY
312: )
314: #define MPI_Startall_irecv(count,number,requests)
315: (
316: PETSC_DUMMY = MPI_Startall(number,requests),
317: irecv_ct += (PetscLogDouble)(number),irecv_len += ((PetscLogDouble) ((count)*sizeof(Scalar))),PETSC_DUMMY
318: )
320: #define MPI_Startall_isend(count,number,requests)
321: (
322: PETSC_DUMMY = MPI_Startall(number,requests),
323: isend_ct += (PetscLogDouble)(number),isend_len += ((PetscLogDouble) ((count)*sizeof(Scalar))),PETSC_DUMMY
324: )
326: #define MPI_Start_isend(count, requests)
327: (
328: PETSC_DUMMY = MPI_Start(requests),
329: isend_ct++,isend_len += ((PetscLogDouble) ((count)*sizeof(Scalar))),PETSC_DUMMY
330: )
332: #define MPI_Recv(buf,count, datatype,source,tag,comm,status)
333: (
334: PETSC_DUMMY = MPI_Recv(buf,count, datatype,source,tag,comm,status),
335: recv_ct++,TypeSize(recv_len,count,datatype),PETSC_DUMMY
336: )
338: #define MPI_Send(buf,count, datatype,dest,tag,comm)
339: (
340: PETSC_DUMMY = MPI_Send(buf,count, datatype,dest,tag,comm),
341: send_ct++, TypeSize(send_len,count,datatype),PETSC_DUMMY
342: )
344: #define MPI_Wait(request,status)
345: (
346: wait_ct++,sum_of_waits_ct++,
347: MPI_Wait(request,status)
348: )
350: #define MPI_Waitany(a,b,c,d)
351: (
352: wait_any_ct++,sum_of_waits_ct++,
353: MPI_Waitany(a,b,c,d)
354: )
356: #define MPI_Waitall(count,array_of_requests,array_of_statuses)
357: (
358: wait_all_ct++,sum_of_waits_ct += (PetscLogDouble) (count),
359: MPI_Waitall(count,array_of_requests,array_of_statuses)
360: )
362: #define MPI_Allreduce(sendbuf, recvbuf,count,datatype,op,comm)
363: (
364: allreduce_ct++,MPI_Allreduce(sendbuf,recvbuf,count,datatype,op,comm)
365: )
367: #else
369: #define MPI_Startall_irecv(count,number,requests)
370: (
371: MPI_Startall(number,requests)
372: )
374: #define MPI_Startall_isend(count,number,requests)
375: (
376: MPI_Startall(number,requests)
377: )
379: #define MPI_Start_isend(count, requests)
380: (
381: MPI_Start(requests)
382: )
384: #endif /* !USING_MPIUNI && ! PETSC_HAVE_BROKEN_RECURSIVE_MACRO */
386: #else /* ---Logging is turned off --------------------------------------------*/
388: #define PetscLogFlops(n) 0
390: /*
391: With logging turned off, then MPE has to be turned off
392: */
393: #define MPEBEGIN 1000
394: #define PetscLogMPEBegin() 0
395: #define PetscLogMPEDump(a) 0
396: #define PetscLogEventMPEActivate(a) 0
397: #define PetscLogEventMPEDeactivate(a) 0
399: #define PetscLogEventActivate(a) 0
400: #define PetscLogEventDeactivate(a) 0
402: #define PetscLogEventActivateClass(a) 0
403: #define PetscLogEventDeactivateClass(a) 0
405: #define _PetscLogPLB 0
406: #define _PetscLogPLE 0
407: #define _PetscLogPHC 0
408: #define _PetscLogPHD 0
409: #define PetscGetFlops(a) (*(a) = 0.0,0)
410: #define PetscLogEventBegin(e,o1,o2,o3,o4) 0
411: #define PetscLogEventEnd(e,o1,o2,o3,o4) 0
412: #define PetscLogEventBarrierBegin(e,o1,o2,o3,o4,cm) 0
413: #define PetscLogEventBarrierEnd(e,o1,o2,o3,o4,cm) 0
414: #define PetscLogObjectParent(p,c)
415: #define PetscLogObjectParents(p,n,c)
416: #define PetscLogObjectCreate(h)
417: #define PetscLogObjectDestroy(h)
418: #define PetscLogObjectMemory(p,m)
419: #define PetscLogDestroy() 0
420: #define PetscLogStagePush(a) 0
421: #define PetscLogStagePop() 0
422: #define PetscLogStageRegister(a,b) 0
423: #define PetscLogStagePrint(a,flg) 0
424: #define PetscLogPrintSummary(comm,file) 0
425: #define PetscLogBegin() 0
426: #define PetscLogTraceBegin(file) 0
427: #define PetscLogSet(lb,le) 0
428: #define PetscLogAllBegin() 0
429: #define PetscLogDump(c) 0
430: #define PetscLogEventRegister(a,b,c) 0
431: EXTERN int PetscLogObjectState(PetscObject,const char[],...);
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)
436: #define MPI_Startall_isend(count,number,requests) MPI_Startall(number,requests)
438: #define MPI_Start_isend(count,requests) MPI_Start(requests)
440: #endif /* PETSC_USE_LOG */
442: extern PetscTruth PetscPreLoadingUsed; /* true if we are or have done preloading */
443: extern PetscTruth PetscPreLoadingOn; /* true if we are currently in a preloading calculation */
445: #define PreLoadBegin(flag,name) {PetscTruth PreLoading = flag; int PreLoadMax,PreLoadIt,__ierr;
446: __PetscOptionsGetLogical(PETSC_NULL,"-preload",&PreLoading,PETSC_NULL);CHKERRQ(__ierr);
447: PreLoadMax = (int)(PreLoading);PetscPreLoadingUsed = PreLoading ? PETSC_TRUE : PetscPreLoadingUsed;
448: for (PreLoadIt=0; PreLoadIt<=PreLoadMax; PreLoadIt++) {
449: PetscPreLoadingOn = PreLoading;
450: __PetscBarrier(PETSC_NULL);CHKERRQ(__ierr);
451: __PetscLogStagePush(PETSC_DETERMINE);CHKERRQ(__ierr);
452: __PetscLogStageRegister(PETSC_DETERMINE,name);CHKERRQ(__ierr);
453: __PetscLogStagePrint(PETSC_DETERMINE,(PetscTruth)(!PreLoadMax || PreLoadIt));
454: #define PreLoadEnd() __PetscLogStagePop();CHKERRQ(__ierr);PreLoading = PETSC_FALSE;}}
455: #define PreLoadStage(name) __PetscLogStagePop();CHKERRQ(__ierr);
456: __PetscLogStagePush(PETSC_DETERMINE);CHKERRQ(__ierr);
457: __PetscLogStageRegister(PETSC_DETERMINE,name);CHKERRQ(__ierr);
458: __PetscLogStagePrint(PETSC_DETERMINE,(PetscTruth)(!PreLoadMax || PreLoadIt));
459: #endif