From 7e245fe6ed87d92eba7da59f94bda439cd682c41 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Mon, 28 Aug 2017 14:41:46 -0700 Subject: [PATCH] Auto Tuner Initial Full Checkin --- src/Tuner/searchtuner.cc | 26 ++++++++++++++++++++++++++ src/Tuner/searchtuner.h | 5 ++++- src/csolver.cc | 4 ++-- src/csolver.h | 2 +- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/Tuner/searchtuner.cc b/src/Tuner/searchtuner.cc index fdc9835..e964f45 100644 --- a/src/Tuner/searchtuner.cc +++ b/src/Tuner/searchtuner.cc @@ -30,6 +30,13 @@ void TunableSetting::setDecision(int _low, int _high, int _default, int _selecti selectedValue = _selection; } +void TunableSetting::print() { + if (hasVar) { + model_print("Type %llu, ", type); + } + model_print("Param %u = %u\n", param, selectedValue); +} + unsigned int tunableSettingHash(TunableSetting *setting) { return setting->hasVar ^ setting->type ^ setting->param; } @@ -105,3 +112,22 @@ void SearchTuner::randomMutate() { else randomSetting->selectedValue = randomchoice + 1; } + +void SearchTuner::print() { + HSIteratorTunableSetting *iterator=settings.iterator(); + while(iterator->hasNext()) { + TunableSetting *setting=iterator->next(); + setting->print(); + } + delete iterator; + +} + +void SearchTuner::printUsed() { + HSIteratorTunableSetting *iterator=usedSettings.iterator(); + while(iterator->hasNext()) { + TunableSetting *setting=iterator->next(); + setting->print(); + } + delete iterator; +} diff --git a/src/Tuner/searchtuner.h b/src/Tuner/searchtuner.h index bf96b29..b41a3e0 100644 --- a/src/Tuner/searchtuner.h +++ b/src/Tuner/searchtuner.h @@ -10,6 +10,7 @@ class TunableSetting { TunableSetting(TunableParam param); TunableSetting(TunableSetting * ts); void setDecision(int _low, int _high, int _default, int _selection); + void print(); MEMALLOC; private: bool hasVar; @@ -39,7 +40,9 @@ class SearchTuner : public Tuner { SearchTuner * copyUsed(); void randomMutate(); uint getSize() { return usedSettings.getSize();} - + void print(); + void printUsed(); + MEMALLOC; private: /** Used Settings keeps track of settings that were actually used by diff --git a/src/csolver.cc b/src/csolver.cc index eecbaf3..a9a4f62 100644 --- a/src/csolver.cc +++ b/src/csolver.cc @@ -243,8 +243,8 @@ long long CSolver::getEncodeTime() { return satEncoder->getEncodeTime(); } long long CSolver::getSolveTime() { return satEncoder->getSolveTime(); } -void CSolver::autoTune() { - AutoTuner * autotuner=new AutoTuner(); +void CSolver::autoTune(uint budget) { + AutoTuner * autotuner=new AutoTuner(budget); autotuner->addProblem(this); autotuner->tune(); } diff --git a/src/csolver.h b/src/csolver.h index 7939ee5..92900a1 100644 --- a/src/csolver.h +++ b/src/csolver.h @@ -117,7 +117,7 @@ public: void replaceBooleanWithFalse(Boolean *bexpr); void replaceBooleanWithBoolean(Boolean *oldb, Boolean *newb); CSolver *clone(); - void autoTune(); + void autoTune(uint budget); void setTuner(Tuner * _tuner) { tuner = _tuner; } long long getElapsedTime() { return elapsedTime; } -- 2.34.1