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;
-}
+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() {
+}
+
+SearchTuner::SearchTuner(const char *filename) {
ifstream myfile;
- myfile.open (TUNEFILE, ios::in);
- if(myfile.is_open()){
+ myfile.open (filename, ios::in);
+ if (myfile.is_open()) {
bool hasVar;
VarType type1;
VarType type2;
int highValue;
int defaultValue;
int selectedValue;
- while(myfile >> hasVar >> type1 >> type2 >> param >> lowValue >> highValue >> defaultValue >> selectedValue){
+ while (myfile >> hasVar >> type1 >> type2 >> param >> lowValue >> highValue >> defaultValue >> selectedValue) {
TunableSetting *setting;
-
- if(hasVar){
+
+ if (hasVar) {
setting = new TunableSetting(type1, type2, param);
- }else{
+ } else {
setting = new TunableSetting(param);
}
setting->setDecision(lowValue, highValue, defaultValue, selectedValue);
delete iterator;
}
+void SearchTuner::setTunable(TunableParam param, TunableDesc *descriptor, uint value) {
+ TunableSetting *result = new TunableSetting(param);
+ result->setDecision(descriptor->lowValue, descriptor->highValue, descriptor->defaultValue, value);
+ settings.add(result);
+ usedSettings.add(result);
+}
+
+void SearchTuner::setVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor, uint value) {
+ setVarTunable(vartype, 0, param, descriptor, value);
+}
+
+void SearchTuner::setVarTunable(VarType vartype1, VarType vartype2, TunableParam param, TunableDesc *descriptor, uint value) {
+ TunableSetting *result = new TunableSetting(vartype1, vartype2, param);
+ result->setDecision(descriptor->lowValue, descriptor->highValue, descriptor->defaultValue, value);
+ settings.add(result);
+ usedSettings.add(result);
+}
+
int SearchTuner::getTunable(TunableParam param, TunableDesc *descriptor) {
TunableSetting setting(param);
TunableSetting *result = usedSettings.get(&setting);
}
-void SearchTuner::serialize() {
+void SearchTuner::serialize(const char *filename) {
ofstream myfile;
- myfile.open (TUNEFILE, ios::out | ios::trunc);
+ myfile.open (filename, ios::out | ios::trunc);
SetIteratorTunableSetting *iterator = settings.iterator();
while (iterator->hasNext()) {
TunableSetting *setting = iterator->next();