00001
00005
00006 #ifndef _TRACE_BIGSIM_H
00007 #define _TRACE_BIGSIM_H
00008
00009 #include "trace.h"
00010
00011
00012 class TraceBluegene : public Trace {
00013
00014 private:
00015 FILE* pfp;
00016 public:
00017 TraceBluegene(char** argv);
00018 ~TraceBluegene();
00019 virtual void setTraceOnPE(int flag) { (void)flag; _traceOn = 1; }
00020 int traceOnPE() { return 1; }
00021 void getForwardDep(void* log, void** fDepPtr);
00022 void getForwardDepForAll(void** logs1, void** logs2, int logsize,void* fDepPtr);
00023 void tlineEnd(void** parentLogPtr);
00024 void bgAddTag(const char *str);
00025 void bgDummyBeginExec(const char* name,void** parentLogPtr, int split);
00026 void bgBeginExec(char* msg, char *str);
00027 void bgAmpiBeginExec(char *msg, char *str, void **logs, int count);
00028 void bgAmpiLog(unsigned short op, unsigned int size);
00029 void bgSetInfo(char *msg, const char *str, void **logs, int count);
00030 void bgEndExec(int);
00031 virtual void beginExecute(envelope *, void *);
00032 virtual void beginExecute(char *) {}
00033 virtual void beginExecute(CmiObjId *tid) { (void)tid; }
00034 virtual void beginExecute(int event,int msgType,int ep,int srcPe, int mlen,CmiObjId *idx, void *obj);
00035 void addBackwardDep(void *log);
00036 void userBracketEvent(int eventID, double bt, double et) {
00037 (void)eventID; (void)bt; (void)et; }
00038 void userBracketEvent(const char* name, double bt, double et, void** parentLogPtr);
00039 void userBracketEvent(const char* name, double bt, double et, void** parentLogPtr, CkVec<void*> bgLogList);
00040 void bgPrint(const char* str);
00041 void bgMark(const char* str);
00042 void creatFiles();
00043 void writePrint(char *, double t);
00044 void traceClose();
00045 };
00046
00047 CkpvExtern(TraceBluegene*, _tracebg);
00048 extern int traceBluegeneLinked;
00049
00050 #if CMK_TRACE_ENABLED
00051 # define _TRACE_BG_ONLY(code) do{ BgGetTime(); if(traceBluegeneLinked && CpvAccess(traceOn)){ code; } resetVTime(); } while(0)
00052 #else
00053 # define _TRACE_BG_ONLY(code)
00054 #endif
00055
00056
00057 #if CMK_TRACE_ENABLED && CMK_TRACE_IN_CHARM
00058
00059
00060 #define BgPrint(x) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgPrint(x))
00061 #define BgMark_(x) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgMark(x))
00062 #define _TRACE_BG_BEGIN_EXECUTE_NOMSG(x,pLogPtr,split) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgDummyBeginExec(x,pLogPtr,split))
00063 #define _TRACE_BG_BEGIN_EXECUTE(msg, str) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgBeginExec(msg, str))
00064 #define _TRACE_BG_SET_INFO(msg, str, logs, count) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgSetInfo(msg, str, logs, count))
00065 #define _TRACE_BG_AMPI_BEGIN_EXECUTE(msg, str, logs, count) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgAmpiBeginExec(msg, str, logs, count))
00066 #define _TRACE_BG_END_EXECUTE(commit) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgEndExec(commit))
00067 #define _TRACE_BG_TLINE_END(pLogPtr) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->tlineEnd(pLogPtr))
00068 #define _TRACE_BG_FORWARD_DEPS(logs1,logs2,size,fDep) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->getForwardDepForAll(logs1,logs2, size,fDep))
00069 #define _TRACE_BG_ADD_BACKWARD_DEP(log) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->addBackwardDep(log))
00070 #define _TRACE_BG_USER_EVENT_BRACKET(x,bt,et,pLogPtr) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->userBracketEvent(x,bt,et,pLogPtr))
00071 #define _TRACE_BGLIST_USER_EVENT_BRACKET(x,bt,et,pLogPtr,bgLogList) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->userBracketEvent(x,bt,et,pLogPtr,bgLogList))
00072 #define TRACE_BG_ADD_TAG(str) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgAddTag(str))
00073
00074 # define TRACE_BG_AMPI_LOG(op,size) \
00075 _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgAmpiLog(op,size))
00076
00077 # define TRACE_BG_AMPI_SUSPEND() \
00078 _TRACE_BG_END_EXECUTE(1); \
00079
00080
00081 # define TRACE_BG_AMPI_START(t, str) { \
00082 void* _bgParentLog = NULL; \
00083 \
00084 if(CpvAccess(traceOn) && t) CthTraceResume(t); \
00085 _TRACE_BG_BEGIN_EXECUTE_NOMSG(str, &_bgParentLog, 1); \
00086 }
00087
00088 # define TRACE_BG_AMPI_BREAK(t, str, event, count, connect) \
00089 { \
00090 void *curLog; \
00091 _TRACE_BG_TLINE_END(&curLog); \
00092 TRACE_BG_AMPI_SUSPEND(); \
00093 \
00094 void * _bgParentLog = NULL; \
00095 _TRACE_BG_BEGIN_EXECUTE_NOMSG(str, &_bgParentLog, 1); \
00096 for(int i=0;i<count;i++) { \
00097 _TRACE_BG_ADD_BACKWARD_DEP(((void**)event)[i]); \
00098 } \
00099 if (connect) _TRACE_BG_ADD_BACKWARD_DEP(curLog); \
00100 }
00101
00102 #define TRACE_BG_AMPI_WAIT(reqs) \
00103 { \
00104 CthThread th = getAmpiInstance(MPI_COMM_WORLD)->getThread(); \
00105 TRACE_BG_AMPI_BREAK(th, "AMPI_WAIT", NULL, 0, 0); \
00106 _TRACE_BG_ADD_BACKWARD_DEP(curLog); \
00107 if (*request != MPI_REQUEST_NULL) { \
00108 void *log = (*reqs)[*request]->event; \
00109 _TRACE_BG_ADD_BACKWARD_DEP(log); \
00110 } \
00111 }
00112
00113 #define TRACE_BG_AMPI_WAITALL(reqs) \
00114 { \
00115 \
00116 CthThread th = getAmpiInstance(MPI_COMM_WORLD)->getThread(); \
00117 TRACE_BG_AMPI_BREAK(th, "AMPI_WAITALL", NULL, 0, 0); \
00118 _TRACE_BG_ADD_BACKWARD_DEP(curLog); \
00119 for(int i=0;i<count;i++) { \
00120 if (request[i] == MPI_REQUEST_NULL) continue; \
00121 void *log = (*reqs)[request[i]]->event; \
00122 _TRACE_BG_ADD_BACKWARD_DEP(log); \
00123 } \
00124 }
00125 extern "C" void BgSetStartEvent();
00126 #else
00127 # define BgPrint(x)
00128 # define BgMark_(x)
00129 #define _TRACE_BG_BEGIN_EXECUTE_NOMSG(x,pLogPtr,split)
00130 #define _TRACE_BG_BEGIN_EXECUTE(msg, str)
00131 #define _TRACE_BG_SET_INFO(msg, str, logs, count)
00132 #define _TRACE_BG_AMPI_BEGIN_EXECUTE(msg, str, logs, count)
00133 #define _TRACE_BG_END_EXECUTE(commit)
00134 #define _TRACE_BG_TLINE_END(x)
00135 #define _TRACE_BG_FORWARD_DEP(logs1,logs2,size,fDep)
00136 #define _TRACE_BG_BACKWARD_DEP(log)
00137 #define _TRACE_BG_USER_EVENT_BRACKET(x,bt,et,pLogPtr)
00138 #define _TRACE_BGLIST_USER_EVENT_BRACKET(x,bt,et,pLogPtr,bgLogList)
00139 #define _TRACE_BG_ADD_TAG(str)
00140
00141 # define TRACE_BG_AMPI_LOG(op, size)
00142 # define TRACE_BG_AMPI_SUSPEND()
00143 # define TRACE_BG_AMPI_RESUME(t, msg, str, log)
00144 # define TRACE_BG_AMPI_START(t, str)
00145 # define TRACE_BG_NEWSTART(t, str, events, count)
00146 # define TRACE_BG_AMPI_BREAK(t, str, event, count)
00147 # define TRACE_BG_AMPI_WAITALL(reqs)
00148 # define TRACE_BG_AMPI_SET_SIZE(size)
00149 #endif
00150
00151 extern "C" void BgPrintf(const char *str);
00152 extern "C" void BgMark(const char *str);
00153
00154 #endif
00155