Skip to content

Commit 12da891

Browse files
authored
Merge pull request #2640 from luarss/topic/at-tunable-vars
[Autotuner] - Tunable variables check v2
2 parents 95e8cd9 + c004437 commit 12da891

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

flow/scripts/variables.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,15 @@ CORE_UTILIZATION:
9494
The core utilization percentage (0-100).
9595
stages:
9696
- floorplan
97+
tunable: 1
9798
CORE_AREA:
9899
description: >
99100
The core area specified as a list of lower-left and upper-right corners in
100101
microns
101102
(X1 Y1 X2 Y2).
102103
stages:
103104
- floorplan
105+
tunable: 1
104106
REPORT_CLOCK_SKEW:
105107
description: >
106108
Report clock skew as part of reporting metrics, starting at CTS, before which
@@ -328,6 +330,7 @@ CELL_PAD_IN_SITES_GLOBAL_PLACEMENT:
328330
- place
329331
- floorplan
330332
default: 0
333+
tunable: 1
331334
CELL_PAD_IN_SITES_DETAIL_PLACEMENT:
332335
description: >
333336
Cell padding on both sides in site widths to ease routability in detail
@@ -337,6 +340,7 @@ CELL_PAD_IN_SITES_DETAIL_PLACEMENT:
337340
- cts
338341
- grt
339342
default: 0
343+
tunable: 1
340344
PLACE_PINS_ARGS:
341345
description: |
342346
Arguments to place_pins
@@ -358,6 +362,7 @@ PLACE_DENSITY_LB_ADDON:
358362
stages:
359363
- floorplan
360364
- place
365+
tunable: 1
361366
REPAIR_PDN_VIA_LAYER:
362367
description: |
363368
Remove power grid vias which generate DRC violations after detailed routing.
@@ -635,6 +640,7 @@ CORE_ASPECT_RATIO:
635640
`CORE_UTILIZATION` is undefined.
636641
stages:
637642
- floorplan
643+
tunable: 1
638644
CORE_MARGIN:
639645
description: >
640646
The margin between the core area and die area, specified in microns.
@@ -644,13 +650,15 @@ CORE_MARGIN:
644650
is undefined.
645651
stages:
646652
- floorplan
653+
tunable: 1
647654
DIE_AREA:
648655
description: >
649656
The die area specified as a list of lower-left and upper-right corners in
650657
microns
651658
(X1 Y1 X2 Y2).
652659
stages:
653660
- floorplan
661+
tunable: 1
654662
RESYNTH_AREA_RECOVER:
655663
description: |
656664
Enable re-synthesis for area reclaim.
@@ -693,12 +701,14 @@ CTS_CLUSTER_DIAMETER:
693701
default: 20
694702
stages:
695703
- cts
704+
tunable: 1
696705
CTS_CLUSTER_SIZE:
697706
description: >
698707
Maximum number of sinks per cluster.
699708
default: 50
700709
stages:
701710
- cts
711+
tunable: 1
702712
CTS_SNAPSHOT:
703713
description: |
704714
Creates ODB/SDC files prior to clock net and setup/hold repair.

tools/AutoTuner/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ protobuf==3.20.3
1010
SQLAlchemy==1.4.17
1111
urllib3<=1.26.15
1212
matplotlib==3.10.0
13+
pyyaml==6.0.1

tools/AutoTuner/src/autotuner/utils.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import os
44
import re
5+
import yaml
56
import subprocess
67
import sys
78
from multiprocessing import cpu_count
@@ -161,6 +162,21 @@ def parse_flow_variables(base_dir, platform):
161162
return variables
162163

163164

165+
def parse_tunable_variables():
166+
"""
167+
Parse the tunable variables from variables.yaml
168+
TODO: Tests.
169+
"""
170+
cur_path = os.path.dirname(os.path.realpath(__file__))
171+
vars_path = os.path.join(cur_path, "../../../../flow/scripts/variables.yaml")
172+
173+
# Read from variables.yaml and get variables with tunable = 1
174+
with open(vars_path) as file:
175+
result = yaml.safe_load(file)
176+
variables = {key for key, value in result.items() if value.get("tunable", 0) == 1}
177+
return variables
178+
179+
164180
def parse_config(
165181
config,
166182
base_dir,
@@ -177,7 +193,7 @@ def parse_config(
177193
options = ""
178194
sdc = {}
179195
fast_route = {}
180-
# flow_variables = parse_flow_variables(base_dir, platform)
196+
flow_variables = parse_tunable_variables()
181197
for key, value in config.items():
182198
# Keys that begin with underscore need special handling.
183199
if key.startswith("_"):
@@ -198,9 +214,9 @@ def parse_config(
198214
# Default case is VAR=VALUE
199215
else:
200216
# Sanity check: ignore all flow variables that are not tunable
201-
# if key not in flow_variables:
202-
# print(f"[ERROR TUN-0017] Variable {key} is not tunable.")
203-
# sys.exit(1)
217+
if key not in flow_variables:
218+
print(f"[ERROR TUN-0017] Variable {key} is not tunable.")
219+
sys.exit(1)
204220
options += f" {key}={value}"
205221
if sdc:
206222
write_sdc(sdc, path, sdc_original, constraints_sdc)

0 commit comments

Comments
 (0)