Adding capability of steering control point based on overhead measurements.
authorIsaac Dooley <isaacdooley@hope.cs.uiuc.edu>
Wed, 3 Feb 2010 22:21:52 +0000 (16:21 -0600)
committerIsaac Dooley <isaacdooley@hope.cs.uiuc.edu>
Wed, 3 Feb 2010 22:21:52 +0000 (16:21 -0600)
src/ck-cp/controlPoints.C

index bbfce282de27b4aedb39552bcb0662e241e3b633..cf4a1f8f5177607e2e12165de793d6b17578486e 100644 (file)
@@ -1267,6 +1267,8 @@ void controlPointManager::generatePlan() {
       
       std::vector<std::map<std::string,int> > possibleNextStepPlans;
 
+
+      // ========================================= Concurrency =============================================
       // See if idle time is high:
       double idleTime = twoAgoPhase->idleTime.avg;
       CkPrintf("Steering encountered idle time (%f)\n", idleTime);
@@ -1274,20 +1276,66 @@ void controlPointManager::generatePlan() {
       if(idleTime > 0.10){
        CkPrintf("Steering encountered high idle time(%f) > 10%%\n", idleTime);
        CkPrintf("Steering controlPointSpace.size()=\n", controlPointSpace.size());
+       
+       std::map<std::string, std::pair<int, std::vector<ControlPoint::ControlPointAssociation> > > &possibleCPsToTune = CkpvAccess(cp_effects)["Concurrency"];
+       
+       bool found = false;
+       std::string cpName;
+       std::pair<int, std::vector<ControlPoint::ControlPointAssociation> > *info;
+       std::map<std::string, std::pair<int, std::vector<ControlPoint::ControlPointAssociation> > >::iterator iter;
+       for(iter = possibleCPsToTune.begin(); iter != possibleCPsToTune.end(); iter++){
+         cpName = iter->first;
+         info = &iter->second;
+         
+         // Initialize a new plan based on two phases ago
+         std::map<std::string,int> aNewPlan;
+         
+         std::map<std::string, std::pair<int,int> >::const_iterator cpsIter;
+         for(cpsIter=controlPointSpace.begin(); cpsIter != controlPointSpace.end(); ++cpsIter){
+           const std::string &name = cpsIter->first;
+           const int& twoAgoValue =  twoAgoPhase->controlPoints[name];
+           aNewPlan[name] = twoAgoValue;
+         }
+         
+         CkPrintf("Steering found knob to turn\n");
+         fflush(stdout);
+
+         if(info->first == ControlPoint::EFF_INC){
+           const int maxValue = controlPointSpace[cpName].second;
+           const int twoAgoValue =  twoAgoPhase->controlPoints[cpName];
+           if(twoAgoValue+1 <= maxValue){
+             aNewPlan[cpName] = twoAgoValue+1; // increase from two phases back
+           }
+         } else {
+           const int minValue = controlPointSpace[cpName].second;
+           const int twoAgoValue =  twoAgoPhase->controlPoints[cpName];
+           if(twoAgoValue-1 >= minValue){
+             aNewPlan[cpName] = twoAgoValue-1; // decrease from two phases back
+           }
+         }
 
+         possibleNextStepPlans.push_back(aNewPlan);
+         
+       }
+      }
 
-       // Initialize the future plan to be the values from two phases ago (later we might adjust this)
 
-       CkPrintf("Steering initialized plan\n");
-       fflush(stdout);
+      // ========================================= Grain Size =============================================
+      // If the grain size is too small, there may be tons of messages and overhead time associated with scheduling
+      
+      double overheadTime = twoAgoPhase->overheadTime.avg;
+      CkPrintf("Steering encountered overhead time (%f)\n", overheadTime);
+      fflush(stdout);
+      if(overheadTime > 0.10){
+       CkPrintf("Steering encountered high overhead time(%f) > 10%%\n", overheadTime);
+       CkPrintf("Steering controlPointSpace.size()=\n", controlPointSpace.size());
 
-       // look for a possible control point knob to turn
-       std::map<std::string, std::pair<int, std::vector<ControlPoint::ControlPointAssociation> > > &possibleCPsToTune = CkpvAccess(cp_effects)["Concurrency"];
+       std::map<std::string, std::pair<int, std::vector<ControlPoint::ControlPointAssociation> > > &possibleCPsToTune = CkpvAccess(cp_effects)["GrainSize"];   
        
        bool found = false;
        std::string cpName;
        std::pair<int, std::vector<ControlPoint::ControlPointAssociation> > *info;
-       std::map<std::string, std::pair<int, std::vector<ControlPoint::ControlPointAssociation> > >::iterator iter;
+       std::map<std::string, std::pair<int, std::vector<ControlPoint::ControlPointAssociation> > >::iterator iter;     
        for(iter = possibleCPsToTune.begin(); iter != possibleCPsToTune.end(); iter++){
          cpName = iter->first;
          info = &iter->second;
@@ -1323,7 +1371,11 @@ void controlPointManager::generatePlan() {
          
        }
 
-      }
+    }
+
+
+      // ========================================= Done =============================================
+
 
       if(possibleNextStepPlans.size() > 0){
        newControlPoints = possibleNextStepPlans[0];