Save all data generated by autotuner pass
authorbdemsky <bdemsky@uci.edu>
Wed, 17 Oct 2018 18:38:02 +0000 (11:38 -0700)
committerbdemsky <bdemsky@uci.edu>
Wed, 17 Oct 2018 18:38:02 +0000 (11:38 -0700)
src/Tuner/multituner.cc
src/Tuner/multituner.h

index f28e781..3dcbacf 100644 (file)
@@ -72,6 +72,7 @@ void MultiTuner::printData() {
 void MultiTuner::addTuner(SearchTuner *tuner) {
        TunerRecord *t = new TunerRecord(tuner);
        tuners.push(t);
+       t->tunernumber = allTuners.getSize();
        allTuners.push(t);
 }
 
@@ -90,6 +91,19 @@ long long MultiTuner::evaluate(Problem *problem, TunerRecord *tuner) {
                }
        }
 
+       {
+               snprintf(buffer, sizeof(buffer), "tunernum%u", execnum);
+
+               ofstream myfile;
+               myfile.open (buffer, ios::out);
+
+
+               if (myfile.is_open()) {
+                       myfile << tuner->tunernumber << endl;
+                       myfile.close();
+               }
+       }
+
        //Write out the tuner
        snprintf(buffer, sizeof(buffer), "tuner%u", execnum);
        tuner->getTuner()->serialize(buffer);
@@ -136,6 +150,7 @@ void MultiTuner::tuneComp() {
                for (uint i = 0; i < tSize; i++) {
                        SearchTuner *tmpTuner = mutateTuner(tunerV->get(i)->getTuner(), b);
                        TunerRecord *tmp = new TunerRecord(tmpTuner);
+                       tmp->tunernumber = allTuners.getSize();
                        allTuners.push(tmp);
                        tunerV->push(tmp);
                }
@@ -298,6 +313,7 @@ TunerRecord *MultiTuner::tune(TunerRecord *tuner) {
        for (uint i = 0; i < budget; i++) {
                SearchTuner *tmpTuner = mutateTuner(oldTuner->getTuner(), i);
                TunerRecord *newTuner = oldTuner->changeTuner(tmpTuner);
+               newTuner->tunernumber = allTuners.getSize();
                allTuners.push(newTuner);
                double newScore = evaluateAll(newTuner);
                newTuner->tuner->printUsed();
index 8ee0170..73201dd 100644 (file)
@@ -19,7 +19,7 @@ private:
 
 class TunerRecord {
 public:
-       TunerRecord(SearchTuner *_tuner) : tuner(_tuner) {}
+       TunerRecord(SearchTuner *_tuner) : tuner(_tuner), tunernumber(-1) {}
        SearchTuner *getTuner() {return tuner;}
        TunerRecord *changeTuner(SearchTuner *_newtuner);
        void updateTuner(SearchTuner *_newtuner) {tuner = _newtuner;}
@@ -29,6 +29,7 @@ private:
        SearchTuner *tuner;
        Vector<Problem *> problems;
        Hashtable<Problem *, long long, uint64_t> timetaken;
+       int tunernumber;
        friend class MultiTuner;
        friend void clearVector(Vector<TunerRecord *> *tunerV);
 };