diff --git a/vpr/src/route/NestedNetlistRouter.h b/vpr/src/route/NestedNetlistRouter.h index e776d0a42d..87a3fdd880 100644 --- a/vpr/src/route/NestedNetlistRouter.h +++ b/vpr/src/route/NestedNetlistRouter.h @@ -2,6 +2,7 @@ /** @file Nested parallel case for NetlistRouter */ #include "netlist_routers.h" +#include "partition_tree.h" #include "vtr_optional.h" #include "vtr_thread_pool.h" #include "serial_connection_router.h" diff --git a/vpr/src/route/SerialNetlistRouter.tpp b/vpr/src/route/SerialNetlistRouter.tpp index b84acfbd58..ae7c8117db 100644 --- a/vpr/src/route/SerialNetlistRouter.tpp +++ b/vpr/src/route/SerialNetlistRouter.tpp @@ -3,7 +3,9 @@ /** @file Templated implementations for SerialNetlistRouter */ #include "SerialNetlistRouter.h" +#include "partition_tree.h" #include "route_net.h" +#include "route_utils.h" #include "vtr_time.h" template diff --git a/vpr/src/route/annotate_routing.cpp b/vpr/src/route/annotate_routing.cpp index 71c78a2498..4f3fdc4c52 100644 --- a/vpr/src/route/annotate_routing.cpp +++ b/vpr/src/route/annotate_routing.cpp @@ -3,13 +3,12 @@ * from VPR to OpenFPGA. (i.e. create a mapping from RRNodeIds to ClusterNetIds) *******************************************************************/ +#include "describe_rr_node.h" #include "vpr_error.h" -#include "vtr_assert.h" #include "vtr_time.h" #include "vtr_log.h" #include "route_utils.h" -#include "rr_graph.h" #include "annotate_routing.h" diff --git a/vpr/src/route/annotate_routing.h b/vpr/src/route/annotate_routing.h index e00be54925..b402656217 100644 --- a/vpr/src/route/annotate_routing.h +++ b/vpr/src/route/annotate_routing.h @@ -1,7 +1,13 @@ #ifndef ANNOTATE_ROUTING_H #define ANNOTATE_ROUTING_H -#include "vpr_context.h" +#include "clustered_netlist_fwd.h" +#include "rr_graph_fwd.h" +#include "vtr_vector.h" + +struct AtomContext; +struct ClusteringContext; +struct DeviceContext; /******************************************************************** * Create a mapping between each rr_node and its mapped nets diff --git a/vpr/src/route/check_route.h b/vpr/src/route/check_route.h index feff233156..609a2fcb8d 100644 --- a/vpr/src/route/check_route.h +++ b/vpr/src/route/check_route.h @@ -1,8 +1,8 @@ #ifndef VPR_CHECK_ROUTE_H #define VPR_CHECK_ROUTE_H -#include "physical_types.h" + +#include "netlist.h" #include "vpr_types.h" -#include "route_common.h" void check_route(const Netlist<>& net_list, enum e_route_type route_type, diff --git a/vpr/src/route/connection_based_routing.h b/vpr/src/route/connection_based_routing.h index 0f0faaaace..2b7915bf6d 100644 --- a/vpr/src/route/connection_based_routing.h +++ b/vpr/src/route/connection_based_routing.h @@ -1,10 +1,10 @@ #pragma once + #include #include -#include "route_tree_fwd.h" -#include "vpr_types.h" #include "timing_info.h" #include "vpr_net_pins_matrix.h" +#include "connection_based_routing_fwd.h" /***************** Connection based rerouting **********************/ // encompasses both incremental rerouting through route tree pruning diff --git a/vpr/src/route/connection_router.h b/vpr/src/route/connection_router.h index f5bb7c57aa..ad88883489 100644 --- a/vpr/src/route/connection_router.h +++ b/vpr/src/route/connection_router.h @@ -22,12 +22,12 @@ */ #include "connection_router_interface.h" +#include "globals.h" #include "rr_graph_storage.h" -#include "route_common.h" #include "router_lookahead.h" #include "route_tree.h" -#include "rr_rc_data.h" #include "router_stats.h" +#include "rr_graph_view.h" #include "spatial_route_tree_lookup.h" /** diff --git a/vpr/src/route/connection_router.tpp b/vpr/src/route/connection_router.tpp index f74b213235..34774ccf9d 100644 --- a/vpr/src/route/connection_router.tpp +++ b/vpr/src/route/connection_router.tpp @@ -4,6 +4,7 @@ #include #include "describe_rr_node.h" +#include "route_common.h" #include "rr_graph_fwd.h" #include "vpr_utils.h" diff --git a/vpr/src/route/connection_router_interface.h b/vpr/src/route/connection_router_interface.h index 178768bf5d..c5b63e57fb 100644 --- a/vpr/src/route/connection_router_interface.h +++ b/vpr/src/route/connection_router_interface.h @@ -1,9 +1,6 @@ #ifndef _CONNECTION_ROUTER_INTERFACE_H #define _CONNECTION_ROUTER_INTERFACE_H -#include - -#include "heap_type.h" #include "route_tree_fwd.h" #include "rr_graph_fwd.h" #include "vpr_types.h" diff --git a/vpr/src/route/edge_groups.cpp b/vpr/src/route/edge_groups.cpp index 6ca1e36692..d23d4d248e 100644 --- a/vpr/src/route/edge_groups.cpp +++ b/vpr/src/route/edge_groups.cpp @@ -2,6 +2,7 @@ #include #include "rr_graph_fwd.h" +#include "vpr_context.h" // Adds non-configurable (undirected) edge to be grouped. // diff --git a/vpr/src/route/edge_groups.h b/vpr/src/route/edge_groups.h index 90236ce3d6..a5521b6d2e 100644 --- a/vpr/src/route/edge_groups.h +++ b/vpr/src/route/edge_groups.h @@ -7,7 +7,8 @@ #include #include "vpr_types.h" -#include "vpr_context.h" + +struct DeviceContext; // Class for identifying the components of a graph as sets of nodes. // Each node is reachable from any other node in the same set, and diff --git a/vpr/src/route/heap_type.h b/vpr/src/route/heap_type.h index dd722928bc..6330fc4c0d 100644 --- a/vpr/src/route/heap_type.h +++ b/vpr/src/route/heap_type.h @@ -2,10 +2,7 @@ #define _HEAP_TYPE_H #include -#include "physical_types.h" #include "device_grid.h" -#include "vtr_memory.h" -#include "vtr_array_view.h" #include "rr_graph_fwd.h" #include "route_path_manager.h" diff --git a/vpr/src/route/multi_queue_d_ary_heap.h b/vpr/src/route/multi_queue_d_ary_heap.h index 5a49dadae5..c5f43e5aa3 100644 --- a/vpr/src/route/multi_queue_d_ary_heap.h +++ b/vpr/src/route/multi_queue_d_ary_heap.h @@ -17,8 +17,7 @@ * Modified: February 2025 ********************************************************************/ -#ifndef _MULTI_QUEUE_D_ARY_HEAP_H -#define _MULTI_QUEUE_D_ARY_HEAP_H +#pragma once #include "device_grid.h" #include "heap_type.h" @@ -129,5 +128,3 @@ class MultiQueueDAryHeap { private: std::unique_ptr pq_; }; - -#endif diff --git a/vpr/src/route/netlist_routers.h b/vpr/src/route/netlist_routers.h index eb8a220f51..d4cb0a3284 100644 --- a/vpr/src/route/netlist_routers.h +++ b/vpr/src/route/netlist_routers.h @@ -19,13 +19,11 @@ #include "NetPinTimingInvalidator.h" #include "clustered_netlist_utils.h" #include "connection_based_routing_fwd.h" -#include "globals.h" +#include "d_ary_heap.h" #include "heap_type.h" #include "netlist_fwd.h" -#include "partition_tree.h" #include "routing_predictor.h" #include "route_budgets.h" -#include "route_utils.h" #include "router_stats.h" #include "timing_info.h" #include "vpr_net_pins_matrix.h" diff --git a/vpr/src/route/overuse_report.cpp b/vpr/src/route/overuse_report.cpp index 24913fad6d..a9300b888c 100644 --- a/vpr/src/route/overuse_report.cpp +++ b/vpr/src/route/overuse_report.cpp @@ -1,6 +1,7 @@ #include "overuse_report.h" #include +#include "globals.h" #include "physical_types_util.h" #include "vpr_utils.h" #include "vtr_log.h" diff --git a/vpr/src/route/overuse_report.h b/vpr/src/route/overuse_report.h index bae9da1d13..04b52f5846 100644 --- a/vpr/src/route/overuse_report.h +++ b/vpr/src/route/overuse_report.h @@ -1,8 +1,7 @@ #pragma once -#include "rr_graph_storage.h" +#include "netlist.h" #include "rr_graph_view.h" -#include "globals.h" #include #include diff --git a/vpr/src/route/parallel_connection_router.cpp b/vpr/src/route/parallel_connection_router.cpp index f3111f156f..b8d97ceedf 100644 --- a/vpr/src/route/parallel_connection_router.cpp +++ b/vpr/src/route/parallel_connection_router.cpp @@ -1,6 +1,7 @@ #include "parallel_connection_router.h" #include +#include "d_ary_heap.h" #include "route_tree.h" #include "rr_graph_fwd.h" diff --git a/vpr/src/route/parallel_connection_router.h b/vpr/src/route/parallel_connection_router.h index 18d873e0c6..b6db78a0d0 100644 --- a/vpr/src/route/parallel_connection_router.h +++ b/vpr/src/route/parallel_connection_router.h @@ -3,7 +3,6 @@ #include "connection_router.h" -#include "d_ary_heap.h" #include "multi_queue_d_ary_heap.h" #include diff --git a/vpr/src/route/partition_tree.cpp b/vpr/src/route/partition_tree.cpp index 497f887cf7..7073db231b 100644 --- a/vpr/src/route/partition_tree.cpp +++ b/vpr/src/route/partition_tree.cpp @@ -1,7 +1,9 @@ #include "partition_tree.h" #include #include +#include #include +#include "globals.h" /** Minimum number of nets inside a partition to continue further partitioning. * Mostly an arbitrary limit. At a certain point, the quality lost due to disturbed net ordering diff --git a/vpr/src/route/partition_tree.h b/vpr/src/route/partition_tree.h index d30d512149..229ba52215 100644 --- a/vpr/src/route/partition_tree.h +++ b/vpr/src/route/partition_tree.h @@ -1,13 +1,10 @@ #pragma once -#include "serial_connection_router.h" -#include "netlist_fwd.h" -#include "router_stats.h" +#include "netlist.h" +#include "vpr_types.h" #include -#include #include -#include #ifdef VPR_USE_TBB #include diff --git a/vpr/src/route/route_budgets.cpp b/vpr/src/route/route_budgets.cpp index 677450ee03..a223c5629c 100644 --- a/vpr/src/route/route_budgets.cpp +++ b/vpr/src/route/route_budgets.cpp @@ -22,33 +22,11 @@ #include #include "vpr_error.h" #include "globals.h" -#include "tatum/util/tatum_assert.hpp" - -#include "tatum/timing_analyzers.hpp" -#include "tatum/graph_walkers.hpp" -#include "tatum/analyzer_factory.hpp" - -#include "tatum/TimingGraph.hpp" -#include "tatum/TimingConstraints.hpp" -#include "tatum/TimingReporter.hpp" -#include "tatum/timing_paths.hpp" - -#include "tatum/delay_calc/FixedDelayCalculator.hpp" - -#include "tatum/report/graphviz_dot_writer.hpp" -#include "tatum/base/sta_util.hpp" -#include "tatum/echo_writer.hpp" #include "tatum/TimingGraphFwd.hpp" -#include "slack_evaluation.h" #include "tatum/TimingGraphFwd.hpp" #include "vtr_assert.h" -#include "vtr_log.h" -#include "tatum/report/TimingPathFwd.hpp" -#include "tatum/base/TimingType.hpp" #include "concrete_timing_info.h" -#include "tatum/echo_writer.hpp" -#include "net_delay.h" #include "route_budgets.h" #include "vtr_time.h" diff --git a/vpr/src/route/route_budgets.h b/vpr/src/route/route_budgets.h index 7518027b85..4d3e1fc03c 100644 --- a/vpr/src/route/route_budgets.h +++ b/vpr/src/route/route_budgets.h @@ -4,10 +4,10 @@ #ifndef ROUTE_BUDGETS_H #define ROUTE_BUDGETS_H -#include #include #include #include "RoutingDelayCalculator.h" +#include "timing_info.h" enum analysis_type { SETUP, diff --git a/vpr/src/route/route_common.cpp b/vpr/src/route/route_common.cpp index 3f6d574b60..7ead8f73cd 100644 --- a/vpr/src/route/route_common.cpp +++ b/vpr/src/route/route_common.cpp @@ -7,6 +7,7 @@ #include "logic_types.h" #include "physical_types_util.h" #include "route_export.h" +#include "vpr_utils.h" #if defined(VPR_USE_TBB) #include diff --git a/vpr/src/route/route_common.h b/vpr/src/route/route_common.h index 1d6bfb5808..49ac82a690 100644 --- a/vpr/src/route/route_common.h +++ b/vpr/src/route/route_common.h @@ -4,8 +4,6 @@ * router files and some used globally. */ #include -#include "clustered_netlist.h" -#include "rr_node_fwd.h" #include "router_stats.h" #include "globals.h" diff --git a/vpr/src/route/route_export.h b/vpr/src/route/route_export.h index 971aeba966..b9c6a28620 100644 --- a/vpr/src/route/route_export.h +++ b/vpr/src/route/route_export.h @@ -3,13 +3,13 @@ /** @file Function prototypes for functions in route_common.cpp that * are used outside the router modules. */ -#include - -#include "route_common.h" -#include "timing_info_fwd.h" -#include "vpr_types.h" - -#include "RoutingDelayCalculator.h" +#include +#include "clustered_netlist_fwd.h" +#include "netlist.h" +#include "route_tree.h" +#include "rr_graph_fwd.h" +#include "vtr_optional.h" +#include "vtr_vector.h" std::vector collect_congested_rr_nodes(); diff --git a/vpr/src/route/route_net.cpp b/vpr/src/route/route_net.cpp index 4d89ae04cf..c2718fbf49 100644 --- a/vpr/src/route/route_net.cpp +++ b/vpr/src/route/route_net.cpp @@ -1,7 +1,7 @@ /** @file Impls for non-templated net routing fns & utils */ #include "route_net.h" -#include "stats.h" +#include "connection_based_routing.h" bool check_hold(const t_router_opts& router_opts, float worst_neg_slack) { if (router_opts.routing_budgets_algorithm != YOYO) { @@ -174,16 +174,6 @@ bool should_route_net(const Netlist<>& net_list, return true; } -bool early_exit_heuristic(const t_router_opts& router_opts, const WirelengthInfo& wirelength_info) { - if (wirelength_info.used_wirelength_ratio() > router_opts.init_wirelength_abort_threshold) { - VTR_LOG("Wire length usage ratio %g exceeds limit of %g, fail routing.\n", - wirelength_info.used_wirelength_ratio(), - router_opts.init_wirelength_abort_threshold); - return true; - } - return false; -} - float get_net_pin_criticality(const SetupHoldTimingInfo* timing_info, const ClusteredPinAtomPinsLookup& netlist_pin_lookup, float max_criticality, @@ -221,124 +211,6 @@ float get_net_pin_criticality(const SetupHoldTimingInfo* timing_info, return pin_criticality; } -size_t calculate_wirelength_available() { - auto& device_ctx = g_vpr_ctx.device(); - const auto& rr_graph = device_ctx.rr_graph; - - size_t available_wirelength = 0; - // But really what's happening is that this for loop iterates over every node and determines the available wirelength - for (const RRNodeId& rr_id : device_ctx.rr_graph.nodes()) { - const e_rr_type channel_type = rr_graph.node_type(rr_id); - if (channel_type == e_rr_type::CHANX || channel_type == e_rr_type::CHANY) { - available_wirelength += rr_graph.node_capacity(rr_id) * rr_graph.node_length(rr_id); - } - } - return available_wirelength; -} - -WirelengthInfo calculate_wirelength_info(const Netlist<>& net_list, size_t available_wirelength) { - size_t used_wirelength = 0; - VTR_ASSERT(available_wirelength > 0); - - auto& route_ctx = g_vpr_ctx.routing(); - -#ifdef VPR_USE_TBB - tbb::combinable thread_used_wirelength(0); - - tbb::parallel_for_each(net_list.nets().begin(), net_list.nets().end(), [&](ParentNetId net_id) { - if (!net_list.net_is_ignored(net_id) - && net_list.net_sinks(net_id).size() != 0 /* Globals don't count. */ - && route_ctx.route_trees[net_id]) { - int bends, wirelength, segments; - bool is_absorbed; - get_num_bends_and_length(net_id, &bends, &wirelength, &segments, &is_absorbed); - - thread_used_wirelength.local() += wirelength; - } - }); - - used_wirelength = thread_used_wirelength.combine(std::plus()); -#else - for (auto net_id : net_list.nets()) { - if (!net_list.net_is_ignored(net_id) - && net_list.net_sinks(net_id).size() != 0 /* Globals don't count. */ - && route_ctx.route_trees[net_id]) { - int bends = 0, wirelength = 0, segments = 0; - bool is_absorbed; - get_num_bends_and_length(net_id, &bends, &wirelength, &segments, &is_absorbed); - - used_wirelength += wirelength; - } - } -#endif - - return WirelengthInfo(available_wirelength, used_wirelength); -} - -t_bb calc_current_bb(const RouteTree& tree) { - auto& device_ctx = g_vpr_ctx.device(); - const auto& rr_graph = device_ctx.rr_graph; - auto& grid = device_ctx.grid; - - t_bb bb; - bb.xmin = grid.width() - 1; - bb.ymin = grid.height() - 1; - bb.layer_min = grid.get_num_layers() - 1; - bb.xmax = 0; - bb.ymax = 0; - bb.layer_max = 0; - - for (auto& rt_node : tree.all_nodes()) { - //The router interprets RR nodes which cross the boundary as being - //'within' of the BB. Only those which are *strictly* out side the - //box are excluded, hence we use the nodes xhigh/yhigh for xmin/xmax, - //and xlow/ylow for xmax/ymax calculations - bb.xmin = std::min(bb.xmin, rr_graph.node_xhigh(rt_node.inode)); - bb.ymin = std::min(bb.ymin, rr_graph.node_yhigh(rt_node.inode)); - bb.layer_min = std::min(bb.layer_min, rr_graph.node_layer(rt_node.inode)); - bb.xmax = std::max(bb.xmax, rr_graph.node_xlow(rt_node.inode)); - bb.ymax = std::max(bb.ymax, rr_graph.node_ylow(rt_node.inode)); - bb.layer_max = std::max(bb.layer_max, rr_graph.node_layer(rt_node.inode)); - } - - VTR_ASSERT(bb.xmin <= bb.xmax); - VTR_ASSERT(bb.ymin <= bb.ymax); - - return bb; -} - -// Initializes net_delay based on best-case delay estimates from the router lookahead -void init_net_delay_from_lookahead(const RouterLookahead& router_lookahead, - const Netlist<>& net_list, - const vtr::vector>& net_rr_terminals, - NetPinsMatrix& net_delay, - const RRGraphView& rr_graph, - bool is_flat) { - t_conn_cost_params cost_params; - cost_params.criticality = 1.; // Ensures lookahead returns delay value - - for (auto net_id : net_list.nets()) { - if (net_list.net_is_ignored(net_id)) continue; - - RRNodeId source_rr = net_rr_terminals[net_id][0]; - - for (size_t ipin = 1; ipin < net_list.net_pins(net_id).size(); ++ipin) { - RRNodeId sink_rr = net_rr_terminals[net_id][ipin]; - - float est_delay = get_cost_from_lookahead(router_lookahead, - rr_graph, - source_rr, - sink_rr, - 0., - cost_params, - is_flat); - VTR_ASSERT(std::isfinite(est_delay) && est_delay < std::numeric_limits::max()); - - net_delay[net_id][ipin] = est_delay; - } - } -} - void update_net_delays_from_route_tree(float* net_delay, const Netlist<>& net_list, ParentNetId inet, diff --git a/vpr/src/route/route_net.h b/vpr/src/route/route_net.h index f996be8b64..e03b010c5e 100644 --- a/vpr/src/route/route_net.h +++ b/vpr/src/route/route_net.h @@ -2,20 +2,10 @@ /** @file Net and sink routing functions, and other utils used by them. */ -#include #include -#include "connection_based_routing.h" -#include "connection_router_interface.h" -#include "heap_type.h" #include "netlist.h" #include "route_budgets.h" -#include "route_utils.h" -#include "router_stats.h" -#include "router_lookahead.h" -#include "routing_predictor.h" -#include "rr_graph_type.h" -#include "spatial_route_tree_lookup.h" #include "timing_info_fwd.h" #include "vpr_types.h" #include "vpr_utils.h" diff --git a/vpr/src/route/route_net.tpp b/vpr/src/route/route_net.tpp index 1a5715b734..dc1cc75dab 100644 --- a/vpr/src/route/route_net.tpp +++ b/vpr/src/route/route_net.tpp @@ -6,12 +6,14 @@ #include +#include "connection_based_routing.h" #include "connection_router_interface.h" #include "describe_rr_node.h" #include "draw.h" #include "route_common.h" #include "route_debug.h" #include "route_profiling.h" +#include "routing_predictor.h" #include "rr_graph_fwd.h" #include "vtr_dynamic_bitset.h" diff --git a/vpr/src/route/route_path_manager.cpp b/vpr/src/route/route_path_manager.cpp index 03dec82399..58aa565aee 100644 --- a/vpr/src/route/route_path_manager.cpp +++ b/vpr/src/route/route_path_manager.cpp @@ -1,5 +1,5 @@ #include "route_path_manager.h" -#include "globals.h" +#include "vpr_context.h" PathManager::PathManager() { // Only init data structure if required by RCV diff --git a/vpr/src/route/route_path_manager.h b/vpr/src/route/route_path_manager.h index f167377219..30377805f0 100644 --- a/vpr/src/route/route_path_manager.h +++ b/vpr/src/route/route_path_manager.h @@ -1,13 +1,10 @@ +#pragma once + #include "rr_graph_fwd.h" -#include "vtr_assert.h" #include -#include #include -#ifndef _PATH_MANAGER_H -#define _PATH_MANAGER_H - /* Extra path data needed by RCV, separated from RTExploredNode struct for performance reasons * Can be accessed by a pointer, won't be initialized unless by RCV * Use PathManager class to handle this structure's allocation and deallocation @@ -115,5 +112,3 @@ class PathManager { // Required by RCV so the router doesn't expand already visited nodes std::set route_tree_nodes_; }; - -#endif diff --git a/vpr/src/route/route_tree.h b/vpr/src/route/route_tree.h index 37e89db16a..36b5dcabfa 100644 --- a/vpr/src/route/route_tree.h +++ b/vpr/src/route/route_tree.h @@ -81,19 +81,16 @@ */ #include -#include #include #include #include #include "connection_based_routing_fwd.h" #include "route_tree_fwd.h" -#include "vtr_assert.h" #include "spatial_route_tree_lookup.h" #include "vtr_dynamic_bitset.h" #include "vtr_optional.h" #include "vtr_range.h" -#include "vtr_vec_id_set.h" /** * @brief A single route tree node diff --git a/vpr/src/route/route_utilization.cpp b/vpr/src/route/route_utilization.cpp index bb9c5e736e..e4bb2df36a 100644 --- a/vpr/src/route/route_utilization.cpp +++ b/vpr/src/route/route_utilization.cpp @@ -1,4 +1,6 @@ #include "route_utilization.h" +#include "draw_global.h" +#include "draw_types.h" #include "globals.h" #include "vpr_utils.h" diff --git a/vpr/src/route/route_utilization.h b/vpr/src/route/route_utilization.h index 194df6deb1..228ac842c8 100644 --- a/vpr/src/route/route_utilization.h +++ b/vpr/src/route/route_utilization.h @@ -1,8 +1,7 @@ -#ifndef VPR_ROUTE_UTIL_H -#define VPR_ROUTE_UTIL_H -#include "vpr_types.h" -#include "draw_types.h" -#include "draw_global.h" +#pragma once + +#include "rr_node_types.h" +#include "vtr_ndmatrix.h" vtr::Matrix calculate_routing_avail(e_rr_type rr_type); @@ -17,5 +16,3 @@ vtr::Matrix calculate_routing_avail(e_rr_type rr_type); */ vtr::Matrix calculate_routing_usage(e_rr_type rr_type, bool is_flat, bool is_print); float routing_util(float used, float avail); - -#endif diff --git a/vpr/src/route/route_utils.cpp b/vpr/src/route/route_utils.cpp index 198d64197e..d61b6bb56c 100644 --- a/vpr/src/route/route_utils.cpp +++ b/vpr/src/route/route_utils.cpp @@ -12,12 +12,18 @@ #include "overuse_report.h" #include "physical_types_util.h" #include "place_and_route.h" +#include "route_common.h" #include "route_debug.h" #include "VprTimingGraphResolver.h" +#include "route_tree.h" #include "rr_graph.h" #include "tatum/TimingReporter.hpp" +#ifdef VPR_USE_TBB +#include "stats.h" +#endif // VPR_USE_TBB + bool check_net_delays(const Netlist<>& net_list, NetPinsMatrix& net_delay) { constexpr float ERROR_TOL = 0.0001; @@ -504,6 +510,134 @@ void try_graph(int width_fac, is_flat); } +bool early_exit_heuristic(const t_router_opts& router_opts, const WirelengthInfo& wirelength_info) { + if (wirelength_info.used_wirelength_ratio() > router_opts.init_wirelength_abort_threshold) { + VTR_LOG("Wire length usage ratio %g exceeds limit of %g, fail routing.\n", + wirelength_info.used_wirelength_ratio(), + router_opts.init_wirelength_abort_threshold); + return true; + } + return false; +} + +size_t calculate_wirelength_available() { + auto& device_ctx = g_vpr_ctx.device(); + const auto& rr_graph = device_ctx.rr_graph; + + size_t available_wirelength = 0; + // But really what's happening is that this for loop iterates over every node and determines the available wirelength + for (RRNodeId rr_id : device_ctx.rr_graph.nodes()) { + const e_rr_type channel_type = rr_graph.node_type(rr_id); + if (channel_type == e_rr_type::CHANX || channel_type == e_rr_type::CHANY) { + available_wirelength += rr_graph.node_capacity(rr_id) * rr_graph.node_length(rr_id); + } + } + return available_wirelength; +} + +WirelengthInfo calculate_wirelength_info(const Netlist<>& net_list, size_t available_wirelength) { + size_t used_wirelength = 0; + VTR_ASSERT(available_wirelength > 0); + + auto& route_ctx = g_vpr_ctx.routing(); + +#ifdef VPR_USE_TBB + tbb::combinable thread_used_wirelength(0); + + tbb::parallel_for_each(net_list.nets().begin(), net_list.nets().end(), [&](ParentNetId net_id) { + if (!net_list.net_is_ignored(net_id) + && net_list.net_sinks(net_id).size() != 0 /* Globals don't count. */ + && route_ctx.route_trees[net_id]) { + int bends, wirelength, segments; + bool is_absorbed; + get_num_bends_and_length(net_id, &bends, &wirelength, &segments, &is_absorbed); + + thread_used_wirelength.local() += wirelength; + } + }); + + used_wirelength = thread_used_wirelength.combine(std::plus()); +#else + for (auto net_id : net_list.nets()) { + if (!net_list.net_is_ignored(net_id) + && net_list.net_sinks(net_id).size() != 0 /* Globals don't count. */ + && route_ctx.route_trees[net_id]) { + int bends = 0, wirelength = 0, segments = 0; + bool is_absorbed; + get_num_bends_and_length(net_id, &bends, &wirelength, &segments, &is_absorbed); + + used_wirelength += wirelength; + } + } +#endif + + return WirelengthInfo(available_wirelength, used_wirelength); +} + +t_bb calc_current_bb(const RouteTree& tree) { + auto& device_ctx = g_vpr_ctx.device(); + const auto& rr_graph = device_ctx.rr_graph; + auto& grid = device_ctx.grid; + + t_bb bb; + bb.xmin = grid.width() - 1; + bb.ymin = grid.height() - 1; + bb.layer_min = grid.get_num_layers() - 1; + bb.xmax = 0; + bb.ymax = 0; + bb.layer_max = 0; + + for (const RouteTreeNode& rt_node : tree.all_nodes()) { + //The router interprets RR nodes which cross the boundary as being + //'within' of the BB. Only those which are *strictly* out side the + //box are excluded, hence we use the nodes xhigh/yhigh for xmin/xmax, + //and xlow/ylow for xmax/ymax calculations + bb.xmin = std::min(bb.xmin, rr_graph.node_xhigh(rt_node.inode)); + bb.ymin = std::min(bb.ymin, rr_graph.node_yhigh(rt_node.inode)); + bb.layer_min = std::min(bb.layer_min, rr_graph.node_layer(rt_node.inode)); + bb.xmax = std::max(bb.xmax, rr_graph.node_xlow(rt_node.inode)); + bb.ymax = std::max(bb.ymax, rr_graph.node_ylow(rt_node.inode)); + bb.layer_max = std::max(bb.layer_max, rr_graph.node_layer(rt_node.inode)); + } + + VTR_ASSERT(bb.xmin <= bb.xmax); + VTR_ASSERT(bb.ymin <= bb.ymax); + + return bb; +} + +// Initializes net_delay based on best-case delay estimates from the router lookahead +void init_net_delay_from_lookahead(const RouterLookahead& router_lookahead, + const Netlist<>& net_list, + const vtr::vector>& net_rr_terminals, + NetPinsMatrix& net_delay, + const RRGraphView& rr_graph, + bool is_flat) { + t_conn_cost_params cost_params; + cost_params.criticality = 1.; // Ensures lookahead returns delay value + + for (ParentNetId net_id : net_list.nets()) { + if (net_list.net_is_ignored(net_id)) continue; + + RRNodeId source_rr = net_rr_terminals[net_id][0]; + + for (size_t ipin = 1; ipin < net_list.net_pins(net_id).size(); ++ipin) { + RRNodeId sink_rr = net_rr_terminals[net_id][ipin]; + + float est_delay = get_cost_from_lookahead(router_lookahead, + rr_graph, + source_rr, + sink_rr, + 0.0f /* R_upstream */, + cost_params, + is_flat); + VTR_ASSERT(std::isfinite(est_delay) && est_delay < std::numeric_limits::max()); + + net_delay[net_id][ipin] = est_delay; + } + } +} + #ifndef NO_GRAPHICS void update_draw_pres_fac(const float new_pres_fac) { #else diff --git a/vpr/src/route/route_utils.h b/vpr/src/route/route_utils.h index 5cac4fbb04..71e3dc895d 100644 --- a/vpr/src/route/route_utils.h +++ b/vpr/src/route/route_utils.h @@ -6,7 +6,6 @@ #include "router_stats.h" #include "timing_info.h" #include "vpr_net_pins_matrix.h" -#include "vpr_types.h" #include "RoutingDelayCalculator.h" diff --git a/vpr/src/route/router_delay_profiling.cpp b/vpr/src/route/router_delay_profiling.cpp index 30180eb7e1..ff9e6e76cb 100644 --- a/vpr/src/route/router_delay_profiling.cpp +++ b/vpr/src/route/router_delay_profiling.cpp @@ -5,7 +5,6 @@ #include "route_export.h" #include "route_tree.h" #include "rr_graph.h" -#include "vtr_time.h" RouterDelayProfiler::RouterDelayProfiler(const Netlist<>& net_list, const RouterLookahead* lookahead, diff --git a/vpr/src/route/router_delay_profiling.h b/vpr/src/route/router_delay_profiling.h index 082349a9a0..e03d62abbd 100644 --- a/vpr/src/route/router_delay_profiling.h +++ b/vpr/src/route/router_delay_profiling.h @@ -1,7 +1,9 @@ -#ifndef ROUTER_DELAY_PROFILING_H_ -#define ROUTER_DELAY_PROFILING_H_ +#pragma once -#include "vpr_types.h" +#include "d_ary_heap.h" +#include "netlist.h" +#include "router_lookahead.h" +#include "router_stats.h" #include "serial_connection_router.h" #include @@ -60,5 +62,3 @@ void alloc_routing_structs(const t_chan_width& chan_width, bool is_flat); void free_routing_structs(); - -#endif /* ROUTER_DELAY_PROFILING_H_ */ diff --git a/vpr/src/route/routing_predictor.cpp b/vpr/src/route/routing_predictor.cpp index 4f0f69a28a..4b8e156d52 100644 --- a/vpr/src/route/routing_predictor.cpp +++ b/vpr/src/route/routing_predictor.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include "vtr_assert.h" diff --git a/vpr/src/route/rr_graph_generation/rr_node_indices.cpp b/vpr/src/route/rr_graph_generation/rr_node_indices.cpp index 99c1a729e6..5fed737666 100644 --- a/vpr/src/route/rr_graph_generation/rr_node_indices.cpp +++ b/vpr/src/route/rr_graph_generation/rr_node_indices.cpp @@ -517,8 +517,7 @@ bool verify_rr_node_indices(const DeviceGrid& grid, y, describe_rr_node(rr_graph, grid, rr_indexed_data, inode, is_flat).c_str()); } - } else if (rr_graph.node_type(inode) == e_rr_type::SOURCE || rr_graph.node_type(inode) == e_rr_type::SINK) { - // Sources have co-ordinates covering the entire block they are in, but not sinks + } else if (rr_graph.node_type(inode) == e_rr_type::SOURCE || rr_graph.node_type(inode) == e_rr_type::SINK || rr_graph.node_type(inode) == e_rr_type::MEDIUM) { if (!rr_graph.x_in_node_range(x, inode)) { VPR_ERROR(VPR_ERROR_ROUTE, "RR node x positions do not agree between rr_nodes (%d <-> %d) and rr_node_indices (%d): %s", rr_graph.node_xlow(inode), diff --git a/vpr/src/route/segment_stats.cpp b/vpr/src/route/segment_stats.cpp index 3d7de733ce..968a12d0c6 100644 --- a/vpr/src/route/segment_stats.cpp +++ b/vpr/src/route/segment_stats.cpp @@ -1,8 +1,6 @@ #include "vtr_log.h" -#include "vtr_memory.h" -#include "vpr_types.h" #include "globals.h" #include "segment_stats.h" diff --git a/vpr/src/route/segment_stats.h b/vpr/src/route/segment_stats.h index 346355c168..a040ab08b0 100644 --- a/vpr/src/route/segment_stats.h +++ b/vpr/src/route/segment_stats.h @@ -1 +1,6 @@ +#pragma once + +#include +#include "physical_types.h" + void get_segment_usage_stats(std::vector& segment_inf); diff --git a/vpr/src/route/serial_connection_router.cpp b/vpr/src/route/serial_connection_router.cpp index 3bb2d2b64a..4a5c074970 100644 --- a/vpr/src/route/serial_connection_router.cpp +++ b/vpr/src/route/serial_connection_router.cpp @@ -1,7 +1,7 @@ #include "serial_connection_router.h" #include -#include "rr_graph.h" +#include "d_ary_heap.h" #include "rr_graph_fwd.h" /** Used to update router statistics for serial connection router */ diff --git a/vpr/src/route/serial_connection_router.h b/vpr/src/route/serial_connection_router.h index 2cd23f1460..990c93c29f 100644 --- a/vpr/src/route/serial_connection_router.h +++ b/vpr/src/route/serial_connection_router.h @@ -3,8 +3,6 @@ #include "connection_router.h" -#include "d_ary_heap.h" - /** * @class SerialConnectionRouter implements the AIR's serial timing-driven connection router * @details This class routes from some initial set of sources (via the input rt tree) to a diff --git a/vpr/src/route/sink_sampling.h b/vpr/src/route/sink_sampling.h index 341a292db7..6277d55407 100644 --- a/vpr/src/route/sink_sampling.h +++ b/vpr/src/route/sink_sampling.h @@ -14,7 +14,6 @@ #include "globals.h" #include "partition_tree.h" #include "route_common.h" -#include "router_lookahead_sampling.h" /** Sink container for geometry operations */ struct SinkPoint { diff --git a/vpr/src/route/spatial_route_tree_lookup.h b/vpr/src/route/spatial_route_tree_lookup.h index 9ac1ac3c23..1766f972c5 100644 --- a/vpr/src/route/spatial_route_tree_lookup.h +++ b/vpr/src/route/spatial_route_tree_lookup.h @@ -1,5 +1,5 @@ -#ifndef VPR_SPATIAL_ROUTE_TREE_LOOKUP_H -#define VPR_SPATIAL_ROUTE_TREE_LOOKUP_H +#pragma once + #include #include "vpr_types.h" @@ -7,6 +7,7 @@ #include "netlist.h" #include "route_tree_fwd.h" +#include "vtr_vector.h" typedef vtr::Matrix>> SpatialRouteTreeLookup; @@ -21,5 +22,3 @@ size_t grid_to_bin_x(size_t grid_x, const SpatialRouteTreeLookup& spatial_lookup size_t grid_to_bin_y(size_t grid_y, const SpatialRouteTreeLookup& spatial_lookup); bool validate_route_tree_spatial_lookup(const RouteTreeNode& rt_node, const SpatialRouteTreeLookup& spatial_lookup); - -#endif diff --git a/vpr/src/tileable_rr_graph/tileable_rr_graph_node_builder.cpp b/vpr/src/tileable_rr_graph/tileable_rr_graph_node_builder.cpp index 887b876def..68bee2bbeb 100644 --- a/vpr/src/tileable_rr_graph/tileable_rr_graph_node_builder.cpp +++ b/vpr/src/tileable_rr_graph/tileable_rr_graph_node_builder.cpp @@ -48,7 +48,7 @@ static size_t estimate_num_grid_rr_nodes_by_type(const DeviceGrid& grids, std::vector io_side = {TOP, RIGHT, BOTTOM, LEFT}; /* If this is the block on borders, we consider IO side */ - if (true == is_io_type(grids.get_physical_type(tile_loc))) { + if (grids.get_physical_type(tile_loc)->is_io()) { vtr::Point io_device_size(grids.width() - 1, grids.height() - 1); vtr::Point grid_coordinate(ix, iy); io_side = determine_io_grid_pin_side(io_device_size, grid_coordinate, perimeter_cb); @@ -745,7 +745,7 @@ static void load_grid_nodes_basic_info(RRGraphBuilder& rr_graph_builder, std::vector wanted_sides{TOP, RIGHT, BOTTOM, LEFT}; /* If this is the block on borders, we consider IO side */ - if (true == is_io_type(grids.get_physical_type(tile_loc))) { + if (grids.get_physical_type(tile_loc)->is_io()) { vtr::Point io_device_size(grids.width() - 1, grids.height() - 1); wanted_sides = determine_io_grid_pin_side(io_device_size, grid_coordinate, perimeter_cb); } diff --git a/vpr/src/util/vpr_utils.h b/vpr/src/util/vpr_utils.h index c81b00db08..525e4bd962 100644 --- a/vpr/src/util/vpr_utils.h +++ b/vpr/src/util/vpr_utils.h @@ -7,6 +7,7 @@ #include "vpr_types.h" #include "vtr_vector.h" #include "atom_pb_bimap.h" +#include #include #include