a new command line option: +traceStartTime for trace-projections
authorGengbin Zheng <gzheng@illinois.edu>
Thu, 31 Mar 2011 15:34:38 +0000 (10:34 -0500)
committerGengbin Zheng <gzheng@illinois.edu>
Thu, 31 Mar 2011 15:34:38 +0000 (10:34 -0500)
at CkExit, it finds the min of start time on all processors and adjust logs before writing them to disks. This is useful if we use absolute wall timer (w/o substracting the artifical init_time)

src/ck-perf/trace-projections.C
src/ck-perf/trace-projections.ci
src/ck-perf/trace-projections.h
src/ck-perf/trace-projectionsBOC.h

index be5a14796103a6e0bb1ed0d05c83f7ac2b4379ca..efdf57bc4b8877cf154953aa23679d515725008c 100644 (file)
@@ -270,6 +270,7 @@ LogPool::LogPool(char *pgm) {
   // **CW** for simple delta encoding
   prevTime = 0.0;
   timeErr = 0.0;
+  globalStartTime = 0.0;
   globalEndTime = 0.0;
   headerWritten = 0;
   numPhases = 0;
@@ -577,7 +578,9 @@ void LogPool::writeRC(void)
     //CkPrintf("write RC is being executed\n");
 #ifdef PROJ_ANALYSIS  
     CkAssert(CkMyPe() == 0);
-    fprintf(rcfp,"RC_GLOBAL_END_TIME %lld\n",
+    fprintf(rcfp,"RC_GLOBAL_START_TIME %lld\n",
+         (CMK_TYPEDEF_UINT8)(1.0e6*globalStartTime));
+    fprintf(rcfp,"RC_GLOBAL_END_TIME   %lld\n",
          (CMK_TYPEDEF_UINT8)(1.0e6*globalEndTime));
     /* //Yanhua comment it because isOutlierAutomatic is not a variable in trace
     if (CkpvAccess(_trace)->isOutlierAutomatic()) {
@@ -1807,7 +1810,8 @@ TraceProjectionsInit::TraceProjectionsInit(CkArgMsg *msg) {
       findOutliers = true;
     }
   }
-  traceProjectionsGID = CProxy_TraceProjectionsBOC::ckNew(findOutliers);
+  bool findStartTime = CmiGetArgFlagDesc(msg->argv,"+traceStartTime", "Find minimum trace start time.");
+  traceProjectionsGID = CProxy_TraceProjectionsBOC::ckNew(findOutliers, findStartTime);
   if (findOutliers) {
     kMeansGID = CProxy_KMeansBOC::ckNew(outlierAutomatic,
                                        numKSeeds,
@@ -1844,6 +1848,9 @@ void TraceProjectionsBOC::traceProjectionsParallelShutdown(int pe) {
     kMeansProxy[CkMyPe()].startKMeansAnalysis();
   }
   parModulesRemaining++;
+  if (findStartTime) 
+  bocProxy[CkMyPe()].startTimeAnalysis();
+  else
   bocProxy[CkMyPe()].startEndTimeAnalysis();
 }
 
@@ -2662,6 +2669,28 @@ void KMeansBOC::phaseDone() {
   }
 }
 
+void TraceProjectionsBOC::startTimeAnalysis()
+{
+  double startTime = 0.0;
+  if (CkpvAccess(_trace)->_logPool->numEntries>0)
+     startTime = CkpvAccess(_trace)->_logPool->pool[0].time;
+  CkCallback cb(CkIndex_TraceProjectionsBOC::startTimeDone(NULL), thisProxy);
+  contribute(sizeof(double), &startTime, CkReduction::min_double, cb);  
+}
+
+void TraceProjectionsBOC::startTimeDone(CkReductionMsg *msg)
+{
+  // CkPrintf("[%d] TraceProjectionsBOC::startTimeDone time=\t%g parModulesRemaining:%d\n", CkMyPe(), CkWallTimer(), parModulesRemaining);
+
+  if (CkpvAccess(_trace) != NULL) {
+    CkpvAccess(_trace)->_logPool->globalStartTime = *(double *)msg->getData();
+    CkpvAccess(_trace)->_logPool->setNewStartTime();
+    //if (CkMyPe() == 0) CkPrintf("Start time determined to be %lf us\n", (CkpvAccess(_trace)->_logPool->globalStartTime)*1e06);
+  }
+  delete msg;
+  thisProxy[CkMyPe()].startEndTimeAnalysis();
+}
+
 void TraceProjectionsBOC::startEndTimeAnalysis()
 {
  //CkPrintf("[%d] TraceProjectionsBOC::startEndTimeAnalysis time=\t%g\n", CkMyPe(), CkWallTimer() );
index 3f7bc1ef09e746cc4a7f209fe6669d9d1491fc49..9de4ea191bbac360355e66a7005c60bf5e2e2234 100644 (file)
@@ -51,9 +51,11 @@ module TraceProjections {
   };
 
   group [migratable] TraceProjectionsBOC {
-    entry TraceProjectionsBOC(bool);
+    entry TraceProjectionsBOC(bool, bool);
 
     entry void traceProjectionsParallelShutdown(int);
+    entry void startTimeAnalysis(void);
+    entry void startTimeDone(CkReductionMsg *);
     entry void startEndTimeAnalysis(void);
     entry void endTimeDone(CkReductionMsg *);
     entry void kMeansDone(void);
index 6508fde60f114e92c65f613f7a968798fc721817..b6f9fad990dd54bcee194bff8916371e8df5ded6 100644 (file)
@@ -224,6 +224,13 @@ class LogEntry {
 #if defined(WIN32) || CMK_MULTIPLE_DELETE
     void operator delete(void *, void *) { }
 #endif
+
+    void setNewStartTime(double t) {
+      time -= t;
+      if (endTime>=t) endTime -= t;
+      if (recvTime>=t) recvTime -= t;
+    }
+
     void pup(PUP::er &p);
     ~LogEntry(){
       if (fName) delete [] fName;
@@ -268,6 +275,7 @@ class LogPool {
     // writing out logs.
     double prevTime;
     double timeErr;
+    double globalStartTime; // used at the end on Pe 0 only
     double globalEndTime; // used at the end on Pe 0 only
 
     int numPhases;
@@ -339,6 +347,10 @@ class LogPool {
       writeData = b;
     }
     void modLastEntryTimestamp(double ts);
+
+    void setNewStartTime() {
+      for(UInt i=0; i<numEntries; i++) pool[i].setNewStartTime(globalStartTime);
+    }
 };
 
 /*
index c91d2e0a4b1552d0f2d1b1e6fb972dc5dab7bb0e..68d032cab4ea2ae72cd60a21bbb3e830ad8d5bdd 100644 (file)
@@ -129,6 +129,7 @@ class KMeansBOC : public CBase_KMeansBOC {
 class TraceProjectionsBOC : public CBase_TraceProjectionsBOC {
  private:
   bool findOutliers;
+  bool findStartTime;
 
   int parModulesRemaining;
 
@@ -137,10 +138,12 @@ class TraceProjectionsBOC : public CBase_TraceProjectionsBOC {
   double analysisStartTime;
   int endPe;                          // end PE which calls CkExit()
  public:
- TraceProjectionsBOC(bool _findOutliers) : findOutliers(_findOutliers), parModulesRemaining(0), endPe(-1) {};
+ TraceProjectionsBOC(bool _findOutliers, bool _findStartTime) : findOutliers(_findOutliers), findStartTime(_findStartTime), parModulesRemaining(0), endPe(-1) {};
  TraceProjectionsBOC(CkMigrateMessage *m):CBase_TraceProjectionsBOC(m), parModulesRemaining(0), endPe(-1) {};
 
   void traceProjectionsParallelShutdown(int);
+  void startTimeAnalysis();
+  void startTimeDone(CkReductionMsg *);
   void startEndTimeAnalysis();
   void endTimeDone(CkReductionMsg *);
   void kMeansDone(CkReductionMsg *);