Skip to content

Commit b993ac4

Browse files
committed
added valid config check
Signed-off-by: Jeff Ng <[email protected]>
1 parent 650e321 commit b993ac4

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tools/AutoTuner/src/autotuner/distributed.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,22 @@ def setup(self, config):
100100
)
101101
self.step_ = 0
102102
self.variant = f"variant-{self.__class__.__name__}-{self.trial_id}-or"
103+
# Do a valid config check here, since we still have the config in a
104+
# dict vs. having to scan through the parameter string later
105+
self.is_valid_config = self._is_valid_config(config)
103106

104107
def step(self):
105108
"""
106109
Run step experiment and compute its score.
107110
"""
111+
112+
# if not a valid config, then don't run and pass back an error
113+
if not self.is_valid_config:
114+
return {
115+
METRIC: ERROR_METRIC,
116+
"effective_clk_period": "-",
117+
"num_drc": "-"
118+
}
108119
self._variant = f"{self.variant}-{self.step_}"
109120
metrics_file = openroad(
110121
args=args,
@@ -142,6 +153,27 @@ def evaluate(self, metrics):
142153
score = score * (100 / self.step_) + gamma * num_drc
143154
return (score, effective_clk_period, num_drc)
144155

156+
def _is_valid_config(self, config):
157+
"""
158+
Checks dependent parameters and returns False if we violate
159+
a dependency. That way, we don't end up running an incompatible run
160+
"""
161+
162+
ret_val = True
163+
ret_val &= self._is_valid_padding(config)
164+
return ret_val
165+
166+
def _is_valid_padding(self, config):
167+
""" Returns True if global padding >= detail padding """
168+
169+
if "CELL_PAD_IN_SITES_GLOBAL_PLACEMENT" in config and "CELL_PAD_IN_SITES_DETAIL_PLACEMENT" in config:
170+
global_padding = config["CELL_PAD_IN_SITES_GLOBAL_PLACEMENT"]
171+
detail_padding = config["CELL_PAD_IN_SITES_DETAIL_PLACEMENT"]
172+
if global_padding < detail_padding:
173+
print(f"[WARN TUN-0032] CELL_PAD_IN_SITES_DETAIL_PLACEMENT cannot be greater than CELL_PAD_IN_SITES_GLOBAL_PLACEMENT: {detail_padding} {global_padding}")
174+
return False
175+
return True
176+
145177

146178
class PPAImprov(AutoTunerBase):
147179
"""

0 commit comments

Comments
 (0)