Added a GPU offload control point steering mechanism.
authorIsaac Dooley <isaacdooley@hope.cs.uiuc.edu>
Sat, 6 Feb 2010 20:51:19 +0000 (14:51 -0600)
committerIsaac Dooley <isaacdooley@hope.cs.uiuc.edu>
Sat, 6 Feb 2010 20:51:19 +0000 (14:51 -0600)
src/ck-cp/controlPoints.C

index cf4a1f8f5177607e2e12165de793d6b17578486e..f5fa0dec3fb13a8f21920838150270eb44aa1d53 100644 (file)
@@ -1270,109 +1270,163 @@ void controlPointManager::generatePlan() {
 
       // ========================================= Concurrency =============================================
       // See if idle time is high:
-      double idleTime = twoAgoPhase->idleTime.avg;
-      CkPrintf("Steering encountered idle time (%f)\n", idleTime);
-      fflush(stdout);
-      if(idleTime > 0.10){
-       CkPrintf("Steering encountered high idle time(%f) > 10%%\n", idleTime);
-       CkPrintf("Steering controlPointSpace.size()=\n", controlPointSpace.size());
+      {
+       double idleTime = twoAgoPhase->idleTime.avg;
+       CkPrintf("Steering encountered idle time (%f)\n", idleTime);
+       fflush(stdout);
+       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"];
+         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;
+         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;
          
-         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;
-         }
+           // Initialize a new plan based on two phases ago
+           std::map<std::string,int> aNewPlan;
          
-         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
+           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;
            }
-         } 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
+         
+           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);
+           possibleNextStepPlans.push_back(aNewPlan);
          
+         }
        }
       }
 
-
       // ========================================= 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());
+      {
+       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());
 
-       std::map<std::string, std::pair<int, std::vector<ControlPoint::ControlPointAssociation> > > &possibleCPsToTune = CkpvAccess(cp_effects)["GrainSize"];   
+         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;     
-       for(iter = possibleCPsToTune.begin(); iter != possibleCPsToTune.end(); iter++){
-         cpName = iter->first;
-         info = &iter->second;
+         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;
+           // 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
+           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;
            }
-         } 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
+         
+           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);
+         
          }
 
-         possibleNextStepPlans.push_back(aNewPlan);
+      }
+      }
+      // ========================================= GPU Offload =============================================
+      // If the grain size is too small, there may be tons of messages and overhead time associated with scheduling
+      {
+       double idleTime = twoAgoPhase->idleTime.avg;
+       CkPrintf("Steering encountered idle time (%f)\n", idleTime);
+       fflush(stdout);
+       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)["GPUOffloadedWork"];   
+       
+         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_DEC){
+             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);
+         
+         }
 
+       }
+      }
 
       // ========================================= Done =============================================