X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=src%2FTuner%2Fsearchtuner.h;h=76244257e08a5ba56de938a0cb4458b7ffb8e488;hb=9e62a28ca34fac2879e180633f3bb63077c1d333;hp=862faf690c45ad6b1f29cfd4d14dce95638b876f;hpb=83849cbb24f9680d1ca7c09d09ecefc6fe461d66;p=satune.git diff --git a/src/Tuner/searchtuner.h b/src/Tuner/searchtuner.h index 862faf6..7624425 100644 --- a/src/Tuner/searchtuner.h +++ b/src/Tuner/searchtuner.h @@ -3,18 +3,23 @@ #include "classlist.h" #include "tunable.h" #include "structs.h" +#include +using namespace std; class TunableSetting { - public: - TunableSetting(VarType type, TunableParam param); +public: + TunableSetting(VarType type, TunableParam param); + TunableSetting(VarType type1, VarType type2, TunableParam param); TunableSetting(TunableParam param); - TunableSetting(TunableSetting * ts); + 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: +private: bool hasVar; - VarType type; + VarType type1; + VarType type2; TunableParam param; int lowValue; int highValue; @@ -23,33 +28,38 @@ class TunableSetting { friend unsigned int tunableSettingHash(TunableSetting *setting); friend bool tunableSettingEquals(TunableSetting *setting1, TunableSetting *setting2); friend class SearchTuner; + friend class SerializeTuner; }; -unsigned int tunableSettingHash(TunableSetting *setting); -bool tunableSettingEquals(TunableSetting *setting1, TunableSetting *setting2); - -typedef Hashset HashsetTunableSetting; -typedef SetIterator SetIteratorTunableSetting; - class SearchTuner : public Tuner { - public: +public: SearchTuner(); + SearchTuner(const char *filename); ~SearchTuner(); - int getTunable(TunableParam param, TunableDesc *descriptor); + virtual int getTunable(TunableParam param, TunableDesc *descriptor); int getVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor); - SearchTuner * copyUsed(); + virtual int getVarTunable(VarType vartype1, VarType vartype2, TunableParam param, TunableDesc *descriptor); + void setTunable(TunableParam param, TunableDesc *descriptor, uint value); + void setVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor, uint value); + void setVarTunable(VarType vartype1, VarType vartype2, TunableParam param, TunableDesc *descriptor, uint value); + SearchTuner *copyUsed(); + bool isSubTunerof(SearchTuner *newTuner); void randomMutate(); uint getSize() { return usedSettings.getSize();} void print(); void printUsed(); - + void serialize(const char *file); + void serializeUsed(const char *file); + void addUsed(const char *file); + bool equalUsed(SearchTuner *tuner); CMEMALLOC; - private: +protected: /** Used Settings keeps track of settings that were actually used by - the example. Mutating settings may cause the Constraint Compiler - not to query other settings.*/ + the example. Mutating settings may cause the Constraint Compiler + not to query other settings.*/ HashsetTunableSetting usedSettings; /** Settings contains all settings. */ HashsetTunableSetting settings; }; + #endif