1 /***********Projector tracing file added by Sayantan ****************/
4 #include "trace-projector.h"
5 #include "trace-projections.h"
7 #define DEBUGF(x) // CmiPrintf x
9 CkpvStaticDeclare(Trace*, _traceproj);
14 UsrEvent(int _e, char* _s): e(_e),str(_s) {}
17 CkpvStaticDeclare(CkVec<UsrEvent *>, usrEventsProjector);
18 #if ! CMK_TRACE_ENABLED
20 #define OPTIMIZED_VERSION \
21 if (!warned) { warned=1; \
22 CmiPrintf("\n\n!!!! Warning: traceUserEvent not available in optimized version!!!!\n\n\n"); }
24 #define OPTIMIZED_VERSION /*empty*/
28 For each TraceFoo module, _createTraceFoo() must be defined.
29 This function is called in _createTraces() generated in moduleInit.C
31 void _createTraceprojector(char **argv)
33 DEBUGF(("%d createTraceProjector\n", CkMyPe()));
34 CkpvInitialize(Trace*, _traceproj);
35 CkpvInitialize(CkVec<UsrEvent *>, usrEventsProjector);
36 CkpvAccess(_traceproj) = new TraceProjector(argv);
37 CkpvAccess(_traces)->addTrace(CkpvAccess(_traceproj));
40 TraceProjector::TraceProjector(char **argv)
43 CpvInitialize(int, _traceCoreOn);
44 CpvAccess(_traceCoreOn)=1;
49 int TraceProjector::traceRegisterUserEvent(const char* evt, int e)
51 CkAssert(e==-1 || e>=0);
52 CkAssert(evt != NULL);
55 for (int i=0; i<CkpvAccess(usrEventsProjector).length(); i++) {
56 int cur = CkpvAccess(usrEventsProjector)[i]->e;
58 CmiAbort("UserEvent double registered!");
59 if (cur > biggest) biggest = cur;
61 // if biggest is -1, it means no user events were previously registered
62 // hence automatically assigned events will start from id of 0.
63 if (e==-1) event = biggest+1; // automatically assign new event id
65 CkpvAccess(usrEventsProjector).push_back(new UsrEvent(event,(char *)evt));
69 void TraceProjector::traceClearEps(void)
71 // In trace-summary, this zeros out the EP bins, to eliminate noise
72 // from startup. Here, this isn't useful, since we can do that in
77 extern "C" void writeSts(){
79 char *fname = new char[strlen(CkpvAccess(traceRoot))+strlen(".sts")+1];
80 sprintf(fname, "%s.sts", CkpvAccess(traceRoot));
82 stsfp = fopen(fname, "w");
83 } while (!stsfp && (errno == EINTR || errno == EMFILE));
85 CmiAbort("Cannot open projections sts file for writing.\n");
88 fprintf(stsfp, "VERSION %s\n", PROJECTION_VERSION);
89 traceWriteSTS(stsfp,CkpvAccess(usrEventsProjector).length());
91 for(i=0;i<CkpvAccess(usrEventsProjector).length();i++)
92 fprintf(stsfp, "EVENT %d %s\n", CkpvAccess(usrEventsProjector)[i]->e, CkpvAccess(usrEventsProjector)[i]->str);
93 fprintf(stsfp, "END\n");
99 void TraceProjector::traceWriteSts(void)
105 void TraceProjector::traceClose(void)
110 CkpvAccess(_traceproj)->endComputation();
114 void TraceProjector::traceBegin(void)
118 void TraceProjector::traceEnd(void)
122 void TraceProjector::userEvent(int e)
124 _LOG_E_USER_EVENT_CHARM(e);
127 void TraceProjector::userBracketEvent(int e, double bt, double et)
129 _LOG_E_USER_EVENT_PAIR_CHARM(e,bt,et);
132 void TraceProjector::creation(envelope *e, int ep,int num)
134 _LOG_E_CREATION_N(e, ep, num);
137 void TraceProjector::beginExecute(envelope *e)
139 //_LOG_E_BEGIN_EXECUTE(e);
141 charm_beginExecute(e);
144 void TraceProjector::beginExecute(CmiObjId *tid)
148 _LOG_E_BEGIN_EXECUTE(0);
152 void TraceProjector::beginExecute(int event,int msgType,int ep,int srcPe,int mlen,CmiObjId *idx)
154 //CmiPrintf("TraceProjector:iData in beginExecuteDetailed %d %d \n",event,srcPe);
155 _LOG_E_BEGIN_EXECUTE_DETAILED(event, msgType, ep, srcPe, mlen);
158 void TraceProjector::endExecute(void)
160 _LOG_E_END_EXECUTE();
163 void TraceProjector::messageRecv(char *env, int pe)
165 _LOG_E_MSG_RECV_CHARM(env, pe);
168 void TraceProjector::beginIdle(double curWallTime)
173 void TraceProjector::endIdle(double curWallTime)
178 void TraceProjector::beginPack(void)
183 void TraceProjector::endPack(void)
188 void TraceProjector::beginUnpack(void)
190 _LOG_E_BEGIN_UNPACK();
193 void TraceProjector::endUnpack(void)
198 void TraceProjector::enqueue(envelope *env)
203 void TraceProjector::dequeue(envelope *env)
208 void TraceProjector::beginComputation(void)
210 _LOG_E_BEGIN_COMPUTATION();
213 void TraceProjector::endComputation(void)
215 _LOG_E_END_COMPUTATION();