router2: Dynamicly expand bounding box based on congestion

Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
gatecat 2021-05-06 19:04:24 +01:00
parent ae8a910339
commit 62613cb266

View File

@ -68,6 +68,7 @@ struct Router2
int cx, cy, hpwl; int cx, cy, hpwl;
int total_route_us = 0; int total_route_us = 0;
float max_crit = 0; float max_crit = 0;
int fail_count = 0;
}; };
struct WireScore 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, 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).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).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++; i++;
} }
} }
@ -264,11 +269,7 @@ struct Router2
}; };
}; };
bool hit_test_pip(ArcBounds &bb, Loc l) 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; }
{
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);
}
double curr_cong_weight, hist_cong_weight, estimate_weight; 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) if (is_bb && !hit_test_pip(ad.bb, ctx->getPipLocation(dh)) && wire_intent != ID_PSEUDO_GND && wire_intent != ID_PSEUDO_VCC)
continue; continue;
#else #else
if (is_bb && !hit_test_pip(ad.bb, ctx->getPipLocation(dh))) if (is_bb && !hit_test_pip(nd.bb, ctx->getPipLocation(dh)))
continue; continue;
if (!ctx->checkPipAvailForNet(dh, net)) { 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), 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); 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) bool bind_and_check(NetInfo *net, int usr_idx, int phys_pin)
@ -1113,10 +1125,10 @@ struct Router2
for (auto &th : tcs) { for (auto &th : tcs) {
th.rng.rngseed(ctx->rng64()); th.rng.rngseed(ctx->rng64());
} }
int le_x = mid_x - cfg.bb_margin_x; int le_x = mid_x;
int rs_x = mid_x + cfg.bb_margin_x; int rs_x = mid_x;
int le_y = mid_y - cfg.bb_margin_y; int le_y = mid_y;
int rs_y = mid_y + cfg.bb_margin_y; int rs_y = mid_y;
// Set up thread bounding boxes // Set up thread bounding boxes
tcs.at(0).bb = ArcBounds(0, 0, mid_x, mid_y); tcs.at(0).bb = ArcBounds(0, 0, mid_x, mid_y);
tcs.at(1).bb = ArcBounds(mid_x + 1, 0, std::numeric_limits<int>::max(), le_y); tcs.at(1).bb = ArcBounds(mid_x + 1, 0, std::numeric_limits<int>::max(), le_y);