From 62613cb266d00e8a56698d38741b0964ab699f8e Mon Sep 17 00:00:00 2001 From: gatecat Date: Thu, 6 May 2021 19:04:24 +0100 Subject: [PATCH] router2: Dynamicly expand bounding box based on congestion Signed-off-by: gatecat --- common/router2.cc | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/common/router2.cc b/common/router2.cc index 1e53d1fc..24bccec7 100644 --- a/common/router2.cc +++ b/common/router2.cc @@ -68,6 +68,7 @@ struct Router2 int cx, cy, hpwl; int total_route_us = 0; float max_crit = 0; + int fail_count = 0; }; struct WireScore @@ -189,6 +190,10 @@ struct Router2 log_info("%s: bb=(%d, %d)->(%d, %d) c=(%d, %d) hpwl=%d\n", ctx->nameOf(ni), nets.at(i).bb.x0, nets.at(i).bb.y0, nets.at(i).bb.x1, nets.at(i).bb.y1, nets.at(i).cx, nets.at(i).cy, nets.at(i).hpwl); + nets.at(i).bb.x0 = std::max(nets.at(i).bb.x0 - cfg.bb_margin_x, 0); + nets.at(i).bb.y0 = std::max(nets.at(i).bb.y0 - cfg.bb_margin_y, 0); + nets.at(i).bb.x1 = std::min(nets.at(i).bb.x1 + cfg.bb_margin_x, ctx->getGridDimX()); + nets.at(i).bb.y1 = std::min(nets.at(i).bb.y1 + cfg.bb_margin_y, ctx->getGridDimY()); i++; } } @@ -264,11 +269,7 @@ struct Router2 }; }; - bool hit_test_pip(ArcBounds &bb, Loc l) - { - return l.x >= (bb.x0 - cfg.bb_margin_x) && l.x <= (bb.x1 + cfg.bb_margin_x) && - l.y >= (bb.y0 - cfg.bb_margin_y) && l.y <= (bb.y1 + cfg.bb_margin_y); - } + bool hit_test_pip(ArcBounds &bb, Loc l) { return l.x >= bb.x0 && l.x <= bb.x1 && l.y >= bb.y0 && l.y <= bb.y1; } double curr_cong_weight, hist_cong_weight, estimate_weight; @@ -684,7 +685,7 @@ struct Router2 if (is_bb && !hit_test_pip(ad.bb, ctx->getPipLocation(dh)) && wire_intent != ID_PSEUDO_GND && wire_intent != ID_PSEUDO_VCC) continue; #else - if (is_bb && !hit_test_pip(ad.bb, ctx->getPipLocation(dh))) + if (is_bb && !hit_test_pip(nd.bb, ctx->getPipLocation(dh))) continue; if (!ctx->checkPipAvailForNet(dh, net)) { ROUTE_LOG_DBG("Skipping pip %s because it is bound to net '%s' not net '%s'\n", ctx->nameOfPip(dh), @@ -870,6 +871,17 @@ struct Router2 failed_nets.insert(bound.first); } } + for (int n : failed_nets) { + auto &net_data = nets.at(n); + ++net_data.fail_count; + if ((net_data.fail_count % 3) == 0) { + // Every three times a net fails to route, expand the bounding box to increase the search space + net_data.bb.x0 = std::max(net_data.bb.x0 - 1, 0); + net_data.bb.y0 = std::max(net_data.bb.y0 - 1, 0); + net_data.bb.x1 = std::min(net_data.bb.x1 + 1, ctx->getGridDimX()); + net_data.bb.y1 = std::min(net_data.bb.y1 + 1, ctx->getGridDimY()); + } + } } bool bind_and_check(NetInfo *net, int usr_idx, int phys_pin) @@ -1113,10 +1125,10 @@ struct Router2 for (auto &th : tcs) { th.rng.rngseed(ctx->rng64()); } - int le_x = mid_x - cfg.bb_margin_x; - int rs_x = mid_x + cfg.bb_margin_x; - int le_y = mid_y - cfg.bb_margin_y; - int rs_y = mid_y + cfg.bb_margin_y; + int le_x = mid_x; + int rs_x = mid_x; + int le_y = mid_y; + int rs_y = mid_y; // Set up thread bounding boxes tcs.at(0).bb = ArcBounds(0, 0, mid_x, mid_y); tcs.at(1).bb = ArcBounds(mid_x + 1, 0, std::numeric_limits::max(), le_y);