From ff48e6bd1cec528d31d3e99ada6f78b3ece38fa8 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Fri, 7 Feb 2025 12:49:42 -0500 Subject: [PATCH 01/28] added load_rr_edge_overrides function --- libs/librrgraph/src/base/rr_graph_builder.h | 8 +- libs/librrgraph/src/base/rr_graph_storage.cpp | 13 +- libs/librrgraph/src/base/rr_graph_storage.h | 17 ++- libs/librrgraph/src/base/rr_graph_view.h | 4 + libs/librrgraph/src/io/rr_graph_reader.cpp | 138 ++++++++++++++++++ libs/librrgraph/src/io/rr_graph_reader.h | 4 + vpr/src/route/rr_graph.cpp | 1 - 7 files changed, 170 insertions(+), 15 deletions(-) diff --git a/libs/librrgraph/src/base/rr_graph_builder.h b/libs/librrgraph/src/base/rr_graph_builder.h index cc367395bc6..68159e95bbf 100644 --- a/libs/librrgraph/src/base/rr_graph_builder.h +++ b/libs/librrgraph/src/base/rr_graph_builder.h @@ -239,7 +239,7 @@ class RRGraphBuilder { /** @brief Reserve the lists of edges to be memory efficient. * This function is mainly used to reserve memory space inside RRGraph, - * when adding a large number of edges in order to avoid memory fragements */ + * when adding a large number of edges in order to avoid memory fragments */ inline void reserve_edges(size_t num_edges) { node_storage_.reserve_edges(num_edges); } @@ -264,6 +264,10 @@ class RRGraphBuilder { node_storage_.alloc_and_load_edges(rr_edges_to_create); } + inline void override_edge_switch(RREdgeId edge_id, RRSwitchId switch_id) { + node_storage_.override_edge_switch(edge_id, switch_id); + } + /** @brief set_node_cost_index gets the index of cost data in the list of cost_indexed_data data structure * It contains the routing cost for different nodes in the RRGraph * when used in evaluate different routing paths @@ -304,7 +308,7 @@ class RRGraphBuilder { /** @brief Reserve the lists of nodes, edges, switches etc. to be memory efficient. * This function is mainly used to reserve memory space inside RRGraph, * when adding a large number of nodes/edge/switches/segments, - * in order to avoid memory fragements */ + * in order to avoid memory fragments */ inline void reserve_nodes(size_t size) { node_storage_.reserve(size); } diff --git a/libs/librrgraph/src/base/rr_graph_storage.cpp b/libs/librrgraph/src/base/rr_graph_storage.cpp index 8d8dcd5ac20..cb7ad810dd8 100644 --- a/libs/librrgraph/src/base/rr_graph_storage.cpp +++ b/libs/librrgraph/src/base/rr_graph_storage.cpp @@ -536,10 +536,9 @@ void t_rr_graph_storage::partition_edges(const vtr::vector& rr_switches) const { VTR_ASSERT(!node_first_edge_.empty() && remapped_edges_); diff --git a/libs/librrgraph/src/base/rr_graph_storage.h b/libs/librrgraph/src/base/rr_graph_storage.h index 82c8f0b2326..ef0a17cb17c 100644 --- a/libs/librrgraph/src/base/rr_graph_storage.h +++ b/libs/librrgraph/src/base/rr_graph_storage.h @@ -448,7 +448,7 @@ class t_rr_graph_storage { * * The following methods implement an interface that appears to be * equivalent to the interface exposed by std::vector. - * This was done for backwards compability. See t_rr_node for more details. + * This was done for backwards compatibility. See t_rr_node for more details. * * Proxy methods: * @@ -483,8 +483,8 @@ class t_rr_graph_storage { ***************************/ /** @brief - * Makes room in storage for RRNodeId in amoritized O(1) fashion. - * This results in an allocation pattern similiar to what would happen + * Makes room in storage for RRNodeId in amortized O(1) fashion. + * This results in an allocation pattern similar to what would happen * if push_back(x) / emplace_back() were used if underlying storage * was not pre-allocated. */ @@ -616,8 +616,8 @@ class t_rr_graph_storage { void set_node_direction(RRNodeId, Direction new_direction); /** @brief - * Add a side to the node abbributes - * This is the function to use when you just add a new side WITHOUT reseting side attributes + * Add a side to the node attributes + * This is the function to use when you just add a new side WITHOUT resetting side attributes */ void add_node_side(RRNodeId, e_side new_side); @@ -707,9 +707,8 @@ class t_rr_graph_storage { * * init_fan_in does not need to be invoked before this method. */ - size_t count_rr_switches( - const std::vector& arch_switch_inf, - t_arch_switch_fanin& arch_switch_fanins); + size_t count_rr_switches(const std::vector& arch_switch_inf, + t_arch_switch_fanin& arch_switch_fanins); /** @brief Maps arch_switch_inf indicies to rr_switch_inf indicies. * @@ -731,6 +730,8 @@ class t_rr_graph_storage { */ void partition_edges(const vtr::vector& rr_switches); + void override_edge_switch(RREdgeId edge_id, RRSwitchId switch_id); + /** @brief Validate that edge data is partitioned correctly.*/ bool validate_node(RRNodeId node_id, const vtr::vector& rr_switches) const; bool validate(const vtr::vector& rr_switches) const; diff --git a/libs/librrgraph/src/base/rr_graph_view.h b/libs/librrgraph/src/base/rr_graph_view.h index d0fffc04307..bb68228aee1 100644 --- a/libs/librrgraph/src/base/rr_graph_view.h +++ b/libs/librrgraph/src/base/rr_graph_view.h @@ -413,6 +413,10 @@ class RRGraphView { return node_storage_.edge_switch(id, iedge); } + inline short edge_switch(RREdgeId id) const { + return node_storage_.edge_switch(id); + } + /** @brief Return the source node for the specified edge. */ inline RRNodeId edge_src_node(const RREdgeId edge_id) const { diff --git a/libs/librrgraph/src/io/rr_graph_reader.cpp b/libs/librrgraph/src/io/rr_graph_reader.cpp index ec574080dba..f5715615c0d 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.cpp +++ b/libs/librrgraph/src/io/rr_graph_reader.cpp @@ -19,6 +19,7 @@ #include "rr_graph_uxsdcxx.h" #include +#include #include "vtr_time.h" #include "pugixml.hpp" @@ -115,3 +116,140 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, read_rr_graph_name); } } + +RREdgeId process_line(const std::string& line, + std::vector& overridden_values, + const RRGraphView& rr_graph) { + std::istringstream iss(line); + char ch; + RREdgeId edge_id; + + if (std::isdigit(line[0])) { + // Line starts with an integer + int first; + iss >> first; + edge_id = (RREdgeId)first; + } else if (line[0] == '(') { + // Line starts with (first, second) + int first, second; + iss >> ch >> first >> ch >> second >> ch; + + RRNodeId src_node_id = RRNodeId(first); + RRNodeId sink_node_id = RRNodeId(second); + + for (RREdgeId outgoing_edge_id : rr_graph.rr_nodes().edge_range(src_node_id)) { + if (rr_graph.rr_nodes().edge_sink_node(outgoing_edge_id) == sink_node_id) { + edge_id = outgoing_edge_id; + break; + } + } + + if (!edge_id.is_valid()) { + VTR_LOG_ERROR("Couldn't find an edge connecting node %d to node %d\n", src_node_id, sink_node_id); + } + + } else { + VTR_LOG_ERROR("Invalid line format: %s\n", line.c_str()); + } + + float value; + while (iss >> value) { + overridden_values.push_back(value); + } + + return edge_id; +} + +struct t_rr_switch_inf_hash { + std::size_t operator()(const t_rr_switch_inf& s) const { + std::size_t seed = 0; + + // Helper function for hashing + auto hash_combine = [&seed](auto&& val) { + seed ^= std::hash>{}(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2); + }; + + // Combine all relevant fields + hash_combine(s.R); + hash_combine(s.Cin); + hash_combine(s.Cout); + hash_combine(s.Cinternal); + hash_combine(s.Tdel); + hash_combine(s.mux_trans_size); + hash_combine(s.buf_size); + hash_combine(static_cast(s.power_buffer_type)); + hash_combine(s.power_buffer_size); + hash_combine(s.intra_tile); + hash_combine(static_cast(s.type())); + + return seed; + } +}; + +struct t_rr_switch_inf_equal { + bool operator()(const t_rr_switch_inf& lhs, const t_rr_switch_inf& rhs) const { + return lhs.R == rhs.R && + lhs.Cin == rhs.Cin && + lhs.Cout == rhs.Cout && + lhs.Cinternal == rhs.Cinternal && + lhs.Tdel == rhs.Tdel && + lhs.mux_trans_size == rhs.mux_trans_size && + lhs.buf_size == rhs.buf_size && + lhs.power_buffer_type == rhs.power_buffer_type && + lhs.power_buffer_size == rhs.power_buffer_size && + lhs.intra_tile == rhs.intra_tile && + lhs.type() == rhs.type(); + } +}; + +void load_rr_edge_overrides(std::string_view filename, + RRGraphBuilder& rr_graph_builder, + RRGraphView& rr_graph) { + std::ifstream file(filename.data()); + if (!file) { + VTR_LOG_ERROR("Failed to open the RR edge override file: %s\n", filename.data()); + } + + std::unordered_map unique_switch_info; + for (const auto& [rr_sw_idx, sw] : rr_graph.rr_switch().pairs()) { + unique_switch_info.insert({sw, rr_sw_idx}); + } + + std::string line; + std::vector overridden_values; + bool firstLine = true; + + while (std::getline(file, line)) { + if (firstLine) { + if (line.empty() || line[0] != '#') { + VTR_LOG_ERROR("Error: First line must start with #\n"); + } + firstLine = false; + continue; // Ignore first line + } + + + if (!line.empty()) { + overridden_values.clear(); + RREdgeId edge_id = process_line(line, overridden_values, rr_graph); + RRSwitchId curr_switch_id = (RRSwitchId)rr_graph.edge_switch(edge_id); + t_rr_switch_inf switch_override_info = rr_graph.rr_switch_inf(curr_switch_id); + + switch_override_info.Tdel = (overridden_values.size() >= 1) ? overridden_values[0] : switch_override_info.Tdel; + switch_override_info.R = (overridden_values.size() >= 2) ? overridden_values[1] : switch_override_info.R; + switch_override_info.Cin = (overridden_values.size() >= 3) ? overridden_values[2] : switch_override_info.Cin; + switch_override_info.Cout = (overridden_values.size() >= 4) ? overridden_values[3] : switch_override_info.Cout; + switch_override_info.Cinternal = (overridden_values.size() >= 5) ? overridden_values[4] : switch_override_info.Cinternal; + + RRSwitchId new_switch_id; + auto it = unique_switch_info.find(switch_override_info); + if (it == unique_switch_info.end()) { + new_switch_id = rr_graph_builder.add_rr_switch(switch_override_info); + unique_switch_info.insert({switch_override_info, new_switch_id}); + } else { + new_switch_id = it->second; + } + rr_graph_builder.override_edge_switch(edge_id, new_switch_id); + } + } +} \ No newline at end of file diff --git a/libs/librrgraph/src/io/rr_graph_reader.h b/libs/librrgraph/src/io/rr_graph_reader.h index 8549b712bdf..245f23aad8e 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.h +++ b/libs/librrgraph/src/io/rr_graph_reader.h @@ -35,4 +35,8 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, const char* echo_file_name, bool is_flat); +void load_rr_edge_overrides(std::string_view filename, + RRGraphBuilder& rr_graph_builder, + RRGraphView& rr_graph); + #endif /* RR_GRAPH_READER_H */ diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index 0b2073555de..dfea2d9b218 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -21,7 +21,6 @@ #include "rr_graph_utils.h" #include "rr_graph.h" #include "rr_graph_area.h" -#include "rr_graph_utils.h" #include "rr_graph2.h" #include "rr_graph_sbox.h" #include "rr_graph_timing_params.h" From 5722c79c527141e399502bd80e9ab3c70b87ae86 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Fri, 7 Feb 2025 13:33:49 -0500 Subject: [PATCH 02/28] add -read_rr_edge_override command line option --- libs/librrgraph/src/io/rr_graph_reader.cpp | 2 +- libs/librrgraph/src/io/rr_graph_reader.h | 2 +- vpr/src/base/SetupVPR.cpp | 1 + vpr/src/base/read_options.cpp | 5 +++++ vpr/src/base/read_options.h | 1 + vpr/src/base/vpr_context.h | 1 + vpr/src/base/vpr_types.h | 1 + vpr/src/route/rr_graph.cpp | 7 +++++++ 8 files changed, 18 insertions(+), 2 deletions(-) diff --git a/libs/librrgraph/src/io/rr_graph_reader.cpp b/libs/librrgraph/src/io/rr_graph_reader.cpp index f5715615c0d..eca56b72769 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.cpp +++ b/libs/librrgraph/src/io/rr_graph_reader.cpp @@ -204,7 +204,7 @@ struct t_rr_switch_inf_equal { void load_rr_edge_overrides(std::string_view filename, RRGraphBuilder& rr_graph_builder, - RRGraphView& rr_graph) { + const RRGraphView& rr_graph) { std::ifstream file(filename.data()); if (!file) { VTR_LOG_ERROR("Failed to open the RR edge override file: %s\n", filename.data()); diff --git a/libs/librrgraph/src/io/rr_graph_reader.h b/libs/librrgraph/src/io/rr_graph_reader.h index 245f23aad8e..b8ac7853798 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.h +++ b/libs/librrgraph/src/io/rr_graph_reader.h @@ -37,6 +37,6 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, void load_rr_edge_overrides(std::string_view filename, RRGraphBuilder& rr_graph_builder, - RRGraphView& rr_graph); + const RRGraphView& rr_graph); #endif /* RR_GRAPH_READER_H */ diff --git a/vpr/src/base/SetupVPR.cpp b/vpr/src/base/SetupVPR.cpp index 9c0fb69ba98..a970072be2e 100644 --- a/vpr/src/base/SetupVPR.cpp +++ b/vpr/src/base/SetupVPR.cpp @@ -232,6 +232,7 @@ void SetupVPR(const t_options* options, SetupPackerOpts(*options, packerOpts); routingArch->write_rr_graph_filename = options->write_rr_graph_file; routingArch->read_rr_graph_filename = options->read_rr_graph_file; + routingArch->read_rr_edge_override_filename = options->read_rr_edge_override_file; for (auto has_global_routing : arch->layer_global_routing) { device_ctx.inter_cluster_prog_routing_resources.emplace_back(has_global_routing); diff --git a/vpr/src/base/read_options.cpp b/vpr/src/base/read_options.cpp index 9e2c7718595..ef5c78cdb4d 100644 --- a/vpr/src/base/read_options.cpp +++ b/vpr/src/base/read_options.cpp @@ -1623,6 +1623,11 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio .metavar("RR_GRAPH_FILE") .show_in(argparse::ShowIn::HELP_ONLY); + file_grp.add_argument(args.read_rr_edge_override_file, "--read_rr_edge_override") + .help( + "to be written!") + .show_in(argparse::ShowIn::HELP_ONLY); + file_grp.add_argument(args.write_rr_graph_file, "--write_rr_graph") .help("Writes the routing resource graph to the specified file") .metavar("RR_GRAPH_FILE") diff --git a/vpr/src/base/read_options.h b/vpr/src/base/read_options.h index 55dc3d50c00..40fba4ecdd6 100644 --- a/vpr/src/base/read_options.h +++ b/vpr/src/base/read_options.h @@ -28,6 +28,7 @@ struct t_options { argparse::ArgValue constraints_file; argparse::ArgValue write_rr_graph_file; argparse::ArgValue read_rr_graph_file; + argparse::ArgValue read_rr_edge_override_file; argparse::ArgValue write_initial_place_file; argparse::ArgValue read_initial_place_file; argparse::ArgValue read_vpr_constraints_file; diff --git a/vpr/src/base/vpr_context.h b/vpr/src/base/vpr_context.h index 0c297f93ac1..21781a6e77e 100644 --- a/vpr/src/base/vpr_context.h +++ b/vpr/src/base/vpr_context.h @@ -248,6 +248,7 @@ struct DeviceContext : public Context { * Used to determine when reading rrgraph if file is already loaded. */ std::string read_rr_graph_filename; + std::string read_rr_edge_override_filename; /******************************************************************* * Place Related diff --git a/vpr/src/base/vpr_types.h b/vpr/src/base/vpr_types.h index abea66f8d6b..2aa52a68661 100644 --- a/vpr/src/base/vpr_types.h +++ b/vpr/src/base/vpr_types.h @@ -1417,6 +1417,7 @@ struct t_det_routing_arch { std::string read_rr_graph_filename; std::string write_rr_graph_filename; + std::string read_rr_edge_override_filename; }; /** diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index dfea2d9b218..da09c0f54b6 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -848,6 +848,13 @@ void create_rr_graph(const t_graph_type graph_type, Warnings, router_opts.route_verbosity); } + + if (!det_routing_arch->read_rr_graph_filename.empty() && + det_routing_arch->read_rr_graph_filename != device_ctx.read_rr_graph_filename) { + load_rr_edge_overrides(det_routing_arch->read_rr_edge_override_filename, + mutable_device_ctx.rr_graph_builder, + device_ctx.rr_graph); + } } if (is_flat) { From 08538ff268b8d10dbdfb89a8fbdbc7575a2bdb06 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 12 Mar 2025 15:11:44 -0400 Subject: [PATCH 03/28] add help message for --read_rr_edge_override --- vpr/src/base/read_options.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vpr/src/base/read_options.cpp b/vpr/src/base/read_options.cpp index 0c134c68a7f..4eb568cdcec 100644 --- a/vpr/src/base/read_options.cpp +++ b/vpr/src/base/read_options.cpp @@ -1736,16 +1736,16 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio file_grp.add_argument(args.read_rr_edge_override_file, "--read_rr_edge_override") .help( - "to be written!") + "The routing resource edge attributes override file to load.") .show_in(argparse::ShowIn::HELP_ONLY); file_grp.add_argument(args.write_rr_graph_file, "--write_rr_graph") - .help("Writes the routing resource graph to the specified file") + .help("Writes the routing resource graph to the specified file.") .metavar("RR_GRAPH_FILE") .show_in(argparse::ShowIn::HELP_ONLY); file_grp.add_argument(args.write_initial_place_file, "--write_initial_place_file") - .help("Writes out the the placement chosen by the initial placement algorithm to the specified file") + .help("Writes out the the placement chosen by the initial placement algorithm to the specified file.") .metavar("INITIAL_PLACE_FILE") .show_in(argparse::ShowIn::HELP_ONLY); From 3be8914fad0387bc5f2b36e1fc17319e1c7fe4df Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 12 Mar 2025 15:13:42 -0400 Subject: [PATCH 04/28] remove unused header files and types in rr_graph.cpp --- vpr/src/route/rr_graph.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index 12e341c9e93..6479673df9c 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -1,7 +1,5 @@ #include -#include #include -#include #include #include #include @@ -34,25 +32,11 @@ #include "rr_graph_clock.h" #include "edge_groups.h" #include "rr_graph_builder.h" - #include "rr_types.h" -#include "echo_files.h" //#define VERBOSE //used for getting the exact count of each edge type and printing it to std out. -struct t_mux { - int size; - t_mux* next; -}; - -struct t_mux_size_distribution { - int mux_count; - int max_index; - int* distr; - t_mux_size_distribution* next; -}; - struct t_clb_to_clb_directs { t_physical_tile_type_ptr from_clb_type; int from_clb_pin_start_index; From 7c6a282504ef3a41c435c663833437b34e610463 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 12 Mar 2025 15:42:11 -0400 Subject: [PATCH 05/28] rename device_ctx.read_rr_graph_filename to loaded_rr_graph_filename and pass the correct argument to load_rr_file --- libs/librrgraph/src/io/rr_graph_reader.cpp | 4 ++-- libs/librrgraph/src/io/rr_graph_reader.h | 2 +- .../src/io/rr_graph_uxsdcxx_serializer.h | 10 +++++----- vpr/src/base/vpr_context.h | 14 +++++++------- vpr/src/route/rr_graph.cpp | 16 +++++++++++----- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/libs/librrgraph/src/io/rr_graph_reader.cpp b/libs/librrgraph/src/io/rr_graph_reader.cpp index eca56b72769..b436b23164d 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.cpp +++ b/libs/librrgraph/src/io/rr_graph_reader.cpp @@ -54,7 +54,7 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, int* wire_to_rr_ipin_switch, int* wire_to_rr_ipin_switch_between_dice, const char* read_rr_graph_name, - std::string* read_rr_graph_filename, + std::string* loaded_rr_graph_filename, bool read_edge_metadata, bool do_check_rr_graph, bool echo_enabled, @@ -75,7 +75,7 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, wire_to_rr_ipin_switch_between_dice, do_check_rr_graph, read_rr_graph_name, - read_rr_graph_filename, + loaded_rr_graph_filename, read_edge_metadata, echo_enabled, echo_file_name, diff --git a/libs/librrgraph/src/io/rr_graph_reader.h b/libs/librrgraph/src/io/rr_graph_reader.h index b8ac7853798..580a9750839 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.h +++ b/libs/librrgraph/src/io/rr_graph_reader.h @@ -28,7 +28,7 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, int* wire_to_rr_ipin_switch, int* wire_to_rr_ipin_switch_between_dice, const char* read_rr_graph_name, - std::string* read_rr_graph_filename, + std::string* loaded_rr_graph_filename, bool read_edge_metadata, bool do_check_rr_graph, bool echo_enabled, diff --git a/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h b/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h index e9e83988d0b..328091bbbae 100644 --- a/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h +++ b/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h @@ -276,7 +276,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { int* wire_to_rr_ipin_switch_between_dice, bool do_check_rr_graph, const char* read_rr_graph_name, - std::string* read_rr_graph_filename, + std::string* loaded_rr_graph_filename, bool read_edge_metadata, bool echo_enabled, const char* echo_file_name, @@ -303,7 +303,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { , rr_graph_(rr_graph) , rr_switch_inf_(rr_switch_inf) , rr_indexed_data_(rr_indexed_data) - , read_rr_graph_filename_(read_rr_graph_filename) + , loaded_rr_graph_filename_(loaded_rr_graph_filename) , rr_rc_data_(rr_rc_data) , graph_type_(graph_type) , base_cost_type_(base_cost_type) @@ -1825,9 +1825,9 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { (*rr_indexed_data_)[RRIndexedDataId(i)].seg_index = seg_index_[RRIndexedDataId(i)]; } - VTR_ASSERT(read_rr_graph_filename_ != nullptr); + VTR_ASSERT(loaded_rr_graph_filename_ != nullptr); VTR_ASSERT(read_rr_graph_name_ != nullptr); - read_rr_graph_filename_->assign(read_rr_graph_name_); + loaded_rr_graph_filename_->assign(read_rr_graph_name_); if (do_check_rr_graph_) { check_rr_graph(*rr_graph_, @@ -2162,7 +2162,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { vtr::vector* rr_switch_inf_; vtr::vector* rr_indexed_data_; t_rr_node_indices* rr_node_indices_; - std::string* read_rr_graph_filename_; + std::string* loaded_rr_graph_filename_; std::vector* rr_rc_data_; // Constant data for loads and writes. diff --git a/vpr/src/base/vpr_context.h b/vpr/src/base/vpr_context.h index a256aedb2f4..0e2bfed14ad 100644 --- a/vpr/src/base/vpr_context.h +++ b/vpr/src/base/vpr_context.h @@ -271,13 +271,13 @@ struct DeviceContext : public Context { ********************************************************************/ t_clock_arch* clock_arch; - /** - * @brief Name of rrgraph file read (if any). - * - * Used to determine when reading rrgraph if file is already loaded. - */ - std::string read_rr_graph_filename; - std::string read_rr_edge_override_filename; + /// @brief Name of rrgraph file read (if any). + /// Used to determine if the file is already loaded when reading rrgraph. + std::string loaded_rr_graph_filename; + + /// @brief Name of rrgraph edge override file read (if any). + /// Used to determine if the file is already loaded when reading rrgraph edge overrides. + std::string loaded_rr_edge_override_filename; /******************************************************************* * Place Related diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index 6479673df9c..953ac0533d4 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -775,7 +775,7 @@ void create_rr_graph(const t_graph_type graph_type, } } else { if (load_rr_graph) { - if (device_ctx.read_rr_graph_filename != det_routing_arch->read_rr_graph_filename) { + if (device_ctx.loaded_rr_graph_filename != det_routing_arch->read_rr_graph_filename) { free_rr_graph(); load_rr_file(&mutable_device_ctx.rr_graph_builder, @@ -793,7 +793,7 @@ void create_rr_graph(const t_graph_type graph_type, &det_routing_arch->wire_to_rr_ipin_switch, &det_routing_arch->wire_to_arch_ipin_switch_between_dice, det_routing_arch->read_rr_graph_filename.c_str(), - &det_routing_arch->read_rr_graph_filename, + &mutable_device_ctx.loaded_rr_graph_filename, router_opts.read_rr_edge_metadata, router_opts.do_check_rr_graph, echo_enabled, @@ -831,11 +831,16 @@ void create_rr_graph(const t_graph_type graph_type, router_opts.route_verbosity); } - if (!det_routing_arch->read_rr_graph_filename.empty() && - det_routing_arch->read_rr_graph_filename != device_ctx.read_rr_graph_filename) { + // Check if there is an edge override file to read and that it is not already loaded. + if (!det_routing_arch->read_rr_edge_override_filename.empty() && + det_routing_arch->read_rr_edge_override_filename != device_ctx.loaded_rr_edge_override_filename) { + load_rr_edge_overrides(det_routing_arch->read_rr_edge_override_filename, mutable_device_ctx.rr_graph_builder, device_ctx.rr_graph); + + // Remember the loaded filename to avoid reloading it before the RR graph is cleared. + mutable_device_ctx.loaded_rr_edge_override_filename = det_routing_arch->read_rr_edge_override_filename; } } @@ -2787,7 +2792,8 @@ void free_rr_graph() { * allocated, as ALL the chunk allocated data is already free! */ auto& device_ctx = g_vpr_ctx.mutable_device(); - device_ctx.read_rr_graph_filename.clear(); + device_ctx.loaded_rr_graph_filename.clear(); + device_ctx.loaded_rr_edge_override_filename.clear(); device_ctx.rr_graph_builder.clear(); From 16870df35c178f0b6299f562168ae208fb1e87bf Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 12 Mar 2025 16:03:42 -0400 Subject: [PATCH 06/28] doxygen comment for t_det_routing_arch. Comment read_rr_edge_override_filename --- libs/libarchfpga/src/physical_types.h | 19 +++++++- vpr/src/base/read_options.cpp | 3 +- vpr/src/base/vpr_types.h | 66 ++++++++++++--------------- 3 files changed, 47 insertions(+), 41 deletions(-) diff --git a/libs/libarchfpga/src/physical_types.h b/libs/libarchfpga/src/physical_types.h index f1851a91214..1818d4eff03 100644 --- a/libs/libarchfpga/src/physical_types.h +++ b/libs/libarchfpga/src/physical_types.h @@ -1587,16 +1587,31 @@ enum class SegResType { NUM_RES_TYPES }; -constexpr std::array(SegResType::NUM_RES_TYPES)> RES_TYPE_STRING = {{"GCLK", "GENERAL"}}; //String versions of segment resource types +/// String versions of segment resource types +constexpr std::array(SegResType::NUM_RES_TYPES)> RES_TYPE_STRING{"GCLK", "GENERAL"}; +/// Defines the type of switch block used in FPGA routing. enum e_switch_block_type { + /// If the type is SUBSET, I use a Xilinx-like switch block where track i in one channel always + /// connects to track i in other channels. SUBSET, + + /// If type is WILTON, I use a switch block where track i + /// does not always connect to track i in other channels. + /// See Steve Wilton, PhD Thesis, University of Toronto, 1996. WILTON, + + /// The UNIVERSAL switch block is from Y. W. Chang et al, TODAES, Jan. 1996, pp. 80 - 101. UNIVERSAL, + + /// The FULL switch block type allows for complete connectivity between tracks. FULL, + + /// A CUSTOM switch block has also been added which allows a user to describe custom permutation functions and connection patterns. + /// See comment at top of SRC/route/build_switchblocks.c CUSTOM }; -typedef enum e_switch_block_type t_switch_block_type; + enum e_Fc_type { ABSOLUTE, FRACTIONAL diff --git a/vpr/src/base/read_options.cpp b/vpr/src/base/read_options.cpp index 4eb568cdcec..248b0b731af 100644 --- a/vpr/src/base/read_options.cpp +++ b/vpr/src/base/read_options.cpp @@ -1728,8 +1728,7 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio .show_in(argparse::ShowIn::HELP_ONLY); file_grp.add_argument(args.read_rr_graph_file, "--read_rr_graph") - .help( - "The routing resource graph file to load." + .help("The routing resource graph file to load." " The loaded routing resource graph overrides any routing architecture specified in the architecture file.") .metavar("RR_GRAPH_FILE") .show_in(argparse::ShowIn::HELP_ONLY); diff --git a/vpr/src/base/vpr_types.h b/vpr/src/base/vpr_types.h index 243c4fd857c..d6060883b8f 100644 --- a/vpr/src/base/vpr_types.h +++ b/vpr/src/base/vpr_types.h @@ -1280,7 +1280,7 @@ struct t_analysis_opts { e_timing_update_type timing_update_type; }; -// used to store NoC specific options, when supplied as an input by the user +/// Stores NoC specific options, when supplied as an input by the user struct t_noc_opts { bool noc; /// switchblocks; short global_route_switch; + + /// Index of a zero delay switch (used to connect things that should have no delay). short delayless_switch; + + /// Keeps track of the type of architecture switch that connects wires to ipins int wire_to_arch_ipin_switch; + + /// Keeps track of the type of architecture switch that connects + /// wires from another die to ipins in different die int wire_to_arch_ipin_switch_between_dice = -1; + + /// keeps track of the type of RR graph switch + /// that connects wires to ipins in the RR graph int wire_to_rr_ipin_switch; + + /// keeps track of the type of RR graph switch that connects wires + /// from another die to ipins in different die in the RR graph int wire_to_rr_ipin_switch_between_dice = -1; + + /// Resistance (in Ohms) of a minimum width nmos transistor. + /// Used only in the FPGA area model. float R_minW_nmos; + + /// Resistance (in Ohms) of a minimum width pmos transistor. float R_minW_pmos; + /// File to read the RR graph from (overrides architecture) std::string read_rr_graph_filename; + /// File to write the RR graph to after generation std::string write_rr_graph_filename; + /// File to read the RR graph edge attribute overrides. std::string read_rr_edge_override_filename; }; From 43bde82dbe7d32850016a16d604d23babdbc2a76 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 12 Mar 2025 17:03:50 -0400 Subject: [PATCH 07/28] add declaration for process_rr_edge_override() --- libs/librrgraph/src/io/rr_graph_reader.cpp | 26 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/libs/librrgraph/src/io/rr_graph_reader.cpp b/libs/librrgraph/src/io/rr_graph_reader.cpp index b436b23164d..533db715286 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.cpp +++ b/libs/librrgraph/src/io/rr_graph_reader.cpp @@ -30,6 +30,23 @@ # include "mmap_file.h" #endif +/** + * @brief Parses a line from the RR edge attribute override file. + * + * @details Expected formats: + * edge_id Tdel [R] [Cin] [Cout] [Cinternal] + * (source_node_id, sink_node_id) Tdel [R] [Cin] [Cout] [Cinternal] + * Attributes in [brackets] are optional. + * + * @param line The line to parse. + * @param overridden_values Parsed override values. + * @param rr_graph The RR graph for edge lookup using source-sink nodes. + * @return The RR edge whose attributes are to be overridden. + */ +static RREdgeId process_rr_edge_override(const std::string& line, + std::vector& overridden_values, + const RRGraphView& rr_graph); + /************************ Subroutine definitions ****************************/ /* loads the given RR_graph file into the appropriate data structures * as specified by read_rr_graph_name. Set up correct routing data @@ -39,6 +56,7 @@ * parameters are a workaround to passing the data structures of DeviceContext. * Needs a solution to reduce the number of parameters passed in.*/ + void load_rr_file(RRGraphBuilder* rr_graph_builder, RRGraphView* rr_graph, const std::vector& physical_tile_types, @@ -117,9 +135,9 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, } } -RREdgeId process_line(const std::string& line, - std::vector& overridden_values, - const RRGraphView& rr_graph) { +static RREdgeId process_rr_edge_override(const std::string& line, + std::vector& overridden_values, + const RRGraphView& rr_graph) { std::istringstream iss(line); char ch; RREdgeId edge_id; @@ -231,7 +249,7 @@ void load_rr_edge_overrides(std::string_view filename, if (!line.empty()) { overridden_values.clear(); - RREdgeId edge_id = process_line(line, overridden_values, rr_graph); + RREdgeId edge_id = process_rr_edge_override(line, overridden_values, rr_graph); RRSwitchId curr_switch_id = (RRSwitchId)rr_graph.edge_switch(edge_id); t_rr_switch_inf switch_override_info = rr_graph.rr_switch_inf(curr_switch_id); From 03849e47b7b42bc7ca7d28516c4fc3b22b506ef4 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 2 Apr 2025 13:38:03 -0400 Subject: [PATCH 08/28] fix a few typos --- Makefile | 4 ++-- utils/route_diag/CMakeLists.txt | 2 +- utils/route_diag/src/main.cpp | 2 +- utils/vqm2blif/test/scripts/test_vqm2blif.sh | 2 +- vpr/src/base/read_options.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 06d2df4c158..109288f0344 100644 --- a/Makefile +++ b/Makefile @@ -48,14 +48,14 @@ ifeq ($(VERBOSE),1) override CMAKE_PARAMS := -DVTR_ENABLE_VERBOSE=on ${CMAKE_PARAMS} endif -# -s : Suppresss makefile output (e.g. entering/leaving directories) +# -s : Suppresses makefile output (e.g. entering/leaving directories) # --output-sync target : For parallel compilation ensure output for each target is synchronized (make version >= 4.0) MAKEFLAGS := -s SOURCE_DIR := $(PWD) BUILD_DIR ?= build -#Check for the cmake exectuable +#Check for the cmake executable CMAKE := $(shell command -v cmake 2> /dev/null) #Show test log on failures with 'make test' diff --git a/utils/route_diag/CMakeLists.txt b/utils/route_diag/CMakeLists.txt index 809785c939a..b6b41592df9 100644 --- a/utils/route_diag/CMakeLists.txt +++ b/utils/route_diag/CMakeLists.txt @@ -8,7 +8,7 @@ target_link_libraries(route_diag libvpr ) -#Supress IPO link warnings if IPO is enabled +#Suppress IPO link warnings if IPO is enabled get_target_property(TEST_ROUTE_DIAG_USES_IPO route_diag INTERPROCEDURAL_OPTIMIZATION) if (TEST_ROUTE_DIAG_USES_IPO) set_property(TARGET route_diag APPEND PROPERTY LINK_FLAGS ${IPO_LINK_WARN_SUPRESS_FLAGS}) diff --git a/utils/route_diag/src/main.cpp b/utils/route_diag/src/main.cpp index 6812b5bc881..5074d79cc09 100644 --- a/utils/route_diag/src/main.cpp +++ b/utils/route_diag/src/main.cpp @@ -247,7 +247,7 @@ t_route_util_options read_route_util_options(int argc, const char** argv) { route_diag_grp.add_argument(args.profile_source, "--profile_source") .help( "Profile routes from source to IPINs at all locations." - "This is similiar to the placer delay matrix construction.") + "This is similar to the placer delay matrix construction.") .show_in(argparse::ShowIn::HELP_ONLY); parser.parse_args(argc, argv); diff --git a/utils/vqm2blif/test/scripts/test_vqm2blif.sh b/utils/vqm2blif/test/scripts/test_vqm2blif.sh index 98966a9bc45..60c217a99e5 100755 --- a/utils/vqm2blif/test/scripts/test_vqm2blif.sh +++ b/utils/vqm2blif/test/scripts/test_vqm2blif.sh @@ -259,7 +259,7 @@ do done -# we create seperate subshells to process each iteration of the loops above. +# we create separate subshells to process each iteration of the loops above. # So below we check the result of the last shell. if [ $? -eq 1 ]; then diff --git a/vpr/src/base/read_options.cpp b/vpr/src/base/read_options.cpp index d8edad4c2d0..c8f76ce7283 100644 --- a/vpr/src/base/read_options.cpp +++ b/vpr/src/base/read_options.cpp @@ -3352,7 +3352,7 @@ void set_conditional_defaults(t_options& args) { bool verify_args(const t_options& args) { /* - * Check for conflicting paramaters or dependencies where one parameter set requires another parameter to be included + * Check for conflicting parameters or dependencies where one parameter set requires another parameter to be included */ if (args.read_rr_graph_file.provenance() == Provenance::SPECIFIED && args.RouteChanWidth.provenance() != Provenance::SPECIFIED) { From 04e25e8c16e9b23002ea29000ad7bf7389b88f5a Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 2 Apr 2025 13:38:26 -0400 Subject: [PATCH 09/28] added a doxygen comments --- libs/librrgraph/src/base/rr_graph_builder.h | 1 + libs/librrgraph/src/base/rr_graph_storage.h | 1 + libs/librrgraph/src/base/rr_graph_view.h | 1 + 3 files changed, 3 insertions(+) diff --git a/libs/librrgraph/src/base/rr_graph_builder.h b/libs/librrgraph/src/base/rr_graph_builder.h index 68159e95bbf..9e72bde0c41 100644 --- a/libs/librrgraph/src/base/rr_graph_builder.h +++ b/libs/librrgraph/src/base/rr_graph_builder.h @@ -264,6 +264,7 @@ class RRGraphBuilder { node_storage_.alloc_and_load_edges(rr_edges_to_create); } + /** @brief Overrides the associated switch for a given edge. */ inline void override_edge_switch(RREdgeId edge_id, RRSwitchId switch_id) { node_storage_.override_edge_switch(edge_id, switch_id); } diff --git a/libs/librrgraph/src/base/rr_graph_storage.h b/libs/librrgraph/src/base/rr_graph_storage.h index ef0a17cb17c..f49dfe9e630 100644 --- a/libs/librrgraph/src/base/rr_graph_storage.h +++ b/libs/librrgraph/src/base/rr_graph_storage.h @@ -730,6 +730,7 @@ class t_rr_graph_storage { */ void partition_edges(const vtr::vector& rr_switches); + /** @brief Overrides the associated switch for a given edge. */ void override_edge_switch(RREdgeId edge_id, RRSwitchId switch_id); /** @brief Validate that edge data is partitioned correctly.*/ diff --git a/libs/librrgraph/src/base/rr_graph_view.h b/libs/librrgraph/src/base/rr_graph_view.h index bb68228aee1..c3a2ff6273f 100644 --- a/libs/librrgraph/src/base/rr_graph_view.h +++ b/libs/librrgraph/src/base/rr_graph_view.h @@ -413,6 +413,7 @@ class RRGraphView { return node_storage_.edge_switch(id, iedge); } + /// @brief Returns the associated switch for a given edge. inline short edge_switch(RREdgeId id) const { return node_storage_.edge_switch(id); } From a648aab364302306abd47b5067efec43c3c08141 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 2 Apr 2025 13:38:55 -0400 Subject: [PATCH 10/28] use VTR_LOGV_ERROR instead of is statements --- libs/librrgraph/src/io/rr_graph_reader.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libs/librrgraph/src/io/rr_graph_reader.cpp b/libs/librrgraph/src/io/rr_graph_reader.cpp index 533db715286..e6be643a2e9 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.cpp +++ b/libs/librrgraph/src/io/rr_graph_reader.cpp @@ -162,9 +162,10 @@ static RREdgeId process_rr_edge_override(const std::string& line, } } - if (!edge_id.is_valid()) { - VTR_LOG_ERROR("Couldn't find an edge connecting node %d to node %d\n", src_node_id, sink_node_id); - } + VTR_LOGV_ERROR(!edge_id.is_valid(), + "Couldn't find an edge connecting node %d to node %d\n", + src_node_id, + sink_node_id); } else { VTR_LOG_ERROR("Invalid line format: %s\n", line.c_str()); @@ -224,9 +225,7 @@ void load_rr_edge_overrides(std::string_view filename, RRGraphBuilder& rr_graph_builder, const RRGraphView& rr_graph) { std::ifstream file(filename.data()); - if (!file) { - VTR_LOG_ERROR("Failed to open the RR edge override file: %s\n", filename.data()); - } + VTR_LOGV_ERROR(!file, "Failed to open the RR edge override file: %s\n", filename.data()); std::unordered_map unique_switch_info; for (const auto& [rr_sw_idx, sw] : rr_graph.rr_switch().pairs()) { From 4115a25ff5ac3bf459287fd18a53c13e1d0bd135 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 2 Apr 2025 13:53:47 -0400 Subject: [PATCH 11/28] doxygen comment for load_rr_edge_overrides() --- libs/librrgraph/src/io/rr_graph_reader.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libs/librrgraph/src/io/rr_graph_reader.h b/libs/librrgraph/src/io/rr_graph_reader.h index 580a9750839..682089e5cc2 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.h +++ b/libs/librrgraph/src/io/rr_graph_reader.h @@ -35,6 +35,19 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, const char* echo_file_name, bool is_flat); +/** + * @brief Reads a text file where the intrinsic delay and electrical characteristics + * of edges are overridden. + * + * @details This function tries to find a switch with the overridden delay and electrical + * characteristics. If such a switch exists, the edge will point to it as its + * corresponding switch. Otherwise, a new switch is created so that the edge + * can point to a valid switch. + * + * @param filename The text file to be ingested by this function. + * @param rr_graph_builder Used to add switches and override switch IDs for edges. + * @param rr_graph Provides read only access to RR graph. + */ void load_rr_edge_overrides(std::string_view filename, RRGraphBuilder& rr_graph_builder, const RRGraphView& rr_graph); From 97da592fe56a961b7d104712713c3967c2b1c7c4 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 2 Apr 2025 14:12:05 -0400 Subject: [PATCH 12/28] make format --- vpr/src/base/read_options.cpp | 4 ++-- vpr/src/route/rr_graph.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vpr/src/base/read_options.cpp b/vpr/src/base/read_options.cpp index c8f76ce7283..7f926d2fc45 100644 --- a/vpr/src/base/read_options.cpp +++ b/vpr/src/base/read_options.cpp @@ -1769,8 +1769,8 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio .show_in(argparse::ShowIn::HELP_ONLY); file_grp.add_argument(args.read_rr_graph_file, "--read_rr_graph") - .help("The routing resource graph file to load." - " The loaded routing resource graph overrides any routing architecture specified in the architecture file.") + .help("The routing resource graph file to load. " + "The loaded routing resource graph overrides any routing architecture specified in the architecture file.") .metavar("RR_GRAPH_FILE") .show_in(argparse::ShowIn::HELP_ONLY); diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index 1dd7e7fe8b9..ecc03fe459a 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -831,15 +831,15 @@ void create_rr_graph(const t_graph_type graph_type, } // Check if there is an edge override file to read and that it is not already loaded. - if (!det_routing_arch->read_rr_edge_override_filename.empty() && - det_routing_arch->read_rr_edge_override_filename != device_ctx.loaded_rr_edge_override_filename) { + if (!det_routing_arch->read_rr_edge_override_filename.empty() + && det_routing_arch->read_rr_edge_override_filename != device_ctx.loaded_rr_edge_override_filename) { load_rr_edge_overrides(det_routing_arch->read_rr_edge_override_filename, mutable_device_ctx.rr_graph_builder, device_ctx.rr_graph); // Remember the loaded filename to avoid reloading it before the RR graph is cleared. - mutable_device_ctx.loaded_rr_edge_override_filename = det_routing_arch->read_rr_edge_override_filename; + mutable_device_ctx.loaded_rr_edge_override_filename = det_routing_arch->read_rr_edge_override_filename; } } From 305c46e3a0c85dfbd798a18a4f73c5df47cfe9e8 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 2 Apr 2025 14:32:30 -0400 Subject: [PATCH 13/28] only override edge delay and not electrical stuff --- libs/librrgraph/src/io/rr_graph_reader.cpp | 36 +++++++++------------- libs/librrgraph/src/io/rr_graph_reader.h | 16 +++++----- vpr/src/route/rr_graph.cpp | 6 ++-- 3 files changed, 24 insertions(+), 34 deletions(-) diff --git a/libs/librrgraph/src/io/rr_graph_reader.cpp b/libs/librrgraph/src/io/rr_graph_reader.cpp index e6be643a2e9..a56ce78451a 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.cpp +++ b/libs/librrgraph/src/io/rr_graph_reader.cpp @@ -31,20 +31,19 @@ #endif /** - * @brief Parses a line from the RR edge attribute override file. + * @brief Parses a line from the RR edge delay override file. * * @details Expected formats: - * edge_id Tdel [R] [Cin] [Cout] [Cinternal] - * (source_node_id, sink_node_id) Tdel [R] [Cin] [Cout] [Cinternal] - * Attributes in [brackets] are optional. + * edge_id Tdel + * (source_node_id, sink_node_id) Tdel * * @param line The line to parse. - * @param overridden_values Parsed override values. + * @param overridden_Tdel Parsed override delay. * @param rr_graph The RR graph for edge lookup using source-sink nodes. * @return The RR edge whose attributes are to be overridden. */ static RREdgeId process_rr_edge_override(const std::string& line, - std::vector& overridden_values, + float& overridden_Tdel, const RRGraphView& rr_graph); /************************ Subroutine definitions ****************************/ @@ -136,7 +135,7 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, } static RREdgeId process_rr_edge_override(const std::string& line, - std::vector& overridden_values, + float& overridden_Tdel, const RRGraphView& rr_graph) { std::istringstream iss(line); char ch; @@ -171,9 +170,8 @@ static RREdgeId process_rr_edge_override(const std::string& line, VTR_LOG_ERROR("Invalid line format: %s\n", line.c_str()); } - float value; - while (iss >> value) { - overridden_values.push_back(value); + if (!(iss >> overridden_Tdel)) { + VTR_LOG_ERROR("Couldn't parse the overridden delay in this line: %s\n", line.c_str()); } return edge_id; @@ -221,9 +219,9 @@ struct t_rr_switch_inf_equal { } }; -void load_rr_edge_overrides(std::string_view filename, - RRGraphBuilder& rr_graph_builder, - const RRGraphView& rr_graph) { +void load_rr_edge_delay_overrides(std::string_view filename, + RRGraphBuilder& rr_graph_builder, + const RRGraphView& rr_graph) { std::ifstream file(filename.data()); VTR_LOGV_ERROR(!file, "Failed to open the RR edge override file: %s\n", filename.data()); @@ -233,7 +231,6 @@ void load_rr_edge_overrides(std::string_view filename, } std::string line; - std::vector overridden_values; bool firstLine = true; while (std::getline(file, line)) { @@ -245,18 +242,13 @@ void load_rr_edge_overrides(std::string_view filename, continue; // Ignore first line } - if (!line.empty()) { - overridden_values.clear(); - RREdgeId edge_id = process_rr_edge_override(line, overridden_values, rr_graph); + float overridden_Tdel; + RREdgeId edge_id = process_rr_edge_override(line, overridden_Tdel, rr_graph); RRSwitchId curr_switch_id = (RRSwitchId)rr_graph.edge_switch(edge_id); t_rr_switch_inf switch_override_info = rr_graph.rr_switch_inf(curr_switch_id); - switch_override_info.Tdel = (overridden_values.size() >= 1) ? overridden_values[0] : switch_override_info.Tdel; - switch_override_info.R = (overridden_values.size() >= 2) ? overridden_values[1] : switch_override_info.R; - switch_override_info.Cin = (overridden_values.size() >= 3) ? overridden_values[2] : switch_override_info.Cin; - switch_override_info.Cout = (overridden_values.size() >= 4) ? overridden_values[3] : switch_override_info.Cout; - switch_override_info.Cinternal = (overridden_values.size() >= 5) ? overridden_values[4] : switch_override_info.Cinternal; + switch_override_info.Tdel = overridden_Tdel; RRSwitchId new_switch_id; auto it = unique_switch_info.find(switch_override_info); diff --git a/libs/librrgraph/src/io/rr_graph_reader.h b/libs/librrgraph/src/io/rr_graph_reader.h index 682089e5cc2..1814700a673 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.h +++ b/libs/librrgraph/src/io/rr_graph_reader.h @@ -36,20 +36,18 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, bool is_flat); /** - * @brief Reads a text file where the intrinsic delay and electrical characteristics - * of edges are overridden. + * @brief Reads a text file where the intrinsic delay of edges are overridden. * - * @details This function tries to find a switch with the overridden delay and electrical - * characteristics. If such a switch exists, the edge will point to it as its - * corresponding switch. Otherwise, a new switch is created so that the edge - * can point to a valid switch. + * @details This function tries to find a switch with the overridden delay. If such a + * switch exists, the edge will point to it as its corresponding switch. + * Otherwise, a new switch is created so that the edge can point to a valid switch. * * @param filename The text file to be ingested by this function. * @param rr_graph_builder Used to add switches and override switch IDs for edges. * @param rr_graph Provides read only access to RR graph. */ -void load_rr_edge_overrides(std::string_view filename, - RRGraphBuilder& rr_graph_builder, - const RRGraphView& rr_graph); +void load_rr_edge_delay_overrides(std::string_view filename, + RRGraphBuilder& rr_graph_builder, + const RRGraphView& rr_graph); #endif /* RR_GRAPH_READER_H */ diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index ecc03fe459a..9574d1d6fc5 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -834,9 +834,9 @@ void create_rr_graph(const t_graph_type graph_type, if (!det_routing_arch->read_rr_edge_override_filename.empty() && det_routing_arch->read_rr_edge_override_filename != device_ctx.loaded_rr_edge_override_filename) { - load_rr_edge_overrides(det_routing_arch->read_rr_edge_override_filename, - mutable_device_ctx.rr_graph_builder, - device_ctx.rr_graph); + load_rr_edge_delay_overrides(det_routing_arch->read_rr_edge_override_filename, + mutable_device_ctx.rr_graph_builder, + device_ctx.rr_graph); // Remember the loaded filename to avoid reloading it before the RR graph is cleared. mutable_device_ctx.loaded_rr_edge_override_filename = det_routing_arch->read_rr_edge_override_filename; From 1163f30c46a2b81a0f00bb2434e0e942574f683c Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 9 Apr 2025 12:06:01 -0400 Subject: [PATCH 14/28] add a unit test for reading edge override file --- libs/librrgraph/src/io/rr_graph_writer.cpp | 2 +- vpr/test/test_vpr.cpp | 112 +++++++++++++++++++++ 2 files changed, 113 insertions(+), 1 deletion(-) diff --git a/libs/librrgraph/src/io/rr_graph_writer.cpp b/libs/librrgraph/src/io/rr_graph_writer.cpp index d254ae9edb7..ce1a2ba352c 100644 --- a/libs/librrgraph/src/io/rr_graph_writer.cpp +++ b/libs/librrgraph/src/io/rr_graph_writer.cpp @@ -21,7 +21,7 @@ /************************ Subroutine definitions ****************************/ -/* This function is used to write the rr_graph into xml format into a a file with name: file_name */ +/* This function is used to write the rr_graph into xml format into a file with name: file_name */ /**FIXME: To make rr_graph_reader independent of vpr_context, the below * parameters are a workaround to passing the data structures of DeviceContext. diff --git a/vpr/test/test_vpr.cpp b/vpr/test/test_vpr.cpp index 5d162c579bc..fe85580a62c 100644 --- a/vpr/test/test_vpr.cpp +++ b/vpr/test/test_vpr.cpp @@ -232,4 +232,116 @@ TEST_CASE("read_rr_graph_metadata", "[vpr]") { vpr_free_all(arch, vpr_setup); } +TEST_CASE("read_rr_edge_override", "[vpr33]") { + + const std::string RR_GRAPH_NAME = "test_read_rr_edge_override"; + const std::string RR_EDGE_OVERRIDE_FILENAME = "test_read_rr_edge_override.txt"; + const std::array file_extensions {".xml", ".bin"}; + + // We test both xml and binary file formats + for (const std::string& file_extension : file_extensions) { + std::string rr_graph_filename = RR_GRAPH_NAME + file_extension ; + std::string overridden_rr_graph_filename = RR_GRAPH_NAME + "_overridden" + file_extension ; + + RRNodeId src_inode = RRNodeId::INVALID(); + RRNodeId sink_inode = RRNodeId::INVALID(); + short switch_id = -1; + + { // Generate an RR graph and write it out + t_vpr_setup vpr_setup; + t_arch arch; + t_options options; + const char* argv[] = { + "test_vpr", + kArchFile, + "wire.eblif", + "--route_chan_width", + "100"}; + vpr_init(sizeof(argv) / sizeof(argv[0]), argv, + &options, &vpr_setup, &arch); + vpr_create_device(vpr_setup, arch); + + const auto& device_ctx = g_vpr_ctx.device(); + auto& mutable_device_ctx = g_vpr_ctx.mutable_device(); + const auto& rr_graph = device_ctx.rr_graph; +// auto& rr_graph_builder = mutable_device_ctx.rr_graph_builder; + bool echo_enabled = getEchoEnabled() && isEchoFileEnabled(E_ECHO_RR_GRAPH_INDEXED_DATA); + const char* echo_file_name = getEchoFileName(E_ECHO_RR_GRAPH_INDEXED_DATA); + + for (const RRNodeId inode : device_ctx.rr_graph.nodes()) { + if ((rr_graph.node_type(inode) == CHANX || rr_graph.node_type(inode) == CHANY) && rr_graph.num_edges(inode) > 0) { + src_inode = inode; + break; + } + } + + REQUIRE(src_inode.is_valid()); + sink_inode = rr_graph.edge_sink_node(RRNodeId(src_inode), 0); + switch_id = rr_graph.edge_switch(RRNodeId(src_inode), 0); + + write_rr_graph(&mutable_device_ctx.rr_graph_builder, + &mutable_device_ctx.rr_graph, + device_ctx.physical_tile_types, + &mutable_device_ctx.rr_indexed_data, + &mutable_device_ctx.rr_rc_data, + device_ctx.grid, + device_ctx.arch_switch_inf, + device_ctx.arch, + &mutable_device_ctx.chan_width, + rr_graph_filename.c_str(), + echo_enabled, + echo_file_name, + false); + + vpr_free_all(arch, vpr_setup); + } + + REQUIRE(src_inode.is_valid()); + REQUIRE(sink_inode.is_valid()); + REQUIRE(switch_id != -1); + + { // Override edge attributes + t_vpr_setup vpr_setup; + t_arch arch; + t_options options; + const char* argv[] = { + "test_vpr", + kArchFile, + "wire.eblif", + "--route_chan_width", + "100", + "--read_rr_graph", + rr_graph_filename.c_str(), + "--read_rr_edge_override", + RR_EDGE_OVERRIDE_FILENAME.c_str()}; + + vpr_init(sizeof(argv) / sizeof(argv[0]), argv, &options, &vpr_setup, &arch); + vpr_create_device(vpr_setup, arch); + + const auto& device_ctx = g_vpr_ctx.device(); + auto& mutable_device_ctx = g_vpr_ctx.mutable_device(); +// const auto& rr_graph = device_ctx.rr_graph; +// auto& rr_graph_builder = mutable_device_ctx.rr_graph_builder; + bool echo_enabled = getEchoEnabled() && isEchoFileEnabled(E_ECHO_RR_GRAPH_INDEXED_DATA); + const char* echo_file_name = getEchoFileName(E_ECHO_RR_GRAPH_INDEXED_DATA); + + write_rr_graph(&mutable_device_ctx.rr_graph_builder, + &mutable_device_ctx.rr_graph, + device_ctx.physical_tile_types, + &mutable_device_ctx.rr_indexed_data, + &mutable_device_ctx.rr_rc_data, + device_ctx.grid, + device_ctx.arch_switch_inf, + device_ctx.arch, + &mutable_device_ctx.chan_width, + overridden_rr_graph_filename.c_str(), + echo_enabled, + echo_file_name, + false); + + vpr_free_all(arch, vpr_setup); + } + } +} + } // namespace From dbeec6925dd70aca46610861e73b7619020b53bf Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 9 Apr 2025 12:06:48 -0400 Subject: [PATCH 15/28] Add edge_id() method to find an edge that connects given src and sink nodes --- libs/librrgraph/src/base/rr_graph_storage.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/librrgraph/src/base/rr_graph_storage.h b/libs/librrgraph/src/base/rr_graph_storage.h index f49dfe9e630..0d5ccf16817 100644 --- a/libs/librrgraph/src/base/rr_graph_storage.h +++ b/libs/librrgraph/src/base/rr_graph_storage.h @@ -393,13 +393,23 @@ class t_rr_graph_storage { * This method should generally not be used, and instead first_edge and * last_edge should be used. */ - RREdgeId edge_id(const RRNodeId& id, t_edge_size iedge) const { + RREdgeId edge_id(RRNodeId id, t_edge_size iedge) const { RREdgeId first_edge = this->first_edge(id); RREdgeId ret(size_t(first_edge) + iedge); VTR_ASSERT_SAFE(ret < last_edge(id)); return ret; } + RREdgeId edge_id(RRNodeId src, RRNodeId sink) { + for (RREdgeId outgoing_edge_id : edge_range(src)) { + if (edge_sink_node(outgoing_edge_id) == sink) { + return outgoing_edge_id; + } + } + + return RREdgeId::INVALID(); + } + /** @brief Get the source node for the specified edge. */ RRNodeId edge_src_node(const RREdgeId& edge) const { VTR_ASSERT_DEBUG(edge.is_valid()); From 690244aaf9d2cb03f65e6adb245600a0160ca2db Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 9 Apr 2025 12:09:31 -0400 Subject: [PATCH 16/28] replace for loop with edge_id() method that return an edge connecting given src/sink nodes --- libs/librrgraph/src/base/rr_graph_storage.h | 2 +- libs/librrgraph/src/io/rr_graph_reader.cpp | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/libs/librrgraph/src/base/rr_graph_storage.h b/libs/librrgraph/src/base/rr_graph_storage.h index 0d5ccf16817..087fd506ca1 100644 --- a/libs/librrgraph/src/base/rr_graph_storage.h +++ b/libs/librrgraph/src/base/rr_graph_storage.h @@ -400,7 +400,7 @@ class t_rr_graph_storage { return ret; } - RREdgeId edge_id(RRNodeId src, RRNodeId sink) { + RREdgeId edge_id(RRNodeId src, RRNodeId sink) const { for (RREdgeId outgoing_edge_id : edge_range(src)) { if (edge_sink_node(outgoing_edge_id) == sink) { return outgoing_edge_id; diff --git a/libs/librrgraph/src/io/rr_graph_reader.cpp b/libs/librrgraph/src/io/rr_graph_reader.cpp index a56ce78451a..e906d448c71 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.cpp +++ b/libs/librrgraph/src/io/rr_graph_reader.cpp @@ -154,12 +154,7 @@ static RREdgeId process_rr_edge_override(const std::string& line, RRNodeId src_node_id = RRNodeId(first); RRNodeId sink_node_id = RRNodeId(second); - for (RREdgeId outgoing_edge_id : rr_graph.rr_nodes().edge_range(src_node_id)) { - if (rr_graph.rr_nodes().edge_sink_node(outgoing_edge_id) == sink_node_id) { - edge_id = outgoing_edge_id; - break; - } - } + edge_id = rr_graph.rr_nodes().edge_id(src_node_id, sink_node_id); VTR_LOGV_ERROR(!edge_id.is_valid(), "Couldn't find an edge connecting node %d to node %d\n", From fb5ad7504151f16176524fcd16e09f51677ad59e Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 9 Apr 2025 12:28:11 -0400 Subject: [PATCH 17/28] add doxygen comment for edge_id() method --- libs/librrgraph/src/base/rr_graph_storage.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/librrgraph/src/base/rr_graph_storage.h b/libs/librrgraph/src/base/rr_graph_storage.h index 087fd506ca1..533bb414735 100644 --- a/libs/librrgraph/src/base/rr_graph_storage.h +++ b/libs/librrgraph/src/base/rr_graph_storage.h @@ -400,6 +400,10 @@ class t_rr_graph_storage { return ret; } + /** + * @brief Retrieve the RREdgeId that connect the given source and sink nodes. + * If the given source/sink nodes are not connected, RREdgeId::INVALID() is returned. + */ RREdgeId edge_id(RRNodeId src, RRNodeId sink) const { for (RREdgeId outgoing_edge_id : edge_range(src)) { if (edge_sink_node(outgoing_edge_id) == sink) { From ebf88f0d5bf7b2969c8d443f5f8694553911d435 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 9 Apr 2025 12:28:44 -0400 Subject: [PATCH 18/28] verify overridden edge attribute in the unit test --- vpr/test/test_vpr.cpp | 56 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/vpr/test/test_vpr.cpp b/vpr/test/test_vpr.cpp index fe85580a62c..ddd408ae815 100644 --- a/vpr/test/test_vpr.cpp +++ b/vpr/test/test_vpr.cpp @@ -232,7 +232,7 @@ TEST_CASE("read_rr_graph_metadata", "[vpr]") { vpr_free_all(arch, vpr_setup); } -TEST_CASE("read_rr_edge_override", "[vpr33]") { +TEST_CASE("read_rr_edge_override", "[vpr]") { const std::string RR_GRAPH_NAME = "test_read_rr_edge_override"; const std::string RR_EDGE_OVERRIDE_FILENAME = "test_read_rr_edge_override.txt"; @@ -264,7 +264,6 @@ TEST_CASE("read_rr_edge_override", "[vpr33]") { const auto& device_ctx = g_vpr_ctx.device(); auto& mutable_device_ctx = g_vpr_ctx.mutable_device(); const auto& rr_graph = device_ctx.rr_graph; -// auto& rr_graph_builder = mutable_device_ctx.rr_graph_builder; bool echo_enabled = getEchoEnabled() && isEchoFileEnabled(E_ECHO_RR_GRAPH_INDEXED_DATA); const char* echo_file_name = getEchoFileName(E_ECHO_RR_GRAPH_INDEXED_DATA); @@ -320,8 +319,6 @@ TEST_CASE("read_rr_edge_override", "[vpr33]") { const auto& device_ctx = g_vpr_ctx.device(); auto& mutable_device_ctx = g_vpr_ctx.mutable_device(); -// const auto& rr_graph = device_ctx.rr_graph; -// auto& rr_graph_builder = mutable_device_ctx.rr_graph_builder; bool echo_enabled = getEchoEnabled() && isEchoFileEnabled(E_ECHO_RR_GRAPH_INDEXED_DATA); const char* echo_file_name = getEchoFileName(E_ECHO_RR_GRAPH_INDEXED_DATA); @@ -341,6 +338,57 @@ TEST_CASE("read_rr_edge_override", "[vpr33]") { vpr_free_all(arch, vpr_setup); } + + { // Verify overridden values + t_vpr_setup vpr_setup; + t_arch arch; + t_options options; + const char* argv[] = { + "test_vpr", + kArchFile, + "wire.eblif", + "--route_chan_width", + "100", + "--read_rr_graph", + overridden_rr_graph_filename.c_str()}; + + vpr_init(sizeof(argv) / sizeof(argv[0]), argv, &options, &vpr_setup, &arch); + vpr_create_device(vpr_setup, arch); + + const auto& device_ctx = g_vpr_ctx.device(); + const auto& rr_graph = device_ctx.rr_graph; + + switch_id = rr_graph.edge_switch((RREdgeId)12); + REQUIRE(rr_graph.rr_switch_inf((RRSwitchId)switch_id).Tdel == 5.9e-11f); + + switch_id = rr_graph.edge_switch((RREdgeId)1586); + REQUIRE(rr_graph.rr_switch_inf((RRSwitchId)switch_id).Tdel == 4.2e-11f); + + switch_id = rr_graph.edge_switch((RREdgeId)1111); + REQUIRE(rr_graph.rr_switch_inf((RRSwitchId)switch_id).Tdel == 7.1e-11f); + + switch_id = rr_graph.edge_switch((RREdgeId)1324); + REQUIRE(rr_graph.rr_switch_inf((RRSwitchId)switch_id).Tdel == 9.4e-11f); + + RREdgeId edge_id; + edge_id = rr_graph.rr_nodes().edge_id((RRNodeId)645, (RRNodeId)127); + switch_id = rr_graph.edge_switch(edge_id); + REQUIRE(rr_graph.rr_switch_inf((RRSwitchId)switch_id).Tdel == 7.3e-11f); + + edge_id = rr_graph.rr_nodes().edge_id((RRNodeId)591, (RRNodeId)347); + switch_id = rr_graph.edge_switch(edge_id); + REQUIRE(rr_graph.rr_switch_inf((RRSwitchId)switch_id).Tdel == 7.9e-11f); + + edge_id = rr_graph.rr_nodes().edge_id((RRNodeId)544, (RRNodeId)45); + switch_id = rr_graph.edge_switch(edge_id); + REQUIRE(rr_graph.rr_switch_inf((RRSwitchId)switch_id).Tdel == 8.3e-11f); + + edge_id = rr_graph.rr_nodes().edge_id((RRNodeId)37, (RRNodeId)511); + switch_id = rr_graph.edge_switch(edge_id); + REQUIRE(rr_graph.rr_switch_inf((RRSwitchId)switch_id).Tdel == 9.5e-11f); + + vpr_free_all(arch, vpr_setup); + } } } From 9b6d8246d62f8df3e9f8d402499e1398b1319574 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 9 Apr 2025 12:48:52 -0400 Subject: [PATCH 19/28] move operator==() and hash function of t_rr_switch_inf to physical_types.cpp --- libs/libarchfpga/src/physical_types.cpp | 39 ++++++++++++++++++- libs/libarchfpga/src/physical_types.h | 14 +++++-- libs/librrgraph/src/io/rr_graph_reader.cpp | 44 +--------------------- 3 files changed, 49 insertions(+), 48 deletions(-) diff --git a/libs/libarchfpga/src/physical_types.cpp b/libs/libarchfpga/src/physical_types.cpp index bdacf50931d..6984dfdff11 100644 --- a/libs/libarchfpga/src/physical_types.cpp +++ b/libs/libarchfpga/src/physical_types.cpp @@ -71,10 +71,47 @@ bool t_rr_switch_inf::configurable() const { return switch_type_is_configurable(type()); } +bool t_rr_switch_inf::operator==(const t_rr_switch_inf& other) const { + return R == other.R && + Cin == other.Cin && + Cout == other.Cout && + Cinternal == other.Cinternal && + Tdel == other.Tdel && + mux_trans_size == other.mux_trans_size && + buf_size == other.buf_size && + power_buffer_type == other.power_buffer_type && + power_buffer_size == other.power_buffer_size && + intra_tile == other.intra_tile && + type() == other.type(); +} + +std::size_t t_rr_switch_inf::Hasher::operator()(const t_rr_switch_inf& s) const { + std::size_t seed = 0; + + auto hash_combine = [&seed](auto&& val) { + seed ^= std::hash>{}(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2); + }; + + hash_combine(s.R); + hash_combine(s.Cin); + hash_combine(s.Cout); + hash_combine(s.Cinternal); + hash_combine(s.Tdel); + hash_combine(s.mux_trans_size); + hash_combine(s.buf_size); + hash_combine(static_cast(s.power_buffer_type)); + hash_combine(s.power_buffer_size); + hash_combine(s.intra_tile); + hash_combine(static_cast(s.type())); + + return seed; +} + void t_rr_switch_inf::set_type(SwitchType type_val) { type_ = type_val; } + static bool switch_type_is_buffered(SwitchType type) { //Muxes and Tristates isolate their input and output into //separate DC connected sub-circuits @@ -360,4 +397,4 @@ const t_physical_tile_port* t_sub_tile::get_port_by_pin(int pin) const { } return nullptr; -} \ No newline at end of file +} diff --git a/libs/libarchfpga/src/physical_types.h b/libs/libarchfpga/src/physical_types.h index 704e5f4b567..2a69b3532f1 100644 --- a/libs/libarchfpga/src/physical_types.h +++ b/libs/libarchfpga/src/physical_types.h @@ -1917,16 +1917,22 @@ struct t_rr_switch_inf { bool intra_tile = false; public: - //Returns the type of switch + /// Returns the type of switch SwitchType type() const; - //Returns true if this switch type isolates its input and output into - //separate DC-connected subcircuits + /// Returns true if this switch type isolates its input and output into + /// separate DC-connected subcircuits bool buffered() const; - //Returns true if this switch type is configurable + /// Returns true if this switch type is configurable bool configurable() const; + bool operator==(const t_rr_switch_inf& other) const; + + struct Hasher { + std::size_t operator()(const t_rr_switch_inf& s) const; + }; + public: void set_type(SwitchType type_val); diff --git a/libs/librrgraph/src/io/rr_graph_reader.cpp b/libs/librrgraph/src/io/rr_graph_reader.cpp index e906d448c71..b2153955f07 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.cpp +++ b/libs/librrgraph/src/io/rr_graph_reader.cpp @@ -172,55 +172,13 @@ static RREdgeId process_rr_edge_override(const std::string& line, return edge_id; } -struct t_rr_switch_inf_hash { - std::size_t operator()(const t_rr_switch_inf& s) const { - std::size_t seed = 0; - - // Helper function for hashing - auto hash_combine = [&seed](auto&& val) { - seed ^= std::hash>{}(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - }; - - // Combine all relevant fields - hash_combine(s.R); - hash_combine(s.Cin); - hash_combine(s.Cout); - hash_combine(s.Cinternal); - hash_combine(s.Tdel); - hash_combine(s.mux_trans_size); - hash_combine(s.buf_size); - hash_combine(static_cast(s.power_buffer_type)); - hash_combine(s.power_buffer_size); - hash_combine(s.intra_tile); - hash_combine(static_cast(s.type())); - - return seed; - } -}; - -struct t_rr_switch_inf_equal { - bool operator()(const t_rr_switch_inf& lhs, const t_rr_switch_inf& rhs) const { - return lhs.R == rhs.R && - lhs.Cin == rhs.Cin && - lhs.Cout == rhs.Cout && - lhs.Cinternal == rhs.Cinternal && - lhs.Tdel == rhs.Tdel && - lhs.mux_trans_size == rhs.mux_trans_size && - lhs.buf_size == rhs.buf_size && - lhs.power_buffer_type == rhs.power_buffer_type && - lhs.power_buffer_size == rhs.power_buffer_size && - lhs.intra_tile == rhs.intra_tile && - lhs.type() == rhs.type(); - } -}; - void load_rr_edge_delay_overrides(std::string_view filename, RRGraphBuilder& rr_graph_builder, const RRGraphView& rr_graph) { std::ifstream file(filename.data()); VTR_LOGV_ERROR(!file, "Failed to open the RR edge override file: %s\n", filename.data()); - std::unordered_map unique_switch_info; + std::unordered_map unique_switch_info; for (const auto& [rr_sw_idx, sw] : rr_graph.rr_switch().pairs()) { unique_switch_info.insert({sw, rr_sw_idx}); } From df627ce93be0b0d47ead8f43aa4c361d63c47f7b Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 9 Apr 2025 12:54:02 -0400 Subject: [PATCH 20/28] add test_read_rr_edge_override.txt --- vpr/test/test_read_rr_edge_override.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 vpr/test/test_read_rr_edge_override.txt diff --git a/vpr/test/test_read_rr_edge_override.txt b/vpr/test/test_read_rr_edge_override.txt new file mode 100644 index 00000000000..05cccc8cbb9 --- /dev/null +++ b/vpr/test/test_read_rr_edge_override.txt @@ -0,0 +1,9 @@ +# edge Tdel +12 5.9e-11 +1586 4.2e-11 +1111 7.1e-11 +1324 9.4e-11 +(645, 127) 7.3e-11 +(591, 347) 7.9e-11 +(544, 45) 8.3e-11 +(37 , 511) 9.5e-11 \ No newline at end of file From 4110acdbd8c494c9b6e8de9a5d58d36c1c40e3bc Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 9 Apr 2025 12:56:15 -0400 Subject: [PATCH 21/28] make format --- libs/libarchfpga/src/physical_types.cpp | 23 +++++++++++------------ vpr/test/test_vpr.cpp | 10 +++++----- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/libs/libarchfpga/src/physical_types.cpp b/libs/libarchfpga/src/physical_types.cpp index 6984dfdff11..ad253c4b556 100644 --- a/libs/libarchfpga/src/physical_types.cpp +++ b/libs/libarchfpga/src/physical_types.cpp @@ -72,17 +72,17 @@ bool t_rr_switch_inf::configurable() const { } bool t_rr_switch_inf::operator==(const t_rr_switch_inf& other) const { - return R == other.R && - Cin == other.Cin && - Cout == other.Cout && - Cinternal == other.Cinternal && - Tdel == other.Tdel && - mux_trans_size == other.mux_trans_size && - buf_size == other.buf_size && - power_buffer_type == other.power_buffer_type && - power_buffer_size == other.power_buffer_size && - intra_tile == other.intra_tile && - type() == other.type(); + return R == other.R + && Cin == other.Cin + && Cout == other.Cout + && Cinternal == other.Cinternal + && Tdel == other.Tdel + && mux_trans_size == other.mux_trans_size + && buf_size == other.buf_size + && power_buffer_type == other.power_buffer_type + && power_buffer_size == other.power_buffer_size + && intra_tile == other.intra_tile + && type() == other.type(); } std::size_t t_rr_switch_inf::Hasher::operator()(const t_rr_switch_inf& s) const { @@ -111,7 +111,6 @@ void t_rr_switch_inf::set_type(SwitchType type_val) { type_ = type_val; } - static bool switch_type_is_buffered(SwitchType type) { //Muxes and Tristates isolate their input and output into //separate DC connected sub-circuits diff --git a/vpr/test/test_vpr.cpp b/vpr/test/test_vpr.cpp index ddd408ae815..31f647936f3 100644 --- a/vpr/test/test_vpr.cpp +++ b/vpr/test/test_vpr.cpp @@ -236,18 +236,18 @@ TEST_CASE("read_rr_edge_override", "[vpr]") { const std::string RR_GRAPH_NAME = "test_read_rr_edge_override"; const std::string RR_EDGE_OVERRIDE_FILENAME = "test_read_rr_edge_override.txt"; - const std::array file_extensions {".xml", ".bin"}; + const std::array file_extensions{".xml", ".bin"}; // We test both xml and binary file formats for (const std::string& file_extension : file_extensions) { - std::string rr_graph_filename = RR_GRAPH_NAME + file_extension ; - std::string overridden_rr_graph_filename = RR_GRAPH_NAME + "_overridden" + file_extension ; + std::string rr_graph_filename = RR_GRAPH_NAME + file_extension; + std::string overridden_rr_graph_filename = RR_GRAPH_NAME + "_overridden" + file_extension; RRNodeId src_inode = RRNodeId::INVALID(); RRNodeId sink_inode = RRNodeId::INVALID(); short switch_id = -1; - { // Generate an RR graph and write it out + { // Generate an RR graph and write it out t_vpr_setup vpr_setup; t_arch arch; t_options options; @@ -299,7 +299,7 @@ TEST_CASE("read_rr_edge_override", "[vpr]") { REQUIRE(sink_inode.is_valid()); REQUIRE(switch_id != -1); - { // Override edge attributes + { // Override edge attributes t_vpr_setup vpr_setup; t_arch arch; t_options options; From 010b0acc47015969043c33d0b7c27042fc79c4e2 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Wed, 9 Apr 2025 15:11:47 -0400 Subject: [PATCH 22/28] init value of false for load_flat_placement --- vpr/src/base/vpr_types.h | 2 +- vpr/test/test_connection_router.cpp | 3 +-- vpr/test/test_vpr.cpp | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/vpr/src/base/vpr_types.h b/vpr/src/base/vpr_types.h index 6cc697ebdaa..91fa2349a5e 100644 --- a/vpr/src/base/vpr_types.h +++ b/vpr/src/base/vpr_types.h @@ -736,7 +736,7 @@ struct t_packer_opts { bool use_attraction_groups; int pack_num_moves; std::string pack_move_type; - bool load_flat_placement; + bool load_flat_placement = false; }; /** diff --git a/vpr/test/test_connection_router.cpp b/vpr/test/test_connection_router.cpp index fbf1a63e142..bc7bdb2332d 100644 --- a/vpr/test/test_connection_router.cpp +++ b/vpr/test/test_connection_router.cpp @@ -143,8 +143,7 @@ TEST_CASE("connection_router", "[vpr]") { kArchFile, "wire.eblif", "--route_chan_width", "100"}; - vpr_init(sizeof(argv) / sizeof(argv[0]), argv, - &options, &vpr_setup, &arch); + vpr_init(sizeof(argv) / sizeof(argv[0]), argv, &options, &vpr_setup, &arch); vpr_create_device_grid(vpr_setup, arch); vpr_setup_clock_networks(vpr_setup, arch); diff --git a/vpr/test/test_vpr.cpp b/vpr/test/test_vpr.cpp index 31f647936f3..c05d33e54f9 100644 --- a/vpr/test/test_vpr.cpp +++ b/vpr/test/test_vpr.cpp @@ -257,8 +257,7 @@ TEST_CASE("read_rr_edge_override", "[vpr]") { "wire.eblif", "--route_chan_width", "100"}; - vpr_init(sizeof(argv) / sizeof(argv[0]), argv, - &options, &vpr_setup, &arch); + vpr_init(sizeof(argv) / sizeof(argv[0]), argv, &options, &vpr_setup, &arch); vpr_create_device(vpr_setup, arch); const auto& device_ctx = g_vpr_ctx.device(); From 9f06be2cadb68892aa93ee0b6c41e313ebf54865 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Tue, 15 Apr 2025 12:30:15 -0400 Subject: [PATCH 23/28] apply PR comments --- libs/libarchfpga/src/physical_types.cpp | 8 +++--- libs/libarchfpga/src/physical_types.h | 6 +++++ libs/librrgraph/src/base/rr_graph_builder.h | 3 ++- libs/librrgraph/src/base/rr_graph_storage.h | 5 ++-- libs/librrgraph/src/io/rr_graph_reader.cpp | 29 ++++++++------------- vpr/src/base/vpr_context.h | 6 +++-- vpr/src/base/vpr_types.h | 2 +- 7 files changed, 31 insertions(+), 28 deletions(-) diff --git a/libs/libarchfpga/src/physical_types.cpp b/libs/libarchfpga/src/physical_types.cpp index ad253c4b556..9b72cb95758 100644 --- a/libs/libarchfpga/src/physical_types.cpp +++ b/libs/libarchfpga/src/physical_types.cpp @@ -86,10 +86,10 @@ bool t_rr_switch_inf::operator==(const t_rr_switch_inf& other) const { } std::size_t t_rr_switch_inf::Hasher::operator()(const t_rr_switch_inf& s) const { - std::size_t seed = 0; + std::size_t hash_val = 0; - auto hash_combine = [&seed](auto&& val) { - seed ^= std::hash>{}(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2); + auto hash_combine = [&hash_val](auto&& val) { + hash_val ^= std::hash>{}(val) + 0x9e3779b9 + (hash_val << 6) + (hash_val >> 2); }; hash_combine(s.R); @@ -104,7 +104,7 @@ std::size_t t_rr_switch_inf::Hasher::operator()(const t_rr_switch_inf& s) const hash_combine(s.intra_tile); hash_combine(static_cast(s.type())); - return seed; + return hash_val; } void t_rr_switch_inf::set_type(SwitchType type_val) { diff --git a/libs/libarchfpga/src/physical_types.h b/libs/libarchfpga/src/physical_types.h index 2a69b3532f1..32bab928ced 100644 --- a/libs/libarchfpga/src/physical_types.h +++ b/libs/libarchfpga/src/physical_types.h @@ -1929,6 +1929,12 @@ struct t_rr_switch_inf { bool operator==(const t_rr_switch_inf& other) const; + /** + * @brief Functor for computing a hash value for t_rr_switch_inf. + * + * This custom hasher enables the use of t_rr_switch_inf objects as keys + * in unordered containers such as std::unordered_map or std::unordered_set. + */ struct Hasher { std::size_t operator()(const t_rr_switch_inf& s) const; }; diff --git a/libs/librrgraph/src/base/rr_graph_builder.h b/libs/librrgraph/src/base/rr_graph_builder.h index 9e72bde0c41..4844a785d70 100644 --- a/libs/librrgraph/src/base/rr_graph_builder.h +++ b/libs/librrgraph/src/base/rr_graph_builder.h @@ -264,7 +264,8 @@ class RRGraphBuilder { node_storage_.alloc_and_load_edges(rr_edges_to_create); } - /** @brief Overrides the associated switch for a given edge. */ + /** @brief Overrides the associated switch for a given edge by + * updating the edge to use the passed in switch. */ inline void override_edge_switch(RREdgeId edge_id, RRSwitchId switch_id) { node_storage_.override_edge_switch(edge_id, switch_id); } diff --git a/libs/librrgraph/src/base/rr_graph_storage.h b/libs/librrgraph/src/base/rr_graph_storage.h index 533bb414735..ac6bece7526 100644 --- a/libs/librrgraph/src/base/rr_graph_storage.h +++ b/libs/librrgraph/src/base/rr_graph_storage.h @@ -401,7 +401,7 @@ class t_rr_graph_storage { } /** - * @brief Retrieve the RREdgeId that connect the given source and sink nodes. + * @brief Retrieve the RREdgeId that connects the given source and sink nodes. * If the given source/sink nodes are not connected, RREdgeId::INVALID() is returned. */ RREdgeId edge_id(RRNodeId src, RRNodeId sink) const { @@ -744,7 +744,8 @@ class t_rr_graph_storage { */ void partition_edges(const vtr::vector& rr_switches); - /** @brief Overrides the associated switch for a given edge. */ + /** @brief Overrides the associated switch for a given edge by + * updating the edge to use the passed in switch. */ void override_edge_switch(RREdgeId edge_id, RRSwitchId switch_id); /** @brief Validate that edge data is partitioned correctly.*/ diff --git a/libs/librrgraph/src/io/rr_graph_reader.cpp b/libs/librrgraph/src/io/rr_graph_reader.cpp index b2153955f07..97318dc0eb3 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.cpp +++ b/libs/librrgraph/src/io/rr_graph_reader.cpp @@ -20,6 +20,7 @@ #include #include +#include #include "vtr_time.h" #include "pugixml.hpp" @@ -38,13 +39,11 @@ * (source_node_id, sink_node_id) Tdel * * @param line The line to parse. - * @param overridden_Tdel Parsed override delay. * @param rr_graph The RR graph for edge lookup using source-sink nodes. - * @return The RR edge whose attributes are to be overridden. + * @return A pair containing an RR edge and the overridden Tdel (intrinsic delay). */ -static RREdgeId process_rr_edge_override(const std::string& line, - float& overridden_Tdel, - const RRGraphView& rr_graph); +static std::pair process_rr_edge_override(const std::string& line, + const RRGraphView& rr_graph); /************************ Subroutine definitions ****************************/ /* loads the given RR_graph file into the appropriate data structures @@ -134,9 +133,8 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, } } -static RREdgeId process_rr_edge_override(const std::string& line, - float& overridden_Tdel, - const RRGraphView& rr_graph) { +static std::pair process_rr_edge_override(const std::string& line, + const RRGraphView& rr_graph) { std::istringstream iss(line); char ch; RREdgeId edge_id; @@ -165,11 +163,12 @@ static RREdgeId process_rr_edge_override(const std::string& line, VTR_LOG_ERROR("Invalid line format: %s\n", line.c_str()); } + float overridden_Tdel; if (!(iss >> overridden_Tdel)) { VTR_LOG_ERROR("Couldn't parse the overridden delay in this line: %s\n", line.c_str()); } - return edge_id; + return {edge_id, overridden_Tdel}; } void load_rr_edge_delay_overrides(std::string_view filename, @@ -184,20 +183,14 @@ void load_rr_edge_delay_overrides(std::string_view filename, } std::string line; - bool firstLine = true; while (std::getline(file, line)) { - if (firstLine) { - if (line.empty() || line[0] != '#') { - VTR_LOG_ERROR("Error: First line must start with #\n"); - } - firstLine = false; - continue; // Ignore first line + if (line[0] == '#') { + continue; // Ignore lines starting with '#' } if (!line.empty()) { - float overridden_Tdel; - RREdgeId edge_id = process_rr_edge_override(line, overridden_Tdel, rr_graph); + const auto [edge_id, overridden_Tdel] = process_rr_edge_override(line, rr_graph); RRSwitchId curr_switch_id = (RRSwitchId)rr_graph.edge_switch(edge_id); t_rr_switch_inf switch_override_info = rr_graph.rr_switch_inf(curr_switch_id); diff --git a/vpr/src/base/vpr_context.h b/vpr/src/base/vpr_context.h index b7d552a6cb0..3a5ca67df21 100644 --- a/vpr/src/base/vpr_context.h +++ b/vpr/src/base/vpr_context.h @@ -270,11 +270,13 @@ struct DeviceContext : public Context { t_clock_arch* clock_arch; /// @brief Name of rrgraph file read (if any). - /// Used to determine if the file is already loaded when reading rrgraph. + /// Used to determine if the specified rr-graph file is already loaded, + /// so we can avoid redundant reading of the rr-graph std::string loaded_rr_graph_filename; /// @brief Name of rrgraph edge override file read (if any). - /// Used to determine if the file is already loaded when reading rrgraph edge overrides. + /// Used to determine if the specified rr-graph edge override file is already loaded, + /// so we can avoid redundant reading of the rr-graph std::string loaded_rr_edge_override_filename; /******************************************************************* diff --git a/vpr/src/base/vpr_types.h b/vpr/src/base/vpr_types.h index d11619c74ef..ac522e69bb1 100644 --- a/vpr/src/base/vpr_types.h +++ b/vpr/src/base/vpr_types.h @@ -1315,7 +1315,7 @@ struct t_noc_opts { * Only important if the route_type is DETAILED. */ struct t_det_routing_arch { - /// Should the tracks be uni-directional or bi-directional? (UDSD by AY) + /// Should the tracks be uni-directional or bi-directional? enum e_directionality directionality; int Fs; From 5da6cf7c4c9074477bfbfab85ba85ea99b5325cd Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Tue, 15 Apr 2025 12:42:47 -0400 Subject: [PATCH 24/28] add the requested comments --- libs/librrgraph/src/io/rr_graph_reader.h | 5 +++++ vpr/src/base/read_options.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/librrgraph/src/io/rr_graph_reader.h b/libs/librrgraph/src/io/rr_graph_reader.h index 1814700a673..c85f9747cbd 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.h +++ b/libs/librrgraph/src/io/rr_graph_reader.h @@ -41,6 +41,11 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, * @details This function tries to find a switch with the overridden delay. If such a * switch exists, the edge will point to it as its corresponding switch. * Otherwise, a new switch is created so that the edge can point to a valid switch. + * The architecture file allows the user to specify nominal switch delays, but delays + * may vary for the same switch type across the device. To represent switch delays + * more accurately, the user can specify multiple switch types in the architecture file + * and restrict each one to a region or a single location. Alternatively, the user can + * use this file to override edge delays. * * @param filename The text file to be ingested by this function. * @param rr_graph_builder Used to add switches and override switch IDs for edges. diff --git a/vpr/src/base/read_options.cpp b/vpr/src/base/read_options.cpp index 728958be8b6..4451dd720cd 100644 --- a/vpr/src/base/read_options.cpp +++ b/vpr/src/base/read_options.cpp @@ -1775,8 +1775,11 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio .show_in(argparse::ShowIn::HELP_ONLY); file_grp.add_argument(args.read_rr_edge_override_file, "--read_rr_edge_override") - .help( - "The routing resource edge attributes override file to load.") + .help("The routing resource edge attributes override file to load. " + "This file overrides edge attributes in the routing resource graph. " + "The user can use the architecture file to specify nominal switch delays, " + "while this file can be used to override the nominal delays to make it more accurate " + "for specific edges.") .show_in(argparse::ShowIn::HELP_ONLY); file_grp.add_argument(args.write_rr_graph_file, "--write_rr_graph") From 8c960f97523acaf32c15cc827a6cc60ba7ff31c0 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Tue, 15 Apr 2025 13:08:10 -0400 Subject: [PATCH 25/28] update file_formats.rst --- doc/src/vpr/file_formats.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/src/vpr/file_formats.rst b/doc/src/vpr/file_formats.rst index dc76e2ff5ea..ede02b9a399 100644 --- a/doc/src/vpr/file_formats.rst +++ b/doc/src/vpr/file_formats.rst @@ -1100,6 +1100,27 @@ To aid in handling large graphs, rr_graph files can also be :ref:`saved in Date: Tue, 15 Apr 2025 15:51:10 -0400 Subject: [PATCH 26/28] add --read_rr_edge_override to command_line_usage.rst --- doc/src/vpr/command_line_usage.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/src/vpr/command_line_usage.rst b/doc/src/vpr/command_line_usage.rst index 6070663eddc..65da468d2e2 100644 --- a/doc/src/vpr/command_line_usage.rst +++ b/doc/src/vpr/command_line_usage.rst @@ -379,6 +379,20 @@ Use the options below to override this default naming behaviour. .. seealso:: :ref:`Routing Resource XML File `. +.. option:: --read_rr_edge_override + + Reads in the routing resource edge override file. This file overrides the intrinsic delay of selected edges. + + This option is intended to be used with both :option:`--read_rr_graph` and :option:`--write_rr_graph` to read the RR graph, + update the delay of selected edges specified by :option:`--read_rr_edge_override`, and write out the updated RR graph. Once + this is done, the output RR graph can be fed into VPR for subsequent runs. + + Reads a file that overrides the intrinsic delay of specific edges in RR graph. + + This option should be used with both :option:`--read_rr_graph` and :option:`--write_rr_graph`. When used this way, + VPR reads the RR graph, updates the delays of selected edges using :option:`--read_rr_edge_override`, + and writes the updated RR graph. The modified RR graph can then be used in later VPR runs. + .. option:: --read_vpr_constraints Reads the :ref:`VPR constraints ` that the flow must respect from the specified XML file. From eac8bfc3c9a508ccf58033b82313564dc3c81675 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Tue, 15 Apr 2025 16:22:59 -0400 Subject: [PATCH 27/28] remove duplicate text in command_line_usage.rst --- doc/src/vpr/command_line_usage.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/doc/src/vpr/command_line_usage.rst b/doc/src/vpr/command_line_usage.rst index 65da468d2e2..f21ee85f1eb 100644 --- a/doc/src/vpr/command_line_usage.rst +++ b/doc/src/vpr/command_line_usage.rst @@ -381,12 +381,6 @@ Use the options below to override this default naming behaviour. .. option:: --read_rr_edge_override - Reads in the routing resource edge override file. This file overrides the intrinsic delay of selected edges. - - This option is intended to be used with both :option:`--read_rr_graph` and :option:`--write_rr_graph` to read the RR graph, - update the delay of selected edges specified by :option:`--read_rr_edge_override`, and write out the updated RR graph. Once - this is done, the output RR graph can be fed into VPR for subsequent runs. - Reads a file that overrides the intrinsic delay of specific edges in RR graph. This option should be used with both :option:`--read_rr_graph` and :option:`--write_rr_graph`. When used this way, From d39029108efd3ab7a84106fe03d882a1610e3d4e Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Sun, 20 Apr 2025 17:47:53 -0400 Subject: [PATCH 28/28] explain what RR edge override feature is useful for --- doc/src/vpr/file_formats.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/src/vpr/file_formats.rst b/doc/src/vpr/file_formats.rst index ede02b9a399..32fbb0dfc93 100644 --- a/doc/src/vpr/file_formats.rst +++ b/doc/src/vpr/file_formats.rst @@ -1120,7 +1120,8 @@ Lines starting with # are comments and ignored. Each other line should specify e a source/sink node pair and its delay. This allows more accurate modeling of switch delays in the RR graph without creating many switch types -in the architecture file and limiting them to small regions. +in the architecture file and limiting them to small regions. This can be useful for more detailed modeling of +a fabricated FPGA where layout differences lead to small delay differences in the same type of routing switch. Network-on-Chip (NoC) Traffic Flows Format (.flows) ---------------------------------------------------