2 #include "trace-controlPoints.h"
3 #include "trace-controlPointsBOC.h"
7 * \addtogroup ControlPointFramework
12 // Charm++ "processor"(user thread)-private global variable
13 CkpvStaticDeclare(TraceControlPoints*, _trace);
15 // This global variable is required for any post-execution
16 // parallel analysis or parallel activities the trace module
17 // might wish to perform.
18 CkGroupID traceControlPointsGID;
21 For each TraceFoo module, _createTraceFoo() must be defined.
22 This function is called in _createTraces() generated in moduleInit.C
24 This module is special in that it is always included in charm, but sometimes it does nothing.
25 This is called on all processors in SMP version.
27 void _createTracecontrolPoints(char **argv)
29 CkpvInitialize(TraceControlPoints*, _trace);
30 CkpvAccess(_trace) = new TraceControlPoints(argv);
31 CkpvAccess(_traces)->addTrace(CkpvAccess(_trace));
34 TraceControlPoints::TraceControlPoints(char **argv)
40 whenStoppedTracing = 0;
46 if (CkpvAccess(traceOnPe) == 0) return;
48 // Process runtime arguments intended for the module
49 // CmiGetArgIntDesc(argv,"+ControlPointsPar0", &par0, "Fake integer parameter 0");
53 void TraceControlPoints::traceBegin(void){
54 if(whenStoppedTracing != 0)
55 totalUntracedTime += CmiWallTimer() - whenStoppedTracing;
56 whenStoppedTracing = 0;
57 CkPrintf("[%d] TraceControlPoints::traceBegin() totalUntracedTime=%f\n", CkMyPe(), totalUntracedTime);
61 void TraceControlPoints::traceEnd(void){
62 CkPrintf("[%d] TraceControlPoints::traceEnd()\n", CkMyPe());
63 CkAssert(whenStoppedTracing == 0); // can't support nested traceEnds on one processor yet...
64 whenStoppedTracing = CmiWallTimer();
69 void TraceControlPoints::userEvent(int eventID)
71 // CkPrintf("[%d] User Point Event id %d encountered\n", CkMyPe(), eventID);
74 void TraceControlPoints::userBracketEvent(int eventID, double bt, double et) {
75 // CkPrintf("[%d] User Bracket Event id %d encountered\n", CkMyPe(), eventID);
78 void TraceControlPoints::creation(envelope *, int epIdx, int num) {
79 // CkPrintf("[%d] Point-to-Point Message for Entry Method id %d sent\n", CkMyPe(), epIdx);
82 void TraceControlPoints::creationMulticast(envelope *, int epIdx, int num,
84 // CkPrintf("[%d] Multicast Message for Entry Method id %d sent to %d pes\n", CkMyPe(), epIdx, num);
87 void TraceControlPoints::creationDone(int num) {
88 // CkPrintf("[%d] Last initiated send completes\n", CkMyPe());
91 void TraceControlPoints::messageRecv(char *env, int pe) {
92 // CkPrintf("[%d] Message from pe %d received by scheduler\n", CkMyPe(), pe);
95 void TraceControlPoints::beginExecute(CmiObjId *tid)
98 if(nesting_level == 1){
99 // CmiObjId is a 4-integer tuple uniquely identifying a migratable
100 // Charm++ object. Note that there are other non-migratable Charm++
101 // objects that CmiObjId will not identify.
103 lastBeginExecuteTime = CmiWallTimer();
104 lastbeginMessageSize = -1;
110 void TraceControlPoints::beginExecute(envelope *e)
113 if(nesting_level == 1){
114 lastBeginExecuteTime = CmiWallTimer();
115 lastbeginMessageSize = e->getTotalsize();
117 b2mlen += lastbeginMessageSize;
121 void TraceControlPoints::beginExecute(int event,int msgType,int ep,int srcPe,
122 int mlen, CmiObjId *idx)
125 if(nesting_level == 1){
128 lastBeginExecuteTime = CmiWallTimer();
129 lastbeginMessageSize = mlen;
133 void TraceControlPoints::endExecute(void)
135 // CkPrintf("TraceControlPoints::endExecute\n");
137 if(nesting_level == 0){
139 double executionTime = CmiWallTimer() - lastBeginExecuteTime;
140 totalEntryMethodTime += executionTime;
141 totalEntryMethodInvocations ++;
143 double m = (double)CmiMemoryUsage();
150 void TraceControlPoints::beginIdle(double curWallTime) {
151 lastBeginIdle = CmiWallTimer();
152 // CkPrintf("[%d] Scheduler has no useful user-work\n", CkMyPe());
154 double m = (double)CmiMemoryUsage();
160 void TraceControlPoints::endIdle(double curWallTime) {
161 totalIdleTime += CmiWallTimer() - lastBeginIdle;
162 // CkPrintf("[%d] Scheduler now has useful user-work\n", CkMyPe());
165 void TraceControlPoints::beginComputation(void)
167 CkPrintf("[%d] TraceControlPoints::beginComputation\n", CkMyPe());
168 // Code Below shows what trace-summary would do.
169 // initialze arrays because now the number of entries is known.
170 // _logPool->initMem();
173 void TraceControlPoints::endComputation(void)
175 CkPrintf("[%d] TraceControlPoints::endComputationn", CkMyPe());
178 void TraceControlPoints::malloc(void *where, int size, void **stack, int stackSize)
180 // CkPrintf("[%d] Memory allocation of size %d occurred\n", CkMyPe(), size);
181 double m = (double)CmiMemoryUsage();
187 void TraceControlPoints::free(void *where, int size) {
188 // CkPrintf("[%d] %d-byte Memory block freed\n", CkMyPe(), size);
191 void TraceControlPoints::traceClose(void)
193 // Print out some performance counters on BG/P
194 CProxy_TraceControlPointsBOC myProxy(traceControlPointsGID);
197 CkpvAccess(_trace)->endComputation();
198 // remove myself from traceArray so that no tracing will be called.
199 CkpvAccess(_traces)->removeTrace(this);
205 void TraceControlPoints::resetTimings(){
207 totalEntryMethodTime = 0.0;
208 totalEntryMethodInvocations = 0;
209 lastResetTime = CmiWallTimer();
210 totalUntracedTime = 0;
211 if(whenStoppedTracing !=0){
212 whenStoppedTracing = CmiWallTimer();
216 void TraceControlPoints::resetAll(){
218 totalEntryMethodTime = 0.0;
220 totalEntryMethodInvocations = 0;
225 lastResetTime = CmiWallTimer();
226 totalUntracedTime = 0;
227 if(whenStoppedTracing !=0){
228 whenStoppedTracing = CmiWallTimer();
237 TraceControlPoints *localControlPointTracingInstance(){
238 return CkpvAccess(_trace);
243 extern "C" void traceControlPointsExitFunction() {
244 // The exit function of any Charm++ module must call CkExit() or
245 // the entire exit process will hang if multiple modules are linked.
246 // FIXME: This is NOT a feature. Something needs to be done about this.
250 // Initialization of the parallel trace module.
251 void initTraceControlPointsBOC() {
254 if (BgNodeRank()==0) {
256 if (CkMyRank() == 0) {
258 registerExitFn(traceControlPointsExitFunction);
265 #include "TraceControlPoints.def.h"