router2: Improvements

Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
David Shah 2020-01-02 14:06:57 +00:00
parent 900fe98f0d
commit 72367e6cfd
3 changed files with 19 additions and 14 deletions

View File

@ -813,7 +813,7 @@ bool router1(Context *ctx, const Router1Cfg &cfg)
std::chrono::duration<float>(rend - rstart).count());
log_info("Routing complete.\n");
ctx->yield();
log_info("Route time %.02fs\n", std::chrono::duration<float>(rend - rstart).count());
log_info("Router1 time %.02fs\n", std::chrono::duration<float>(rend - rstart).count());
#ifndef NDEBUG
router.check();

View File

@ -28,6 +28,7 @@
#include <algorithm>
#include <boost/container/flat_map.hpp>
#include <chrono>
#include <deque>
#include <fstream>
#include <queue>
@ -353,10 +354,6 @@ struct Router2
// Find all the wires that must be used to route a given arc
void reserve_wires_for_arc(NetInfo *net, size_t i)
{
// This is slightly tricky, because of the possibility of "diamonds"
// eg /--C--\\
// sink ----B----D--...
// we need to discover that D is a reserved wire; despite the branch and choice of B/C
WireId src = ctx->getNetinfoSourceWire(net);
WireId sink = ctx->getNetinfoSinkWire(net, net->users.at(i));
if (sink == WireId())
@ -364,6 +361,7 @@ struct Router2
std::unordered_set<WireId> rsv;
WireId cursor = sink;
bool done = false;
if (ctx->debug)
log("resevering wires for arc %d of net %s\n", int(i), ctx->nameOf(net));
while (!done) {
auto &wd = wires.at(cursor);
@ -855,8 +853,10 @@ struct Router2
mid_y = p.first;
accum_y += p.second;
}
if (ctx->verbose) {
log_info(" x splitpoint: %d\n", mid_x);
log_info(" y splitpoint: %d\n", mid_y);
}
std::vector<int> bins(5, 0);
for (auto &n : nets) {
if (n.bb.x0 < mid_x && n.bb.x1 < mid_x && n.bb.y0 < mid_y && n.bb.y1 < mid_y)
@ -870,6 +870,7 @@ struct Router2
else
++bins[4]; // cross-boundary
}
if (ctx->verbose)
for (int i = 0; i < 5; i++)
log_info(" bin %d N=%d\n", i, bins[i]);
}
@ -914,6 +915,7 @@ struct Router2
bin = 3;
tcs.at(bin).route_nets.push_back(ni);
}
if (ctx->verbose)
log_info("%d/%d nets not multi-threadable\n", int(tcs.at(N).route_nets.size()), int(route_queue.size()));
// Multithreaded part of routing
std::vector<std::thread> threads;
@ -958,7 +960,7 @@ struct Router2
do_route();
route_queue.clear();
update_congestion();
#if 1
#if 0
if (iter == 1 && ctx->debug) {
std::ofstream cong_map("cong_map_0.csv");
write_heatmap(cong_map, true);
@ -979,11 +981,14 @@ struct Router2
};
} // namespace
void router2_test(Context *ctx)
void router2(Context *ctx)
{
Router2 rt;
rt.ctx = ctx;
auto rstart = std::chrono::high_resolution_clock::now();
rt.router_test();
auto rend = std::chrono::high_resolution_clock::now();
log_info("Router2 time %.02fs\n", std::chrono::duration<float>(rend - rstart).count());
}
NEXTPNR_NAMESPACE_END

View File

@ -21,6 +21,6 @@
NEXTPNR_NAMESPACE_BEGIN
void router2_test(Context *ctx);
void router2(Context *ctx);
NEXTPNR_NAMESPACE_END