Improving the performance steering planning routine in the control point framework.
authorIsaac Dooley <isaacdooley@hope.cs.uiuc.edu>
Tue, 26 Jan 2010 23:06:38 +0000 (17:06 -0600)
committerIsaac Dooley <isaacdooley@hope.cs.uiuc.edu>
Tue, 26 Jan 2010 23:06:38 +0000 (17:06 -0600)
src/ck-cp/API-generator/cp_effects.C
src/ck-cp/API-generator/cp_effects.h
src/ck-cp/API-generator/cp_effects.pl
src/ck-cp/API-generator/cp_effects.txt
src/ck-cp/controlPoints.C

index a65f0f17636d1f08ac1c684f0ac9ccdc0353fd59..2c74da8a7493ed10059e3bb4e12bb77b0aab2ec2 100644 (file)
@@ -9,10 +9,8 @@
 using namespace ControlPoint;
 using namespace std;
 
-enum DIRECTION {EFF_DEC, EFF_INC};
-
 CkpvDeclare(ControlPoint::cp_effect_map, cp_effects);
-CkpvDeclare(ControlPoint::cp_name_map, cp_names);
+//CkpvDeclare(ControlPoint::cp_name_map, cp_names);
 
 NoControlPointAssociation default_assoc;
 
@@ -28,7 +26,7 @@ ControlPoint::ControlPointAssociatedArray ControlPoint::assocWithArray(const CPr
 
 void ControlPoint::initControlPointEffects() {
     CkpvInitialize(cp_effect_map, cp_effects);
-    CkpvInitialize(cp_name_map, cp_names);
+//    CkpvInitialize(cp_name_map, cp_names);
 }
 
 void testControlPointEffects() {
@@ -40,10 +38,10 @@ void testControlPointEffects() {
        ControlPoint::EffectDecrease::MemoryConsumption("name");
        ControlPoint::EffectIncrease::MemoryConsumption("name", assocWithEntry(0));
        ControlPoint::EffectDecrease::MemoryConsumption("name", assocWithEntry(0));
-       ControlPoint::EffectIncrease::Granularity("name");
-       ControlPoint::EffectDecrease::Granularity("name");
-       ControlPoint::EffectIncrease::Granularity("name", assocWithEntry(0));
-       ControlPoint::EffectDecrease::Granularity("name", assocWithEntry(0));
+       ControlPoint::EffectIncrease::GrainSize("name");
+       ControlPoint::EffectDecrease::GrainSize("name");
+       ControlPoint::EffectIncrease::GrainSize("name", assocWithEntry(0));
+       ControlPoint::EffectDecrease::GrainSize("name", assocWithEntry(0));
        ControlPoint::EffectIncrease::ComputeDurations("name");
        ControlPoint::EffectDecrease::ComputeDurations("name");
        ControlPoint::EffectIncrease::ComputeDurations("name", assocWithEntry(0));
@@ -92,8 +90,10 @@ void testControlPointEffects() {
 }
 
 void insert(const std::string effect, const std::string name, const ControlPoint::ControlPointAssociation &assoc, const int direction) {
-    CkpvAccess(cp_effects)[effect][name].push_back(std::make_pair(direction, assoc));
-    CkpvAccess(cp_names)[name].push_back(std::make_pair(direction, assoc));
+   std::pair<int, std::vector<ControlPoint::ControlPointAssociation> > &info = CkpvAccess(cp_effects)[effect][name];
+   info.first = direction;
+   info.second.push_back(assoc);
+  // CkpvAccess(cp_names)[name] = make_pair(push_back(std::make_pair(direction, assoc));
 }
 
 void ControlPoint::EffectDecrease::Priority(std::string s, const ControlPoint::ControlPointAssociation &a) {
@@ -120,17 +120,17 @@ void ControlPoint::EffectDecrease::MemoryConsumption(std::string s) {
 void ControlPoint::EffectIncrease::MemoryConsumption(std::string s) {
        insert("MemoryConsumption", s, default_assoc, EFF_INC);
 }
-void ControlPoint::EffectDecrease::Granularity(std::string s, const ControlPoint::ControlPointAssociation &a) {
-       insert("Granularity", s, a, EFF_DEC);
+void ControlPoint::EffectDecrease::GrainSize(std::string s, const ControlPoint::ControlPointAssociation &a) {
+       insert("GrainSize", s, a, EFF_DEC);
 }
-void ControlPoint::EffectIncrease::Granularity(std::string s, const ControlPoint::ControlPointAssociation &a) {
-       insert("Granularity", s, a, EFF_INC);
+void ControlPoint::EffectIncrease::GrainSize(std::string s, const ControlPoint::ControlPointAssociation &a) {
+       insert("GrainSize", s, a, EFF_INC);
 }
-void ControlPoint::EffectDecrease::Granularity(std::string s) {
-       insert("Granularity", s, default_assoc, EFF_DEC);
+void ControlPoint::EffectDecrease::GrainSize(std::string s) {
+       insert("GrainSize", s, default_assoc, EFF_DEC);
 }
-void ControlPoint::EffectIncrease::Granularity(std::string s) {
-       insert("Granularity", s, default_assoc, EFF_INC);
+void ControlPoint::EffectIncrease::GrainSize(std::string s) {
+       insert("GrainSize", s, default_assoc, EFF_INC);
 }
 void ControlPoint::EffectDecrease::ComputeDurations(std::string s, const ControlPoint::ControlPointAssociation &a) {
        insert("ComputeDurations", s, a, EFF_DEC);
index e5e126703b0aaaaa60e4d4cfefc5ce0beb6786be..c943aebc2afaa9f0eaba18f949fb130663c41ecb 100644 (file)
@@ -17,6 +17,9 @@
 #define __CP_EFFECTS_H__
 
 namespace ControlPoint {
+
+  enum DIRECTION {EFF_DEC, EFF_INC};
+
   class ControlPointAssociation {
   public:
     std::set<int> EntryID;
@@ -53,8 +56,11 @@ namespace ControlPoint {
   ControlPointAssociatedEntry assocWithEntry(const int entry);
   ControlPointAssociatedArray assocWithArray(const CProxy_ArrayBase &array);
 
-  typedef std::map<std::string,std:: map<std::string, std::vector<std::pair<int, ControlPoint::ControlPointAssociation> > > > cp_effect_map;
-  typedef std::map<std::string, std::vector<std::pair<int, ControlPoint::ControlPointAssociation> > > cp_name_map;
+ //                 effect               cp                 direction           associations
+  typedef std::map<std::string,std::map<std::string, std::pair<int, std::vector<ControlPoint::ControlPointAssociation> > > > cp_effect_map;
+
+ //                   cp                          direction           associations
+ //  typedef std::map<std::string, std::vector<std::pair<int, ControlPoint::ControlPointAssociation> > > cp_name_map;
 
 
 namespace EffectIncrease {
@@ -62,8 +68,8 @@ namespace EffectIncrease {
        void Priority(std::string name);
        void MemoryConsumption(std::string name, const ControlPoint::ControlPointAssociation &a);
        void MemoryConsumption(std::string name);
-       void Granularity(std::string name, const ControlPoint::ControlPointAssociation &a);
-       void Granularity(std::string name);
+       void GrainSize(std::string name, const ControlPoint::ControlPointAssociation &a);
+       void GrainSize(std::string name);
        void ComputeDurations(std::string name, const ControlPoint::ControlPointAssociation &a);
        void ComputeDurations(std::string name);
        void FlopRate(std::string name, const ControlPoint::ControlPointAssociation &a);
@@ -94,8 +100,8 @@ namespace EffectDecrease {
        void Priority(std::string name);
        void MemoryConsumption(std::string name, const ControlPoint::ControlPointAssociation &a);
        void MemoryConsumption(std::string name);
-       void Granularity(std::string name, const ControlPoint::ControlPointAssociation &a);
-       void Granularity(std::string name);
+       void GrainSize(std::string name, const ControlPoint::ControlPointAssociation &a);
+       void GrainSize(std::string name);
        void ComputeDurations(std::string name, const ControlPoint::ControlPointAssociation &a);
        void ComputeDurations(std::string name);
        void FlopRate(std::string name, const ControlPoint::ControlPointAssociation &a);
@@ -125,6 +131,6 @@ namespace EffectDecrease {
 } //namespace ControlPoint
 
 CkpvExtern(ControlPoint::cp_effect_map, cp_effects);
-CkpvExtern(ControlPoint::cp_name_map, cp_names);
+//CkpvExtern(ControlPoint::cp_name_map, cp_names);
 
 #endif
index 92d7a5a7fad2cb6b692b173802593582409a56fb..86d9ec025188473a1debe375a651ccb8ef44b26f 100755 (executable)
@@ -66,6 +66,9 @@ print OUT_H <<EOF;
 #define __CP_EFFECTS_H__
 
 namespace ControlPoint {
+
+  enum DIRECTION {EFF_DEC, EFF_INC};
+
   class ControlPointAssociation {
   public:
     std::set<int> EntryID;
@@ -102,8 +105,11 @@ namespace ControlPoint {
   ControlPointAssociatedEntry assocWithEntry(const int entry);
   ControlPointAssociatedArray assocWithArray(const CProxy_ArrayBase &array);
 
-  typedef std::map<std::string,std:: map<std::string, std::vector<std::pair<int, ControlPoint::ControlPointAssociation> > > > cp_effect_map;
-  typedef std::map<std::string, std::vector<std::pair<int, ControlPoint::ControlPointAssociation> > > cp_name_map;
+ //                 effect               cp                 direction           associations
+  typedef std::map<std::string,std::map<std::string, std::pair<int, std::vector<ControlPoint::ControlPointAssociation> > > > cp_effect_map;
+
+ //                   cp                          direction           associations
+ //  typedef std::map<std::string, std::vector<std::pair<int, ControlPoint::ControlPointAssociation> > > cp_name_map;
 
 
 namespace EffectIncrease {
@@ -118,7 +124,7 @@ $funcdecls
 } //namespace ControlPoint
 
 CkpvExtern(ControlPoint::cp_effect_map, cp_effects);
-CkpvExtern(ControlPoint::cp_name_map, cp_names);
+//CkpvExtern(ControlPoint::cp_name_map, cp_names);
 
 #endif
 EOF
@@ -136,10 +142,8 @@ print OUT_CPP <<EOF;
 using namespace ControlPoint;
 using namespace std;
 
-enum DIRECTION {EFF_DEC, EFF_INC};
-
 CkpvDeclare(ControlPoint::cp_effect_map, cp_effects);
-CkpvDeclare(ControlPoint::cp_name_map, cp_names);
+//CkpvDeclare(ControlPoint::cp_name_map, cp_names);
 
 NoControlPointAssociation default_assoc;
 
@@ -155,7 +159,7 @@ ControlPoint::ControlPointAssociatedArray ControlPoint::assocWithArray(const CPr
 
 void ControlPoint::initControlPointEffects() {
     CkpvInitialize(cp_effect_map, cp_effects);
-    CkpvInitialize(cp_name_map, cp_names);
+//    CkpvInitialize(cp_name_map, cp_names);
 }
 
 void testControlPointEffects() {
@@ -163,8 +167,10 @@ $funccalls
 }
 
 void insert(const std::string effect, const std::string name, const ControlPoint::ControlPointAssociation &assoc, const int direction) {
-    CkpvAccess(cp_effects)[effect][name].push_back(std::make_pair(direction, assoc));
-    CkpvAccess(cp_names)[name].push_back(std::make_pair(direction, assoc));
+   std::pair<int, std::vector<ControlPoint::ControlPointAssociation> > &info = CkpvAccess(cp_effects)[effect][name];
+   info.first = direction;
+   info.second.push_back(assoc);
+  // CkpvAccess(cp_names)[name] = make_pair(push_back(std::make_pair(direction, assoc));
 }
 
 $funcdefs
index 567d6d67ecbd63397be89e9a8e6e673db72ddc53..8ac4af5005bf07e41158002d66d09ddf89e89291 100644 (file)
@@ -1,6 +1,6 @@
 Priority
 MemoryConsumption
-Granularity
+GrainSize
 ComputeDurations
 FlopRate
 NumComputeObjects
index 2dd0ce32aafa520695075763e4eddb94e2f04915..f7a429a8d61d5d98cbf5546d49c814359674b896 100644 (file)
@@ -1189,13 +1189,13 @@ void controlPointManager::generatePlan() {
        fflush(stdout);
 
        // look for a possible control point knob to turn
-       std::map<std::string, std::vector<std::pair<int, ControlPoint::ControlPointAssociation> > > &possibleCPsToTune = CkpvAccess(cp_effects)["MemoryConsumption"];
+       std::map<std::string, std::pair<int, std::vector<ControlPoint::ControlPointAssociation> > > &possibleCPsToTune = CkpvAccess(cp_effects)["MemoryConsumption"];
        
        // FIXME: assume for now that we just have one control point with the effect, and one direction to turn it
        bool found = false;
        std::string cpName;
-       std::vector<std::pair<int, ControlPoint::ControlPointAssociation> > *info;
-       std::map<std::string, std::vector<std::pair<int, ControlPoint::ControlPointAssociation> > >::iterator iter;
+       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;
@@ -1249,13 +1249,15 @@ void controlPointManager::generatePlan() {
 
     instrumentedPhase *twoAgoPhase = twoAgoPhaseData();
     instrumentedPhase *prevPhase = previousPhaseData();
+
     if(phase_id%4 == 0){
       CkPrintf("Steering based on 2 phases ago:\n");
       twoAgoPhase->print();
       CkPrintf("\n");
       fflush(stdout);
       
+      std::vector<std::map<std::string,int> > possibleNextStepPlans;
+
       // See if idle time is high:
       double idleTime = twoAgoPhase->idleTime.avg;
       CkPrintf("Steering encountered idle time (%f)\n", idleTime);
@@ -1264,44 +1266,60 @@ void controlPointManager::generatePlan() {
        CkPrintf("Steering encountered high idle time(%f) > 10%%\n", idleTime);
        CkPrintf("Steering controlPointSpace.size()=\n", controlPointSpace.size());
 
-       // Initialize plan to be the values from two phases ago (later we'll adjust this)
-       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];
-         newControlPoints[name] = twoAgoValue;
-       }
+
+       // Initialize the future plan to be the values from two phases ago (later we might adjust this)
+
        CkPrintf("Steering initialized plan\n");
        fflush(stdout);
 
        // look for a possible control point knob to turn
-       std::map<std::string, std::vector<std::pair<int, ControlPoint::ControlPointAssociation> > > &possibleCPsToTune = CkpvAccess(cp_effects)["Concurrency"];
+       std::map<std::string, std::pair<int, std::vector<ControlPoint::ControlPointAssociation> > > &possibleCPsToTune = CkpvAccess(cp_effects)["Concurrency"];
        
-       // FIXME: assume for now that we just have one control point with the effect
        bool found = false;
        std::string cpName;
-       std::vector<std::pair<int, ControlPoint::ControlPointAssociation> > *info;
-       std::map<std::string, std::vector<std::pair<int, ControlPoint::ControlPointAssociation> > >::iterator iter;
+       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;
-         found = true;
-         break;
-       }
-
-       // Adapt the control point value
-       if(found){
+         
+         // 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);
-         const int twoAgoValue =  twoAgoPhase->controlPoints[cpName];
-         const int maxValue = controlPointSpace[cpName].second;
 
-         if(twoAgoValue+1 <= maxValue){
-           newControlPoints[cpName] = twoAgoValue+1; // incrase from two phases back
+         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);
+         
        }
-       
+
       }
+
+      if(possibleNextStepPlans.size() > 0){
+       newControlPoints = possibleNextStepPlans[0];
+      } 
+          
       
       CkPrintf("Steering done for this phase\n");
       fflush(stdout);