From bb95e237d699d0c859ef948399b63651d21d432e Mon Sep 17 00:00:00 2001 From: Hamed Gorjiara Date: Thu, 18 Oct 2018 10:41:38 -0700 Subject: [PATCH] Bug fix for tuner timeout --- src/Tuner/multituner.cc | 19 ++++++++++++------- src/Tuner/multituner.h | 3 ++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Tuner/multituner.cc b/src/Tuner/multituner.cc index e872fac..64f67ae 100644 --- a/src/Tuner/multituner.cc +++ b/src/Tuner/multituner.cc @@ -11,7 +11,12 @@ #define UNSETVALUE -1 -Problem::Problem(const char *_problem) : problemnumber(-1), result(UNSETVALUE) , besttime(std::numeric_limits::infinity()){ +Problem::Problem(const char *_problem, uint _timeout) : + problemnumber(-1), + result(UNSETVALUE) , + besttime(std::numeric_limits::infinity()), + timeout(_timeout) +{ uint len = strlen(_problem); problem = (char *) ourmalloc(len + 1); memcpy(problem, _problem, len + 1); @@ -51,7 +56,7 @@ MultiTuner::~MultiTuner() { } void MultiTuner::addProblem(const char *filename) { - Problem *p = new Problem(filename); + Problem *p = new Problem(filename, timeout); p->problemnumber = problems.getSize(); problems.push(p); } @@ -110,7 +115,7 @@ void MultiTuner::readData(uint numRuns) { if (problems.getSize() <= problemnumber) problems.setSize(problemnumber + 1); if (problems.get(problemnumber) == NULL) - problems.set(problemnumber, new Problem(problemname)); + problems.set(problemnumber, new Problem(problemname, timeout)); Problem *problem = problems.get(problemnumber); long long metric = -1; int sat = IS_INDETER; @@ -175,7 +180,7 @@ long long MultiTuner::evaluate(Problem *problem, TunerRecord *tuner) { tuner->getTuner()->serialize(buffer); //Do run - snprintf(buffer, sizeof(buffer), "./run.sh deserializerun %s %u tuner%u result%u > log%u", problem->getProblem(), timeout, execnum, execnum, execnum); + snprintf(buffer, sizeof(buffer), "./run.sh deserializerun %s %u tuner%u result%u > log%u", problem->getProblem(), problem->timeout, execnum, execnum, execnum); int status = system(buffer); long long metric = -1; @@ -223,10 +228,10 @@ void MultiTuner::updateTimeout(Problem *problem, long long metric){ }else { adoptive = 150; } - if(adoptive < timeout){ - timeout = adoptive; + if(adoptive < problem->timeout){ + problem->timeout = adoptive; } - LOG("Timeout=%u\tadoptive%u\tcurrentTime=%f\n", timeout, adoptive, currentTime); + LOG("Timeout=%u\tadoptive%u\tcurrentTime=%f\n", problem->timeout, adoptive, currentTime); } void MultiTuner::tuneComp() { diff --git a/src/Tuner/multituner.h b/src/Tuner/multituner.h index 95354c8..85b028b 100644 --- a/src/Tuner/multituner.h +++ b/src/Tuner/multituner.h @@ -7,7 +7,7 @@ class Problem { public: - Problem(const char *problem); + Problem(const char *problem, uint timeout); char *getProblem() {return problem;} ~Problem(); CMEMALLOC; @@ -16,6 +16,7 @@ private: int result; char *problem; double besttime; + uint timeout; friend class MultiTuner; }; -- 2.34.1