From e9be8a7c3f779898510dceb7462b6d18438c15d7 Mon Sep 17 00:00:00 2001 From: Hamed Gorjiara Date: Fri, 14 Dec 2018 15:32:58 -0800 Subject: [PATCH] removing duplicates --- deploy-cs.sh | 4 ++-- src/Tuner/randomtuner.cc | 10 +++++++--- src/analyzer/tunerloganalyzer.py | 28 ++++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/deploy-cs.sh b/deploy-cs.sh index 899f6c5..2f41b32 100755 --- a/deploy-cs.sh +++ b/deploy-cs.sh @@ -17,7 +17,7 @@ cd $BASE rm -f $OUTFILE tar -czvf $OUTFILE $INFILE +cp $OUTFILE $SHAREDDIR for SERVER in $SERVERS; do - cp $OUTFILE $SHAREDDIR - ssh $USER@$SERVER "mv $SHAREDDIR$OUTFILE $REMOTEDIR; cd $REMOTEDIR; sudo rm -r $SRC; tar -xzvf $OUTFILE; cd $SRC; make clean; ./setup.sh" + ssh $USER@$SERVER "cp $SHAREDDIR$OUTFILE $REMOTEDIR; cd $REMOTEDIR; sudo rm -r $SRC; tar -xzvf $OUTFILE; cd $SRC; make clean; ./setup.sh" done diff --git a/src/Tuner/randomtuner.cc b/src/Tuner/randomtuner.cc index 67e53b8..3156190 100644 --- a/src/Tuner/randomtuner.cc +++ b/src/Tuner/randomtuner.cc @@ -147,6 +147,7 @@ void RandomTuner::tune() { model_print("Round %u of %u\n", r, budget); for (uint i = 0; i < tuners.getSize(); i++){ TunerRecord *tuner = tuners.get(i); + bool isNew = true; for (uint j = 0; j < problems.getSize(); j++){ Problem *problem = problems.get(j); long long metric = tuner->getTime(problem); @@ -159,15 +160,18 @@ void RandomTuner::tune() { tuner->setTime(problem, metric); else tuner->setTime(problem, -2); - if(j == 0 && tunerExists(tuner->getTuner())){ + if(tunerExists(tuner->getTuner())){ //Solving the first problem and noticing the tuner //already exists + isNew = false; break; - } else if(j == 0 && !tunerExists(tuner->getTuner())){ - explored.push(tuner); } } } + if(isNew){ + explored.push(tuner); + } + } uint tSize = tuners.getSize(); for (uint i = 0; i < tSize; i++) { diff --git a/src/analyzer/tunerloganalyzer.py b/src/analyzer/tunerloganalyzer.py index 92a0912..2417621 100644 --- a/src/analyzer/tunerloganalyzer.py +++ b/src/analyzer/tunerloganalyzer.py @@ -17,6 +17,8 @@ class AutoTunerArgParser: def getRunNumber(self): return self.args.number[0] +PROBLEMS = [] + TUNABLEHEADER = ["DECOMPOSEORDER", "MUSTREACHGLOBAL", "MUSTREACHLOCAL", "MUSTREACHPRUNE", "OPTIMIZEORDERSTRUCTURE", "ORDERINTEGERENCODING", "PREPROCESS", "NODEENCODING", "EDGEENCODING", "MUSTEDGEPRUNE", "ELEMENTOPT", "ENCODINGGRAPHOPT", "ELEMENTOPTSETS", "PROXYVARIABLE", "MUSTVALUE", "NAIVEENCODER", "VARIABLEORDER", @@ -89,8 +91,16 @@ def loadSolverTime(row, filename): row["EXECTIME"] = configs["EXECTIME"] def loadProblemName(row,filename): + global PROBLEMS with open(filename) as f: - row["PROBLEM"] = f.readline().replace("\n","") + problem = f.readline().replace("\n","") + probNumber = int(f.readline()) + if probNumber >= len(PROBLEMS): + PROBLEMS.insert(probNumber,problem) + elif PROBLEMS[probNumber] != problem: + PROBLEMS[probNumber] = problem + row["PROBLEM"] = problem + def loadTunerNumber(row, filename): with open(filename) as f: row["TUNERNUMBER"] = f.readline().replace("\n","") @@ -132,6 +142,7 @@ def analyzeLogs(file): def tunerCountAnalysis(file, rows): global TUNABLEHEADER + global PROBLEMS tunercount = {} tunernumber = {} for row in rows: @@ -154,11 +165,24 @@ def tunerCountAnalysis(file, rows): if tunercount[key] > 1: print key + "(ids:" + tunernumber[key] + ") = #" + str(tunercount[key]) +def combineRowForEachTuner(rows): + global PROBLEMS + newRows = [] + combined = None + for row in rows: + if row["PROBLEM"] == PROBLEMS[0]: + combined = row + for key in row: + if row[key]: + combined[key] = row[key] + if row["PROBLEM"] == PROBLEMS[len(PROBLEMS)-1]: + newRows.append(combined) + return newRows def main(): file = open("tuner.csv", "w") rows = analyzeLogs(file) - tunerCountAnalysis(file, rows) + tunerCountAnalysis(file, combineRowForEachTuner(rows) ) file.close() return -- 2.34.1