@@ -2297,20 +2297,43 @@ void Connection_based_routing_resources::clear_force_reroute_for_net() {
2297
2297
2298
2298
static OveruseInfo calculate_overuse_info () {
2299
2299
auto & device_ctx = g_vpr_ctx.device ();
2300
+ auto & cluster_ctx = g_vpr_ctx.clustering ();
2300
2301
auto & route_ctx = g_vpr_ctx.routing ();
2301
2302
2303
+ std::unordered_set<int > checked_nodes;
2304
+
2302
2305
size_t overused_nodes = 0 ;
2303
2306
size_t total_overuse = 0 ;
2304
2307
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 ;
2309
2308
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
+ }
2312
2334
}
2313
2335
}
2336
+
2314
2337
return OveruseInfo (device_ctx.rr_nodes .size (), overused_nodes, total_overuse, worst_overuse);
2315
2338
}
2316
2339
0 commit comments