6 #ifndef _TRACE_BIGSIM_H
7 #define _TRACE_BIGSIM_H
11 // Bigsim emulator specific tracing subroutines.
12 class TraceBluegene
: public Trace
{
17 TraceBluegene(char** argv
);
19 virtual void setTraceOnPE(int flag
) { (void)flag
; _traceOn
= 1; } // always on
20 int traceOnPE() { return 1; }
21 void getForwardDep(void* log
, void** fDepPtr
);
22 void getForwardDepForAll(void** logs1
, void** logs2
, int logsize
,void* fDepPtr
);
23 void tlineEnd(void** parentLogPtr
);
24 void bgAddTag(const char *str
);
25 void bgDummyBeginExec(const char* name
,void** parentLogPtr
, int split
);
26 void bgBeginExec(char* msg
, char *str
);
27 void bgAmpiBeginExec(char *msg
, char *str
, void **logs
, int count
);
28 void bgAmpiLog(unsigned short op
, unsigned int size
);
29 void bgSetInfo(char *msg
, const char *str
, void **logs
, int count
);
31 virtual void beginExecute(envelope
*, void *);
32 virtual void beginExecute(char *) {}
33 virtual void beginExecute(CmiObjId
*tid
) { (void)tid
; }
34 virtual void beginExecute(int event
,int msgType
,int ep
,int srcPe
, int mlen
,CmiObjId
*idx
, void *obj
);
35 void addBackwardDep(void *log
);
36 void userBracketEvent(int eventID
, double bt
, double et
) { // from trace.h
37 (void)eventID
; (void)bt
; (void)et
; }
38 void userBracketEvent(const char* name
, double bt
, double et
, void** parentLogPtr
);
39 void userBracketEvent(const char* name
, double bt
, double et
, void** parentLogPtr
, CkVec
<void*> bgLogList
);
40 void bgPrint(const char* str
);
41 void bgMark(const char* str
);
43 void writePrint(char *, double t
);
47 CkpvExtern(TraceBluegene
*, _tracebg
);
48 extern int traceBluegeneLinked
;
51 # define _TRACE_BG_ONLY(code) do{ BgGetTime(); if(traceBluegeneLinked && CpvAccess(traceOn)){ code; } resetVTime(); } while(0)
53 # define _TRACE_BG_ONLY(code) /*empty*/
56 /* tracing for Blue Gene - before trace projector era */
57 #if CMK_TRACE_ENABLED && CMK_TRACE_IN_CHARM
59 // fixme - think of better api for tracing sdag code
60 #define BgPrint(x) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgPrint(x))
61 #define BgMark_(x) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgMark(x))
62 #define _TRACE_BG_BEGIN_EXECUTE_NOMSG(x,pLogPtr,split) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgDummyBeginExec(x,pLogPtr,split))
63 #define _TRACE_BG_BEGIN_EXECUTE(msg, str) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgBeginExec(msg, str))
64 #define _TRACE_BG_SET_INFO(msg, str, logs, count) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgSetInfo(msg, str, logs, count))
65 #define _TRACE_BG_AMPI_BEGIN_EXECUTE(msg, str, logs, count) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgAmpiBeginExec(msg, str, logs, count))
66 #define _TRACE_BG_END_EXECUTE(commit) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgEndExec(commit))
67 #define _TRACE_BG_TLINE_END(pLogPtr) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->tlineEnd(pLogPtr))
68 #define _TRACE_BG_FORWARD_DEPS(logs1,logs2,size,fDep) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->getForwardDepForAll(logs1,logs2, size,fDep))
69 #define _TRACE_BG_ADD_BACKWARD_DEP(log) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->addBackwardDep(log))
70 #define _TRACE_BG_USER_EVENT_BRACKET(x,bt,et,pLogPtr) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->userBracketEvent(x,bt,et,pLogPtr))
71 #define _TRACE_BGLIST_USER_EVENT_BRACKET(x,bt,et,pLogPtr,bgLogList) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->userBracketEvent(x,bt,et,pLogPtr,bgLogList))
72 #define TRACE_BG_ADD_TAG(str) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgAddTag(str))
74 # define TRACE_BG_AMPI_LOG(op,size) \
75 _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgAmpiLog(op,size))
77 # define TRACE_BG_AMPI_SUSPEND() \
78 _TRACE_BG_END_EXECUTE(1); \
79 /* if(CpvAccess(traceOn)) traceSuspend(); */
81 # define TRACE_BG_AMPI_START(t, str) { \
82 void* _bgParentLog = NULL; \
83 /*_TRACE_BG_TLINE_END(&_bgParentLog);*/ \
84 if(CpvAccess(traceOn) && t) CthTraceResume(t); \
85 _TRACE_BG_BEGIN_EXECUTE_NOMSG(str, &_bgParentLog, 1); \
88 # define TRACE_BG_AMPI_BREAK(t, str, event, count, connect) \
90 void *curLog; /* store current log in timeline */ \
91 _TRACE_BG_TLINE_END(&curLog); \
92 TRACE_BG_AMPI_SUSPEND(); \
93 /* TRACE_BG_AMPI_START(t, str); */ \
94 void * _bgParentLog = NULL; \
95 _TRACE_BG_BEGIN_EXECUTE_NOMSG(str, &_bgParentLog, 1); \
96 for(int i=0;i<count;i++) { \
97 _TRACE_BG_ADD_BACKWARD_DEP(((void**)event)[i]); \
99 if (connect) _TRACE_BG_ADD_BACKWARD_DEP(curLog); \
102 #define TRACE_BG_AMPI_WAIT(reqs) \
104 CthThread th = getAmpiInstance(MPI_COMM_WORLD)->getThread(); \
105 TRACE_BG_AMPI_BREAK(th, "AMPI_WAIT", NULL, 0, 0); \
106 _TRACE_BG_ADD_BACKWARD_DEP(curLog); \
107 if (*request != MPI_REQUEST_NULL) { \
108 void *log = (*reqs)[*request]->event; \
109 _TRACE_BG_ADD_BACKWARD_DEP(log); \
113 #define TRACE_BG_AMPI_WAITALL(reqs) \
115 /* TRACE_BG_AMPI_SUSPEND(); */ \
116 CthThread th = getAmpiInstance(MPI_COMM_WORLD)->getThread(); \
117 TRACE_BG_AMPI_BREAK(th, "AMPI_WAITALL", NULL, 0, 0); \
118 _TRACE_BG_ADD_BACKWARD_DEP(curLog); \
119 for(int i=0;i<count;i++) { \
120 if (request[i] == MPI_REQUEST_NULL) continue; \
121 void *log = (*reqs)[request[i]]->event; \
122 _TRACE_BG_ADD_BACKWARD_DEP(log); \
125 extern "C" void BgSetStartEvent();
129 #define _TRACE_BG_BEGIN_EXECUTE_NOMSG(x,pLogPtr,split)
130 #define _TRACE_BG_BEGIN_EXECUTE(msg, str)
131 #define _TRACE_BG_SET_INFO(msg, str, logs, count)
132 #define _TRACE_BG_AMPI_BEGIN_EXECUTE(msg, str, logs, count)
133 #define _TRACE_BG_END_EXECUTE(commit)
134 #define _TRACE_BG_TLINE_END(x)
135 #define _TRACE_BG_FORWARD_DEP(logs1,logs2,size,fDep)
136 #define _TRACE_BG_BACKWARD_DEP(log)
137 #define _TRACE_BG_USER_EVENT_BRACKET(x,bt,et,pLogPtr)
138 #define _TRACE_BGLIST_USER_EVENT_BRACKET(x,bt,et,pLogPtr,bgLogList)
139 #define _TRACE_BG_ADD_TAG(str)
141 # define TRACE_BG_AMPI_LOG(op, size)
142 # define TRACE_BG_AMPI_SUSPEND()
143 # define TRACE_BG_AMPI_RESUME(t, msg, str, log)
144 # define TRACE_BG_AMPI_START(t, str)
145 # define TRACE_BG_NEWSTART(t, str, events, count)
146 # define TRACE_BG_AMPI_BREAK(t, str, event, count)
147 # define TRACE_BG_AMPI_WAITALL(reqs)
148 # define TRACE_BG_AMPI_SET_SIZE(size)
149 #endif /* CMK_TRACE_IN_CHARM */
151 extern "C" void BgPrintf(const char *str
);
152 extern "C" void BgMark(const char *str
);