Skip to content

Commit 38dd51f

Browse files
committed
add prototype for CPUBudgetSmokeTest
Signed-off-by: Jack Luar <[email protected]>
1 parent da50d19 commit 38dd51f

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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 BaseCPUBudgetSmokeTest(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-timeout-{self.platform}"
20+
21+
cpu_budget = 1
22+
self.expected_timeout = cpu_budget / os.cpu_count()
23+
24+
self.command = (
25+
"python3 distributed.py"
26+
f" --design {self.design}"
27+
f" --platform {self.platform}"
28+
f" --experiment {self.experiment}"
29+
f" --config {self.config}"
30+
f" --cpu_budget 1"
31+
f" --yes"
32+
f" tune --samples 1000"
33+
)
34+
35+
def test_cpu_budget(self):
36+
raise NotImplementedError(
37+
"This method needs to be implemented in the derivative classes."
38+
)
39+
40+
41+
class ASAP7CPUBudgetSmokeTest(BaseCPUBudgetSmokeTest):
42+
platform = "asap7"
43+
design = "gcd"
44+
45+
def test_cpu_budget(self):
46+
try:
47+
out = subprocess.run(
48+
self.command, shell=True, check=True, timeout=self.expected_timeout
49+
)
50+
successful = out.returncode == 0
51+
except subprocess.TimeoutExpired:
52+
successful = False
53+
self.assertFalse(successful)
54+
55+
56+
class SKY130HDCPUBudgetSmokeTest(BaseCPUBudgetSmokeTest):
57+
platform = "sky130hd"
58+
design = "gcd"
59+
60+
def test_cpu_budget(self):
61+
try:
62+
out = subprocess.run(
63+
self.command, shell=True, check=True, timeout=self.expected_timeout
64+
)
65+
successful = out.returncode == 0
66+
except subprocess.TimeoutExpired:
67+
successful = False
68+
self.assertFalse(successful)
69+
70+
71+
class IHPSG13G2CPUBudgetSmokeTest(BaseCPUBudgetSmokeTest):
72+
platform = "ihp-sg13g2"
73+
design = "gcd"
74+
75+
def test_cpu_budget(self):
76+
try:
77+
out = subprocess.run(
78+
self.command, shell=True, check=True, timeout=self.expected_timeout
79+
)
80+
successful = out.returncode == 0
81+
except subprocess.TimeoutExpired:
82+
successful = False
83+
self.assertFalse(successful)
84+
85+
86+
if __name__ == "__main__":
87+
unittest.main()

0 commit comments

Comments
 (0)