Skip to content

Commit

Permalink
tools: Autotuner: Update smoke tests to use AutoTuner as module
Browse files Browse the repository at this point in the history
Signed-off-by: Eryk Szpotanski <[email protected]>
  • Loading branch information
eszpotanski committed Nov 4, 2024
1 parent c674f3f commit ba652d0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 96 deletions.
42 changes: 11 additions & 31 deletions tools/AutoTuner/test/smoke_test_algo_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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}"
Expand All @@ -34,23 +32,18 @@ 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):
if not (self.platform and self.design):
raise unittest.SkipTest("Platform and design have to be defined")
# Run `make` to get baseline metrics (metadata-base-ok.json)
self.make_base()
for command in self.commands:
Expand All @@ -60,33 +53,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()
30 changes: 8 additions & 22 deletions tools/AutoTuner/test/smoke_test_sample_iteration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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}"
Expand All @@ -28,42 +26,30 @@ def setUp(self):
for s, i in self.matrix
]


class ASAP7SampleIterationSmokeTest(BaseSampleIterationSmokeTest):
platform = "asap7"
design = "gcd"

def test_sample_iteration(self):
if not (self.platform and self.design):
raise unittest.SkipTest("Platform and design have to be defined")
for command in self.commands:
print(command)
out = subprocess.run(command, shell=True, check=True)
successful = out.returncode == 0
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()
31 changes: 9 additions & 22 deletions tools/AutoTuner/test/smoke_test_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
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):
platform = ""
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)
Expand All @@ -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}"
Expand All @@ -41,40 +41,27 @@ def setUp(self):
)

def test_sweep(self):
raise NotImplementedError(
"This method needs to be implemented in the derivative classes."
)
if not (self.platform and self.design):
raise unittest.SkipTest("Platform and design have to be defined")
out = subprocess.run(self.command, shell=True, check=True)
successful = out.returncode == 0
self.assertTrue(successful)


class ASAP7SweepSmokeTest(BaseSweepSmokeTest):
platform = "asap7"
design = "gcd"

def test_sweep(self):
out = subprocess.run(self.command, shell=True, check=True)
successful = out.returncode == 0
self.assertTrue(successful)


class SKY130HDSweepSmokeTest(BaseSweepSmokeTest):
platform = "sky130hd"
design = "gcd"

def test_sweep(self):
out = subprocess.run(self.command, shell=True, check=True)
successful = out.returncode == 0
self.assertTrue(successful)


class IHPSG13G2SweepSmokeTest(BaseSweepSmokeTest):
platform = "ihp-sg13g2"
design = "gcd"

def test_sweep(self):
out = subprocess.run(self.command, shell=True, check=True)
successful = out.returncode == 0
self.assertTrue(successful)


if __name__ == "__main__":
unittest.main()
27 changes: 6 additions & 21 deletions tools/AutoTuner/test/smoke_test_tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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}"
Expand All @@ -27,40 +25,27 @@ def setUp(self):
)

def test_tune(self):
raise NotImplementedError(
"This method needs to be implemented in the derivative classes."
)
if not (self.platform and self.design):
raise unittest.SkipTest("Platform and design have to be defined")
out = subprocess.run(self.command, shell=True, check=True)
successful = out.returncode == 0
self.assertTrue(successful)


class ASAP7TuneSmokeTest(BaseTuneSmokeTest):
platform = "asap7"
design = "gcd"

def test_tune(self):
out = subprocess.run(self.command, shell=True, check=True)
successful = out.returncode == 0
self.assertTrue(successful)


class SKY130HDTuneSmokeTest(BaseTuneSmokeTest):
platform = "sky130hd"
design = "gcd"

def test_tune(self):
out = subprocess.run(self.command, shell=True, check=True)
successful = out.returncode == 0
self.assertTrue(successful)


class IHPSG13G2TuneSmokeTest(BaseTuneSmokeTest):
platform = "ihp-sg13g2"
design = "gcd"

def test_tune(self):
out = subprocess.run(self.command, shell=True, check=True)
successful = out.returncode == 0
self.assertTrue(successful)


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

0 comments on commit ba652d0

Please sign in to comment.