diff --git a/tools/AutoTuner/test/smoke_test_algo_eval.py b/tools/AutoTuner/test/smoke_test_algo_eval.py index a695489b48..985526e2bc 100644 --- a/tools/AutoTuner/test/smoke_test_algo_eval.py +++ b/tools/AutoTuner/test/smoke_test_algo_eval.py @@ -3,9 +3,7 @@ import os cur_dir = os.path.dirname(os.path.abspath(__file__)) -src_dir = os.path.join(cur_dir, "../src/autotuner") orfs_dir = os.path.join(cur_dir, "../../../flow") -os.chdir(src_dir) class BaseAlgoEvalSmokeTest(unittest.TestCase): @@ -22,7 +20,7 @@ def setUp(self): _eval = ["default", "ppa-improv"] self.matrix = [(a, e) for a in _algo for e in _eval] self.commands = [ - f"python3 distributed.py" + f"python3 -m autotuner.distributed" f" --design {self.design}" f" --platform {self.platform}" f" --experiment {self.experiment}" @@ -34,21 +32,14 @@ def setUp(self): ] def make_base(self): - os.chdir(orfs_dir) commands = [ - f"make DESIGN_CONFIG=./designs/{self.platform}/{self.design}/config.mk clean_all", - f"make DESIGN_CONFIG=./designs/{self.platform}/{self.design}/config.mk EQUIVALENCE_CHECK=0", - f"make DESIGN_CONFIG=./designs/{self.platform}/{self.design}/config.mk update_metadata_autotuner", + f"make -C {orfs_dir} DESIGN_CONFIG=./designs/{self.platform}/{self.design}/config.mk clean_all", + f"make -C {orfs_dir} DESIGN_CONFIG=./designs/{self.platform}/{self.design}/config.mk EQUIVALENCE_CHECK=0", + f"make -C {orfs_dir} DESIGN_CONFIG=./designs/{self.platform}/{self.design}/config.mk update_metadata_autotuner", ] for command in commands: out = subprocess.run(command, shell=True, check=True) self.assertTrue(out.returncode == 0) - os.chdir(src_dir) - - -class ASAP7AlgoEvalSmokeTest(BaseAlgoEvalSmokeTest): - platform = "asap7" - design = "gcd" def test_algo_eval(self): # Run `make` to get baseline metrics (metadata-base-ok.json) @@ -60,33 +51,20 @@ def test_algo_eval(self): self.assertTrue(successful) +class ASAP7AlgoEvalSmokeTest(BaseAlgoEvalSmokeTest): + platform = "asap7" + design = "gcd" + + class IHPSG13G2AlgoEvalSmokeTest(BaseAlgoEvalSmokeTest): platform = "ihp-sg13g2" design = "gcd" - def test_algo_eval(self): - # Run `make` to get baseline metrics (metadata-base-ok.json) - self.make_base() - for command in self.commands: - print(command) - out = subprocess.run(command, shell=True, check=True) - successful = out.returncode == 0 - self.assertTrue(successful) - class SKY130HDAlgoEvalSmokeTest(BaseAlgoEvalSmokeTest): platform = "sky130hd" design = "gcd" - def test_algo_eval(self): - # Run `make` to get baseline metrics (metadata-base-ok.json) - self.make_base() - for command in self.commands: - print(command) - out = subprocess.run(command, shell=True, check=True) - successful = out.returncode == 0 - self.assertTrue(successful) - if __name__ == "__main__": unittest.main() diff --git a/tools/AutoTuner/test/smoke_test_sample_iteration.py b/tools/AutoTuner/test/smoke_test_sample_iteration.py index f49c22a088..eb6ff4017c 100644 --- a/tools/AutoTuner/test/smoke_test_sample_iteration.py +++ b/tools/AutoTuner/test/smoke_test_sample_iteration.py @@ -3,8 +3,6 @@ import os cur_dir = os.path.dirname(os.path.abspath(__file__)) -src_dir = os.path.join(cur_dir, "../src/autotuner") -os.chdir(src_dir) class BaseSampleIterationSmokeTest(unittest.TestCase): @@ -19,7 +17,7 @@ def setUp(self): self.experiment = f"smoke-test-sample-iteration-{self.platform}" self.matrix = [(5, 1), (1, 5), (2, 2), (1, 1)] self.commands = [ - f"python3 distributed.py" + f"python3 -m autotuner.distributed" f" --design {self.design}" f" --platform {self.platform}" f" --experiment {self.experiment}" @@ -28,11 +26,6 @@ def setUp(self): for s, i in self.matrix ] - -class ASAP7SampleIterationSmokeTest(BaseSampleIterationSmokeTest): - platform = "asap7" - design = "gcd" - def test_sample_iteration(self): for command in self.commands: print(command) @@ -41,29 +34,20 @@ def test_sample_iteration(self): self.assertTrue(successful) +class ASAP7SampleIterationSmokeTest(BaseSampleIterationSmokeTest): + platform = "asap7" + design = "gcd" + + class SKY130HDSampleIterationSmokeTest(BaseSampleIterationSmokeTest): platform = "sky130hd" design = "gcd" - def test_sample_iteration(self): - for command in self.commands: - print(command) - out = subprocess.run(command, shell=True, check=True) - successful = out.returncode == 0 - self.assertTrue(successful) - class IHPSG13G2SampleIterationSmokeTest(BaseSampleIterationSmokeTest): platform = "ihp-sg13g2" design = "gcd" - def test_sample_iteration(self): - for command in self.commands: - print(command) - out = subprocess.run(command, shell=True, check=True) - successful = out.returncode == 0 - self.assertTrue(successful) - if __name__ == "__main__": unittest.main() diff --git a/tools/AutoTuner/test/smoke_test_sweep.py b/tools/AutoTuner/test/smoke_test_sweep.py index 7a1b013911..e09abff15b 100644 --- a/tools/AutoTuner/test/smoke_test_sweep.py +++ b/tools/AutoTuner/test/smoke_test_sweep.py @@ -4,8 +4,6 @@ import json cur_dir = os.path.dirname(os.path.abspath(__file__)) -src_dir = os.path.join(cur_dir, "../src/autotuner") -os.chdir(src_dir) class BaseSweepSmokeTest(unittest.TestCase): @@ -13,7 +11,9 @@ class BaseSweepSmokeTest(unittest.TestCase): design = "" def setUp(self): - self.config = "distributed-sweep-example.json" + self.config = os.path.abspath( + os.path.join(cur_dir, "../src/autotuner/distributed-sweep-example.json") + ) # make sure this json only has 1 key called "CTS_CLUSTER_SIZE" and 4 possible values with open(self.config) as f: contents = json.load(f) @@ -31,7 +31,7 @@ def setUp(self): self.jobs = 4 if core >= 4 else core self.experiment = f"smoke-test-sweep-{self.platform}" self.command = ( - "python3 distributed.py" + "python3 -m autotuner.distributed" f" --design {self.design}" f" --platform {self.platform}" f" --experiment {self.experiment}" @@ -40,6 +40,7 @@ def setUp(self): f" sweep" ) + @unittest.skip("abstract_method") def test_sweep(self): raise NotImplementedError( "This method needs to be implemented in the derivative classes." diff --git a/tools/AutoTuner/test/smoke_test_tune.py b/tools/AutoTuner/test/smoke_test_tune.py index 9710416745..dd94f02113 100644 --- a/tools/AutoTuner/test/smoke_test_tune.py +++ b/tools/AutoTuner/test/smoke_test_tune.py @@ -3,8 +3,6 @@ import os cur_dir = os.path.dirname(os.path.abspath(__file__)) -src_dir = os.path.join(cur_dir, "../src/autotuner") -os.chdir(src_dir) class BaseTuneSmokeTest(unittest.TestCase): @@ -18,7 +16,7 @@ def setUp(self): ) self.experiment = f"smoke-test-tune-{self.platform}" self.command = ( - "python3 distributed.py" + "python3 -m autotuner.distributed" f" --design {self.design}" f" --platform {self.platform}" f" --experiment {self.experiment}" @@ -26,6 +24,7 @@ def setUp(self): f" tune --samples 5" ) + @unittest.skip("abstract_method") def test_tune(self): raise NotImplementedError( "This method needs to be implemented in the derivative classes."