From d3e4d3c4b13d6b0e577f1cc8dd8f5d7b9c3f7f97 Mon Sep 17 00:00:00 2001 From: Amin Mohaghegh Date: Mon, 10 Nov 2025 07:49:36 -0800 Subject: [PATCH 1/4] [vpr][route] calculate routing_struggle metric for router --- vpr/src/route/route.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/vpr/src/route/route.cpp b/vpr/src/route/route.cpp index 0696996cf8..1cff3b1f83 100644 --- a/vpr/src/route/route.cpp +++ b/vpr/src/route/route.cpp @@ -5,6 +5,7 @@ #include "place_and_route.h" #include "read_route.h" #include "route.h" +#include #include "route_common.h" #include "route_debug.h" #include "route_profiling.h" @@ -251,6 +252,8 @@ bool route(const Netlist<>& net_list, int rcv_finished_count = RCV_FINISH_EARLY_COUNTDOWN; + std::vector per_iter_heap_ops_count; + print_route_status_header(); #ifndef NO_GRAPHICS // Reset router iteration in the current route attempt. @@ -286,6 +289,7 @@ bool route(const Netlist<>& net_list, /* Route each net */ RouteIterResults iter_results = netlist_router->route_netlist(itry, pres_fac, worst_negative_slack); + per_iter_heap_ops_count.push_back(iter_results.stats.heap_pushes + iter_results.stats.heap_pops); if (!iter_results.is_routable) { /* Disconnected RRG */ return false; @@ -578,6 +582,24 @@ bool route(const Netlist<>& net_list, // profiling::time_on_criticality_analysis(); } + int num_high_heap_ops_iters = 0; + if (per_iter_heap_ops_count.size() > 4) { + for (int i = 3; i < static_cast(per_iter_heap_ops_count.size()); i++) { + size_t max_heap_ops = 0; + for (int j = i - 3; j < i; j++) { + max_heap_ops = std::max(max_heap_ops, per_iter_heap_ops_count[j]); + } + if (per_iter_heap_ops_count[i] >= max_heap_ops) { + num_high_heap_ops_iters++; + } + } + } + + float routing_struggle_ratio = 0.0; + if (per_iter_heap_ops_count.size() > 4) { + routing_struggle_ratio = static_cast(num_high_heap_ops_iters) / static_cast(per_iter_heap_ops_count.size() - 3); + } + /* Write out partition tree logs (no-op if debug option not set) */ PartitionTreeDebug::write("partition_tree.log"); @@ -624,8 +646,8 @@ bool route(const Netlist<>& net_list, VTR_ASSERT(router_stats.heap_pushes >= router_stats.intra_cluster_node_pushes); VTR_ASSERT(router_stats.heap_pops >= router_stats.intra_cluster_node_pops); VTR_LOG( - "Router Stats: total_nets_routed: %zu total_connections_routed: %zu total_heap_pushes: %zu total_heap_pops: %zu ", - router_stats.nets_routed, router_stats.connections_routed, router_stats.heap_pushes, router_stats.heap_pops); + "Router Stats: total_nets_routed: %zu total_connections_routed: %zu total_heap_pushes: %zu total_heap_pops: %zu routing_struggle_ratio: %.2f ", + router_stats.nets_routed, router_stats.connections_routed, router_stats.heap_pushes, router_stats.heap_pops, routing_struggle_ratio); if constexpr (VTR_ENABLE_DEBUG_LOGGING_CONST_EXPR) { VTR_LOG( "total_internal_heap_pushes: %zu total_internal_heap_pops: %zu total_external_heap_pushes: %zu total_external_heap_pops: %zu ", From aba6197148e3eff468e827bd8b97d67c3f22797d Mon Sep 17 00:00:00 2001 From: Amin Mohaghegh Date: Mon, 10 Nov 2025 07:50:13 -0800 Subject: [PATCH 2/4] [vtr_flow][parse] parse routing struggle metric --- .../parse/parse_config/common/vpr.route_fixed_chan_width.txt | 3 ++- .../parse/parse_config/timing/vpr.route_relaxed_chan_width.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/vtr_flow/parse/parse_config/common/vpr.route_fixed_chan_width.txt b/vtr_flow/parse/parse_config/common/vpr.route_fixed_chan_width.txt index a71f259d7a..976aa7e5b7 100644 --- a/vtr_flow/parse/parse_config/common/vpr.route_fixed_chan_width.txt +++ b/vtr_flow/parse/parse_config/common/vpr.route_fixed_chan_width.txt @@ -7,7 +7,8 @@ avg_routed_wiresegment;vpr.out;\s.*average wire segments per net: (.*) total_nets_routed;vpr.out;Router Stats: total_nets_routed: (\d+) .* total_connections_routed;vpr.out;Router Stats: .*total_connections_routed: (\d+) .* total_heap_pushes;vpr.out;Router Stats: .*total_heap_pushes: (\d+) .* -total_heap_pops;vpr.out;Router Stats: .*total_heap_pops: (\d+) +total_heap_pops;vpr.out;Router Stats: .*total_heap_pops: (\d+) .* +routing_struggle;vpr.out;Router Stats: .*routing_struggle_ratio: (.*) #Area Metrics logic_block_area_total;vpr.out;\s*Total logic block area .*: (.*) diff --git a/vtr_flow/parse/parse_config/timing/vpr.route_relaxed_chan_width.txt b/vtr_flow/parse/parse_config/timing/vpr.route_relaxed_chan_width.txt index d13e1d7449..c62980daeb 100644 --- a/vtr_flow/parse/parse_config/timing/vpr.route_relaxed_chan_width.txt +++ b/vtr_flow/parse/parse_config/timing/vpr.route_relaxed_chan_width.txt @@ -11,6 +11,7 @@ crit_path_total_nets_routed;vpr.crit_path.out;.* total_nets_routed: (\d+) crit_path_total_connections_routed;vpr.crit_path.out;.* total_connections_routed: (\d+) crit_path_total_heap_pushes;vpr.crit_path.out;.* total_heap_pushes: (\d+) crit_path_total_heap_pops;vpr.crit_path.out;.* total_heap_pops: (\d+) +crit_path_routing_struggle;vpr.crit_path.out;.* routing_struggle_ratio: (.*) #VPR Analysis (final implementation) Metrics critical_path_delay;vpr.crit_path.out;Final critical path delay \(least slack\): (.*) ns From a3d9784b7e08174122583f9c0c83051a509755d5 Mon Sep 17 00:00:00 2001 From: Amin Mohaghegh Date: Mon, 10 Nov 2025 07:53:53 -0800 Subject: [PATCH 3/4] [vpr][route] add comment for routing struggle metric --- vpr/src/route/route.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vpr/src/route/route.cpp b/vpr/src/route/route.cpp index 1cff3b1f83..e4a7b0f4b2 100644 --- a/vpr/src/route/route.cpp +++ b/vpr/src/route/route.cpp @@ -595,6 +595,11 @@ bool route(const Netlist<>& net_list, } } + // Calculates the routing struggle ratio. + // This ratio is defined as the number of iterations with high heap ops + // (i.e., iterations having more heap operations than the maximum of the previous three iterations + // divided by the total number of iterations. + // For more details, see TODO: routing struggle paper is not published yet. float routing_struggle_ratio = 0.0; if (per_iter_heap_ops_count.size() > 4) { routing_struggle_ratio = static_cast(num_high_heap_ops_iters) / static_cast(per_iter_heap_ops_count.size() - 3); From f9673e90c70dee5d6a29fd1737294d335091a62c Mon Sep 17 00:00:00 2001 From: Amin Mohaghegh Date: Mon, 10 Nov 2025 07:54:33 -0800 Subject: [PATCH 4/4] [vpr][route] add comment for routing struggle metric --- vpr/src/route/route.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vpr/src/route/route.cpp b/vpr/src/route/route.cpp index e4a7b0f4b2..8571d62045 100644 --- a/vpr/src/route/route.cpp +++ b/vpr/src/route/route.cpp @@ -582,6 +582,8 @@ bool route(const Netlist<>& net_list, // profiling::time_on_criticality_analysis(); } + // Calculates the number of iterations with high heap ops. + // This is defined as an iteration that has more heap operations than the maximum of the previous three iterations. int num_high_heap_ops_iters = 0; if (per_iter_heap_ops_count.size() > 4) { for (int i = 3; i < static_cast(per_iter_heap_ops_count.size()); i++) {