Skip to content

Commit 18cadb4

Browse files
authored
[Autotuner] CI Smoke Test - Sample & Iteration (#2048)
* Add smoke test for sample and iteration Signed-off-by: Song Luar <[email protected]>
1 parent 51286a1 commit 18cadb4

File tree

3 files changed

+77
-4
lines changed

3 files changed

+77
-4
lines changed

docs/user/InstructionsForAutoTuner.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ Assuming the virtual environment is setup at `./tools/AutoTuner/autotuner_env`:
208208
./tools/AutoTuner/setup.sh
209209
python3 ./tools/AutoTuner/test/smoke_test_sweep.py
210210
python3 ./tools/AutoTuner/test/smoke_test_tune.py
211+
python3 ./tools/AutoTuner/test/smoke_test_sample_iteration.py
211212
```
212213

213214
## Citation

flow/test/test_helper.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ case $PLATFORM in
9494
esac
9595

9696
if [ $RUN_AUTOTUNER -eq 1 ]; then
97-
# change directory to the root of the repo
98-
echo "Install and starting venv"
97+
# run the commands in ORFS root dir
98+
echo "[INFO FLW-0029] Installing dependencies in virtual environment."
9999
cd ../
100100
./tools/AutoTuner/installer.sh
101101
. ./tools/AutoTuner/setup.sh
102102

103-
# remove dashes
103+
# remove dashes and capitalize platform name
104104
PLATFORM=${PLATFORM//-/}
105105
# convert to uppercase
106106
PLATFORM=${PLATFORM^^}
@@ -111,8 +111,11 @@ if [ $RUN_AUTOTUNER -eq 1 ]; then
111111
echo "Running Autotuner smoke sweep test"
112112
python3 -m unittest tools.AutoTuner.test.smoke_test_sweep.${PLATFORM}SweepSmokeTest.test_sweep
113113

114-
echo "Running Autotuner ref file test (only once)"
114+
echo "Running Autotuner smoke tests for --sample and --iteration."
115+
python3 -m unittest tools.AutoTuner.test.smoke_test_sample_iteration.${PLATFORM}SampleIterationSmokeTest.test_sample_iteration
116+
115117
if [ "$PLATFORM" == "asap7" ] && [ "$DESIGN" == "gcd" ]; then
118+
echo "Running Autotuner ref file test (only once)"
116119
python3 -m unittest tools.AutoTuner.test.ref_file_check.RefFileCheck.test_files
117120
fi
118121

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import unittest
2+
import subprocess
3+
import os
4+
5+
cur_dir = os.path.dirname(os.path.abspath(__file__))
6+
src_dir = os.path.join(cur_dir, "../src/autotuner")
7+
os.chdir(src_dir)
8+
9+
10+
class BaseSampleIterationSmokeTest(unittest.TestCase):
11+
platform = ""
12+
design = ""
13+
14+
def setUp(self):
15+
self.config = os.path.join(
16+
cur_dir,
17+
f"../../../flow/designs/{self.platform}/{self.design}/autotuner.json",
18+
)
19+
self.experiment = f"smoke-test-sample-iteration-{self.platform}"
20+
self.matrix = [(5, 1), (1, 5), (2, 2), (1, 1)]
21+
self.commands = [
22+
f"python3 distributed.py"
23+
f" --design {self.design}"
24+
f" --platform {self.platform}"
25+
f" --experiment {self.experiment}"
26+
f" --config {self.config}"
27+
f" tune --samples {s} --iterations {i}"
28+
for s, i in self.matrix
29+
]
30+
31+
32+
class ASAP7SampleIterationSmokeTest(BaseSampleIterationSmokeTest):
33+
platform = "asap7"
34+
design = "gcd"
35+
36+
def test_sample_iteration(self):
37+
for command in self.commands:
38+
print(command)
39+
out = subprocess.run(command, shell=True, check=True)
40+
successful = out.returncode == 0
41+
self.assertTrue(successful)
42+
43+
44+
class SKY130HDSampleIterationSmokeTest(BaseSampleIterationSmokeTest):
45+
platform = "sky130hd"
46+
design = "gcd"
47+
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+
55+
56+
class IHPSG13G2SampleIterationSmokeTest(BaseSampleIterationSmokeTest):
57+
platform = "ihp-sg13g2"
58+
design = "gcd"
59+
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+
67+
68+
if __name__ == "__main__":
69+
unittest.main()

0 commit comments

Comments
 (0)