Simplifying the control point effects script, and exposing the effect information.
authorIsaac Dooley <isaacdooley@hope.cs.uiuc.edu>
Tue, 22 Dec 2009 21:23:22 +0000 (15:23 -0600)
committerIsaac Dooley <isaacdooley@hope.cs.uiuc.edu>
Tue, 22 Dec 2009 21:23:22 +0000 (15:23 -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

index e45111d361e26407ec711209979d54b836a32bf8..a65f0f17636d1f08ac1c684f0ac9ccdc0353fd59 100644 (file)
@@ -9,13 +9,10 @@
 using namespace ControlPoint;
 using namespace std;
 
-enum EFFECT {EFF_DEC, EFF_INC};
+enum DIRECTION {EFF_DEC, EFF_INC};
 
-typedef map<std::string, map<std::string, vector<pair<int, ControlPoint::ControlPointAssociation> > > > cp_effect_map;
-typedef map<std::string, vector<pair<int, ControlPoint::ControlPointAssociation> > > cp_name_map;
-
-CkpvDeclare(cp_effect_map, cp_effects);
-CkpvDeclare(cp_name_map, cp_names);
+CkpvDeclare(ControlPoint::cp_effect_map, cp_effects);
+CkpvDeclare(ControlPoint::cp_name_map, cp_names);
 
 NoControlPointAssociation default_assoc;
 
@@ -30,12 +27,11 @@ ControlPoint::ControlPointAssociatedArray ControlPoint::assocWithArray(const CPr
 }
 
 void ControlPoint::initControlPointEffects() {
-       CkpvInitialize(cp_effect_map, cp_effects);
-       CkpvInitialize(cp_name_map, cp_names);
+    CkpvInitialize(cp_effect_map, cp_effects);
+    CkpvInitialize(cp_name_map, cp_names);
 }
 
 void testControlPointEffects() {
-
        ControlPoint::EffectIncrease::Priority("name");
        ControlPoint::EffectDecrease::Priority("name");
        ControlPoint::EffectIncrease::Priority("name", assocWithEntry(0));
@@ -92,12 +88,14 @@ void testControlPointEffects() {
        ControlPoint::EffectDecrease::GPUOffloadedWork("name");
        ControlPoint::EffectIncrease::GPUOffloadedWork("name", assocWithEntry(0));
        ControlPoint::EffectDecrease::GPUOffloadedWork("name", assocWithEntry(0));
+
 }
 
-void insert(const std::string control_type, const std::string name, const ControlPoint::ControlPointAssociation &a, const int effect) {
-       CkpvAccess(cp_effects)[control_type][name].push_back(std::make_pair(effect, a));
-       CkpvAccess(cp_names)[name].push_back(std::make_pair(effect, a));
+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));
 }
+
 void ControlPoint::EffectDecrease::Priority(std::string s, const ControlPoint::ControlPointAssociation &a) {
        insert("Priority", s, a, EFF_DEC);
 }
@@ -266,3 +264,5 @@ void ControlPoint::EffectDecrease::GPUOffloadedWork(std::string s) {
 void ControlPoint::EffectIncrease::GPUOffloadedWork(std::string s) {
        insert("GPUOffloadedWork", s, default_assoc, EFF_INC);
 }
+
+
index 9e1d497d50d48e260fb5a0d084220fdc73f763d0..e5e126703b0aaaaa60e4d4cfefc5ce0beb6786be 100644 (file)
@@ -53,6 +53,9 @@ 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;
+
 
 namespace EffectIncrease {
        void Priority(std::string name, const ControlPoint::ControlPointAssociation &a);
@@ -83,6 +86,7 @@ namespace EffectIncrease {
        void LoadBalancingPeriod(std::string name);
        void GPUOffloadedWork(std::string name, const ControlPoint::ControlPointAssociation &a);
        void GPUOffloadedWork(std::string name);
+
 }
 
 namespace EffectDecrease {
@@ -114,9 +118,13 @@ namespace EffectDecrease {
        void LoadBalancingPeriod(std::string name);
        void GPUOffloadedWork(std::string name, const ControlPoint::ControlPointAssociation &a);
        void GPUOffloadedWork(std::string name);
+
 }
 
 
-} //namespace ControlPoint 
+} //namespace ControlPoint
+
+CkpvExtern(ControlPoint::cp_effect_map, cp_effects);
+CkpvExtern(ControlPoint::cp_name_map, cp_names);
 
 #endif
index 4165f9a1801c9270912daa9f9b98534a264e79cd..92d7a5a7fad2cb6b692b173802593582409a56fb 100755 (executable)
@@ -102,20 +102,26 @@ 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;
 
-EOF
 
+namespace EffectIncrease {
+$funcdecls
+}
 
-print OUT_H "namespace EffectIncrease {\n";
-print OUT_H $funcdecls;
-print OUT_H "}\n\n";
+namespace EffectDecrease {
+$funcdecls
+}
 
-print OUT_H "namespace EffectDecrease {\n";
-print OUT_H $funcdecls;
-print OUT_H "}\n\n\n";
 
-print OUT_H "} //namespace ControlPoint \n\n";
-print OUT_H "#endif\n";
+} //namespace ControlPoint
+
+CkpvExtern(ControlPoint::cp_effect_map, cp_effects);
+CkpvExtern(ControlPoint::cp_name_map, cp_names);
+
+#endif
+EOF
 
 
 print OUT_CPP <<EOF;
@@ -130,16 +136,10 @@ print OUT_CPP <<EOF;
 using namespace ControlPoint;
 using namespace std;
 
-enum EFFECT {EFF_DEC, EFF_INC};
-
-EOF
-
-print OUT_CPP <<EOF;
-typedef map<std::string, map<std::string, vector<pair<int, ControlPoint::ControlPointAssociation> > > > cp_effect_map;
-typedef map<std::string, vector<pair<int, ControlPoint::ControlPointAssociation> > > cp_name_map;
+enum DIRECTION {EFF_DEC, EFF_INC};
 
-CkpvDeclare(cp_effect_map, cp_effects);
-CkpvDeclare(cp_name_map, cp_names);
+CkpvDeclare(ControlPoint::cp_effect_map, cp_effects);
+CkpvDeclare(ControlPoint::cp_name_map, cp_names);
 
 NoControlPointAssociation default_assoc;
 
@@ -154,23 +154,19 @@ ControlPoint::ControlPointAssociatedArray ControlPoint::assocWithArray(const CPr
 }
 
 void ControlPoint::initControlPointEffects() {
-\tCkpvInitialize(cp_effect_map, cp_effects);
-\tCkpvInitialize(cp_name_map, cp_names);
+    CkpvInitialize(cp_effect_map, cp_effects);
+    CkpvInitialize(cp_name_map, cp_names);
 }
 
 void testControlPointEffects() {
-
-EOF
-
-print OUT_CPP "$funccalls";
-
-print OUT_CPP <<EOF;
+$funccalls
 }
 
-void insert(const std::string control_type, const std::string name, const ControlPoint::ControlPointAssociation &a, const int effect) {
-\tCkpvAccess(cp_effects)[control_type][name].push_back(std::make_pair(effect, a));
-\tCkpvAccess(cp_names)[name].push_back(std::make_pair(effect, a));
+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));
 }
-EOF
 
-print OUT_CPP "$funcdefs";
+$funcdefs
+
+EOF