diff --git a/vpr/src/route/route.cpp b/vpr/src/route/route.cpp index 0696996cf85..8571d620452 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,31 @@ 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++) { + 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++; + } + } + } + + // 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); + } + /* Write out partition tree logs (no-op if debug option not set) */ PartitionTreeDebug::write("partition_tree.log"); @@ -624,8 +653,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 ", 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 a71f259d7a8..976aa7e5b7b 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 d13e1d74491..c62980daeb7 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