From 0cfed30d0d1803a0cef6f3f92f9fdb3fd84e035c Mon Sep 17 00:00:00 2001 From: Raza Jafari Date: Thu, 16 Dec 2021 14:44:09 +0500 Subject: [PATCH 1/8] after adding api --- vpr/src/device/rr_graph_builder.cpp | 87 +++++++++++++++++++++++++++++ vpr/src/device/rr_graph_builder.h | 2 + vpr/src/route/rr_graph_util.cpp | 5 +- 3 files changed, 93 insertions(+), 1 deletion(-) diff --git a/vpr/src/device/rr_graph_builder.cpp b/vpr/src/device/rr_graph_builder.cpp index 6cf28ca276c..c4bf7cf22f5 100644 --- a/vpr/src/device/rr_graph_builder.cpp +++ b/vpr/src/device/rr_graph_builder.cpp @@ -1,5 +1,8 @@ #include "vtr_log.h" #include "rr_graph_builder.h" +#include "vtr_time.h" +#include +#include "globals.h" RRGraphBuilder::RRGraphBuilder(t_rr_graph_storage* node_storage) : node_storage_(*node_storage) { @@ -50,3 +53,87 @@ void RRGraphBuilder::add_node_to_all_locs(RRNodeId node) { void RRGraphBuilder::clear() { node_lookup_.clear(); } + +// Reorder RRNodeId's using one of these algorithms: +// - DONT_REORDER: The identity reordering (does nothing.) +// - DEGREE_BFS: Order by degree primarily, and BFS traversal order secondarily. +// - RANDOM_SHUFFLE: Shuffle using the specified seed. Great for testing. +// The DEGREE_BFS algorithm was selected because it had the best performance of seven +// existing algorithms here: https://github.com/SymbiFlow/vtr-rrgraph-reordering-tool +// It might be worth further research, as the DEGREE_BFS algorithm is simple and +// makes some arbitrary choices, such as the starting node. +// Nonetheless, it does improve performance ~7% for the SymbiFlow Xilinx Artix 7 graph. +// +// NOTE: Re-ordering will invalidate any references to rr_graph nodes, so this +// should generally be called before creating such references. +void RRGraphBuilder::reorder_rr_graph_nodes_(const t_router_opts& router_opts) { + auto& device_ctx = g_vpr_ctx.mutable_device(); + auto& rr_graph = device_ctx.rr_graph; + size_t v_num = node_storage_.size(); + + if (router_opts.reorder_rr_graph_nodes_algorithm == DONT_REORDER) return; + if (router_opts.reorder_rr_graph_nodes_threshold < 0 || v_num < (size_t)router_opts.reorder_rr_graph_nodes_threshold) return; + + vtr::ScopedStartFinishTimer timer("Reordering rr_graph nodes"); + + vtr::vector src_order(v_num); // new id -> old id + size_t cur_idx = 0; + for (RRNodeId& n : src_order) { // Initialize to [0, 1, 2 ...] + n = RRNodeId(cur_idx++); + } + + // This method works well. The intution is that highly connected nodes are enumerated first (together), + // and since there will be a lot of nodes with the same degree, they are then ordered based on some + // distance from the starting node. + if (router_opts.reorder_rr_graph_nodes_algorithm == DEGREE_BFS) { + vtr::vector bfs_idx(v_num); + vtr::vector degree(v_num); + std::queue que; + + // Compute both degree (in + out) and an index based on the BFS traversal + cur_idx = 0; + for (size_t i = 0; i < v_num; ++i) { + if (bfs_idx[RRNodeId(i)]) continue; + que.push(RRNodeId(i)); + bfs_idx[RRNodeId(i)] = cur_idx++; + while (!que.empty()) { + RRNodeId u = que.front(); + que.pop(); + degree[u] += node_storage_.num_edges(u); + for (RREdgeId edge = rr_graph.node_first_edge(u); edge < rr_graph.node_last_edge(u); edge = RREdgeId(size_t(edge) + 1)) { + RRNodeId v = node_storage_.edge_sink_node(edge); + degree[v]++; + if (bfs_idx[v]) continue; + bfs_idx[v] = cur_idx++; + que.push(v); + } + } + } + + // Sort by degree primarily, and BFS order secondarily + sort(src_order.begin(), src_order.end(), + [&](auto a, auto b) -> bool { + auto deg_a = degree[a]; + auto deg_b = degree[b]; + return deg_a > deg_b || (deg_a == deg_b && bfs_idx[a] < bfs_idx[b]); + }); + } else if (router_opts.reorder_rr_graph_nodes_algorithm == RANDOM_SHUFFLE) { + std::mt19937 g(router_opts.reorder_rr_graph_nodes_seed); + std::shuffle(src_order.begin(), src_order.end(), g); + } + vtr::vector dest_order(v_num); + cur_idx = 0; + for (auto u : src_order) + dest_order[u] = RRNodeId(cur_idx++); + + node_storage_.reorder(dest_order, src_order); + + node_lookup().reorder(dest_order); + + device_ctx.rr_node_metadata.remap_keys([&](int node) { return size_t(dest_order[RRNodeId(node)]); }); + device_ctx.rr_edge_metadata.remap_keys([&](std::tuple edge) { + return std::make_tuple(size_t(dest_order[RRNodeId(std::get<0>(edge))]), + size_t(dest_order[RRNodeId(std::get<1>(edge))]), + std::get<2>(edge)); + }); +} diff --git a/vpr/src/device/rr_graph_builder.h b/vpr/src/device/rr_graph_builder.h index 66fa3e94c28..81f00bbc47c 100644 --- a/vpr/src/device/rr_graph_builder.h +++ b/vpr/src/device/rr_graph_builder.h @@ -59,6 +59,8 @@ class RRGraphBuilder { /** @brief Clear all the underlying data storage */ void clear(); + void reorder_rr_graph_nodes_(const t_router_opts& router_opts); + /** @brief Set capacity of this node (number of routes that can use it). */ inline void set_node_capacity(RRNodeId id, short new_capacity) { node_storage_.set_node_capacity(id, new_capacity); diff --git a/vpr/src/route/rr_graph_util.cpp b/vpr/src/route/rr_graph_util.cpp index 84b89c6e47c..834742efba1 100644 --- a/vpr/src/route/rr_graph_util.cpp +++ b/vpr/src/route/rr_graph_util.cpp @@ -96,6 +96,9 @@ int seg_index_of_sblock(int from_node, int to_node) { // NOTE: Re-ordering will invalidate any references to rr_graph nodes, so this // should generally be called before creating such references. void reorder_rr_graph_nodes(const t_router_opts& router_opts) { + return reorder_rr_graph_nodes (router_opts); +} + /* auto& device_ctx = g_vpr_ctx.mutable_device(); auto& graph = device_ctx.rr_nodes; auto& rr_graph = device_ctx.rr_graph; @@ -167,7 +170,7 @@ void reorder_rr_graph_nodes(const t_router_opts& router_opts) { std::get<2>(edge)); }); } - +*/ vtr::vector> get_fan_in_list() { auto& rr_nodes = g_vpr_ctx.device().rr_nodes; From 17f164c5350aed7c460855e662f5be68bb67bf4f Mon Sep 17 00:00:00 2001 From: Raza Jafari Date: Fri, 17 Dec 2021 16:27:28 +0500 Subject: [PATCH 2/8] Completely removing the function from rr_graph_util --- vpr/src/device/rr_graph_builder.cpp | 14 +---- vpr/src/device/rr_graph_builder.h | 14 ++++- vpr/src/route/rr_graph.cpp | 6 +- vpr/src/route/rr_graph_util.cpp | 88 ----------------------------- vpr/src/route/rr_graph_util.h | 2 +- 5 files changed, 19 insertions(+), 105 deletions(-) diff --git a/vpr/src/device/rr_graph_builder.cpp b/vpr/src/device/rr_graph_builder.cpp index c4bf7cf22f5..969b122f82a 100644 --- a/vpr/src/device/rr_graph_builder.cpp +++ b/vpr/src/device/rr_graph_builder.cpp @@ -54,19 +54,7 @@ void RRGraphBuilder::clear() { node_lookup_.clear(); } -// Reorder RRNodeId's using one of these algorithms: -// - DONT_REORDER: The identity reordering (does nothing.) -// - DEGREE_BFS: Order by degree primarily, and BFS traversal order secondarily. -// - RANDOM_SHUFFLE: Shuffle using the specified seed. Great for testing. -// The DEGREE_BFS algorithm was selected because it had the best performance of seven -// existing algorithms here: https://github.com/SymbiFlow/vtr-rrgraph-reordering-tool -// It might be worth further research, as the DEGREE_BFS algorithm is simple and -// makes some arbitrary choices, such as the starting node. -// Nonetheless, it does improve performance ~7% for the SymbiFlow Xilinx Artix 7 graph. -// -// NOTE: Re-ordering will invalidate any references to rr_graph nodes, so this -// should generally be called before creating such references. -void RRGraphBuilder::reorder_rr_graph_nodes_(const t_router_opts& router_opts) { +void RRGraphBuilder::reorder_rr_graph_nodes(const t_router_opts& router_opts) { auto& device_ctx = g_vpr_ctx.mutable_device(); auto& rr_graph = device_ctx.rr_graph; size_t v_num = node_storage_.size(); diff --git a/vpr/src/device/rr_graph_builder.h b/vpr/src/device/rr_graph_builder.h index 81f00bbc47c..adadaa9dbfc 100644 --- a/vpr/src/device/rr_graph_builder.h +++ b/vpr/src/device/rr_graph_builder.h @@ -59,7 +59,19 @@ class RRGraphBuilder { /** @brief Clear all the underlying data storage */ void clear(); - void reorder_rr_graph_nodes_(const t_router_opts& router_opts); + // Reorder RRNodeId's using one of these algorithms: + // - DONT_REORDER: The identity reordering (does nothing.) + // - DEGREE_BFS: Order by degree primarily, and BFS traversal order secondarily. + // - RANDOM_SHUFFLE: Shuffle using the specified seed. Great for testing. + // The DEGREE_BFS algorithm was selected because it had the best performance of seven + // existing algorithms here: https://github.com/SymbiFlow/vtr-rrgraph-reordering-tool + // It might be worth further research, as the DEGREE_BFS algorithm is simple and + // makes some arbitrary choices, such as the starting node. + // Nonetheless, it does improve performance ~7% for the SymbiFlow Xilinx Artix 7 graph. + // + // NOTE: Re-ordering will invalidate any references to rr_graph nodes, so this + // should generally be called before creating such references. + void reorder_rr_graph_nodes(const t_router_opts& router_opts); /** @brief Set capacity of this node (number of routes that can use it). */ inline void set_node_capacity(RRNodeId id, short new_capacity) { diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index d63c447207a..db8636f16f9 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -34,6 +34,7 @@ #include "router_lookahead_map.h" #include "rr_graph_clock.h" #include "edge_groups.h" +#include "rr_graph_builder.h" #include "rr_types.h" @@ -313,6 +314,7 @@ void create_rr_graph(const t_graph_type graph_type, const int num_directs, int* Warnings) { const auto& device_ctx = g_vpr_ctx.device(); + auto& mutable_device_ctx = g_vpr_ctx.mutable_device(); if (!det_routing_arch->read_rr_graph_filename.empty()) { if (device_ctx.read_rr_graph_filename != det_routing_arch->read_rr_graph_filename) { @@ -327,7 +329,7 @@ void create_rr_graph(const t_graph_type graph_type, router_opts.read_rr_edge_metadata, router_opts.do_check_rr_graph); - reorder_rr_graph_nodes(router_opts); + mutable_device_ctx.rr_graph_builder.reorder_rr_graph_nodes(router_opts); } } else { if (channel_widths_unchanged(device_ctx.chan_width, nodes_per_chan) && !device_ctx.rr_nodes.empty()) { @@ -357,7 +359,7 @@ void create_rr_graph(const t_graph_type graph_type, directs, num_directs, &det_routing_arch->wire_to_rr_ipin_switch, Warnings); - reorder_rr_graph_nodes(router_opts); + mutable_device_ctx.rr_graph_builder.reorder_rr_graph_nodes(router_opts); } process_non_config_sets(); diff --git a/vpr/src/route/rr_graph_util.cpp b/vpr/src/route/rr_graph_util.cpp index 834742efba1..b1b23194353 100644 --- a/vpr/src/route/rr_graph_util.cpp +++ b/vpr/src/route/rr_graph_util.cpp @@ -83,94 +83,6 @@ int seg_index_of_sblock(int from_node, int to_node) { } } -// Reorder RRNodeId's using one of these algorithms: -// - DONT_REORDER: The identity reordering (does nothing.) -// - DEGREE_BFS: Order by degree primarily, and BFS traversal order secondarily. -// - RANDOM_SHUFFLE: Shuffle using the specified seed. Great for testing. -// The DEGREE_BFS algorithm was selected because it had the best performance of seven -// existing algorithms here: https://github.com/SymbiFlow/vtr-rrgraph-reordering-tool -// It might be worth further research, as the DEGREE_BFS algorithm is simple and -// makes some arbitrary choices, such as the starting node. -// Nonetheless, it does improve performance ~7% for the SymbiFlow Xilinx Artix 7 graph. -// -// NOTE: Re-ordering will invalidate any references to rr_graph nodes, so this -// should generally be called before creating such references. -void reorder_rr_graph_nodes(const t_router_opts& router_opts) { - return reorder_rr_graph_nodes (router_opts); -} - /* - auto& device_ctx = g_vpr_ctx.mutable_device(); - auto& graph = device_ctx.rr_nodes; - auto& rr_graph = device_ctx.rr_graph; - size_t v_num = graph.size(); - - if (router_opts.reorder_rr_graph_nodes_algorithm == DONT_REORDER) return; - if (router_opts.reorder_rr_graph_nodes_threshold < 0 || v_num < (size_t)router_opts.reorder_rr_graph_nodes_threshold) return; - - vtr::ScopedStartFinishTimer timer("Reordering rr_graph nodes"); - - vtr::vector src_order(v_num); // new id -> old id - size_t cur_idx = 0; - for (RRNodeId& n : src_order) { // Initialize to [0, 1, 2 ...] - n = RRNodeId(cur_idx++); - } - - // This method works well. The intution is that highly connected nodes are enumerated first (together), - // and since there will be a lot of nodes with the same degree, they are then ordered based on some - // distance from the starting node. - if (router_opts.reorder_rr_graph_nodes_algorithm == DEGREE_BFS) { - vtr::vector bfs_idx(v_num); - vtr::vector degree(v_num); - std::queue que; - - // Compute both degree (in + out) and an index based on the BFS traversal - cur_idx = 0; - for (size_t i = 0; i < v_num; ++i) { - if (bfs_idx[RRNodeId(i)]) continue; - que.push(RRNodeId(i)); - bfs_idx[RRNodeId(i)] = cur_idx++; - while (!que.empty()) { - RRNodeId u = que.front(); - que.pop(); - degree[u] += graph.num_edges(u); - for (RREdgeId edge = rr_graph.node_first_edge(u); edge < rr_graph.node_last_edge(u); edge = RREdgeId(size_t(edge) + 1)) { - RRNodeId v = graph.edge_sink_node(edge); - degree[v]++; - if (bfs_idx[v]) continue; - bfs_idx[v] = cur_idx++; - que.push(v); - } - } - } - - // Sort by degree primarily, and BFS order secondarily - sort(src_order.begin(), src_order.end(), - [&](auto a, auto b) -> bool { - auto deg_a = degree[a]; - auto deg_b = degree[b]; - return deg_a > deg_b || (deg_a == deg_b && bfs_idx[a] < bfs_idx[b]); - }); - } else if (router_opts.reorder_rr_graph_nodes_algorithm == RANDOM_SHUFFLE) { - std::mt19937 g(router_opts.reorder_rr_graph_nodes_seed); - std::shuffle(src_order.begin(), src_order.end(), g); - } - vtr::vector dest_order(v_num); - cur_idx = 0; - for (auto u : src_order) - dest_order[u] = RRNodeId(cur_idx++); - - graph.reorder(dest_order, src_order); - - device_ctx.rr_graph_builder.node_lookup().reorder(dest_order); - - device_ctx.rr_node_metadata.remap_keys([&](int node) { return size_t(dest_order[RRNodeId(node)]); }); - device_ctx.rr_edge_metadata.remap_keys([&](std::tuple edge) { - return std::make_tuple(size_t(dest_order[RRNodeId(std::get<0>(edge))]), - size_t(dest_order[RRNodeId(std::get<1>(edge))]), - std::get<2>(edge)); - }); -} -*/ vtr::vector> get_fan_in_list() { auto& rr_nodes = g_vpr_ctx.device().rr_nodes; diff --git a/vpr/src/route/rr_graph_util.h b/vpr/src/route/rr_graph_util.h index 514f396f0d2..5bfe1c68197 100644 --- a/vpr/src/route/rr_graph_util.h +++ b/vpr/src/route/rr_graph_util.h @@ -7,7 +7,7 @@ int seg_index_of_cblock(t_rr_type from_rr_type, int to_node); int seg_index_of_sblock(int from_node, int to_node); -void reorder_rr_graph_nodes(const t_router_opts& router_opts); +//void reorder_rr_graph_nodes(const t_router_opts& router_opts); // This function generates and returns a vector indexed by RRNodeId // containing a list of fan-in edges for each node. From 0d9b9ddb2ec1cfe2555a3229bb7be1d852281e66 Mon Sep 17 00:00:00 2001 From: Raza Jafari Date: Mon, 20 Dec 2021 15:21:48 +0500 Subject: [PATCH 3/8] (All done except one) --- vpr/src/device/rr_graph_builder.cpp | 18 ++++++++++-------- vpr/src/device/rr_graph_builder.h | 2 +- vpr/src/route/rr_graph.cpp | 9 ++++++--- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/vpr/src/device/rr_graph_builder.cpp b/vpr/src/device/rr_graph_builder.cpp index 969b122f82a..bd0aa5caf10 100644 --- a/vpr/src/device/rr_graph_builder.cpp +++ b/vpr/src/device/rr_graph_builder.cpp @@ -2,7 +2,8 @@ #include "rr_graph_builder.h" #include "vtr_time.h" #include -#include "globals.h" +#include "vpr_context.h" +//#include "globals.h" RRGraphBuilder::RRGraphBuilder(t_rr_graph_storage* node_storage) : node_storage_(*node_storage) { @@ -54,12 +55,13 @@ void RRGraphBuilder::clear() { node_lookup_.clear(); } -void RRGraphBuilder::reorder_rr_graph_nodes(const t_router_opts& router_opts) { - auto& device_ctx = g_vpr_ctx.mutable_device(); - auto& rr_graph = device_ctx.rr_graph; +void RRGraphBuilder::reorder_nodes(const t_router_opts& router_opts) { + //auto& device_ctx = g_vpr_ctx.mutable_device(); + //auto& rr_graph = device_ctx.rr_graph; size_t v_num = node_storage_.size(); + DeviceContext deviceContext_; - if (router_opts.reorder_rr_graph_nodes_algorithm == DONT_REORDER) return; + //if (router_opts.reorder_rr_graph_nodes_algorithm == DONT_REORDER) return; if (router_opts.reorder_rr_graph_nodes_threshold < 0 || v_num < (size_t)router_opts.reorder_rr_graph_nodes_threshold) return; vtr::ScopedStartFinishTimer timer("Reordering rr_graph nodes"); @@ -88,7 +90,7 @@ void RRGraphBuilder::reorder_rr_graph_nodes(const t_router_opts& router_opts) { RRNodeId u = que.front(); que.pop(); degree[u] += node_storage_.num_edges(u); - for (RREdgeId edge = rr_graph.node_first_edge(u); edge < rr_graph.node_last_edge(u); edge = RREdgeId(size_t(edge) + 1)) { + for (RREdgeId edge = node_storage_.first_edge(u); edge < node_storage_.last_edge(u); edge = RREdgeId(size_t(edge) + 1)) { RRNodeId v = node_storage_.edge_sink_node(edge); degree[v]++; if (bfs_idx[v]) continue; @@ -118,8 +120,8 @@ void RRGraphBuilder::reorder_rr_graph_nodes(const t_router_opts& router_opts) { node_lookup().reorder(dest_order); - device_ctx.rr_node_metadata.remap_keys([&](int node) { return size_t(dest_order[RRNodeId(node)]); }); - device_ctx.rr_edge_metadata.remap_keys([&](std::tuple edge) { + deviceContext_.rr_node_metadata.remap_keys([&](int node) { return size_t(dest_order[RRNodeId(node)]); }); + deviceContext_.rr_edge_metadata.remap_keys([&](std::tuple edge) { return std::make_tuple(size_t(dest_order[RRNodeId(std::get<0>(edge))]), size_t(dest_order[RRNodeId(std::get<1>(edge))]), std::get<2>(edge)); diff --git a/vpr/src/device/rr_graph_builder.h b/vpr/src/device/rr_graph_builder.h index adadaa9dbfc..2d2bf11e479 100644 --- a/vpr/src/device/rr_graph_builder.h +++ b/vpr/src/device/rr_graph_builder.h @@ -71,7 +71,7 @@ class RRGraphBuilder { // // NOTE: Re-ordering will invalidate any references to rr_graph nodes, so this // should generally be called before creating such references. - void reorder_rr_graph_nodes(const t_router_opts& router_opts); + void reorder_nodes(const t_router_opts& router_opts); /** @brief Set capacity of this node (number of routes that can use it). */ inline void set_node_capacity(RRNodeId id, short new_capacity) { diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index db8636f16f9..e242dc43c46 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -328,8 +328,9 @@ void create_rr_graph(const t_graph_type graph_type, det_routing_arch->read_rr_graph_filename.c_str(), router_opts.read_rr_edge_metadata, router_opts.do_check_rr_graph); - - mutable_device_ctx.rr_graph_builder.reorder_rr_graph_nodes(router_opts); + if (router_opts.reorder_rr_graph_nodes_algorithm != DONT_REORDER){ + mutable_device_ctx.rr_graph_builder.reorder_nodes(router_opts); + } } } else { if (channel_widths_unchanged(device_ctx.chan_width, nodes_per_chan) && !device_ctx.rr_nodes.empty()) { @@ -359,7 +360,9 @@ void create_rr_graph(const t_graph_type graph_type, directs, num_directs, &det_routing_arch->wire_to_rr_ipin_switch, Warnings); - mutable_device_ctx.rr_graph_builder.reorder_rr_graph_nodes(router_opts); + if (router_opts.reorder_rr_graph_nodes_algorithm != DONT_REORDER){ + mutable_device_ctx.rr_graph_builder.reorder_nodes(router_opts); + } } process_non_config_sets(); From 96f351b06371025d2b333566505e0e7ba97799c3 Mon Sep 17 00:00:00 2001 From: Raza Jafari Date: Mon, 20 Dec 2021 18:56:22 +0500 Subject: [PATCH 4/8] The changes recemended mainy the remove of globals.h and function arguments passing) --- vpr/src/device/rr_graph_builder.cpp | 12 +++++++----- vpr/src/device/rr_graph_builder.h | 28 ++++++++++++++-------------- vpr/src/route/rr_graph.cpp | 8 ++++---- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/vpr/src/device/rr_graph_builder.cpp b/vpr/src/device/rr_graph_builder.cpp index bd0aa5caf10..95ad1dbf9eb 100644 --- a/vpr/src/device/rr_graph_builder.cpp +++ b/vpr/src/device/rr_graph_builder.cpp @@ -55,14 +55,16 @@ void RRGraphBuilder::clear() { node_lookup_.clear(); } -void RRGraphBuilder::reorder_nodes(const t_router_opts& router_opts) { +void RRGraphBuilder::reorder_nodes(e_rr_node_reorder_algorithm reorder_rr_graph_nodes_algorithm, int reorder_rr_graph_nodes_threshold, int reorder_rr_graph_nodes_seed) { //auto& device_ctx = g_vpr_ctx.mutable_device(); //auto& rr_graph = device_ctx.rr_graph; size_t v_num = node_storage_.size(); DeviceContext deviceContext_; + //int reorder_rr_graph_nodes_threshold = 0; + // int reorder_rr_graph_nodes_seed = 1; //if (router_opts.reorder_rr_graph_nodes_algorithm == DONT_REORDER) return; - if (router_opts.reorder_rr_graph_nodes_threshold < 0 || v_num < (size_t)router_opts.reorder_rr_graph_nodes_threshold) return; + if (reorder_rr_graph_nodes_threshold < 0 || v_num < (size_t)reorder_rr_graph_nodes_threshold) return; vtr::ScopedStartFinishTimer timer("Reordering rr_graph nodes"); @@ -75,7 +77,7 @@ void RRGraphBuilder::reorder_nodes(const t_router_opts& router_opts) { // This method works well. The intution is that highly connected nodes are enumerated first (together), // and since there will be a lot of nodes with the same degree, they are then ordered based on some // distance from the starting node. - if (router_opts.reorder_rr_graph_nodes_algorithm == DEGREE_BFS) { + if (reorder_rr_graph_nodes_algorithm == DEGREE_BFS) { vtr::vector bfs_idx(v_num); vtr::vector degree(v_num); std::queue que; @@ -107,8 +109,8 @@ void RRGraphBuilder::reorder_nodes(const t_router_opts& router_opts) { auto deg_b = degree[b]; return deg_a > deg_b || (deg_a == deg_b && bfs_idx[a] < bfs_idx[b]); }); - } else if (router_opts.reorder_rr_graph_nodes_algorithm == RANDOM_SHUFFLE) { - std::mt19937 g(router_opts.reorder_rr_graph_nodes_seed); + } else if (reorder_rr_graph_nodes_algorithm == RANDOM_SHUFFLE) { + std::mt19937 g(reorder_rr_graph_nodes_seed); std::shuffle(src_order.begin(), src_order.end(), g); } vtr::vector dest_order(v_num); diff --git a/vpr/src/device/rr_graph_builder.h b/vpr/src/device/rr_graph_builder.h index 2d2bf11e479..dc9634b8fd4 100644 --- a/vpr/src/device/rr_graph_builder.h +++ b/vpr/src/device/rr_graph_builder.h @@ -58,20 +58,20 @@ class RRGraphBuilder { /** @brief Clear all the underlying data storage */ void clear(); - - // Reorder RRNodeId's using one of these algorithms: - // - DONT_REORDER: The identity reordering (does nothing.) - // - DEGREE_BFS: Order by degree primarily, and BFS traversal order secondarily. - // - RANDOM_SHUFFLE: Shuffle using the specified seed. Great for testing. - // The DEGREE_BFS algorithm was selected because it had the best performance of seven - // existing algorithms here: https://github.com/SymbiFlow/vtr-rrgraph-reordering-tool - // It might be worth further research, as the DEGREE_BFS algorithm is simple and - // makes some arbitrary choices, such as the starting node. - // Nonetheless, it does improve performance ~7% for the SymbiFlow Xilinx Artix 7 graph. - // - // NOTE: Re-ordering will invalidate any references to rr_graph nodes, so this - // should generally be called before creating such references. - void reorder_nodes(const t_router_opts& router_opts); + /** @brief reorder all the nodes + * Reorder RRNodeId's using one of these algorithms: + * - DEGREE_BFS: Order by degree primarily, and BFS traversal order secondarily. + * - RANDOM_SHUFFLE: Shuffle using the specified seed. Great for testing. + * The DEGREE_BFS algorithm was selected because it had the best performance of seven + * existing algorithms here: https://github.com/SymbiFlow/vtr-rrgraph-reordering-tool + * It might be worth further research, as the DEGREE_BFS algorithm is simple and + * makes some arbitrary choices, such as the starting node. + * Nonetheless, it does improve performance ~7% for the SymbiFlow Xilinx Artix 7 graph. + * + * NOTE: Re-ordering will invalidate any references to rr_graph nodes, so this + * should generally be called before creating such references. + */ + void reorder_nodes(e_rr_node_reorder_algorithm reorder_rr_graph_nodes_algorithm, int reorder_rr_graph_nodes_threshold, int reorder_rr_graph_nodes_seed); /** @brief Set capacity of this node (number of routes that can use it). */ inline void set_node_capacity(RRNodeId id, short new_capacity) { diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index e242dc43c46..701e46aa4b7 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -328,8 +328,8 @@ void create_rr_graph(const t_graph_type graph_type, det_routing_arch->read_rr_graph_filename.c_str(), router_opts.read_rr_edge_metadata, router_opts.do_check_rr_graph); - if (router_opts.reorder_rr_graph_nodes_algorithm != DONT_REORDER){ - mutable_device_ctx.rr_graph_builder.reorder_nodes(router_opts); + if (router_opts.reorder_rr_graph_nodes_algorithm != DONT_REORDER) { + mutable_device_ctx.rr_graph_builder.reorder_nodes(router_opts.reorder_rr_graph_nodes_algorithm, router_opts.reorder_rr_graph_nodes_threshold, router_opts.reorder_rr_graph_nodes_seed); } } } else { @@ -360,8 +360,8 @@ void create_rr_graph(const t_graph_type graph_type, directs, num_directs, &det_routing_arch->wire_to_rr_ipin_switch, Warnings); - if (router_opts.reorder_rr_graph_nodes_algorithm != DONT_REORDER){ - mutable_device_ctx.rr_graph_builder.reorder_nodes(router_opts); + if (router_opts.reorder_rr_graph_nodes_algorithm != DONT_REORDER) { + mutable_device_ctx.rr_graph_builder.reorder_nodes(router_opts.reorder_rr_graph_nodes_algorithm, router_opts.reorder_rr_graph_nodes_threshold, router_opts.reorder_rr_graph_nodes_seed); } } From d2a3d1aa9588305be05e840a0bc3c26654a44cd5 Mon Sep 17 00:00:00 2001 From: Raza Jafari Date: Tue, 21 Dec 2021 15:55:09 +0500 Subject: [PATCH 5/8] (removing the structure used and adding the globals back) --- vpr/src/device/rr_graph_builder.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vpr/src/device/rr_graph_builder.cpp b/vpr/src/device/rr_graph_builder.cpp index 95ad1dbf9eb..7f6297d38dc 100644 --- a/vpr/src/device/rr_graph_builder.cpp +++ b/vpr/src/device/rr_graph_builder.cpp @@ -2,8 +2,8 @@ #include "rr_graph_builder.h" #include "vtr_time.h" #include -#include "vpr_context.h" -//#include "globals.h" +//#include "vpr_context.h" +#include "globals.h" RRGraphBuilder::RRGraphBuilder(t_rr_graph_storage* node_storage) : node_storage_(*node_storage) { @@ -56,7 +56,7 @@ void RRGraphBuilder::clear() { } void RRGraphBuilder::reorder_nodes(e_rr_node_reorder_algorithm reorder_rr_graph_nodes_algorithm, int reorder_rr_graph_nodes_threshold, int reorder_rr_graph_nodes_seed) { - //auto& device_ctx = g_vpr_ctx.mutable_device(); + auto& device_ctx = g_vpr_ctx.mutable_device(); //auto& rr_graph = device_ctx.rr_graph; size_t v_num = node_storage_.size(); DeviceContext deviceContext_; @@ -122,8 +122,8 @@ void RRGraphBuilder::reorder_nodes(e_rr_node_reorder_algorithm reorder_rr_graph_ node_lookup().reorder(dest_order); - deviceContext_.rr_node_metadata.remap_keys([&](int node) { return size_t(dest_order[RRNodeId(node)]); }); - deviceContext_.rr_edge_metadata.remap_keys([&](std::tuple edge) { + device_ctx.rr_node_metadata.remap_keys([&](int node) { return size_t(dest_order[RRNodeId(node)]); }); + device_ctx.rr_edge_metadata.remap_keys([&](std::tuple edge) { return std::make_tuple(size_t(dest_order[RRNodeId(std::get<0>(edge))]), size_t(dest_order[RRNodeId(std::get<1>(edge))]), std::get<2>(edge)); From 72a35cb1788cee003b3e4e2c1b52073da725c292 Mon Sep 17 00:00:00 2001 From: Raza Jafari Date: Wed, 22 Dec 2021 16:46:23 +0500 Subject: [PATCH 6/8] (removing the globals from rr_graph_builder.cpp) --- vpr/src/base/vpr_context.h | 2 +- vpr/src/device/rr_graph_builder.cpp | 33 ++++++++++++++--------------- vpr/src/device/rr_graph_builder.h | 14 ++++++++++-- vpr/src/route/rr_graph.cpp | 9 +++++--- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/vpr/src/base/vpr_context.h b/vpr/src/base/vpr_context.h index 79af2c0401d..f7ea66e140f 100644 --- a/vpr/src/base/vpr_context.h +++ b/vpr/src/base/vpr_context.h @@ -163,7 +163,7 @@ struct DeviceContext : public Context { /* A writeable view of routing resource graph to be the ONLY database * for routing resource graph builder functions. */ - RRGraphBuilder rr_graph_builder{&rr_nodes}; + RRGraphBuilder rr_graph_builder{&rr_nodes, &rr_node_metadata, &rr_edge_metadata}; /* A read-only view of routing resource graph to be the ONLY database * for client functions: GUI, placer, router, timing analyzer etc. diff --git a/vpr/src/device/rr_graph_builder.cpp b/vpr/src/device/rr_graph_builder.cpp index 7f6297d38dc..f0c17151f47 100644 --- a/vpr/src/device/rr_graph_builder.cpp +++ b/vpr/src/device/rr_graph_builder.cpp @@ -2,12 +2,18 @@ #include "rr_graph_builder.h" #include "vtr_time.h" #include -//#include "vpr_context.h" -#include "globals.h" +#include +//#include -RRGraphBuilder::RRGraphBuilder(t_rr_graph_storage* node_storage) - : node_storage_(*node_storage) { -} +//#include "globals.h" + +RRGraphBuilder::RRGraphBuilder(t_rr_graph_storage* node_storage, + MetadataStorage* rr_node_metadata, + MetadataStorage>* rr_edge_metadata + ): node_storage_(*node_storage) + , rr_node_metadata_(*rr_node_metadata) + , rr_edge_metadata_(*rr_edge_metadata){ + } t_rr_graph_storage& RRGraphBuilder::node_storage() { return node_storage_; @@ -55,19 +61,12 @@ void RRGraphBuilder::clear() { node_lookup_.clear(); } -void RRGraphBuilder::reorder_nodes(e_rr_node_reorder_algorithm reorder_rr_graph_nodes_algorithm, int reorder_rr_graph_nodes_threshold, int reorder_rr_graph_nodes_seed) { - auto& device_ctx = g_vpr_ctx.mutable_device(); - //auto& rr_graph = device_ctx.rr_graph; +void RRGraphBuilder::reorder_nodes(e_rr_node_reorder_algorithm reorder_rr_graph_nodes_algorithm, + int reorder_rr_graph_nodes_threshold, + int reorder_rr_graph_nodes_seed) { size_t v_num = node_storage_.size(); - DeviceContext deviceContext_; - //int reorder_rr_graph_nodes_threshold = 0; - // int reorder_rr_graph_nodes_seed = 1; - - //if (router_opts.reorder_rr_graph_nodes_algorithm == DONT_REORDER) return; if (reorder_rr_graph_nodes_threshold < 0 || v_num < (size_t)reorder_rr_graph_nodes_threshold) return; - vtr::ScopedStartFinishTimer timer("Reordering rr_graph nodes"); - vtr::vector src_order(v_num); // new id -> old id size_t cur_idx = 0; for (RRNodeId& n : src_order) { // Initialize to [0, 1, 2 ...] @@ -122,8 +121,8 @@ void RRGraphBuilder::reorder_nodes(e_rr_node_reorder_algorithm reorder_rr_graph_ node_lookup().reorder(dest_order); - device_ctx.rr_node_metadata.remap_keys([&](int node) { return size_t(dest_order[RRNodeId(node)]); }); - device_ctx.rr_edge_metadata.remap_keys([&](std::tuple edge) { + rr_node_metadata_.remap_keys([&](int node) { return size_t(dest_order[RRNodeId(node)]); }); + rr_edge_metadata_.remap_keys([&](std::tuple edge) { return std::make_tuple(size_t(dest_order[RRNodeId(std::get<0>(edge))]), size_t(dest_order[RRNodeId(std::get<1>(edge))]), std::get<2>(edge)); diff --git a/vpr/src/device/rr_graph_builder.h b/vpr/src/device/rr_graph_builder.h index dc9634b8fd4..ae1e2a5dd03 100644 --- a/vpr/src/device/rr_graph_builder.h +++ b/vpr/src/device/rr_graph_builder.h @@ -15,12 +15,17 @@ */ #include "rr_graph_storage.h" #include "rr_spatial_lookup.h" +#include "metadata_storage.h" class RRGraphBuilder { /* -- Constructors -- */ public: /* See detailed comments about the data structures in the internal data storage section of this file */ - RRGraphBuilder(t_rr_graph_storage* node_storage); + RRGraphBuilder(t_rr_graph_storage* node_storage, + MetadataStorage* rr_node_metadata, + MetadataStorage>* rr_edge_metadata + ); + /* Disable copy constructors and copy assignment operator * This is to avoid accidental copy because it could be an expensive operation considering that the @@ -71,7 +76,9 @@ class RRGraphBuilder { * NOTE: Re-ordering will invalidate any references to rr_graph nodes, so this * should generally be called before creating such references. */ - void reorder_nodes(e_rr_node_reorder_algorithm reorder_rr_graph_nodes_algorithm, int reorder_rr_graph_nodes_threshold, int reorder_rr_graph_nodes_seed); + void reorder_nodes(e_rr_node_reorder_algorithm reorder_rr_graph_nodes_algorithm, + int reorder_rr_graph_nodes_threshold, + int reorder_rr_graph_nodes_seed); /** @brief Set capacity of this node (number of routes that can use it). */ inline void set_node_capacity(RRNodeId id, short new_capacity) { @@ -222,6 +229,9 @@ class RRGraphBuilder { t_rr_graph_storage& node_storage_; /* Fast look-up for rr nodes */ RRSpatialLookup node_lookup_; +MetadataStorage& rr_node_metadata_; + MetadataStorage>& rr_edge_metadata_; + }; #endif diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index 701e46aa4b7..a29334c67de 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -315,7 +315,6 @@ void create_rr_graph(const t_graph_type graph_type, int* Warnings) { const auto& device_ctx = g_vpr_ctx.device(); auto& mutable_device_ctx = g_vpr_ctx.mutable_device(); - if (!det_routing_arch->read_rr_graph_filename.empty()) { if (device_ctx.read_rr_graph_filename != det_routing_arch->read_rr_graph_filename) { free_rr_graph(); @@ -329,7 +328,9 @@ void create_rr_graph(const t_graph_type graph_type, router_opts.read_rr_edge_metadata, router_opts.do_check_rr_graph); if (router_opts.reorder_rr_graph_nodes_algorithm != DONT_REORDER) { - mutable_device_ctx.rr_graph_builder.reorder_nodes(router_opts.reorder_rr_graph_nodes_algorithm, router_opts.reorder_rr_graph_nodes_threshold, router_opts.reorder_rr_graph_nodes_seed); + mutable_device_ctx.rr_graph_builder.reorder_nodes(router_opts.reorder_rr_graph_nodes_algorithm, + router_opts.reorder_rr_graph_nodes_threshold, + router_opts.reorder_rr_graph_nodes_seed); } } } else { @@ -361,7 +362,9 @@ void create_rr_graph(const t_graph_type graph_type, &det_routing_arch->wire_to_rr_ipin_switch, Warnings); if (router_opts.reorder_rr_graph_nodes_algorithm != DONT_REORDER) { - mutable_device_ctx.rr_graph_builder.reorder_nodes(router_opts.reorder_rr_graph_nodes_algorithm, router_opts.reorder_rr_graph_nodes_threshold, router_opts.reorder_rr_graph_nodes_seed); + mutable_device_ctx.rr_graph_builder.reorder_nodes(router_opts.reorder_rr_graph_nodes_algorithm, + router_opts.reorder_rr_graph_nodes_threshold, + router_opts.reorder_rr_graph_nodes_seed); } } From 8229337fcd3cc3e37f9e2a8f2803b268e89651f4 Mon Sep 17 00:00:00 2001 From: Raza Jafari Date: Wed, 22 Dec 2021 16:48:34 +0500 Subject: [PATCH 7/8] (globals removed from rr_graph_builder) --- vpr/src/base/vpr_context.h | 2 +- vpr/src/device/rr_graph_builder.cpp | 16 ++++++++-------- vpr/src/device/rr_graph_builder.h | 15 ++++++--------- vpr/src/route/rr_graph.cpp | 12 ++++++------ 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/vpr/src/base/vpr_context.h b/vpr/src/base/vpr_context.h index f7ea66e140f..85a0a323b65 100644 --- a/vpr/src/base/vpr_context.h +++ b/vpr/src/base/vpr_context.h @@ -163,7 +163,7 @@ struct DeviceContext : public Context { /* A writeable view of routing resource graph to be the ONLY database * for routing resource graph builder functions. */ - RRGraphBuilder rr_graph_builder{&rr_nodes, &rr_node_metadata, &rr_edge_metadata}; + RRGraphBuilder rr_graph_builder{&rr_nodes, &rr_node_metadata, &rr_edge_metadata}; /* A read-only view of routing resource graph to be the ONLY database * for client functions: GUI, placer, router, timing analyzer etc. diff --git a/vpr/src/device/rr_graph_builder.cpp b/vpr/src/device/rr_graph_builder.cpp index f0c17151f47..38ca752a620 100644 --- a/vpr/src/device/rr_graph_builder.cpp +++ b/vpr/src/device/rr_graph_builder.cpp @@ -8,12 +8,12 @@ //#include "globals.h" RRGraphBuilder::RRGraphBuilder(t_rr_graph_storage* node_storage, - MetadataStorage* rr_node_metadata, - MetadataStorage>* rr_edge_metadata - ): node_storage_(*node_storage) - , rr_node_metadata_(*rr_node_metadata) - , rr_edge_metadata_(*rr_edge_metadata){ - } + MetadataStorage* rr_node_metadata, + MetadataStorage>* rr_edge_metadata) + : node_storage_(*node_storage) + , rr_node_metadata_(*rr_node_metadata) + , rr_edge_metadata_(*rr_edge_metadata) { +} t_rr_graph_storage& RRGraphBuilder::node_storage() { return node_storage_; @@ -62,8 +62,8 @@ void RRGraphBuilder::clear() { } void RRGraphBuilder::reorder_nodes(e_rr_node_reorder_algorithm reorder_rr_graph_nodes_algorithm, - int reorder_rr_graph_nodes_threshold, - int reorder_rr_graph_nodes_seed) { + int reorder_rr_graph_nodes_threshold, + int reorder_rr_graph_nodes_seed) { size_t v_num = node_storage_.size(); if (reorder_rr_graph_nodes_threshold < 0 || v_num < (size_t)reorder_rr_graph_nodes_threshold) return; vtr::ScopedStartFinishTimer timer("Reordering rr_graph nodes"); diff --git a/vpr/src/device/rr_graph_builder.h b/vpr/src/device/rr_graph_builder.h index ae1e2a5dd03..d36abf719c1 100644 --- a/vpr/src/device/rr_graph_builder.h +++ b/vpr/src/device/rr_graph_builder.h @@ -22,10 +22,8 @@ class RRGraphBuilder { public: /* See detailed comments about the data structures in the internal data storage section of this file */ RRGraphBuilder(t_rr_graph_storage* node_storage, - MetadataStorage* rr_node_metadata, - MetadataStorage>* rr_edge_metadata - ); - + MetadataStorage* rr_node_metadata, + MetadataStorage>* rr_edge_metadata); /* Disable copy constructors and copy assignment operator * This is to avoid accidental copy because it could be an expensive operation considering that the @@ -76,9 +74,9 @@ class RRGraphBuilder { * NOTE: Re-ordering will invalidate any references to rr_graph nodes, so this * should generally be called before creating such references. */ - void reorder_nodes(e_rr_node_reorder_algorithm reorder_rr_graph_nodes_algorithm, - int reorder_rr_graph_nodes_threshold, - int reorder_rr_graph_nodes_seed); + void reorder_nodes(e_rr_node_reorder_algorithm reorder_rr_graph_nodes_algorithm, + int reorder_rr_graph_nodes_threshold, + int reorder_rr_graph_nodes_seed); /** @brief Set capacity of this node (number of routes that can use it). */ inline void set_node_capacity(RRNodeId id, short new_capacity) { @@ -229,9 +227,8 @@ class RRGraphBuilder { t_rr_graph_storage& node_storage_; /* Fast look-up for rr nodes */ RRSpatialLookup node_lookup_; -MetadataStorage& rr_node_metadata_; + MetadataStorage& rr_node_metadata_; MetadataStorage>& rr_edge_metadata_; - }; #endif diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index a29334c67de..5242385d9d6 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -328,9 +328,9 @@ void create_rr_graph(const t_graph_type graph_type, router_opts.read_rr_edge_metadata, router_opts.do_check_rr_graph); if (router_opts.reorder_rr_graph_nodes_algorithm != DONT_REORDER) { - mutable_device_ctx.rr_graph_builder.reorder_nodes(router_opts.reorder_rr_graph_nodes_algorithm, - router_opts.reorder_rr_graph_nodes_threshold, - router_opts.reorder_rr_graph_nodes_seed); + mutable_device_ctx.rr_graph_builder.reorder_nodes(router_opts.reorder_rr_graph_nodes_algorithm, + router_opts.reorder_rr_graph_nodes_threshold, + router_opts.reorder_rr_graph_nodes_seed); } } } else { @@ -362,9 +362,9 @@ void create_rr_graph(const t_graph_type graph_type, &det_routing_arch->wire_to_rr_ipin_switch, Warnings); if (router_opts.reorder_rr_graph_nodes_algorithm != DONT_REORDER) { - mutable_device_ctx.rr_graph_builder.reorder_nodes(router_opts.reorder_rr_graph_nodes_algorithm, - router_opts.reorder_rr_graph_nodes_threshold, - router_opts.reorder_rr_graph_nodes_seed); + mutable_device_ctx.rr_graph_builder.reorder_nodes(router_opts.reorder_rr_graph_nodes_algorithm, + router_opts.reorder_rr_graph_nodes_threshold, + router_opts.reorder_rr_graph_nodes_seed); } } From 16e3a13ee1cf5952f0b5cd5592b97da3c97bce66 Mon Sep 17 00:00:00 2001 From: Raza Jafari Date: Mon, 3 Jan 2022 11:39:11 +0500 Subject: [PATCH 8/8] Comments added --- vpr/src/device/rr_graph_builder.h | 13 +++++++++++++ vpr/src/route/rr_graph_util.h | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/vpr/src/device/rr_graph_builder.h b/vpr/src/device/rr_graph_builder.h index d36abf719c1..53df08d1ae2 100644 --- a/vpr/src/device/rr_graph_builder.h +++ b/vpr/src/device/rr_graph_builder.h @@ -62,6 +62,9 @@ class RRGraphBuilder { /** @brief Clear all the underlying data storage */ void clear(); /** @brief reorder all the nodes + * Reordering the rr-graph nodes may be helpful in + * - Increasing cache locality during routing + * - Improving compile time * Reorder RRNodeId's using one of these algorithms: * - DEGREE_BFS: Order by degree primarily, and BFS traversal order secondarily. * - RANDOM_SHUFFLE: Shuffle using the specified seed. Great for testing. @@ -69,6 +72,10 @@ class RRGraphBuilder { * existing algorithms here: https://github.com/SymbiFlow/vtr-rrgraph-reordering-tool * It might be worth further research, as the DEGREE_BFS algorithm is simple and * makes some arbitrary choices, such as the starting node. + * The re-ordering algorithm (DEGREE_BFS) does not speed up the router on most architectures + * vs. using the node ordering created by the rr-graph builder in VPR, so it is off by default. + * The other use of this algorithm is for some unit tests; by changing the order of the nodes + * in the rr-graph before routing we check that no code depends on the rr-graph node order * Nonetheless, it does improve performance ~7% for the SymbiFlow Xilinx Artix 7 graph. * * NOTE: Re-ordering will invalidate any references to rr_graph nodes, so this @@ -227,6 +234,12 @@ class RRGraphBuilder { t_rr_graph_storage& node_storage_; /* Fast look-up for rr nodes */ RRSpatialLookup node_lookup_; + + /* Metadata is an extra data on rr-nodes and edges, respectively, that is not used by vpr + * but simply passed through the flow so that it can be used by downstream tools. + * The main (perhaps only) current use of this metadata is the fasm tool of symbiflow, + * which needs extra metadata on which programming bits control which switch in order to produce a bitstream.*/ + MetadataStorage& rr_node_metadata_; MetadataStorage>& rr_edge_metadata_; }; diff --git a/vpr/src/route/rr_graph_util.h b/vpr/src/route/rr_graph_util.h index 5bfe1c68197..3b61263c566 100644 --- a/vpr/src/route/rr_graph_util.h +++ b/vpr/src/route/rr_graph_util.h @@ -7,8 +7,6 @@ int seg_index_of_cblock(t_rr_type from_rr_type, int to_node); int seg_index_of_sblock(int from_node, int to_node); -//void reorder_rr_graph_nodes(const t_router_opts& router_opts); - // This function generates and returns a vector indexed by RRNodeId // containing a list of fan-in edges for each node. vtr::vector> get_fan_in_list();