Skip to content

Commit f1f1920

Browse files
committed
* add calculate_trial_path function for log path handling, redirecting sdc files to correct dir
Signed-off-by: Jack Luar <jluar@precisioninno.com>
1 parent b38911e commit f1f1920

1 file changed

Lines changed: 34 additions & 7 deletions

File tree

‎tools/AutoTuner/src/autotuner/utils.py‎

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,21 @@ def run_command(
287287
raise RuntimeError
288288

289289

290+
def calculate_trial_path(args, base_dir, flow_variant):
291+
"""
292+
Calculate the log path and flow variant
293+
"""
294+
flow_variant_with_experiment = f"{args.experiment}/{flow_variant}"
295+
log_path = os.path.abspath(
296+
os.path.join(
297+
base_dir,
298+
f"flow/logs/{args.platform}/{args.design}",
299+
flow_variant_with_experiment,
300+
)
301+
)
302+
return log_path, flow_variant_with_experiment
303+
304+
290305
def openroad(
291306
args,
292307
base_dir,
@@ -297,10 +312,8 @@ def openroad(
297312
"""
298313
Run OpenROAD-flow-scripts with a given set of parameters.
299314
"""
300-
# Make sure path ends in a slash, i.e., is a folder
301-
flow_variant = f"{args.experiment}/{flow_variant}"
302-
log_path = os.path.abspath(
303-
os.path.join(base_dir, f"flow/logs/{args.platform}/{args.design}", flow_variant)
315+
log_path, flow_variant = calculate_trial_path(
316+
args=args, base_dir=base_dir, flow_variant=flow_variant
304317
)
305318
report_path = os.path.abspath(
306319
os.path.join(
@@ -643,6 +656,20 @@ def openroad_distributed(
643656
variant=None,
644657
):
645658
"""Simple wrapper to run openroad distributed with Ray."""
659+
if variant is None:
660+
variant_parts = []
661+
for key, value in config.items():
662+
if key not in ["_SDC_FILE_PATH", "_FR_FILE_PATH"]:
663+
variant_parts.append(f"{key}_{value}")
664+
variant = "_".join(variant_parts) if variant_parts else ""
665+
flow_variant = f"{uuid.uuid4()}-{variant}" if variant else f"{uuid.uuid4()}"
666+
667+
trial_path, _ = calculate_trial_path(
668+
args=args, base_dir=repo_dir, flow_variant=flow_variant
669+
)
670+
671+
os.makedirs(trial_path, exist_ok=True)
672+
646673
config = parse_config(
647674
config=config,
648675
base_dir=repo_dir,
@@ -651,15 +678,15 @@ def openroad_distributed(
651678
constraints_sdc=CONSTRAINTS_SDC,
652679
fr_original=fr_original,
653680
fastroute_tcl=FASTROUTE_TCL,
681+
path=trial_path,
654682
)
655-
if variant is None:
656-
variant = config.replace(" ", "_").replace("=", "_")
683+
657684
t = time.time()
658685
metric_file = openroad(
659686
args=args,
660687
base_dir=repo_dir,
661688
parameters=config,
662-
flow_variant=f"{uuid.uuid4()}-{variant}" if variant else f"{uuid.uuid4()}",
689+
flow_variant=flow_variant,
663690
install_path=install_path,
664691
)
665692
duration = time.time() - t

0 commit comments

Comments
 (0)