From 4b54253c24e6d1bae4dc25e95c25ef95d8d07086 Mon Sep 17 00:00:00 2001 From: David Shah Date: Sat, 1 Feb 2020 15:37:50 +0000 Subject: [PATCH] router2: Prevent overflow Signed-off-by: David Shah --- common/router2.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/router2.cc b/common/router2.cc index 00760c78..26e78eaa 100644 --- a/common/router2.cc +++ b/common/router2.cc @@ -747,7 +747,7 @@ struct Router2 total_wire_use += int(wire.bound_nets.size()); int overuse = int(wire.bound_nets.size()) - 1; if (overuse > 0) { - wire.hist_cong_cost += overuse * hist_cong_weight; + wire.hist_cong_cost = std::min(1e9, wire.hist_cong_cost + overuse * hist_cong_weight); total_overuse += overuse; overused_wires += 1; for (auto &bound : wire.bound_nets) @@ -1082,7 +1082,8 @@ struct Router2 log_info(" iter=%d wires=%d overused=%d overuse=%d archfail=%s\n", iter, total_wire_use, overused_wires, total_overuse, overused_wires > 0 ? "NA" : std::to_string(arch_fail).c_str()); ++iter; - curr_cong_weight *= cfg.curr_cong_mult; + if (curr_cong_weight < 1e9) + curr_cong_weight *= cfg.curr_cong_mult; } while (!failed_nets.empty()); if (cfg.perf_profile) { std::vector> nets_by_runtime;