From 368d5880a5e0dc02ea20611c8177c37410381480 Mon Sep 17 00:00:00 2001 From: amin1377 Date: Wed, 27 Mar 2024 14:46:16 -0400 Subject: [PATCH 1/7] vpr: only pass rr_graph view and node id to is_inter_cluster_node --- vpr/src/route/overuse_report.cpp | 2 +- vpr/src/route/router_lookahead_map.cpp | 4 +--- vpr/src/route/router_lookahead_map_utils.cpp | 12 +++--------- vpr/src/util/vpr_utils.cpp | 14 +++++++++----- vpr/src/util/vpr_utils.h | 5 ++--- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/vpr/src/route/overuse_report.cpp b/vpr/src/route/overuse_report.cpp index 077401d7289..605eba1adb3 100644 --- a/vpr/src/route/overuse_report.cpp +++ b/vpr/src/route/overuse_report.cpp @@ -222,7 +222,7 @@ static void report_overused_ipin_opin(std::ostream& os, t_physical_tile_type_ptr physical_tile = device_ctx.grid.get_physical_type({grid_x, grid_y, grid_layer}); os << "Pin physical number = " << rr_graph.node_pin_num(node_id) << '\n'; - if (is_inter_cluster_node(physical_tile, rr_graph.node_type(node_id), rr_graph.node_ptc_num(node_id))) { + if (is_inter_cluster_node(rr_graph, node_id)) { os << "On Tile Pin" << "\n"; } else { diff --git a/vpr/src/route/router_lookahead_map.cpp b/vpr/src/route/router_lookahead_map.cpp index 019fe03311c..f386aa0b7e4 100644 --- a/vpr/src/route/router_lookahead_map.cpp +++ b/vpr/src/route/router_lookahead_map.cpp @@ -228,9 +228,7 @@ float MapLookahead::get_expected_cost_flat_router(RRNodeId current_node, RRNodeI return delay_cost + cong_cost + delay_offset_cost + cong_offset_cost; } else if (from_rr_type == OPIN) { - if (is_inter_cluster_node(from_physical_type, - from_rr_type, - from_node_ptc_num)) { + if (is_inter_cluster_node(rr_graph, current_node)) { // Similar to CHANX and CHANY std::tie(delay_cost, cong_cost) = get_expected_delay_and_cong(current_node, target_node, params, R_upstream); diff --git a/vpr/src/route/router_lookahead_map_utils.cpp b/vpr/src/route/router_lookahead_map_utils.cpp index 3094c97e4d5..beaba76592d 100644 --- a/vpr/src/route/router_lookahead_map_utils.cpp +++ b/vpr/src/route/router_lookahead_map_utils.cpp @@ -385,9 +385,7 @@ t_src_opin_delays compute_router_src_opin_lookahead(bool is_flat) { for (RRNodeId node_id : rr_nodes_at_loc) { int ptc = rr_graph.node_ptc_num(node_id); // For the time being, we decide to not let the lookahead explore the node inside the clusters - if (!is_inter_cluster_node(&device_ctx.physical_tile_types[itile], - rr_type, - ptc)) { + if (!is_inter_cluster_node(rr_graph, node_id)) { continue; } @@ -991,9 +989,7 @@ static void dijkstra_flood_to_wires(int itile, t_physical_tile_type_ptr physical_type = device_ctx.grid.get_physical_type({rr_graph.node_xlow(next_node), rr_graph.node_ylow(next_node), rr_graph.node_layer(next_node)}); - if (!is_inter_cluster_node(physical_type, - rr_graph.node_type(next_node), - rr_graph.node_ptc_num(next_node))) { + if (!is_inter_cluster_node(rr_graph, next_node)) { // Don't go inside the clusters continue; } @@ -1357,9 +1353,7 @@ static void expand_dijkstra_neighbours(util::PQ_Entry parent_entry, rr_graph.node_ylow(child_node), rr_graph.node_layer(child_node)}); - if (!is_inter_cluster_node(physical_type, - rr_graph.node_type(child_node), - rr_graph.node_ptc_num(child_node))) { + if (!is_inter_cluster_node(rr_graph, child_node)) { continue; } int switch_ind = size_t(rr_graph.edge_switch(parent, edge)); diff --git a/vpr/src/util/vpr_utils.cpp b/vpr/src/util/vpr_utils.cpp index db422bea509..1a8c8da0f0b 100644 --- a/vpr/src/util/vpr_utils.cpp +++ b/vpr/src/util/vpr_utils.cpp @@ -2275,17 +2275,21 @@ std::vector get_all_pb_graph_node_primitives(const t_pb_ return primitives; } -bool is_inter_cluster_node(t_physical_tile_type_ptr physical_tile, - t_rr_type node_type, - int node_ptc) { +bool is_inter_cluster_node(const RRGraphView& rr_graph_view, + RRNodeId node_id) { + auto node_type = rr_graph_view.node_type(node_id); if (node_type == CHANX || node_type == CHANY) { return true; } else { - VTR_ASSERT(node_type == IPIN || node_type == SINK || node_type == OPIN || node_type == SOURCE); + int x_low = rr_graph_view.node_xlow(node_id); + int y_low = rr_graph_view.node_ylow(node_id); + int layer = rr_graph_view.node_layer(node_id); + int node_ptc = rr_graph_view.node_ptc_num(node_id); + const t_physical_tile_type_ptr physical_tile = g_vpr_ctx.device().grid.get_physical_type({x_low, y_low, layer}); if (node_type == IPIN || node_type == OPIN) { return is_pin_on_tile(physical_tile, node_ptc); } else { - VTR_ASSERT(node_type == SINK || node_type == SOURCE); + VTR_ASSERT_DEBUG(node_type == SINK || node_type == SOURCE); return is_class_on_tile(physical_tile, node_ptc); } } diff --git a/vpr/src/util/vpr_utils.h b/vpr/src/util/vpr_utils.h index a4c20feb61b..17cf04e3fb2 100644 --- a/vpr/src/util/vpr_utils.h +++ b/vpr/src/util/vpr_utils.h @@ -256,9 +256,8 @@ void print_timing_stats(const std::string& name, std::vector get_all_pb_graph_node_primitives(const t_pb_graph_node* pb_graph_node); -bool is_inter_cluster_node(t_physical_tile_type_ptr physical_tile, - t_rr_type node_type, - int node_ptc); +bool is_inter_cluster_node(const RRGraphView& rr_graph_view, + RRNodeId node_id); int get_rr_node_max_ptc(const RRGraphView& rr_graph_view, RRNodeId node_id, From 363c70a21a7db6a2dfeee6857dd32fddb09199ad Mon Sep 17 00:00:00 2001 From: amin1377 Date: Wed, 27 Mar 2024 15:05:08 -0400 Subject: [PATCH 2/7] vpr: remove unused variables --- vpr/src/route/overuse_report.cpp | 2 -- vpr/src/route/router_lookahead_map_utils.cpp | 7 +------ 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/vpr/src/route/overuse_report.cpp b/vpr/src/route/overuse_report.cpp index 605eba1adb3..2e07f446314 100644 --- a/vpr/src/route/overuse_report.cpp +++ b/vpr/src/route/overuse_report.cpp @@ -219,8 +219,6 @@ static void report_overused_ipin_opin(std::ostream& os, grid_x == rr_graph.node_xhigh(node_id) && grid_y == rr_graph.node_yhigh(node_id), "Non-track RR node should not span across multiple grid blocks."); - t_physical_tile_type_ptr physical_tile = device_ctx.grid.get_physical_type({grid_x, grid_y, grid_layer}); - os << "Pin physical number = " << rr_graph.node_pin_num(node_id) << '\n'; if (is_inter_cluster_node(rr_graph, node_id)) { os << "On Tile Pin" diff --git a/vpr/src/route/router_lookahead_map_utils.cpp b/vpr/src/route/router_lookahead_map_utils.cpp index beaba76592d..798d56aa59b 100644 --- a/vpr/src/route/router_lookahead_map_utils.cpp +++ b/vpr/src/route/router_lookahead_map_utils.cpp @@ -986,9 +986,7 @@ static void dijkstra_flood_to_wires(int itile, RRNodeId next_node = rr_graph.rr_nodes().edge_sink_node(edge); // For the time being, we decide to not let the lookahead explore the node inside the clusters - t_physical_tile_type_ptr physical_type = device_ctx.grid.get_physical_type({rr_graph.node_xlow(next_node), - rr_graph.node_ylow(next_node), - rr_graph.node_layer(next_node)}); + if (!is_inter_cluster_node(rr_graph, next_node)) { // Don't go inside the clusters continue; @@ -1349,9 +1347,6 @@ static void expand_dijkstra_neighbours(util::PQ_Entry parent_entry, for (t_edge_size edge : rr_graph.edges(parent)) { RRNodeId child_node = rr_graph.edge_sink_node(parent, edge); // For the time being, we decide to not let the lookahead explore the node inside the clusters - t_physical_tile_type_ptr physical_type = device_ctx.grid.get_physical_type({rr_graph.node_xlow(child_node), - rr_graph.node_ylow(child_node), - rr_graph.node_layer(child_node)}); if (!is_inter_cluster_node(rr_graph, child_node)) { continue; From 65c4c3dac086d2e0b9292914ccdd867e735e6d23 Mon Sep 17 00:00:00 2001 From: amin1377 Date: Wed, 27 Mar 2024 15:06:14 -0400 Subject: [PATCH 3/7] make format --- .../src/read_fpga_interchange_arch.cpp | 51 ++++++------ .../src/read_fpga_interchange_arch.h | 16 ++-- vpr/src/base/read_interchange_netlist.cpp | 60 +++++++------- vpr/src/noc/noc_link.cpp | 2 +- vpr/src/noc/noc_link.h | 3 +- vpr/src/noc/noc_storage.cpp | 2 +- vpr/src/noc/noc_storage.h | 2 +- vpr/src/place/initial_noc_placement.cpp | 1 - vpr/src/place/noc_place_utils.cpp | 38 ++++----- vpr/src/place/noc_place_utils.h | 4 +- vpr/src/place/place.cpp | 12 +-- vpr/src/place/place_util.cpp | 1 - vpr/src/place/place_util.h | 82 +++++++++---------- .../route/router_lookahead_extended_map.cpp | 9 +- vpr/src/route/router_lookahead_map_utils.cpp | 2 +- vpr/test/test_noc_place_utils.cpp | 5 +- vpr/test/test_xy_routing.cpp | 12 +-- 17 files changed, 143 insertions(+), 159 deletions(-) diff --git a/libs/libarchfpga/src/read_fpga_interchange_arch.cpp b/libs/libarchfpga/src/read_fpga_interchange_arch.cpp index 38066842db5..828f935369f 100644 --- a/libs/libarchfpga/src/read_fpga_interchange_arch.cpp +++ b/libs/libarchfpga/src/read_fpga_interchange_arch.cpp @@ -5,29 +5,28 @@ #ifdef VTR_ENABLE_CAPNPROTO -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "vtr_assert.h" -#include "vtr_digest.h" -#include "vtr_log.h" -#include "vtr_memory.h" -#include "vtr_util.h" - -#include "arch_check.h" -#include "arch_error.h" -#include "arch_util.h" -#include "arch_types.h" - +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + +# include "vtr_assert.h" +# include "vtr_digest.h" +# include "vtr_log.h" +# include "vtr_memory.h" +# include "vtr_util.h" + +# include "arch_check.h" +# include "arch_error.h" +# include "arch_util.h" +# include "arch_types.h" /* * FPGA Interchange Device frontend @@ -2503,7 +2502,7 @@ struct ArchReader { } }; -#endif // VTR_ENABLE_CAPNPROTO +#endif // VTR_ENABLE_CAPNPROTO void FPGAInterchangeReadArch(const char* FPGAInterchangeDeviceFile, const bool /*timing_enabled*/, @@ -2551,12 +2550,12 @@ void FPGAInterchangeReadArch(const char* FPGAInterchangeDeviceFile, ArchReader reader(arch, device_reader, FPGAInterchangeDeviceFile, PhysicalTileTypes, LogicalBlockTypes); reader.read_arch(); -#else // VTR_ENABLE_CAPNPROTO +#else // VTR_ENABLE_CAPNPROTO // If CAPNPROTO is disabled, throw an error. (void)FPGAInterchangeDeviceFile; (void)arch; (void)PhysicalTileTypes; (void)LogicalBlockTypes; throw vtr::VtrError("Unable to read FPGA interchange if CAPNPROTO is not enabled", __FILE__, __LINE__); -#endif // VTR_ENABLE_CAPNPROTO +#endif // VTR_ENABLE_CAPNPROTO } diff --git a/libs/libarchfpga/src/read_fpga_interchange_arch.h b/libs/libarchfpga/src/read_fpga_interchange_arch.h index 3853ce93799..c859f97a002 100644 --- a/libs/libarchfpga/src/read_fpga_interchange_arch.h +++ b/libs/libarchfpga/src/read_fpga_interchange_arch.h @@ -5,14 +5,14 @@ #ifdef VTR_ENABLE_CAPNPROTO -#include "DeviceResources.capnp.h" -#include "LogicalNetlist.capnp.h" -#include "capnp/serialize.h" -#include "capnp/serialize-packed.h" -#include -#include - -#endif // VTR_ENABLE_CAPNPROTO +# include "DeviceResources.capnp.h" +# include "LogicalNetlist.capnp.h" +# include "capnp/serialize.h" +# include "capnp/serialize-packed.h" +# include +# include + +#endif // VTR_ENABLE_CAPNPROTO #ifdef __cplusplus extern "C" { diff --git a/vpr/src/base/read_interchange_netlist.cpp b/vpr/src/base/read_interchange_netlist.cpp index d584a1c6893..c29cea8326d 100644 --- a/vpr/src/base/read_interchange_netlist.cpp +++ b/vpr/src/base/read_interchange_netlist.cpp @@ -13,33 +13,33 @@ #ifdef VTR_ENABLE_CAPNPROTO -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "LogicalNetlist.capnp.h" -#include "capnp/serialize.h" -#include "capnp/serialize-packed.h" - -#include "vtr_assert.h" -#include "vtr_hash.h" -#include "vtr_util.h" -#include "vtr_log.h" -#include "vtr_logic.h" -#include "vtr_time.h" -#include "vtr_digest.h" - -#include "vpr_types.h" -#include "vpr_error.h" -#include "globals.h" -#include "arch_types.h" +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + +# include "LogicalNetlist.capnp.h" +# include "capnp/serialize.h" +# include "capnp/serialize-packed.h" + +# include "vtr_assert.h" +# include "vtr_hash.h" +# include "vtr_util.h" +# include "vtr_log.h" +# include "vtr_logic.h" +# include "vtr_time.h" +# include "vtr_digest.h" + +# include "vpr_types.h" +# include "vpr_error.h" +# include "globals.h" +# include "arch_types.h" struct NetlistReader { public: @@ -524,7 +524,7 @@ struct NetlistReader { } }; -#endif // VTR_ENABLE_CAPNPROTO +#endif // VTR_ENABLE_CAPNPROTO AtomNetlist read_interchange_netlist(const char* ic_netlist_file, t_arch& arch) { @@ -572,12 +572,12 @@ AtomNetlist read_interchange_netlist(const char* ic_netlist_file, return netlist; -#else // VTR_ENABLE_CAPNPROTO +#else // VTR_ENABLE_CAPNPROTO // If CAPNPROTO is not enabled, throw an error (void)ic_netlist_file; (void)arch; throw vtr::VtrError("Unable to read interchange netlist with CAPNPROTO disabled", __FILE__, __LINE__); -#endif // VTR_ENABLE_CAPNPROTO +#endif // VTR_ENABLE_CAPNPROTO } diff --git a/vpr/src/noc/noc_link.cpp b/vpr/src/noc/noc_link.cpp index 4407642ddae..59619418ca2 100644 --- a/vpr/src/noc/noc_link.cpp +++ b/vpr/src/noc/noc_link.cpp @@ -6,7 +6,7 @@ NocLink::NocLink(NocLinkId link_id, NocRouterId source, NocRouterId sink, double , source_router(source) , sink_router(sink) , bandwidth_usage(0.0) - , bandwidth(bw) { } + , bandwidth(bw) {} // getters NocRouterId NocLink::get_source_router(void) const { diff --git a/vpr/src/noc/noc_link.h b/vpr/src/noc/noc_link.h index 2aa5d55cd67..8f940d269c2 100644 --- a/vpr/src/noc/noc_link.h +++ b/vpr/src/noc/noc_link.h @@ -50,7 +50,7 @@ class NocLink { NocRouterId sink_router; /*!< The router which uses this link as an incoming edge*/ double bandwidth_usage; /*!< Represents the bandwidth of the data being transmitted on the link. Units in bits-per-second(bps)*/ - double bandwidth; /*!< Represents the maximum bits per second that can be transmitted over the link without causing congestion*/ + double bandwidth; /*!< Represents the maximum bits per second that can be transmitted over the link without causing congestion*/ public: NocLink(NocLinkId link_id, NocRouterId source_router, NocRouterId sink_router, double bw); @@ -135,7 +135,6 @@ class NocLink { */ void set_bandwidth(double new_bandwidth); - /** * @brief Returns the unique link ID. The ID can be used to index * vtr::vector instances. diff --git a/vpr/src/noc/noc_storage.cpp b/vpr/src/noc/noc_storage.cpp index 8438838c1f9..f4b0c1827ed 100644 --- a/vpr/src/noc/noc_storage.cpp +++ b/vpr/src/noc/noc_storage.cpp @@ -56,7 +56,7 @@ const NocLink& NocStorage::get_single_noc_link(NocLinkId id) const { return link_storage[id]; } -NocLinkId NocStorage::get_single_noc_link_id(NocRouterId src_router, NocRouterId dst_router) const { +NocLinkId NocStorage::get_single_noc_link_id(NocRouterId src_router, NocRouterId dst_router) const { NocLinkId link_id = NocLinkId::INVALID(); for (const auto& link : link_storage) { diff --git a/vpr/src/noc/noc_storage.h b/vpr/src/noc/noc_storage.h index 637d9f52126..022471c21b1 100644 --- a/vpr/src/noc/noc_storage.h +++ b/vpr/src/noc/noc_storage.h @@ -282,7 +282,7 @@ class NocStorage { * to the destination router. NocLinkId::INVALID() is such a link is not * found. */ - NocLinkId get_single_noc_link_id(NocRouterId src_router, NocRouterId dst_router) const; + NocLinkId get_single_noc_link_id(NocRouterId src_router, NocRouterId dst_router) const; /** * @brief Given a unique link identifier, get the corresponding link diff --git a/vpr/src/place/initial_noc_placement.cpp b/vpr/src/place/initial_noc_placement.cpp index 9294f3b291b..603860b3d22 100644 --- a/vpr/src/place/initial_noc_placement.cpp +++ b/vpr/src/place/initial_noc_placement.cpp @@ -187,7 +187,6 @@ static void noc_routers_anneal(const t_noc_opts& noc_opts) { const double starting_prob = 0.5; const double prob_step = starting_prob / N_MOVES; - // The checkpoint stored the placement with the lowest cost. NoCPlacementCheckpoint checkpoint; diff --git a/vpr/src/place/noc_place_utils.cpp b/vpr/src/place/noc_place_utils.cpp index a228cd1836e..8b724ff9637 100644 --- a/vpr/src/place/noc_place_utils.cpp +++ b/vpr/src/place/noc_place_utils.cpp @@ -9,7 +9,7 @@ static vtr::vector traffic_flow_costs, p static std::vector affected_traffic_flows; /* Proposed and actual congestion cost of a NoC link used for each move assessment */ -static vtr::vector link_congestion_costs, proposed_link_congestion_costs; +static vtr::vector link_congestion_costs, proposed_link_congestion_costs; /* Keeps track of NoC links whose bandwidth usage have been updated at each attempted placement move*/ static std::unordered_set affected_noc_links; @@ -57,7 +57,7 @@ void initial_noc_routing(void) { const t_noc_traffic_flow& curr_traffic_flow = noc_traffic_flows_storage.get_single_noc_traffic_flow(traffic_flow_id); // update the traffic flow route based on where the router cluster blocks are placed - std::vector& curr_traffic_flow_route = route_traffic_flow(traffic_flow_id, noc_ctx.noc_model,noc_traffic_flows_storage, *noc_ctx.noc_flows_router); + std::vector& curr_traffic_flow_route = route_traffic_flow(traffic_flow_id, noc_ctx.noc_model, noc_traffic_flows_storage, *noc_ctx.noc_flows_router); // update the links used in the found traffic flow route, links' bandwidth should be incremented since the traffic flow is routed update_traffic_flow_link_usage(curr_traffic_flow_route, noc_ctx.noc_model, 1, curr_traffic_flow.traffic_flow_bandwidth); @@ -126,7 +126,8 @@ void find_affected_noc_routers_and_update_noc_costs(const t_pl_blocks_to_be_move // calculate the new aggregate bandwidth and latency costs for the affected traffic flow proposed_traffic_flow_costs[traffic_flow_id].aggregate_bandwidth = calculate_traffic_flow_aggregate_bandwidth_cost(traffic_flow_route, curr_traffic_flow); std::tie(proposed_traffic_flow_costs[traffic_flow_id].latency, - proposed_traffic_flow_costs[traffic_flow_id].latency_overrun) = calculate_traffic_flow_latency_cost(traffic_flow_route, noc_ctx.noc_model, curr_traffic_flow); + proposed_traffic_flow_costs[traffic_flow_id].latency_overrun) + = calculate_traffic_flow_latency_cost(traffic_flow_route, noc_ctx.noc_model, curr_traffic_flow); // compute how much the aggregate bandwidth and latency costs change with this swap delta_c.aggregate_bandwidth += proposed_traffic_flow_costs[traffic_flow_id].aggregate_bandwidth - traffic_flow_costs[traffic_flow_id].aggregate_bandwidth; @@ -163,7 +164,7 @@ void commit_noc_costs() { } // Iterate over all the NoC links whose bandwidth utilization was affected by the proposed move - for(auto link_id : affected_noc_links) { + for (auto link_id : affected_noc_links) { // get the affected link const auto& link = noc_ctx.noc_model.get_single_noc_link(link_id); @@ -458,7 +459,7 @@ int check_noc_placement_costs(const t_placer_costs& costs, double error_toleranc vtr::vector temp_noc_link_storage = noc_model.get_noc_links(); // reset bandwidth utilization for all links - std::for_each(temp_noc_link_storage.begin(), temp_noc_link_storage.end(), [](NocLink& link) {link.set_bandwidth_usage(0.0); }); + std::for_each(temp_noc_link_storage.begin(), temp_noc_link_storage.end(), [](NocLink& link) { link.set_bandwidth_usage(0.0); }); // need to create a temporary noc routing algorithm std::unique_ptr temp_noc_routing_algorithm = NocRoutingAlgorithmCreator::create_routing_algorithm(noc_opts.noc_routing_algorithm); @@ -503,7 +504,7 @@ int check_noc_placement_costs(const t_placer_costs& costs, double error_toleranc } // Iterate over all NoC links and accumulate congestion cost - for(const auto& link : temp_noc_link_storage) { + for (const auto& link : temp_noc_link_storage) { cost_check.congestion += calculate_link_congestion_cost(link); } @@ -590,10 +591,7 @@ double calculate_link_congestion_cost(const NocLink& link) { } void normalize_noc_cost_weighting_factor(t_noc_opts& noc_opts) { - - double weighting_factor_sum = noc_opts.noc_latency_weighting + - noc_opts.noc_latency_constraints_weighting + - noc_opts.noc_congestion_weighting; + double weighting_factor_sum = noc_opts.noc_latency_weighting + noc_opts.noc_latency_constraints_weighting + noc_opts.noc_congestion_weighting; VTR_ASSERT(weighting_factor_sum <= 1.0 && weighting_factor_sum >= 0.0); @@ -617,11 +615,7 @@ double calculate_noc_cost(const NocCostTerms& cost_terms, * is computed. Weighting factors determine the contribution of each * normalized term to the sum. */ - cost = noc_opts.noc_placement_weighting * ( - cost_terms.aggregate_bandwidth * norm_factors.aggregate_bandwidth * noc_opts.noc_aggregate_bandwidth_weighting + - cost_terms.latency * norm_factors.latency * noc_opts.noc_latency_weighting + - cost_terms.latency_overrun * norm_factors.latency_overrun * noc_opts.noc_latency_constraints_weighting + - cost_terms.congestion * norm_factors.congestion * noc_opts.noc_congestion_weighting); + cost = noc_opts.noc_placement_weighting * (cost_terms.aggregate_bandwidth * norm_factors.aggregate_bandwidth * noc_opts.noc_aggregate_bandwidth_weighting + cost_terms.latency * norm_factors.latency * noc_opts.noc_latency_weighting + cost_terms.latency_overrun * norm_factors.latency_overrun * noc_opts.noc_latency_constraints_weighting + cost_terms.congestion * norm_factors.congestion * noc_opts.noc_congestion_weighting); return cost; } @@ -668,11 +662,11 @@ int get_number_of_congested_noc_links(void) { // Iterate over all NoC links and count the congested ones for (const auto& link : noc_links) { - double congested_bw_ratio = link.get_congested_bandwidth_ratio(); + double congested_bw_ratio = link.get_congested_bandwidth_ratio(); - if (congested_bw_ratio > MIN_EXPECTED_NOC_CONGESTION_COST) { + if (congested_bw_ratio > MIN_EXPECTED_NOC_CONGESTION_COST) { num_congested_links++; - } + } } return num_congested_links; @@ -686,8 +680,8 @@ double get_total_congestion_bandwidth_ratio(void) { // Iterate over all NoC links and count the congested ones for (const auto& link : noc_links) { - double congested_bw_ratio = link.get_congested_bandwidth_ratio(); - accum_congestion_ratio += congested_bw_ratio; + double congested_bw_ratio = link.get_congested_bandwidth_ratio(); + accum_congestion_ratio += congested_bw_ratio; } return accum_congestion_ratio; @@ -701,8 +695,8 @@ std::vector get_top_n_congested_links(int n) { // stable_sort is used to make sure the order is the same across different machines/compilers // Note that when the vector is sorted, indexing it with NocLinkId does return the corresponding link std::stable_sort(noc_links.begin(), noc_links.end(), [](const NocLink& l1, const NocLink& l2) { - return l1.get_congested_bandwidth_ratio() > l2.get_congested_bandwidth_ratio(); - }); + return l1.get_congested_bandwidth_ratio() > l2.get_congested_bandwidth_ratio(); + }); int pick_n = std::min((int)noc_links.size(), n); diff --git a/vpr/src/place/noc_place_utils.h b/vpr/src/place/noc_place_utils.h index 24926c48925..83dcddc9156 100644 --- a/vpr/src/place/noc_place_utils.h +++ b/vpr/src/place/noc_place_utils.h @@ -210,7 +210,8 @@ void update_traffic_flow_link_usage(const std::vector& traffic_flow_r */ void re_route_associated_traffic_flows(ClusterBlockId moved_router_block_id, NocTrafficFlows& noc_traffic_flows_storage, - NocStorage& noc_model, NocRouting& noc_flows_router, + NocStorage& noc_model, + NocRouting& noc_flows_router, std::unordered_set& updated_traffic_flows); /** @@ -462,7 +463,6 @@ double get_total_congestion_bandwidth_ratio(void); */ std::vector get_top_n_congested_links(int n); - /** * @brief Goes through all NoC links and determines whether they * are congested or not. Then finds n links that are most congested. diff --git a/vpr/src/place/place.cpp b/vpr/src/place/place.cpp index 2e30d2f3c43..c7a98d9bc92 100644 --- a/vpr/src/place/place.cpp +++ b/vpr/src/place/place.cpp @@ -826,7 +826,8 @@ void try_place(const Netlist<>& net_list, VTR_LOG("Initial placement cost: %g bb_cost: %g td_cost: %g\n", costs.cost, costs.bb_cost, costs.timing_cost); if (noc_opts.noc) { - VTR_LOG("NoC Placement Costs. " + VTR_LOG( + "NoC Placement Costs. " "cost: %g, " "aggregate_bandwidth_cost: %g, " "latency_cost: %g, " @@ -893,9 +894,6 @@ void try_place(const Netlist<>& net_list, costs.noc_cost_terms.congestion, get_total_congestion_bandwidth_ratio(), get_number_of_congested_noc_links()); - - - } //Draw the initial placement update_screen(ScreenUpdatePriority::MAJOR, msg, PLACEMENT, timing_info); @@ -1224,7 +1222,8 @@ void try_place(const Netlist<>& net_list, get_total_congestion_bandwidth_ratio(), get_number_of_congested_noc_links()); - VTR_LOG("\nNoC Placement Costs. " + VTR_LOG( + "\nNoC Placement Costs. " "cost: %g, " "aggregate_bandwidth_cost: %g, " "latency_cost: %g, " @@ -1481,7 +1480,6 @@ static void recompute_costs_from_scratch(const t_placer_opts& placer_opts, "noc_congestion_cost"); } costs->noc_cost_terms.congestion = new_noc_cost.congestion; - } } @@ -1818,7 +1816,6 @@ static e_move_result try_swap(const t_annealing_state* state, delta_c = bb_delta_c * costs->bb_cost_norm; } - NocCostTerms noc_delta_c; // change in NoC cost /* Update the NoC datastructure and costs*/ if (noc_opts.noc) { @@ -4246,7 +4243,6 @@ static void print_place_status_header(bool noc_enabled) { VTR_LOG( "---- ------ ------- ------- ---------- ---------- ------- ---------- -------- ------- ------- ------ -------- --------- ------ -------- -------- --------- ---------\n"); } - } static void print_place_status(const t_annealing_state& state, diff --git a/vpr/src/place/place_util.cpp b/vpr/src/place/place_util.cpp index 6c7f506ee3e..52b9fdeb3d1 100644 --- a/vpr/src/place/place_util.cpp +++ b/vpr/src/place/place_util.cpp @@ -493,4 +493,3 @@ NocCostTerms& NocCostTerms::operator+=(const NocCostTerms& noc_delta_cost) { return *this; } - diff --git a/vpr/src/place/place_util.h b/vpr/src/place/place_util.h index 12bd6ce745b..d65d460446c 100644 --- a/vpr/src/place/place_util.h +++ b/vpr/src/place/place_util.h @@ -98,18 +98,18 @@ class t_placer_costs { public: //Mutator /** - * @brief Mutator: updates the norm factors in the outer loop iteration. - * - * At each temperature change we update these values to be used - * for normalizing the trade-off between timing and wirelength (bb) - */ + * @brief Mutator: updates the norm factors in the outer loop iteration. + * + * At each temperature change we update these values to be used + * for normalizing the trade-off between timing and wirelength (bb) + */ void update_norm_factors(); /** - * @brief Accumulates NoC cost difference terms - * - * @param noc_delta_cost Cost difference for NoC-related costs terms - */ + * @brief Accumulates NoC cost difference terms + * + * @param noc_delta_cost Cost difference for NoC-related costs terms + */ t_placer_costs& operator+=(const NocCostTerms& noc_delta_cost); private: @@ -193,15 +193,15 @@ class t_annealing_state { public: //Mutator /** - * @brief Update the annealing state according to the annealing schedule selected. - * - * USER_SCHED: A manual fixed schedule with fixed alpha and exit criteria. - * AUTO_SCHED: A more sophisticated schedule where alpha varies based on success ratio. - * DUSTY_SCHED: This schedule jumps backward and slows down in response to success ratio. - * See doc/src/vpr/dusty_sa.rst for more details. - * - * @return True->continues the annealing. False->exits the annealing. - */ + * @brief Update the annealing state according to the annealing schedule selected. + * + * USER_SCHED: A manual fixed schedule with fixed alpha and exit criteria. + * AUTO_SCHED: A more sophisticated schedule where alpha varies based on success ratio. + * DUSTY_SCHED: This schedule jumps backward and slows down in response to success ratio. + * See doc/src/vpr/dusty_sa.rst for more details. + * + * @return True->continues the annealing. False->exits the annealing. + */ bool outer_loop_update(float success_rate, const t_placer_costs& costs, const t_placer_opts& placer_opts, @@ -209,35 +209,35 @@ class t_annealing_state { private: //Mutator /** - * @brief Update the range limiter to keep acceptance prob. near 0.44. - * - * Use a floating point rlim to allow gradual transitions at low temps. - * The range is bounded by 1 (FINAL_RLIM) and the grid size (UPPER_RLIM). - */ + * @brief Update the range limiter to keep acceptance prob. near 0.44. + * + * Use a floating point rlim to allow gradual transitions at low temps. + * The range is bounded by 1 (FINAL_RLIM) and the grid size (UPPER_RLIM). + */ inline void update_rlim(float success_rate); /** - * @brief Update the criticality exponent. - * - * When rlim shrinks towards the FINAL_RLIM value (indicating - * that we are fine-tuning a more optimized placement), we can - * focus more on a smaller number of critical connections. - * To achieve this, we make the crit_exponent sharper, so that - * critical connections would become more critical than before. - * - * We calculate how close rlim is to its final value comparing - * to its initial value. Then, we apply the same scaling factor - * on the crit_exponent so that it lands on the suitable value - * between td_place_exp_first and td_place_exp_last. The scaling - * factor is calculated and applied linearly. - */ + * @brief Update the criticality exponent. + * + * When rlim shrinks towards the FINAL_RLIM value (indicating + * that we are fine-tuning a more optimized placement), we can + * focus more on a smaller number of critical connections. + * To achieve this, we make the crit_exponent sharper, so that + * critical connections would become more critical than before. + * + * We calculate how close rlim is to its final value comparing + * to its initial value. Then, we apply the same scaling factor + * on the crit_exponent so that it lands on the suitable value + * between td_place_exp_first and td_place_exp_last. The scaling + * factor is calculated and applied linearly. + */ inline void update_crit_exponent(const t_placer_opts& placer_opts); /** - * @brief Update the move limit based on the success rate. - * - * The value is bounded between 1 and move_lim_max. - */ + * @brief Update the move limit based on the success rate. + * + * The value is bounded between 1 and move_lim_max. + */ inline void update_move_lim(float success_target, float success_rate); }; diff --git a/vpr/src/route/router_lookahead_extended_map.cpp b/vpr/src/route/router_lookahead_extended_map.cpp index 6db4c4ff7bc..d72f5471130 100644 --- a/vpr/src/route/router_lookahead_extended_map.cpp +++ b/vpr/src/route/router_lookahead_extended_map.cpp @@ -611,18 +611,17 @@ void ExtendedMapLookahead::read(const std::string& file) { this->src_opin_delays = util::compute_router_src_opin_lookahead(is_flat_); this->chan_ipins_delays = util::compute_router_chan_ipin_lookahead(); -#else // VTR_ENABLE_CAPNPROTO +#else // VTR_ENABLE_CAPNPROTO (void)file; VPR_THROW(VPR_ERROR_ROUTE, "MapLookahead::read not implemented"); -#endif // VTR_ENABLE_CAPNPROTO +#endif // VTR_ENABLE_CAPNPROTO } void ExtendedMapLookahead::write(const std::string& file) const { #ifndef VTR_ENABLE_CAPNPROTO cost_map_.write(file); -#else // VTR_ENABLE_CAPNPROTO +#else // VTR_ENABLE_CAPNPROTO (void)file; VPR_THROW(VPR_ERROR_ROUTE, "MapLookahead::write not implemented"); -#endif // VTR_ENABLE_CAPNPROTO +#endif // VTR_ENABLE_CAPNPROTO } - diff --git a/vpr/src/route/router_lookahead_map_utils.cpp b/vpr/src/route/router_lookahead_map_utils.cpp index 798d56aa59b..64b6356bc3b 100644 --- a/vpr/src/route/router_lookahead_map_utils.cpp +++ b/vpr/src/route/router_lookahead_map_utils.cpp @@ -1114,7 +1114,7 @@ static int get_tile_src_opin_max_ptc(int itile) { int max_ptc = 0; // Output pin - for (const auto& class_inf: physical_tile.class_inf) { + for (const auto& class_inf : physical_tile.class_inf) { if (class_inf.type != e_pin_type::DRIVER) { continue; } diff --git a/vpr/test/test_noc_place_utils.cpp b/vpr/test/test_noc_place_utils.cpp index 8e53ec68ed9..e461c319e0a 100644 --- a/vpr/test/test_noc_place_utils.cpp +++ b/vpr/test/test_noc_place_utils.cpp @@ -1182,7 +1182,7 @@ TEST_CASE("test_find_affected_noc_routers_and_update_noc_costs, test_commit_noc_ // now check whether the expected noc costs that we manually calculated above match the noc costs found through the test function (we allow for a tolerance of difference) REQUIRE(vtr::isclose(golden_total_noc_aggr_bandwidth_cost, test_noc_costs.aggregate_bandwidth)); REQUIRE(vtr::isclose(golden_total_noc_latency_cost, test_noc_costs.latency)); - std::cout << golden_total_noc_latency_overrun_cost << " " << test_noc_costs.latency_overrun << std::endl; + std::cout << golden_total_noc_latency_overrun_cost << " " << test_noc_costs.latency_overrun << std::endl; REQUIRE(vtr::isclose(golden_total_noc_latency_overrun_cost, test_noc_costs.latency_overrun)); REQUIRE(vtr::isclose(golden_total_noc_congestion_cost, test_noc_costs.congestion)); @@ -1614,7 +1614,7 @@ TEST_CASE("test_revert_noc_traffic_flow_routes", "[noc_place_utils]") { } // re-route the traffic flow - noc_ctx.noc_flows_router->route_flow(router_where_cluster_is_placed[curr_traffic_flow.source_router_cluster_id],router_where_cluster_is_placed[curr_traffic_flow.sink_router_cluster_id], golden_traffic_flow_routes[traffic_flow], noc_ctx.noc_model); + noc_ctx.noc_flows_router->route_flow(router_where_cluster_is_placed[curr_traffic_flow.source_router_cluster_id], router_where_cluster_is_placed[curr_traffic_flow.sink_router_cluster_id], golden_traffic_flow_routes[traffic_flow], noc_ctx.noc_model); // go through the current traffic flow and reduce the bandwidths of the links (we only update this in the NoC, since these changes should be rectified by the test function) // This shouldn't be updated in the golden bandwidths since we are imitating a swap of blocks and not having a real swap of blocks @@ -1642,7 +1642,6 @@ TEST_CASE("test_revert_noc_traffic_flow_routes", "[noc_place_utils]") { const NocLink& current_link = noc_ctx.noc_model.get_single_noc_link(current_link_id); REQUIRE(golden_link_bandwidths[current_link_id] == current_link.get_bandwidth_usage()); - } for (int traffic_flow_number = 0; traffic_flow_number < NUM_OF_TRAFFIC_FLOWS_NOC_PLACE_UTILS_TEST; traffic_flow_number++) { diff --git a/vpr/test/test_xy_routing.cpp b/vpr/test/test_xy_routing.cpp index 49b58662ca2..09fbe80e3bd 100644 --- a/vpr/test/test_xy_routing.cpp +++ b/vpr/test/test_xy_routing.cpp @@ -109,7 +109,7 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") { std::vector golden_path; for (int current_router = 7; current_router != 4; current_router--) { - NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_router), NocRouterId(current_router - 1)); + NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_router), NocRouterId(current_router - 1)); const auto& link = noc_model.get_single_noc_link(link_id); golden_path.push_back(link); } @@ -133,7 +133,7 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") { std::vector golden_path; for (int current_row = 0; current_row < 3; current_row++) { - NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_row * 4 + 2), NocRouterId((current_row + 1) * 4 + 2)); + NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_row * 4 + 2), NocRouterId((current_row + 1) * 4 + 2)); const auto& link = noc_model.get_single_noc_link(link_id); golden_path.push_back(link); } @@ -158,14 +158,14 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") { // generate the horizontal path first for (int current_router = 3; current_router != 0; current_router--) { - NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_router), NocRouterId(current_router - 1)); + NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_router), NocRouterId(current_router - 1)); const auto& link = noc_model.get_single_noc_link(link_id); golden_path.push_back(link); } // generate the vertical path next for (int current_row = 0; current_row < 3; current_row++) { - NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_row * 4), NocRouterId((current_row + 1) * 4)); + NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_row * 4), NocRouterId((current_row + 1) * 4)); const auto& link = noc_model.get_single_noc_link(link_id); golden_path.push_back(link); } @@ -193,14 +193,14 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") { // generate the horizontal path first for (int current_router = 12; current_router != 15; current_router++) { - NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_router), NocRouterId(current_router + 1)); + NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_router), NocRouterId(current_router + 1)); const auto& link = noc_model.get_single_noc_link(link_id); golden_path.push_back(link); } // generate the vertical path next for (int current_row = 3; current_row > 0; current_row--) { - NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_row * 4 + 3), NocRouterId((current_row - 1) * 4 + 3)); + NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_row * 4 + 3), NocRouterId((current_row - 1) * 4 + 3)); const auto& link = noc_model.get_single_noc_link(link_id); golden_path.push_back(link); } From 86df9370328ca6a4f227dbac88babec9addedff6 Mon Sep 17 00:00:00 2001 From: amin1377 Date: Wed, 27 Mar 2024 16:35:58 -0400 Subject: [PATCH 4/7] vpr: graphic: edge is not valid for drawing if one of its endpoints is an intra-cluster pin --- vpr/src/draw/draw_basic.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vpr/src/draw/draw_basic.cpp b/vpr/src/draw/draw_basic.cpp index 8cd2e9b414d..707eea41d1c 100644 --- a/vpr/src/draw/draw_basic.cpp +++ b/vpr/src/draw/draw_basic.cpp @@ -773,6 +773,10 @@ bool is_edge_valid_to_draw(RRNodeId current_node, RRNodeId prev_node) { int current_node_layer = rr_graph.node_layer(current_node); int prev_node_layer = rr_graph.node_layer(prev_node); + if (!(is_inter_cluster_node(rr_graph, current_node)) || !(is_inter_cluster_node(rr_graph, prev_node))) { + return false; + } + if (current_node_layer != prev_node_layer) { if (draw_state->cross_layer_display.visible && draw_state->draw_layer_display[current_node_layer].visible && draw_state->draw_layer_display[prev_node_layer].visible) { return true; //if both layers are enabled and cross layer connections are enabled From ae854f53030d0fd70d740a240c40da69c7f143b5 Mon Sep 17 00:00:00 2001 From: amin1377 Date: Wed, 27 Mar 2024 16:37:27 -0400 Subject: [PATCH 5/7] vpr: graphics: don't draw pin or sink/source if they are inside a cluster --- vpr/src/draw/draw_rr.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vpr/src/draw/draw_rr.cpp b/vpr/src/draw/draw_rr.cpp index fa04c388cfe..fcbab699029 100644 --- a/vpr/src/draw/draw_rr.cpp +++ b/vpr/src/draw/draw_rr.cpp @@ -549,6 +549,9 @@ void draw_rr_pin(RRNodeId inode, const ezgl::color& color, ezgl::renderer* g) { char str[vtr::bufsize]; auto& device_ctx = g_vpr_ctx.device(); const auto& rr_graph = device_ctx.rr_graph; + if (!is_inter_cluster_node(rr_graph, inode)) { + return; + } int ipin = rr_graph.node_pin_num(RRNodeId(inode)); @@ -581,6 +584,9 @@ void draw_rr_src_sink(RRNodeId inode, ezgl::color color, ezgl::renderer* g) { auto& device_ctx = g_vpr_ctx.device(); const auto& rr_graph = device_ctx.rr_graph; + if (!is_inter_cluster_node(rr_graph, inode)) { + return; + } int transparency_factor = get_rr_node_transparency(inode); From 269790e1388801e9cb090c2661050d7fa6d48eef Mon Sep 17 00:00:00 2001 From: amin1377 Date: Wed, 27 Mar 2024 16:49:45 -0400 Subject: [PATCH 6/7] vpr: graphic: do not draw a partial route if it is inside a cluster --- vpr/src/draw/draw_basic.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vpr/src/draw/draw_basic.cpp b/vpr/src/draw/draw_basic.cpp index 707eea41d1c..07b54793ee8 100644 --- a/vpr/src/draw/draw_basic.cpp +++ b/vpr/src/draw/draw_basic.cpp @@ -660,6 +660,10 @@ void draw_partial_route(const std::vector& rr_nodes_to_draw, ezgl::ren RRNodeId prev_node = rr_nodes_to_draw[i - 1]; auto prev_type = rr_graph.node_type(RRNodeId(prev_node)); + if (!is_inter_cluster_node(rr_graph, prev_node) || !is_inter_cluster_node(rr_graph, inode)) { + continue; + } + auto iedge = find_edge(prev_node, inode); auto switch_type = rr_graph.edge_switch(RRNodeId(prev_node), iedge); From b207bb9011fee4ed55c682c16f935c0106c11408 Mon Sep 17 00:00:00 2001 From: amin1377 Date: Wed, 22 May 2024 18:05:57 -0400 Subject: [PATCH 7/7] [vpr][router] fix the bug when is_inter_cluster_node is called --- vpr/src/route/connection_router.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vpr/src/route/connection_router.cpp b/vpr/src/route/connection_router.cpp index 956a4864854..8277f6b20cd 100644 --- a/vpr/src/route/connection_router.cpp +++ b/vpr/src/route/connection_router.cpp @@ -1133,9 +1133,8 @@ static inline void update_router_stats(RouterStats* router_stats, rr_graph->node_ylow(rr_node_id), rr_graph->node_layer(rr_node_id)}); - if (is_inter_cluster_node(physical_type, - node_type, - rr_graph->node_ptc_num(rr_node_id))) { + if (is_inter_cluster_node(*rr_graph, + rr_node_id)) { if (is_push) { router_stats->inter_cluster_node_pushes++; router_stats->inter_cluster_node_type_cnt_pushes[node_type]++;