Fixing a few bugs in the performance measurement reduction.
authorIsaac Dooley <isaacdooley@hope.cs.uiuc.edu>
Wed, 13 Jan 2010 22:07:12 +0000 (16:07 -0600)
committerIsaac Dooley <isaacdooley@hope.cs.uiuc.edu>
Wed, 13 Jan 2010 22:07:12 +0000 (16:07 -0600)
src/ck-cp/controlPoints.C
src/ck-cp/controlPoints.ci
src/ck-cp/controlPoints.h
src/ck-perf/trace-controlPoints.C
src/ck-perf/trace-controlPoints.h

index fd8d079b702aa92513f9e262fad0491271d57cff..b061ced930d33918d298de6ee45fd97a33b95d85 100644 (file)
@@ -37,6 +37,7 @@ static void periodicProcessControlPoints(void* ptr, double currWallTime);
 /* readonly */ bool loadDataFileAtStartup;
 /* readonly */ bool shouldGatherMemoryUsage;
 /* readonly */ bool shouldGatherUtilization;
+/* readonly */ bool shouldGatherAll;
 
 
 typedef enum tuningSchemeEnum {RandomSelection, SimulatedAnnealing, ExhaustiveSearch, CriticalPathAutoPrioritization, UseBestKnownTiming, UseSteering}  tuningScheme;
@@ -97,9 +98,9 @@ CkReductionMsg *idleTimeReduction(int nMsg,CkReductionMsg **msgs){
 
 
 /// A reduction type that combines idle, overhead, and memory measurements
-CkReduction::reducerType idleOverMemReductionType;
+CkReduction::reducerType allMeasuresReductionType;
 /// A reducer that combines idle, overhead, and memory measurements
-CkReductionMsg *idleOverMemReduction(int nMsg,CkReductionMsg **msgs){
+CkReductionMsg *allMeasuresReduction(int nMsg,CkReductionMsg **msgs){
   double ret[7];
   if(nMsg > 0){
     CkAssert(msgs[0]->getSize()==7*sizeof(double));
@@ -126,14 +127,14 @@ CkReductionMsg *idleOverMemReduction(int nMsg,CkReductionMsg **msgs){
     // mem usage (max)
     ret[6]=max(ret[6],m[6]);
   }  
-  return CkReductionMsg::buildNew(3*sizeof(double),ret);   
+  return CkReductionMsg::buildNew(7*sizeof(double),ret);   
 }
 
 
 /// Registers the control point framework's reduction handlers at startup on each PE
 /*initproc*/ void registerCPReductions(void) {
   idleTimeReductionType=CkReduction::addReducer(idleTimeReduction);
-  idleOverMemReductionType=CkReduction::addReducer(idleOverMemReduction);
+  allMeasuresReductionType=CkReduction::addReducer(allMeasuresReduction);
 }
 
 
@@ -546,20 +547,34 @@ controlPointManager::controlPointManager(){
 
   /// Called by either the application or the Control Point Framework to advance to the next phase  
   void controlPointManager::gotoNextPhase(){
-
-    if(shouldGatherMemoryUsage && CkMyPe() == 0 && !alreadyRequestedMemoryUsage){
-      alreadyRequestedMemoryUsage = true;
-      CkCallback *cb = new CkCallback(CkIndex_controlPointManager::gatherMemoryUsage(NULL), 0, thisProxy);
-      thisProxy.requestMemoryUsage(*cb);
-      delete cb;
-    }
-
-    if(shouldGatherUtilization && CkMyPe() == 0 && !alreadyRequestedIdleTime){
-      alreadyRequestedIdleTime = true;
-      CkCallback *cb = new CkCallback(CkIndex_controlPointManager::gatherIdleTime(NULL), 0, thisProxy);
-      thisProxy.requestIdleTime(*cb);
+    
+    CkPrintf("gotoNextPhase shouldGatherAll=%d\n", (int)shouldGatherAll);
+    fflush(stdout);
+
+    if(shouldGatherAll && CkMyPe() == 0 && !alreadyRequestedAll){
+      alreadyRequestedAll = true;
+      CkCallback *cb = new CkCallback(CkIndex_controlPointManager::gatherAll(NULL), 0, thisProxy);
+      CkPrintf("Requesting all measurements\n");
+      thisProxy.requestAll(*cb);
       delete cb;
+    
+    } else {
+      
+      if(shouldGatherMemoryUsage && CkMyPe() == 0 && !alreadyRequestedMemoryUsage){
+       alreadyRequestedMemoryUsage = true;
+       CkCallback *cb = new CkCallback(CkIndex_controlPointManager::gatherMemoryUsage(NULL), 0, thisProxy);
+       thisProxy.requestMemoryUsage(*cb);
+       delete cb;
+      }
+      
+      if(shouldGatherUtilization && CkMyPe() == 0 && !alreadyRequestedIdleTime){
+       alreadyRequestedIdleTime = true;
+       CkCallback *cb = new CkCallback(CkIndex_controlPointManager::gatherIdleTime(NULL), 0, thisProxy);
+       thisProxy.requestIdleTime(*cb);
+       delete cb;
+      }
     }
+    
 
 
 
@@ -690,10 +705,10 @@ controlPointManager::controlPointManager(){
 
 
   /// Entry method called on all PEs to request CPU utilization statistics and memory usage
-  void controlPointManager::requestIdleOverMem(CkCallback cb){
+  void controlPointManager::requestAll(CkCallback cb){
     const double i = localControlPointTracingInstance()->idleRatio();
     const double o = localControlPointTracingInstance()->overheadRatio();
-    const double m = localControlPointTracingInstance()->memoryUsage();
+    const double m = localControlPointTracingInstance()->memoryUsageMB();
     
     double data[3+3+1];
 
@@ -711,13 +726,13 @@ controlPointManager::controlPointManager(){
 
     mem[0] = m;
     
-    localControlPointTracingInstance()->resetIdleOverheadMem();
+    localControlPointTracingInstance()->resetAll();
 
-    contribute(7*sizeof(double),idle,idleOverMemReductionType, cb);
+    contribute(7*sizeof(double),data,allMeasuresReductionType, cb);
   }
   
   /// All processors reduce their memory usages in requestIdleTime() to this method
-  void controlPointManager::gatherIdleOverMem(CkReductionMsg *msg){
+  void controlPointManager::gatherAll(CkReductionMsg *msg){
     int size=msg->getSize() / sizeof(double);
     CkAssert(size==7);
     double *data=(double *) msg->getData();
@@ -741,7 +756,7 @@ controlPointManager::controlPointManager(){
       CkPrintf("There is no previous phase to store measurements\n");
     }
     
-    alreadyRequestedIdleOverMem = false;
+    alreadyRequestedAll = false;
     checkForShutdown();
     delete msg;
   }
@@ -916,18 +931,24 @@ public:
       whichTuningScheme = UseBestKnownTiming;
     } else if ( CmiGetArgFlagDesc(args->argv,"+CPSteering","Use Steering to adjust Control Point Values") ){
       whichTuningScheme = UseSteering;
-    } 
-
-    shouldGatherMemoryUsage = false;
-    if ( CmiGetArgFlagDesc(args->argv,"+CPGatherMemoryUsage","Gather memory usage after each phase") ){
-      shouldGatherMemoryUsage = true;
     }
 
+
+    shouldGatherAll = false;
+    shouldGatherMemoryUsage = false;
     shouldGatherUtilization = false;
-    if ( CmiGetArgFlagDesc(args->argv,"+CPGatherUtilization","Gather utilization & Idle time after each phase") ){
-      shouldGatherUtilization = true;
+    
+    if ( CmiGetArgFlagDesc(args->argv,"+CPGatherAll","Gather all types of measurements for each phase") ){
+      shouldGatherAll = true;
+    } else {
+      if ( CmiGetArgFlagDesc(args->argv,"+CPGatherMemoryUsage","Gather memory usage after each phase") ){
+       shouldGatherMemoryUsage = true;
+      }
+      if ( CmiGetArgFlagDesc(args->argv,"+CPGatherUtilization","Gather utilization & Idle time after each phase") ){
+       shouldGatherUtilization = true;
+      }
     }
-
+    
     writeDataFileAtShutdown = false;   
     if( CmiGetArgFlagDesc(args->argv,"+CPSaveData","Save Control Point timings & configurations at completion") ){
       writeDataFileAtShutdown = true;
index 1439600c44adc810c33ebeb6af4c080be981aafd..705e990f20ffa22d66047422aeb0a8f98bc392fd 100644 (file)
@@ -6,7 +6,7 @@ module ControlPoints {
   readonly int whichTuningScheme;
   readonly bool shouldGatherMemoryUsage;
   readonly bool shouldGatherUtilization;
-
+  readonly bool shouldGatherAll;
 
   initproc void registerCPReductions(void);    
 
@@ -36,6 +36,9 @@ module ControlPoints {
     entry void requestIdleTime(CkCallback cb);
     entry void gatherIdleTime(CkReductionMsg *msg);
 
+    entry void requestAll(CkCallback cb);
+    entry void gatherAll(CkReductionMsg *msg);
+  
  }   
 
 
index a705b9a79d283b69fb9433197d3bc45633a702d3..421d133ca02a803f85cba8dae064b210a5cd979d 100644 (file)
@@ -546,7 +546,7 @@ public:
 
   bool alreadyRequestedMemoryUsage;
   bool alreadyRequestedIdleTime;
-  bool alreadyRequestedIdleOverMem;
+  bool alreadyRequestedAll;
 
   bool exitWhenReady;
 
@@ -615,13 +615,11 @@ public:
   
 
   /// Entry method called on all PEs to request Idle, Overhead, and Memory measurements
-  void requestIdleOverMem(CkCallback cb);
+  void requestAll(CkCallback cb);
   /// All processors reduce their memory usages in requestIdleTime() to this method
-  void gatherIdleOverMem(CkReductionMsg *msg);
+  void gatherAll(CkReductionMsg *msg);
   
 
-
-
   /// Inform the control point framework that a named control point affects the priorities of some array  
   void associatePriorityArray(const char *name, int groupIdx);
   
index d11db2051dde90a9630c89c80dedc6c319ef0364..30565738f0bf3d63739c68dfe814c615dc20a6ce 100644 (file)
@@ -186,7 +186,7 @@ void TraceControlPoints::resetTimings(){
   lastResetTime = CmiWallTimer();
 }
 
-void TraceControlPoints::resetIdleOverheadMem(){
+void TraceControlPoints::resetAll(){
   totalIdleTime = 0.0;
   totalEntryMethodTime = 0.0;
   memUsage = 0;
index 9b43bdd9ecf9805837ff11c7d6e08d5ac67bf945..c0e36d3e1c5b30daa62d71c40a53715e093e61c8 100644 (file)
@@ -99,21 +99,23 @@ class TraceControlPoints : public Trace {
   void resetTimings();
 
   /** Reset the idle, overhead, and memory measurements */
-  void resetIdleOverheadMem();
+  void resetAll();
 
   /** Fraction of the time spent idle */
   double idleRatio(){
-    return (totalIdleTime) / (CmiWallTimer() - lastResetTime);
+    double t = CmiWallTimer() - lastResetTime;
+    return (totalIdleTime) / t;
   }
 
   /** Fraction of time spent as overhead */
   double overheadRatio(){
-    return 0.0;
+    double t = CmiWallTimer() - lastResetTime;
+    return (t - totalIdleTime - totalEntryMethodTime) / t;
   }
 
-  /** Highest memory usage value we've seen since last time */
-  double memoryUsage(){
-    return 0.0;
+  /** Highest memory usage (in MB) value we've seen since last time */
+  double memoryUsageMB(){
+    return memUsage / 1024.0 / 1024.0;
   }