10 #include "trace-common.h"
13 * \addtogroup ControlPointFramework
19 * An instrumentation module making use of
20 * the tracing framework hooks provided in Charm++. It is used
21 * by the control point framework to monitor idle time.
23 * Only the more common hooks are listened to in this module.
25 class TraceControlPoints
: public Trace
{
28 double lastBeginExecuteTime
;
29 int lastbeginMessageSize
;
31 /** The start of the idle region */
34 /** Amount of time spent so far in untraced regions */
35 double totalUntracedTime
;
37 /** When tracing was suspended (0 if not currently suspended) */
38 double whenStoppedTracing
;
40 /** The amount of time spent executing entry methods since we last reset the counters */
41 double totalEntryMethodTime
;
43 /** The amount of time spent idle since we last reset the counters */
46 /** The highest seen memory usage since we last reset the counters */
49 /** The number of entry method invocations since we last reset the counters */
50 long totalEntryMethodInvocations
;
53 /** The time we last rest the counters */
61 // In some programs like Changa, entry methods may be nested, and hence we only want to consider the outermost one
66 TraceControlPoints(char **argv
);
69 void traceBegin(void);
73 // a user event has just occured
74 void userEvent(int eventID
);
75 // a pair of begin/end user event has just occured
76 void userBracketEvent(int eventID
, double bt
, double et
);
78 // "creation" of message(s) - message Sends
79 void creation(envelope
*, int epIdx
, int num
=1);
80 void creationMulticast(envelope
*, int epIdx
, int num
=1, int *pelist
=NULL
);
81 void creationDone(int num
=1);
83 void messageRecv(char *env
, int pe
);
85 // **************************************************************
86 // begin/end execution of a Charm++ entry point
87 // NOTE: begin/endPack and begin/endUnpack can be called in between
88 // a beginExecute and its corresponding endExecute.
89 void beginExecute(envelope
*);
90 void beginExecute(CmiObjId
*tid
);
92 int event
, // event type defined in trace-common.h
93 int msgType
, // message type
94 int ep
, // Charm++ entry point id
95 int srcPe
, // Which PE originated the call
96 int ml
, // message size
97 CmiObjId
* idx
); // index
98 void endExecute(void);
100 // begin/end idle time for this pe
101 void beginIdle(double curWallTime
);
102 void endIdle(double curWallTime
);
104 // begin/end of execution
105 void beginComputation(void);
106 void endComputation(void);
109 void malloc(void *where
, int size
, void **stack
, int stackSize
);
110 void free(void *where
, int size
);
112 // do any clean-up necessary for tracing
116 // ==================================================================
117 // The following methods are not required for a tracing module
119 /** reset the idle time and entry method execution time accumulators */
122 /** Reset the idle, overhead, and memory measurements */
125 /** Fraction of the time spent idle since resetting the counters */
127 double t
= CmiWallTimer() - lastResetTime
;
128 return (totalIdleTime
) / (t
-untracedTime());
131 double untracedTime(){
132 if(whenStoppedTracing
== 0){
133 return totalUntracedTime
;
135 return totalUntracedTime
+ (CmiWallTimer()-whenStoppedTracing
);
140 /** Fraction of time spent as overhead since resetting the counters */
141 double overheadRatio(){
142 double t
= CmiWallTimer() - lastResetTime
;
143 return (t
- totalIdleTime
- totalEntryMethodTime
) / (t
-untracedTime());
146 /** Highest memory usage (in MB) value we've seen since resetting the counters */
147 double memoryUsageMB(){
148 return ((double)memUsage
) / 1024.0 / 1024.0;
151 /** Determine the average grain size since last reset of counters */
153 return (double)totalEntryMethodTime
/ totalEntryMethodInvocations
;
156 double bytesPerEntry() {
157 return (double)(b2mlen
+ b3mlen
) / (double)(b2
+b3
);
164 TraceControlPoints
*localControlPointTracingInstance();