Skip to content

Commit 2f5ebe2

Browse files
committed
fix timeout test and add cpu_budget logic
Signed-off-by: Jack Luar <[email protected]>
1 parent 051c6ba commit 2f5ebe2

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

tools/AutoTuner/src/autotuner/distributed.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,30 @@
7272
# URL to ORFS GitHub repository
7373
ORFS_URL = "https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts"
7474

75+
TEMPLATE = """
76+
Expected figures for this experiment.
77+
Wall time: {runtime:.2f} hours
78+
Number of Samples:
79+
Samples per minute: {num_samples_per_minute:.2f}
80+
Design runtime of 10 min: {num_samples_10min:.2f}
81+
Design runtime of 1h: {num_samples_1h:.2f}
82+
Number of iterations
83+
Design runtime of 10 min: {num_iterations_10min:.2f}
84+
Design runtime of 1h: {num_iterations_1h:.2f}
85+
"""
86+
87+
88+
def calculate_expected_numbers(runtime, num_samples):
89+
# Runtime - hours
90+
return TEMPLATE.format(
91+
runtime=runtime,
92+
num_samples_per_minute=num_samples / (runtime * 60),
93+
num_samples_10min=(num_samples / (runtime * 60)) * 10,
94+
num_samples_1h=(num_samples / (runtime * 60)) * 60,
95+
num_iterations_10min=((num_samples / (runtime * 60)) * 10) / num_samples,
96+
num_iterations_1h=((num_samples / (runtime * 60)) * 60) / num_samples,
97+
)
98+
7599

76100
class AutoTunerBase(tune.Trainable):
77101
"""
@@ -415,7 +439,7 @@ def parse_arguments():
415439
type=int,
416440
metavar="<int>",
417441
default=int(np.floor(cpu_count() / 2)),
418-
help="Number of cpus to be used.",
442+
help="CPU Hours",
419443
)
420444
parser.add_argument(
421445
"--openroad_threads",
@@ -485,6 +509,15 @@ def parse_arguments():
485509
jobs = int(args.cpu_budget / args.resources_per_trial)
486510
args.jobs = jobs
487511

512+
# Calculate timeout based on cpu_budget
513+
if args.cpu_budget is not None:
514+
args.timeout = args.cpu_budget / os.cpu_count()
515+
template = calculate_expected_numbers(args.timeout, args.samples)
516+
print(template)
517+
ans = input("Do you want to continue? [Y/n]")
518+
if ans.lower() != "y":
519+
sys.exit(0)
520+
488521
return args
489522

490523

tools/AutoTuner/test/smoke_test_timeout.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
os.chdir(src_dir)
88

99

10-
class BaseTuneTimeoutTest(unittest.TestCase):
10+
class BaseTimeoutSmokeTest(unittest.TestCase):
1111
platform = ""
1212
design = ""
1313

@@ -37,7 +37,7 @@ def test_trial_timeout(self):
3737
)
3838

3939

40-
class ASAP7TuneTimeoutTest(BaseTuneTimeoutTest):
40+
class ASAP7TimeoutSmokeTest(BaseTimeoutSmokeTest):
4141
platform = "asap7"
4242
design = "gcd"
4343

@@ -48,7 +48,7 @@ def test_trial_timeout(self):
4848
self.assertFalse(successful)
4949

5050

51-
class SKY130HDTuneTimeoutTest(BaseTuneTimeoutTest):
51+
class SKY130HDTimeoutSmokeTest(BaseTimeoutSmokeTest):
5252
platform = "sky130hd"
5353
design = "gcd"
5454

@@ -59,7 +59,7 @@ def test_trial_timeout(self):
5959
self.assertFalse(successful)
6060

6161

62-
class IHPSG13G2TuneTimeoutTest(BaseTuneTimeoutTest):
62+
class IHPSG13G2TimeoutSmokeTest(BaseTimeoutSmokeTest):
6363
platform = "ihp-sg13g2"
6464
design = "gcd"
6565

0 commit comments

Comments
 (0)