From e7618e37c666c14b49e6ad300b7bb5cae66cd6f4 Mon Sep 17 00:00:00 2001
From: Hashim Sharif <hsharif3@tyler.cs.illinois.edu>
Date: Mon, 17 Feb 2020 03:49:54 -0600
Subject: [PATCH] Using Unique IDs across multiple devtuner invocations

---
 .../autotuner/opentuner/autotuner/devtuner.py       |  8 ++++++--
 .../autotuner/tuner_driver_src/run_devtime_tuner.py | 13 ++++++++++---
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/llvm/projects/hpvm-tensor-rt/autotuner/opentuner/autotuner/devtuner.py b/llvm/projects/hpvm-tensor-rt/autotuner/opentuner/autotuner/devtuner.py
index cd2af2e93d..3d95a19da8 100644
--- a/llvm/projects/hpvm-tensor-rt/autotuner/opentuner/autotuner/devtuner.py
+++ b/llvm/projects/hpvm-tensor-rt/autotuner/opentuner/autotuner/devtuner.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 #
-# Algorithmic Approximation Tuning
-# Purpose: Tunes for Perforation, Sampling, Numerical Precision (FP16)
+# Development-time Tuner with Algorithmic Approximations:
+# Approximations: Perforation, Sampling with varying knobs for rate, skip offset
 
 
 import adddeps  
@@ -282,6 +282,8 @@ if __name__ == '__main__':
   argparser.add_argument('--cost-file', help='layer description')
   argparser.add_argument('--knobs-config', help='knob settings and ID mapping')
   argparser.add_argument('--layer-knobs', help='per-layer Knobs')
+  # NOTE: needed to have unique file-names across runs
+  argparser.add_argument('--start-id', type=int, help='start id for naming output files')
   
   
   args = argparser.parse_args()
@@ -298,6 +300,8 @@ if __name__ == '__main__':
   
   tunerData.knobs_list = readLayerKnobs(args.layer_knobs)
   tunerData.knobs_speedup = readKnobConfig(args.knobs_config)
+  tunerData.test_id = args.start_id
+
   
   result_dir = args.result_dir
   if result_dir == "":
diff --git a/llvm/projects/hpvm-tensor-rt/autotuner/tuner_driver_src/run_devtime_tuner.py b/llvm/projects/hpvm-tensor-rt/autotuner/tuner_driver_src/run_devtime_tuner.py
index 1cbb1eceea..1f6592d85d 100644
--- a/llvm/projects/hpvm-tensor-rt/autotuner/tuner_driver_src/run_devtime_tuner.py
+++ b/llvm/projects/hpvm-tensor-rt/autotuner/tuner_driver_src/run_devtime_tuner.py
@@ -17,6 +17,8 @@ class DevTimeTuner:
     self.cost_file = tensorRT_dir + "/" + Bench.cost_file
     self.layer_knobs = tensorRT_dir + "/" + Bench.layer_knobs
     self.result_dir = tensorRT_dir + "/" + Bench.base_dir + "/loss_123/" + batch_id + "/dev_tuner/"
+    # NOTE: maintains overall autotuning iterations completed - across multiple devtuner invocations 
+    self.iterations_completed = 0
 
   
     
@@ -41,20 +43,25 @@ class DevTimeTuner:
     tuner_cmd += "../autotuner/data/global_knobs.txt"
     tuner_cmd += " --layer-knobs "
     tuner_cmd += self.layer_knobs
+    tuner_cmd += " --start-id "
+    tuner_cmd += str(self.iterations_completed)
   
 
     print (tuner_cmd)
 
     p = subprocess.Popen(tuner_cmd, shell=True)
     p.wait()
-  
+
+
+    # Update iterations completed after each completed devtuner.py invocation with N iterations
+    self.iterations_completed += self.autotuner_runs
 
   
   def runDevTuner(self):
 
     self.invokeDevTunerScript(0.85, self.autotuner_runs)
-    #self.invokeDevTunerScript(1.7, self.autotuner_runs)
-    #self.invokeDevTunerScript(2.5, self.autotuner_runs)
+    self.invokeDevTunerScript(1.7, self.autotuner_runs)
+    self.invokeDevTunerScript(2.5, self.autotuner_runs)
   
  
 
-- 
GitLab