Skip to content

Commit 65b1d5a

Browse files
committed
vpr: Update router overuse calculation to be O(routing) rather than O(RR graph)
This should by more efficient.
1 parent bf0d613 commit 65b1d5a

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

vpr/src/route/route_timing.cpp

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,20 +2297,43 @@ void Connection_based_routing_resources::clear_force_reroute_for_net() {
22972297

22982298
static OveruseInfo calculate_overuse_info() {
22992299
auto& device_ctx = g_vpr_ctx.device();
2300+
auto& cluster_ctx = g_vpr_ctx.clustering();
23002301
auto& route_ctx = g_vpr_ctx.routing();
23012302

2303+
std::unordered_set<int> checked_nodes;
2304+
23022305
size_t overused_nodes = 0;
23032306
size_t total_overuse = 0;
23042307
size_t worst_overuse = 0;
2305-
for (size_t inode = 0; inode < device_ctx.rr_nodes.size(); inode++) {
2306-
int overuse = route_ctx.rr_node_route_inf[inode].occ() - device_ctx.rr_nodes[inode].capacity();
2307-
if (overuse > 0) {
2308-
overused_nodes += 1;
23092308

2310-
total_overuse += overuse;
2311-
worst_overuse = std::max(worst_overuse, size_t(overuse));
2309+
//We walk through the entire routing calculating the overuse for each node.
2310+
//Since in the presence of overuse multiple nets could be using a single node
2311+
//(and also since branch nodes show up multiple times in the traceback) we use
2312+
//checked_nodes to avoid double counting the overuse.
2313+
//
2314+
//Note that we walk through the entire routing and *not* the RR graph, which
2315+
//should be more efficient (since usually only a portion of the RR graph is
2316+
//used by routing, particularly on large devices).
2317+
for (auto net_id : cluster_ctx.clb_nlist.nets()) {
2318+
2319+
for(t_trace* tptr = route_ctx.trace[net_id].head; tptr != nullptr; tptr = tptr->next) {
2320+
int inode = tptr->index;
2321+
2322+
auto result = checked_nodes.insert(inode);
2323+
if (!result.second) { //Already counted
2324+
continue;
2325+
}
2326+
2327+
int overuse = route_ctx.rr_node_route_inf[inode].occ() - device_ctx.rr_nodes[inode].capacity();
2328+
if (overuse > 0) {
2329+
overused_nodes += 1;
2330+
2331+
total_overuse += overuse;
2332+
worst_overuse = std::max(worst_overuse, size_t(overuse));
2333+
}
23122334
}
23132335
}
2336+
23142337
return OveruseInfo(device_ctx.rr_nodes.size(), overused_nodes, total_overuse, worst_overuse);
23152338
}
23162339

0 commit comments

Comments
 (0)