Bug fix for tuner timeout
authorHamed Gorjiara <hgorjiar@uci.edu>
Thu, 18 Oct 2018 17:41:38 +0000 (10:41 -0700)
committerHamed Gorjiara <hgorjiar@uci.edu>
Thu, 18 Oct 2018 17:41:38 +0000 (10:41 -0700)
src/Tuner/multituner.cc
src/Tuner/multituner.h

index e872fac..64f67ae 100644 (file)
 
 #define UNSETVALUE -1
 
-Problem::Problem(const char *_problem) : problemnumber(-1), result(UNSETVALUE) , besttime(std::numeric_limits<double>::infinity()){
+Problem::Problem(const char *_problem, uint _timeout) : 
+       problemnumber(-1),
+       result(UNSETVALUE) , 
+       besttime(std::numeric_limits<double>::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() {
index 95354c8..85b028b 100644 (file)
@@ -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;
 };