after merge (mostly tabbing issues)
authorHamed Gorjiara <hgorjiar@uci.edu>
Mon, 27 Aug 2018 18:32:04 +0000 (11:32 -0700)
committerHamed Gorjiara <hgorjiar@uci.edu>
Mon, 27 Aug 2018 18:32:04 +0000 (11:32 -0700)
src/ASTTransform/elementopt.cc
src/Tuner/autotuner.cc
src/Tuner/searchtuner.cc
src/Tuner/searchtuner.h
src/Tuner/tunable.cc

index 6fec15597d29f84d21b7cef38130ee7467eca364..44773795c965a180014fdcae8a0788974cecb7dc 100644 (file)
@@ -71,7 +71,7 @@ void ElementOpt::handlePredicateEquals(BooleanPredicate *pred, ElementSet *left,
                replaceVarWithConst(pred, left, right);
        } else if (pred->isFalse() && updateSets) {
                constrainVarWithConst(pred, left, right);
-       } else ASSERT(0);
+       }
 }
 
 void ElementOpt::handlePredicateInequality(BooleanPredicate *pred, ElementSet *var, ElementConst *value) {
index 3b5f8ccf6441f47ff1297db3a3dca0a8f6434cea..ff3aa3f9f81b16b0ea368af69fbf94c72497e028 100644 (file)
@@ -102,6 +102,7 @@ void AutoTuner::tune() {
        }
        model_print("Best tuner:\n");
        bestTuner->print();
+       bestTuner->serialize();
        model_print("Received score %f\n", bestScore);
        if (bestTuner != NULL)
                delete bestTuner;
index a0fc1bca4a90d5b0d03bff4e541910b767b0d517..6803c448c0d3402338fa8865830e026fe39d1e72 100644 (file)
@@ -1,4 +1,7 @@
 #include "searchtuner.h"
+#include <iostream>
+#include <fstream>
+using namespace std;
 
 TunableSetting::TunableSetting(VarType _type, TunableParam _param) :
        hasVar(true),
@@ -59,7 +62,39 @@ bool tunableSettingEquals(TunableSetting *setting1, TunableSetting *setting2) {
                                 setting1->param == setting2->param;
 }
 
+ostream& operator<<(ostream& os, const TunableSetting& ts)  
+{  
+    os << ts.hasVar <<" " << ts.type1 <<" " << ts.type2 << " " << ts.param << " " << ts.lowValue <<" " 
+            << ts.highValue << " " << ts.defaultValue << " " << ts.selectedValue;  
+    return os;  
+}  
+
+
 SearchTuner::SearchTuner() {
+       ifstream myfile;
+       myfile.open (TUNEFILE, ios::in);
+       if(myfile.is_open()){
+               bool hasVar;
+               VarType type1;
+               VarType type2;
+               TunableParam param;
+               int lowValue;
+               int highValue;
+               int defaultValue;
+               int selectedValue;
+               while(myfile >> hasVar >> type1 >> type2 >> param >> lowValue >> highValue >> defaultValue >> selectedValue){
+                       TunableSetting *setting;
+                       
+                       if(hasVar){
+                               setting = new TunableSetting(type1, type2, param);
+                       }else{
+                               setting = new TunableSetting(param);
+                       }
+                       setting->setDecision(lowValue, highValue, defaultValue, selectedValue);
+                       usedSettings.add(setting);
+               }
+               myfile.close();
+       }
 }
 
 SearchTuner *SearchTuner::copyUsed() {
@@ -140,6 +175,18 @@ void SearchTuner::print() {
 
 }
 
+void SearchTuner::serialize() {
+       ofstream myfile;
+       myfile.open (TUNEFILE, ios::out | ios::trunc);
+       SetIteratorTunableSetting *iterator = settings.iterator();
+       while (iterator->hasNext()) {
+               TunableSetting *setting = iterator->next();
+               myfile << *setting << endl;
+       }
+       myfile.close();
+       delete iterator;
+}
+
 void SearchTuner::printUsed() {
        SetIteratorTunableSetting *iterator = usedSettings.iterator();
        while (iterator->hasNext()) {
index 1464849e520f2b905a1627071af6760f3f7ea23c..0aabb6465affbc8b116b6271ef562efc7663f21e 100644 (file)
@@ -3,6 +3,9 @@
 #include "classlist.h"
 #include "tunable.h"
 #include "structs.h"
+#include <ostream>
+using namespace std;
+#define TUNEFILE "tune.conf"
 
 class TunableSetting {
 public:
@@ -12,6 +15,7 @@ public:
        TunableSetting(TunableSetting *ts);
        void setDecision(int _low, int _high, int _default, int _selection);
        void print();
+        friend std::ostream& operator<< (std::ostream& stream, const TunableSetting& matrix);
        CMEMALLOC;
 private:
        bool hasVar;
@@ -45,7 +49,8 @@ public:
        uint getSize() { return usedSettings.getSize();}
        void print();
        void printUsed();
-
+        void serialize();
+        
        CMEMALLOC;
 private:
        /** Used Settings keeps track of settings that were actually used by
@@ -55,4 +60,6 @@ private:
        /** Settings contains all settings. */
        HashsetTunableSetting settings;
 };
+
+
 #endif
index 6a74926901adb287d4f9893fc3a7f24f2d5c547c..a06d0f1290b888bcb0a167b86a2961a2c7ec1f21 100644 (file)
@@ -15,29 +15,35 @@ int DefaultTuner::getVarTunable(VarType vartype1, VarType vartype2, TunableParam
        return descriptor->defaultValue;
 }
 
-const char *tunableParameterToString(Tunables tunable) {
-       switch (tunable) {
-       case DECOMPOSEORDER:
-               return "DECOMPOSEORDER";
-       case MUSTREACHGLOBAL:
-               return "MUSTREACHGLOBAL";
-       case MUSTREACHLOCAL:
-               return "MUSTREACHLOCAL";
-       case MUSTREACHPRUNE:
-               return "MUSTREACHPRUNE";
-       case OPTIMIZEORDERSTRUCTURE:
-               return "OPTIMIZEORDERSTRUCTURE";
-       case ORDERINTEGERENCODING:
-               return "ORDERINTEGERENCODING";
-       case PREPROCESS:
-               return "PREPROCESS";
-       case NODEENCODING:
-               return "NODEENCODING";
-       case EDGEENCODING:
-               return "EDGEENCODING";
-       case MUSTEDGEPRUNE:
-               return "MUSTEDGEPRUNE";
-       default:
-               ASSERT(0);
-       }
-}
\ No newline at end of file
+const char* tunableParameterToString(Tunables tunable){
+        switch(tunable){
+                case DECOMPOSEORDER:
+                        return "DECOMPOSEORDER";
+                case MUSTREACHGLOBAL:
+                        return "MUSTREACHGLOBAL";
+                case MUSTREACHLOCAL:
+                        return "MUSTREACHLOCAL";
+                case MUSTREACHPRUNE:
+                        return "MUSTREACHPRUNE";
+                case OPTIMIZEORDERSTRUCTURE:
+                        return "OPTIMIZEORDERSTRUCTURE";
+                case ORDERINTEGERENCODING:
+                        return "ORDERINTEGERENCODING";
+                case PREPROCESS:
+                        return "PREPROCESS";
+                case NODEENCODING:
+                        return "NODEENCODING";
+                case EDGEENCODING:
+                        return "EDGEENCODING";
+                case MUSTEDGEPRUNE:
+                        return "MUSTEDGEPRUNE";
+               case ELEMENTOPT: 
+                       return "ELEMENTOPT";
+               case ELEMENTOPTSETS:
+                       return "ELEMENTOPTSETS";
+               case PROXYVARIABLE:
+                       return "PROXYVARIABLE";
+                default:
+                        ASSERT(0);
+        }
+}