cleanup trace bluegene code. moved all bluegene specific tracing calls and macros...
authorGengbin Zheng <gzheng@illinois.edu>
Thu, 28 Aug 2003 22:32:03 +0000 (22:32 +0000)
committerGengbin Zheng <gzheng@illinois.edu>
Thu, 28 Aug 2003 22:32:03 +0000 (22:32 +0000)
src/ck-perf/trace-bluegene.C
src/ck-perf/trace-bluegene.h
src/ck-perf/trace-common.C
src/ck-perf/trace.h

index c8fdbb8663e8ce94f55e616349f90b28737cff66..6636637e776f7ad5c551311904f0c2f5b6c443eb 100644 (file)
 #include "charm++.h"
 #include "trace-common.h"
 #include "trace-bluegene.h"
+#include "blue.h"
+#include "blue_impl.h"
 
-CkpvStaticDeclare(Trace*, _tracebg);
-
-extern int traceBluegeneLinked;
+#undef DEBUGF
+#define DEBUGF(x)  // CmiPrintf x
 
 void _createTracebluegene(char** argv)
 {
-  //DEBUGF(("%d createTraceBluegene\n", CkMyPe()));
+  DEBUGF(("%d createTraceBluegene\n", CkMyPe()));
   CkpvInitialize(Trace*, _tracebg);
   CkpvAccess(_tracebg) = new  TraceBluegene(argv);
   CkpvAccess(_traces)->addTrace(CkpvAccess(_tracebg));
@@ -52,10 +53,10 @@ TraceBluegene::TraceBluegene(char** argv): stsfp(NULL), pfp(NULL)
     if(stsfp==0)
       CmiAbort("Cannot open Bluegene sts file for writing.\n");
   }
-  currLog = NULL;
 }
 
 void TraceBluegene::traceClose() {
+  DEBUGF(("%d TraceBluegene::traceClose\n", CkMyPe()));
   bgUpdateProj(2);
   if(pfp != 0)  fclose(pfp);
   if((CkMyPe() == 0)&&(stsfp !=0)) fclose(stsfp);
@@ -90,11 +91,9 @@ void TraceBluegene::tlineEnd(void** parentLogPtr){
 }
 
 
-void TraceBluegene::bgBeginExec(char* name,void** parentLogPtr){
-
-
+void TraceBluegene::bgDummyBeginExec(char* name,void** parentLogPtr)
+{
   if (!genTimeLog) return;
-
   bgTimeLog* newLog = new bgTimeLog(_threadEP,name,BgGetCurTime());
   if(*parentLogPtr)
     newLog->addBackwardDep(*(bgTimeLog**)parentLogPtr);
@@ -102,10 +101,20 @@ void TraceBluegene::bgBeginExec(char* name,void** parentLogPtr){
   *parentLogPtr = newLog;
 }
 
+void TraceBluegene::bgBeginExec(char* msg)
+{
+  if (!genTimeLog) return;
+  bgTimeLog* newLog = new bgTimeLog(msg);
+  tTIMELINEREC.logEntryStart(newLog);
+}
 
-void TraceBluegene::bgEndExec()
+void TraceBluegene::bgEndExec(int commit)
 {
-  tTIMELINEREC.logEntryClose();
+  if (!genTimeLog) return;
+  if (commit) 
+    BgLogEntryCommit(tTIMELINEREC);
+  else
+    tTIMELINEREC.logEntryClose();
 }
 
 
@@ -149,7 +158,6 @@ void TraceBluegene::userBracketEvent(char* name, double bt, double et, void** pa
   if(*parentLogPtr)
     newLog->addBackwardDep(*(bgTimeLog**)parentLogPtr);
   *parentLogPtr = newLog;
-  currLog = newLog;
   tTIMELINEREC.logEntryInsert(newLog);
 }
 
@@ -161,7 +169,6 @@ void TraceBluegene::userBracketEvent(char* name, double bt, double et, void** pa
   bgTimeLog* newLog = new bgTimeLog(_threadEP,name,bt,et);
   newLog->addBackwardDeps(bgLogList);
   *parentLogPtr = newLog;
-  currLog = newLog;
   tTIMELINEREC.logEntryInsert(newLog);
 }
 
index f5990b402951adcd43c9da9b8bb58fbbdd4c1031..ecc8b22455c4f4c060ea5a07ea09f316bde6c52a 100644 (file)
 */
 /*@{*/
 
-
 #ifndef _TRACE_BLUEGENE_H
 #define _TRACE_BLUEGENE_H
 
 #include "trace.h"
-#include "blue.h"
-#include "blue_impl.h"
 
+// TraceBluegene is subclass of Trace, 
+// it defines Blue Gene specific tracing subroutines.
 class TraceBluegene : public Trace {
 
  private:
-    bgTimeLog* currLog;
     FILE* stsfp;
     FILE* pfp;
  public:
@@ -33,8 +31,9 @@ class TraceBluegene : public Trace {
     void getForwardDep(void* log, void** fDepPtr);
     void getForwardDepForAll(void** logs1, void** logs2, int logsize,void* fDepPtr);
     void tlineEnd(void** parentLogPtr);
-    void bgBeginExec(char* name,void** parentLogPtr);
-    void bgEndExec(void);
+    void bgDummyBeginExec(char* name,void** parentLogPtr);
+    void bgBeginExec(char* msg);
+    void bgEndExec(int);
     void userBracketEvent(char* name, double bt, double et, void** parentLogPtr);
     void userBracketEvent(char* name, double bt, double et, void** parentLogPtr, CkVec<void*> bgLogList);
     void bgPrint(char* str);
@@ -44,6 +43,43 @@ class TraceBluegene : public Trace {
     void traceClose();
 };
 
+CkpvExtern(TraceBluegene*, _tracebg);
+extern int traceBluegeneLinked;
+
+#ifndef CMK_OPTIMIZE
+#  define _TRACE_BG_ONLY(code) do{if(traceBluegeneLinked && CpvAccess(traceOn)){ code; }} while(0)
+#else
+#  define _TRACE_BG_ONLY(code) /*empty*/
+#endif
+
+// for Sdag only
+// fixme - think of better api for tracing sdag code
+#define BgPrint(x)  _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgPrint(x))
+#define _TRACE_BG_BEGIN_EXECUTE_NOMSG(x,pLogPtr)  _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgDummyBeginExec(x,pLogPtr))
+#define _TRACE_BG_BEGIN_EXECUTE(msg)  _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgBeginExec(msg))
+#define _TRACE_BG_END_EXECUTE(commit)   _TRACE_BG_ONLY(CkpvAccess(_tracebg)->bgEndExec(commit))
+#define _TRACE_BG_TLINE_END(pLogPtr) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->tlineEnd(pLogPtr))
+#define _TRACE_BG_FORWARD_DEPS(logs1,logs2,size,fDep)  _TRACE_BG_ONLY(CkpvAccess(_tracebg)->getForwardDepForAll(logs1,logs2, size,fDep))
+#define _TRACE_BG_USER_EVENT_BRACKET(x,bt,et,pLogPtr) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->userBracketEvent(x,bt,et,pLogPtr))
+#define _TRACE_BGLIST_USER_EVENT_BRACKET(x,bt,et,pLogPtr,bgLogList) _TRACE_BG_ONLY(CkpvAccess(_tracebg)->userBracketEvent(x,bt,et,pLogPtr,bgLogList))
+
+/* tracing for Blue Gene - before trace projector era */
+#if !defined(CMK_OPTIMIZE) && CMK_TRACE_IN_CHARM
+# define TRACE_BG_SUSPEND()     \
+        if(CpvAccess(traceOn)) traceSuspend();  \
+        _TRACE_BG_END_EXECUTE(1);
+# define TRACE_BG_RESUME(t, msg)        \
+        _TRACE_BG_BEGIN_EXECUTE((char *)UsrToEnv(msg)); \
+        if(CpvAccess(traceOn)) CthTraceResume(t);
+# define TRACE_BG_START(t, str) \
+        void* _bgParentLog = NULL;      \
+        _TRACE_BG_BEGIN_EXECUTE_NOMSG(str, &_bgParentLog);      \
+        if(CpvAccess(traceOn)) CthTraceResume(t);
+#else
+# define TRACE_BG_SUSPEND()
+# define TRACE_BG_RESUME(t, msg)
+# define TRACE_BG_START(t, str)
+#endif   /* CMK_TRACE_IN_CHARM */
 
 #endif
 
index 61a276d40f1804f0b033631f291689a61d1f8252..1d2faf7b5b9388733aeb1a094e6ae0aaf594bdf4 100644 (file)
@@ -35,13 +35,19 @@ static int warned = 0;
 #define OPTIMIZE_WARNING /*empty*/
 #endif
 
-CkpvDeclare(TraceArray*, _traces);
+CkpvDeclare(TraceArray*, _traces);             // lists of all trace modules
+
+/* trace for bluegene */
+class TraceBluegene;
+CkpvDeclare(TraceBluegene*, _tracebg);
+int traceBluegeneLinked=0;                     // if trace-bluegene is linked
 
 CkpvDeclare(double, traceInitTime);
 CpvDeclare(int, traceOn);
 #if CMK_TRACE_IN_CHARM
 CkpvDeclare(int, traceOnPe);
 #endif
+
 CkpvDeclare(int, CtrLogBufSize);
 CkpvDeclare(char*, traceRoot);
 
@@ -50,7 +56,6 @@ int _packMsg, _packChare, _packEP;
 int _unpackMsg, _unpackChare, _unpackEP;
 int _dummyMsg, _dummyChare, _dummyEP;
 
-
 /// decide parameters from command line
 static void traceCommonInit(char **argv)
 {
@@ -97,7 +102,6 @@ static void traceCommonInit(char **argv)
     strcpy(CkpvAccess(traceRoot), argv[0]);
   }
   
-  
 #ifdef __BLUEGENE__
   if(BgNodeRank()==0) {
 #else
@@ -213,7 +217,7 @@ void traceMessageRecv(char *msg, int pe)
 extern "C"
 void traceResume(CmiObjId *tid)
 {
-    CkpvAccess(_traces)->beginExecute(tid);
+    _TRACE_ONLY(CkpvAccess(_traces)->beginExecute(tid));
     if(CpvAccess(_traceCoreOn))
            resumeTraceCore();
 }
@@ -221,7 +225,7 @@ void traceResume(CmiObjId *tid)
 extern "C"
 void traceSuspend(void)
 {
-  CkpvAccess(_traces)->endExecute();
+  _TRACE_ONLY(CkpvAccess(_traces)->endExecute());
 }
 
 extern "C"
index 5a6cf5c1ef9014d4200efc5fb0f17ab0bb560fc1..77378d11b4c9b4fd5794296f39cd3d6b0c3b8d8f 100644 (file)
@@ -89,14 +89,6 @@ class Trace {
     virtual void traceWriteSts() {}
     // do any clean-up necessary for tracing
     virtual void traceClose() {}
-    // only for Blue Gene
-    virtual void tlineEnd(void** parentLogPtr){}
-    virtual void bgBeginExec(char* name,void** pLogPtr){}
-    virtual void bgEndExec(){}
-    virtual void bgPrint(char* str){}
-    virtual void getForwardDepForAll(void** logs1,void** logs2, int size ,void* fDepPtr){}
-    virtual void userBracketEvent(char* name, double bt, double et, void** parentLogPtr){}
-    virtual void userBracketEvent(char* name, double bt, double et, void** parentLogPtr, CkVec<void*> bgLogList){}
 };
 
 #define ALLDO(x) for (int i=0; i<length(); i++) if (traces[i]->traceOnPE()) traces[i]->x
@@ -162,16 +154,6 @@ public:
     inline void traceClose() {ALLDO(traceClose()); clearTrace();}
     inline void traceBegin() {ALLDO(traceBegin());}
     inline void traceEnd() {ALLDO(traceEnd());}
-    // only for Blue Gene
-    inline void tlineEnd(void** pLogPtr){ALLDO(tlineEnd(pLogPtr));}
-    inline void bgBeginExec(char* name,void** pLogPtr){ALLDO(bgBeginExec(name,pLogPtr));}
-    inline void bgEndExec(){ALLDO(bgEndExec());}
-    inline void bgPrint(char* str){ALLDO(bgPrint(str));}
-    inline void getForwardDepForAll(void** logs1, void**logs2,int size,void* fDepPtr){ALLDO(getForwardDepForAll(logs1, logs2,size,fDepPtr));}
-    inline void userBracketEvent(char* name,double bt, double et, void** pLogPtr) {ALLDO(userBracketEvent(name,bt,et,pLogPtr));}
-    inline void userBracketEvent(char* name,double bt, double et, void** pLogPtr, CkVec<void*> bgLogList) {ALLDO(userBracketEvent(name,bt,et,pLogPtr,bgLogList))
-;}
-
 };
 
 CkpvExtern(TraceArray*, _traces);
@@ -208,16 +190,7 @@ extern "C" {
 #define _TRACE_ENQUEUE(env) _TRACE_ONLY(CkpvAccess(_traces)->enqueue(env))
 #define _TRACE_DEQUEUE(env) _TRACE_ONLY(CkpvAccess(_traces)->dequeue(env))
 
-// for Sdag only
-// fixme - think of better api for tracing sdag code
-#define BgPrint(x)  _TRACE_ONLY(CkpvAccess(_traces)->bgPrint(x))
-#define _TRACE_BG_BEGIN_EXECUTE(x,pLogPtr)  _TRACE_ONLY(CkpvAccess(_traces)->bgBeginExec(x,pLogPtr))
-#define _TRACE_BG_END_EXECUTE()   _TRACE_ONLY(CkpvAccess(_traces)->bgEndExec())
-#define _TRACE_BG_TLINE_END(pLogPtr) _TRACE_ONLY(CkpvAccess(_traces)->tlineEnd(pLogPtr))
-#define _TRACE_BG_FORWARD_DEPS(logs1,logs2,size,fDep)  _TRACE_ONLY(CkpvAccess(_traces)->getForwardDepForAll(logs1,logs2, size,fDep))
-#define _TRACE_BG_USER_EVENT_BRACKET(x,bt,et,pLogPtr) _TRACE_ONLY(CkpvAccess(_traces)->userBracketEvent(x,bt,et,pLogPtr))
-#define _TRACE_BGLIST_USER_EVENT_BRACKET(x,bt,et,pLogPtr,bgLogList) _TRACE_ONLY(CkpvAccess(_traces)->userBracketEvent(x,bt,et,pLogPtr,bgLogList))
-
+#include "trace-bluegene.h"
 
 #endif