Skip to content

Commit 93c3da6

Browse files
committed
tools: AutoTuner: Update smoke tests
Signed-off-by: Eryk Szpotanski <eszpotanski@antmicro.com>
1 parent e09c466 commit 93c3da6

4 files changed

Lines changed: 22 additions & 60 deletions

File tree

‎tools/AutoTuner/test/smoke_test_algo_eval.py‎

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
import os
44

55
cur_dir = os.path.dirname(os.path.abspath(__file__))
6-
src_dir = os.path.join(cur_dir, "../src/autotuner")
76
orfs_dir = os.path.join(cur_dir, "../../../flow")
8-
os.chdir(src_dir)
97

108

119
class BaseAlgoEvalSmokeTest(unittest.TestCase):
@@ -22,7 +20,7 @@ def setUp(self):
2220
_eval = ["default", "ppa-improv"]
2321
self.matrix = [(a, e) for a in _algo for e in _eval]
2422
self.commands = [
25-
f"python3 distributed.py"
23+
f"python3 -m autotuner.distributed"
2624
f" --design {self.design}"
2725
f" --platform {self.platform}"
2826
f" --experiment {self.experiment}"
@@ -34,21 +32,14 @@ def setUp(self):
3432
]
3533

3634
def make_base(self):
37-
os.chdir(orfs_dir)
3835
commands = [
39-
f"make DESIGN_CONFIG=./designs/{self.platform}/{self.design}/config.mk clean_all",
40-
f"make DESIGN_CONFIG=./designs/{self.platform}/{self.design}/config.mk EQUIVALENCE_CHECK=0",
41-
f"make DESIGN_CONFIG=./designs/{self.platform}/{self.design}/config.mk update_metadata_autotuner",
36+
f"make -C {orfs_dir} DESIGN_CONFIG=./designs/{self.platform}/{self.design}/config.mk clean_all",
37+
f"make -C {orfs_dir} DESIGN_CONFIG=./designs/{self.platform}/{self.design}/config.mk EQUIVALENCE_CHECK=0",
38+
f"make -C {orfs_dir} DESIGN_CONFIG=./designs/{self.platform}/{self.design}/config.mk update_metadata_autotuner",
4239
]
4340
for command in commands:
4441
out = subprocess.run(command, shell=True, check=True)
4542
self.assertTrue(out.returncode == 0)
46-
os.chdir(src_dir)
47-
48-
49-
class ASAP7AlgoEvalSmokeTest(BaseAlgoEvalSmokeTest):
50-
platform = "asap7"
51-
design = "gcd"
5243

5344
def test_algo_eval(self):
5445
# Run `make` to get baseline metrics (metadata-base-ok.json)
@@ -60,33 +51,20 @@ def test_algo_eval(self):
6051
self.assertTrue(successful)
6152

6253

54+
class ASAP7AlgoEvalSmokeTest(BaseAlgoEvalSmokeTest):
55+
platform = "asap7"
56+
design = "gcd"
57+
58+
6359
class IHPSG13G2AlgoEvalSmokeTest(BaseAlgoEvalSmokeTest):
6460
platform = "ihp-sg13g2"
6561
design = "gcd"
6662

67-
def test_algo_eval(self):
68-
# Run `make` to get baseline metrics (metadata-base-ok.json)
69-
self.make_base()
70-
for command in self.commands:
71-
print(command)
72-
out = subprocess.run(command, shell=True, check=True)
73-
successful = out.returncode == 0
74-
self.assertTrue(successful)
75-
7663

7764
class SKY130HDAlgoEvalSmokeTest(BaseAlgoEvalSmokeTest):
7865
platform = "sky130hd"
7966
design = "gcd"
8067

81-
def test_algo_eval(self):
82-
# Run `make` to get baseline metrics (metadata-base-ok.json)
83-
self.make_base()
84-
for command in self.commands:
85-
print(command)
86-
out = subprocess.run(command, shell=True, check=True)
87-
successful = out.returncode == 0
88-
self.assertTrue(successful)
89-
9068

9169
if __name__ == "__main__":
9270
unittest.main()

‎tools/AutoTuner/test/smoke_test_sample_iteration.py‎

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import os
44

55
cur_dir = os.path.dirname(os.path.abspath(__file__))
6-
src_dir = os.path.join(cur_dir, "../src/autotuner")
7-
os.chdir(src_dir)
86

97

108
class BaseSampleIterationSmokeTest(unittest.TestCase):
@@ -19,7 +17,7 @@ def setUp(self):
1917
self.experiment = f"smoke-test-sample-iteration-{self.platform}"
2018
self.matrix = [(5, 1), (1, 5), (2, 2), (1, 1)]
2119
self.commands = [
22-
f"python3 distributed.py"
20+
f"python3 -m autotuner.distributed"
2321
f" --design {self.design}"
2422
f" --platform {self.platform}"
2523
f" --experiment {self.experiment}"
@@ -28,11 +26,6 @@ def setUp(self):
2826
for s, i in self.matrix
2927
]
3028

31-
32-
class ASAP7SampleIterationSmokeTest(BaseSampleIterationSmokeTest):
33-
platform = "asap7"
34-
design = "gcd"
35-
3629
def test_sample_iteration(self):
3730
for command in self.commands:
3831
print(command)
@@ -41,29 +34,20 @@ def test_sample_iteration(self):
4134
self.assertTrue(successful)
4235

4336

37+
class ASAP7SampleIterationSmokeTest(BaseSampleIterationSmokeTest):
38+
platform = "asap7"
39+
design = "gcd"
40+
41+
4442
class SKY130HDSampleIterationSmokeTest(BaseSampleIterationSmokeTest):
4543
platform = "sky130hd"
4644
design = "gcd"
4745

48-
def test_sample_iteration(self):
49-
for command in self.commands:
50-
print(command)
51-
out = subprocess.run(command, shell=True, check=True)
52-
successful = out.returncode == 0
53-
self.assertTrue(successful)
54-
5546

5647
class IHPSG13G2SampleIterationSmokeTest(BaseSampleIterationSmokeTest):
5748
platform = "ihp-sg13g2"
5849
design = "gcd"
5950

60-
def test_sample_iteration(self):
61-
for command in self.commands:
62-
print(command)
63-
out = subprocess.run(command, shell=True, check=True)
64-
successful = out.returncode == 0
65-
self.assertTrue(successful)
66-
6751

6852
if __name__ == "__main__":
6953
unittest.main()

‎tools/AutoTuner/test/smoke_test_sweep.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
import json
55

66
cur_dir = os.path.dirname(os.path.abspath(__file__))
7-
src_dir = os.path.join(cur_dir, "../src/autotuner")
8-
os.chdir(src_dir)
97

108

119
class BaseSweepSmokeTest(unittest.TestCase):
1210
platform = ""
1311
design = ""
1412

1513
def setUp(self):
16-
self.config = "distributed-sweep-example.json"
14+
self.config = os.path.abspath(
15+
os.path.join(cur_dir, "../src/autotuner/distributed-sweep-example.json")
16+
)
1717
# make sure this json only has 1 key called "CTS_CLUSTER_SIZE" and 4 possible values
1818
with open(self.config) as f:
1919
contents = json.load(f)
@@ -31,7 +31,7 @@ def setUp(self):
3131
self.jobs = 4 if core >= 4 else core
3232
self.experiment = f"smoke-test-sweep-{self.platform}"
3333
self.command = (
34-
"python3 distributed.py"
34+
"python3 -m autotuner.distributed"
3535
f" --design {self.design}"
3636
f" --platform {self.platform}"
3737
f" --experiment {self.experiment}"
@@ -40,6 +40,7 @@ def setUp(self):
4040
f" sweep"
4141
)
4242

43+
@unittest.skip("abstract_method")
4344
def test_sweep(self):
4445
raise NotImplementedError(
4546
"This method needs to be implemented in the derivative classes."

‎tools/AutoTuner/test/smoke_test_tune.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import os
44

55
cur_dir = os.path.dirname(os.path.abspath(__file__))
6-
src_dir = os.path.join(cur_dir, "../src/autotuner")
7-
os.chdir(src_dir)
86

97

108
class BaseTuneSmokeTest(unittest.TestCase):
@@ -18,14 +16,15 @@ def setUp(self):
1816
)
1917
self.experiment = f"smoke-test-tune-{self.platform}"
2018
self.command = (
21-
"python3 distributed.py"
19+
"python3 -m autotuner.distributed"
2220
f" --design {self.design}"
2321
f" --platform {self.platform}"
2422
f" --experiment {self.experiment}"
2523
f" --config {self.config}"
2624
f" tune --samples 5"
2725
)
2826

27+
@unittest.skip("abstract_method")
2928
def test_tune(self):
3029
raise NotImplementedError(
3130
"This method needs to be implemented in the derivative classes."

0 commit comments

Comments
 (0)