router2: Multi-thread in more cases

Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
David Shah 2020-01-14 15:36:42 +00:00
parent 3b043432f5
commit c27e7780d1

View File

@ -942,7 +942,8 @@ struct Router2
} }
return; return;
} }
const int N = 4; const int Nq = 4, Nv = 2, Nh = 2;
const int N = Nq + Nv + Nh;
std::vector<ThreadContext> tcs(N + 1); std::vector<ThreadContext> tcs(N + 1);
for (auto n : route_queue) { for (auto n : route_queue) {
auto &nd = nets.at(n); auto &nd = nets.at(n);
@ -952,7 +953,7 @@ struct Router2
int rs_x = mid_x + bb_margin_x; int rs_x = mid_x + bb_margin_x;
int le_y = mid_y - bb_margin_y; int le_y = mid_y - bb_margin_y;
int rs_y = mid_y + bb_margin_y; int rs_y = mid_y + bb_margin_y;
// Quadrants
if (nd.bb.x0 < le_x && nd.bb.x1 < le_x && nd.bb.y0 < le_y && nd.bb.y1 < le_y) if (nd.bb.x0 < le_x && nd.bb.x1 < le_x && nd.bb.y0 < le_y && nd.bb.y1 < le_y)
bin = 0; bin = 0;
else if (nd.bb.x0 >= rs_x && nd.bb.x1 >= rs_x && nd.bb.y0 < le_y && nd.bb.y1 < le_y) else if (nd.bb.x0 >= rs_x && nd.bb.x1 >= rs_x && nd.bb.y0 < le_y && nd.bb.y1 < le_y)
@ -961,17 +962,42 @@ struct Router2
bin = 2; bin = 2;
else if (nd.bb.x0 >= rs_x && nd.bb.x1 >= rs_x && nd.bb.y0 >= rs_y && nd.bb.y1 >= rs_y) else if (nd.bb.x0 >= rs_x && nd.bb.x1 >= rs_x && nd.bb.y0 >= rs_y && nd.bb.y1 >= rs_y)
bin = 3; bin = 3;
// Vertical split
else if (nd.bb.y0 < le_y && nd.bb.y1 < le_y)
bin = Nq + 0;
else if (nd.bb.y0 >= rs_y && nd.bb.y1 >= rs_y)
bin = Nq + 1;
// Horizontal split
else if (nd.bb.x0 < le_x && nd.bb.x1 < le_x)
bin = Nq + Nv + 0;
else if (nd.bb.x0 >= rs_x && nd.bb.x1 >= rs_x)
bin = Nq + Nv + 1;
tcs.at(bin).route_nets.push_back(ni); tcs.at(bin).route_nets.push_back(ni);
} }
if (ctx->verbose) if (ctx->verbose)
log_info("%d/%d nets not multi-threadable\n", int(tcs.at(N).route_nets.size()), int(route_queue.size())); log_info("%d/%d nets not multi-threadable\n", int(tcs.at(N).route_nets.size()), int(route_queue.size()));
// Multithreaded part of routing // Multithreaded part of routing - quadrants
std::vector<std::thread> threads; std::vector<std::thread> threads;
for (int i = 0; i < N; i++) { for (int i = 0; i < Nq; i++) {
threads.emplace_back([this, &tcs, i]() { router_thread(tcs.at(i)); }); threads.emplace_back([this, &tcs, i]() { router_thread(tcs.at(i)); });
} }
for (int i = 0; i < N; i++) for (auto &t : threads)
threads.at(i).join(); t.join();
threads.clear();
// Vertical splits
for (int i = Nq; i < Nq + Nv; i++) {
threads.emplace_back([this, &tcs, i]() { router_thread(tcs.at(i)); });
}
for (auto &t : threads)
t.join();
threads.clear();
// Horizontal splits
for (int i = Nq + Nv; i < Nq + Nv + Nh; i++) {
threads.emplace_back([this, &tcs, i]() { router_thread(tcs.at(i)); });
}
for (auto &t : threads)
t.join();
threads.clear();
// Singlethreaded part of routing - nets that cross partitions // Singlethreaded part of routing - nets that cross partitions
// or don't fit within bounding box // or don't fit within bounding box
for (auto st_net : tcs.at(N).route_nets) for (auto st_net : tcs.at(N).route_nets)