From 0cc81ff25e979fb2a3aa3525ed2631ec94ca8b1a Mon Sep 17 00:00:00 2001 From: Hamed Gorjiara Date: Sat, 27 Oct 2018 02:07:50 -0700 Subject: [PATCH] Bug fix: deserializing the tunernumber ... --- src/Tuner/multituner.cc | 22 +++++++++++----------- src/Tuner/multituner.h | 1 + src/common.h | 2 -- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Tuner/multituner.cc b/src/Tuner/multituner.cc index d8c8fb7..5ea9800 100644 --- a/src/Tuner/multituner.cc +++ b/src/Tuner/multituner.cc @@ -146,7 +146,7 @@ void MultiTuner::readData(uint numRuns) { allTuners.setSize(tunernumber + 1); if (allTuners.get(tunernumber) == NULL) { snprintf(buffer, sizeof(buffer), "tuner%u", i); - allTuners.set(tunernumber, new TunerRecord(new SearchTuner(buffer))); + allTuners.set(tunernumber, new TunerRecord(new SearchTuner(buffer), tunernumber)); } //Add any new used records snprintf(buffer, sizeof(buffer), "tuner%uused", i); @@ -171,7 +171,7 @@ void MultiTuner::readData(uint numRuns) { snprintf(buffer, sizeof(buffer), "result%u", i); myfile.open (buffer, ios::in); - + if (myfile.is_open()) { myfile >> metric; @@ -302,8 +302,8 @@ void MultiTuner::tuneComp() { if (tuner->getTime(problem) == -1) { tuner->problems.push(problem); } - LOG("%u.Problem<%s>\tTuner<%p, %d>\tMetric<%lld>\n", i, problem->problem,tuner, tuner->tunernumber, metric); - LOG("*****************************\n"); + model_print("%u.Problem<%s>\tTuner<%p, %d>\tMetric<%lld>\n", i, problem->problem,tuner, tuner->tunernumber, metric); + model_print("*****************************\n"); if (metric != -1) tuner->setTime(problem, metric); } @@ -313,7 +313,7 @@ void MultiTuner::tuneComp() { if (metric < places.get(k)->getTime(problem)) break; } - LOG("place[%u]=Tuner<%p,%d>\n", k, tuner, tuner->tunernumber); + model_print("place[%u]=Tuner<%p,%d>\n", k, tuner, tuner->tunernumber); places.insertAt(k, tuner); } } @@ -324,8 +324,8 @@ void MultiTuner::tuneComp() { if (scores.contains(tuner)) currScore = scores.get(tuner); currScore += points; - LOG("Problem<%s>\tTuner<%p,%d>\tmetric<%d>\n", problem->problem, tuner, tuner->tunernumber, currScore); - LOG("**************************\n"); + model_print("Problem<%s>\tTuner<%p,%d>\tmetric<%d>\n", problem->problem, tuner, tuner->tunernumber, currScore); + model_print("**************************\n"); scores.put(tuner, currScore); points = points / 3; } @@ -345,14 +345,14 @@ void MultiTuner::tuneComp() { if (score > tscore) break; } - LOG("ranking[%u]=tuner<%p,%u>(Score=%d)\n", j, tuner, tuner->tunernumber, score); - LOG("************************\n"); + model_print("ranking[%u]=tuner<%p,%u>(Score=%d)\n", j, tuner, tuner->tunernumber, score); + model_print("************************\n"); ranking.insertAt(j, tuner); } - LOG("tunerSize=%u\trankingSize=%u\ttunerVSize=%u\n", tuners.getSize(), ranking.getSize(), tunerV->getSize()); + model_print("tunerSize=%u\trankingSize=%u\ttunerVSize=%u\n", tuners.getSize(), ranking.getSize(), tunerV->getSize()); for (uint i = tuners.getSize(); i < ranking.getSize(); i++) { TunerRecord *tuner = ranking.get(i); - LOG("Removing tuner %u\n", tuner->tunernumber); + model_print("Removing tuner %u\n", tuner->tunernumber); for (uint j = 0; j < tunerV->getSize(); j++) { if (tunerV->get(j) == tuner) tunerV->removeAt(j); diff --git a/src/Tuner/multituner.h b/src/Tuner/multituner.h index deb980b..87e8557 100644 --- a/src/Tuner/multituner.h +++ b/src/Tuner/multituner.h @@ -22,6 +22,7 @@ private: class TunerRecord { public: TunerRecord(SearchTuner *_tuner) : tuner(_tuner), tunernumber(-1) {} + TunerRecord(SearchTuner *_tuner, int _tunernumber) : tuner(_tuner), tunernumber(_tunernumber) {} SearchTuner *getTuner() {return tuner;} TunerRecord *changeTuner(SearchTuner *_newtuner); void updateTuner(SearchTuner *_newtuner) {tuner = _newtuner;} diff --git a/src/common.h b/src/common.h index b3ddb77..401a5e8 100644 --- a/src/common.h +++ b/src/common.h @@ -41,11 +41,9 @@ extern int switch_alloc; #ifdef CONFIG_DEBUG #define DEBUG(fmt, ...) do { model_print("*** %15s:%-4d %25s() *** " fmt, __FILE__, __LINE__, __func__, ## __VA_ARGS__); } while (0) #define DBG() DEBUG("\n") -#define LOG(fmt, ...) do {model_print(fmt, ## __VA_ARGS__);} while (0) #define DBG_ENABLED() (1) #else #define DEBUG(fmt, ...) -#define LOG(fmt, ...) #define DBG() #define DBG_ENABLED() (0) #endif -- 2.34.1