|
69 | 69 | # Name of the TCL script run before routing |
70 | 70 | FASTROUTE_TCL = "fastroute.tcl" |
71 | 71 | DATE = datetime.now().strftime("%Y-%m-%d-%H-%M-%S") |
| 72 | +# The worst of optimized metric |
| 73 | +ERROR_METRIC = 9e99 |
| 74 | + |
| 75 | + |
| 76 | +def calculate_score(metrics, step=1): |
| 77 | + """Calculate optimization score from metrics.""" |
| 78 | + error = "ERR" in metrics.values() |
| 79 | + not_found = "N/A" in metrics.values() |
| 80 | + |
| 81 | + if error or not_found: |
| 82 | + return (ERROR_METRIC, "-", "-", "-") |
| 83 | + |
| 84 | + effective_clk_period = metrics["clk_period"] - metrics["worst_slack"] |
| 85 | + num_drc = metrics["num_drc"] |
| 86 | + gamma = effective_clk_period / 10 |
| 87 | + score = effective_clk_period * (100 / step) + gamma * num_drc |
| 88 | + |
| 89 | + return (score, effective_clk_period, num_drc, metrics["die_area"]) |
72 | 90 |
|
73 | 91 |
|
74 | 92 | def write_sdc(variables, path, sdc_original, constraints_sdc): |
@@ -708,21 +726,16 @@ def consumer(queue): |
708 | 726 | print(f"[INFO TUN-0008] Finished run for parameter {config}.") |
709 | 727 |
|
710 | 728 | metrics = read_metrics(metric_file, args.stop_stage) |
711 | | - effective_clk_period = ( |
712 | | - metrics["clk_period"] - metrics["worst_slack"] |
713 | | - if metrics["worst_slack"] not in ("ERR", "N/A") |
714 | | - else "-" |
715 | | - ) |
716 | | - score = effective_clk_period if effective_clk_period != "-" else 999999.0 |
| 729 | + score, effective_clk_period, num_drc, die_area = calculate_score(metrics) |
717 | 730 |
|
718 | 731 | ray.get( |
719 | 732 | tb_logger.log_sweep_metrics.remote( |
720 | 733 | params=config, |
721 | 734 | metrics=metrics, |
722 | 735 | score=score, |
723 | 736 | effective_clk_period=effective_clk_period, |
724 | | - num_drc=metrics.get("num_drc", "-"), |
725 | | - die_area=metrics.get("die_area", "-"), |
| 737 | + num_drc=num_drc, |
| 738 | + die_area=die_area, |
726 | 739 | ) |
727 | 740 | ) |
728 | 741 |
|
|
0 commit comments