From ba0eebd6e5945876b99b55bde41252e86d0b9754 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Sun, 15 Aug 2021 18:03:12 -0600 Subject: [PATCH 1/3] [VPR] Reworked verify_rr_node_indices function to use RRSpatialLookup in place of the legacy data structure ``rr_node_indices`` --- vpr/src/route/rr_graph.cpp | 3 +- vpr/src/route/rr_graph2.cpp | 244 ++++++++++++++++++------------------ vpr/src/route/rr_graph2.h | 5 +- 3 files changed, 125 insertions(+), 127 deletions(-) diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index 48ddde5ee3d..a5d1016fd35 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -363,7 +363,7 @@ void create_rr_graph(const t_graph_type graph_type, process_non_config_sets(); - verify_rr_node_indices(grid, device_ctx.rr_node_indices, device_ctx.rr_nodes); + verify_rr_node_indices(grid, device_ctx.rr_graph, device_ctx.rr_nodes); print_rr_graph_stats(); @@ -2423,6 +2423,7 @@ static vtr::NdMatrix, 4> alloc_and_load_track_to_pin_lookup(vtr return track_to_pin_lookup; } +/* TODO: This function should adapt RRNodeId */ std::string describe_rr_node(int inode) { auto& device_ctx = g_vpr_ctx.device(); const auto& rr_graph = device_ctx.rr_graph; diff --git a/vpr/src/route/rr_graph2.cpp b/vpr/src/route/rr_graph2.cpp index b3d4eb7367e..7db10469d6e 100644 --- a/vpr/src/route/rr_graph2.cpp +++ b/vpr/src/route/rr_graph2.cpp @@ -1163,135 +1163,129 @@ void alloc_and_load_rr_node_indices(RRGraphBuilder& rr_graph_builder, CHANY, chan_details_y, rr_graph_builder, index); } -bool verify_rr_node_indices(const DeviceGrid& grid, const t_rr_node_indices& rr_node_indices, const t_rr_graph_storage& rr_nodes) { - std::unordered_map rr_node_counts; - auto& device_ctx = g_vpr_ctx.device(); - const auto& rr_graph = device_ctx.rr_graph; - - for (t_rr_type rr_type : RR_TYPES) { - int width = grid.width(); - int height = grid.height(); - - //CHANX bizarely stores with x/y swapped... - if (rr_type == CHANX) { - std::swap(width, height); - } +/** + * Validate the node look-up matches all the node-level information + * in the storage of a routing resource graph + * This function will check the following aspects: + * - The type of each node matches its type that is indexed in the node look-up + * - For bounding box (xlow, ylow, xhigh, yhigh) of each node is indexable in the node look-up + * - The number of unique indexable nodes in the node look up matches the number of nodes in the storage + * This ensures that every node in the storage is indexable and there are no hidden nodes in the look-up + */ +bool verify_rr_node_indices(const DeviceGrid& grid, + const RRGraphView& rr_graph, + const t_rr_graph_storage& rr_nodes) { + std::unordered_map rr_node_counts; + + int width = grid.width(); + int height = grid.height(); + + for (int x = 0; x < width; ++x) { + for (int y = 0; y < height; ++y) { + for (t_rr_type rr_type : RR_TYPES) { + /* Get the list of nodes at a specific location (x, y) */ + std::vector nodes_from_lookup; + if (rr_type == CHANX || rr_type == CHANY) { + nodes_from_lookup = rr_graph.node_lookup().find_channel_nodes(x, y, rr_type); + } else { + nodes_from_lookup = rr_graph.node_lookup().find_grid_nodes_at_all_sides(x, y, rr_type); + } + for (RRNodeId inode : nodes_from_lookup) { + rr_node_counts[inode]++; - for (int x = 0; x < width; ++x) { - for (int y = 0; y < height; ++y) { - for (e_side side : SIDES) { - for (int inode : rr_node_indices[rr_type][x][y][side]) { - if (inode < 0) continue; + auto& rr_node = rr_nodes[size_t(inode)]; - rr_node_counts[inode]++; + if (rr_graph.node_type(inode) != rr_type) { + VPR_ERROR(VPR_ERROR_ROUTE, "RR node type does not match between rr_nodes and rr_node_indices (%s/%s): %s", + rr_node_typename[rr_graph.node_type(inode)], + rr_node_typename[rr_type], + describe_rr_node(size_t(inode)).c_str()); + } - auto& rr_node = rr_nodes[inode]; + if (rr_graph.node_type(inode) == CHANX) { + VTR_ASSERT_MSG(rr_node.ylow() == rr_node.yhigh(), "CHANX should be horizontal"); - if (rr_graph.node_type(RRNodeId(inode)) != rr_type) { - VPR_ERROR(VPR_ERROR_ROUTE, "RR node type does not match between rr_nodes and rr_node_indices (%s/%s): %s", - rr_node_typename[rr_graph.node_type(RRNodeId(inode))], - rr_node_typename[rr_type], - describe_rr_node(inode).c_str()); + if (y != rr_node.ylow()) { + VPR_ERROR(VPR_ERROR_ROUTE, "RR node y position does not agree between rr_nodes (%d) and rr_node_indices (%d): %s", + rr_node.ylow(), + y, + describe_rr_node(size_t(inode)).c_str()); } - if (rr_graph.node_type(RRNodeId(inode)) == CHANX) { - //CHANX has this bizare swapped x / y storage... - std::swap(x, y); - - VTR_ASSERT_MSG(rr_node.ylow() == rr_node.yhigh(), "CHANX should be horizontal"); - - if (y != rr_node.ylow()) { - VPR_ERROR(VPR_ERROR_ROUTE, "RR node y position does not agree between rr_nodes (%d) and rr_node_indices (%d): %s", - rr_node.ylow(), - y, - describe_rr_node(inode).c_str()); - } - - if (x < rr_node.xlow() || x > rr_node.xhigh()) { - VPR_ERROR(VPR_ERROR_ROUTE, "RR node x positions do not agree between rr_nodes (%d <-> %d) and rr_node_indices (%d): %s", - rr_node.xlow(), - rr_node.xlow(), - x, - describe_rr_node(inode).c_str()); - } - - std::swap(x, y); //Swap back - } else if (rr_graph.node_type(RRNodeId(inode)) == CHANY) { - VTR_ASSERT_MSG(rr_node.xlow() == rr_node.xhigh(), "CHANY should be veritcal"); - - if (x != rr_node.xlow()) { - VPR_ERROR(VPR_ERROR_ROUTE, "RR node x position does not agree between rr_nodes (%d) and rr_node_indices (%d): %s", - rr_node.xlow(), - x, - describe_rr_node(inode).c_str()); - } - - if (y < rr_node.ylow() || y > rr_node.yhigh()) { - VPR_ERROR(VPR_ERROR_ROUTE, "RR node y positions do not agree between rr_nodes (%d <-> %d) and rr_node_indices (%d): %s", - rr_node.ylow(), - rr_node.ylow(), - y, - describe_rr_node(inode).c_str()); - } - } else if (rr_graph.node_type(RRNodeId(inode)) == SOURCE || rr_graph.node_type(RRNodeId(inode)) == SINK) { - //Sources have co-ordintes covering the entire block they are in - if (x < rr_node.xlow() || x > rr_node.xhigh()) { - VPR_ERROR(VPR_ERROR_ROUTE, "RR node x positions do not agree between rr_nodes (%d <-> %d) and rr_node_indices (%d): %s", - rr_node.xlow(), - rr_node.xlow(), - x, - describe_rr_node(inode).c_str()); - } - - if (y < rr_node.ylow() || y > rr_node.yhigh()) { - VPR_ERROR(VPR_ERROR_ROUTE, "RR node y positions do not agree between rr_nodes (%d <-> %d) and rr_node_indices (%d): %s", - rr_node.ylow(), - rr_node.ylow(), - y, - describe_rr_node(inode).c_str()); - } + if (x < rr_node.xlow() || x > rr_node.xhigh()) { + VPR_ERROR(VPR_ERROR_ROUTE, "RR node x positions do not agree between rr_nodes (%d <-> %d) and rr_node_indices (%d): %s", + rr_node.xlow(), + rr_node.xlow(), + x, + describe_rr_node(size_t(inode)).c_str()); + } + } else if (rr_graph.node_type(inode) == CHANY) { + VTR_ASSERT_MSG(rr_node.xlow() == rr_node.xhigh(), "CHANY should be veritcal"); + + if (x != rr_node.xlow()) { + VPR_ERROR(VPR_ERROR_ROUTE, "RR node x position does not agree between rr_nodes (%d) and rr_node_indices (%d): %s", + rr_node.xlow(), + x, + describe_rr_node(size_t(inode)).c_str()); + } - } else { - VTR_ASSERT(rr_graph.node_type(RRNodeId(inode)) == IPIN || rr_graph.node_type(RRNodeId(inode)) == OPIN); - /* As we allow a pin to be indexable on multiple sides, - * This check code should be invalid - * if (rr_node.xlow() != x) { - * VPR_ERROR(VPR_ERROR_ROUTE, "RR node xlow does not match between rr_nodes and rr_node_indices (%d/%d): %s", - * rr_node.xlow(), - * x, - * describe_rr_node(inode).c_str()); - * } - * - * if (rr_node.ylow() != y) { - * VPR_ERROR(VPR_ERROR_ROUTE, "RR node ylow does not match between rr_nodes and rr_node_indices (%d/%d): %s", - * rr_node.ylow(), - * y, - * describe_rr_node(inode).c_str()); - * } - */ + if (y < rr_node.ylow() || y > rr_node.yhigh()) { + VPR_ERROR(VPR_ERROR_ROUTE, "RR node y positions do not agree between rr_nodes (%d <-> %d) and rr_node_indices (%d): %s", + rr_node.ylow(), + rr_node.ylow(), + y, + describe_rr_node(size_t(inode)).c_str()); + } + } else if (rr_graph.node_type(inode) == SOURCE || rr_graph.node_type(inode) == SINK) { + //Sources have co-ordintes covering the entire block they are in + if (x < rr_node.xlow() || x > rr_node.xhigh()) { + VPR_ERROR(VPR_ERROR_ROUTE, "RR node x positions do not agree between rr_nodes (%d <-> %d) and rr_node_indices (%d): %s", + rr_node.xlow(), + rr_node.xlow(), + x, + describe_rr_node(size_t(inode)).c_str()); } - if (rr_type == IPIN || rr_type == OPIN) { - /* As we allow a pin to be indexable on multiple sides, - * This check code should be invalid - * if (rr_node.side() != side) { - * VPR_ERROR(VPR_ERROR_ROUTE, "RR node xlow does not match between rr_nodes and rr_node_indices (%s/%s): %s", - * SIDE_STRING[rr_node.side()], - * SIDE_STRING[side], - * describe_rr_node(inode).c_str()); - * } else { - * VTR_ASSERT(rr_node.side() == side); - * } - */ - } else { //Non-pin's don't have sides, and should only be in side 0 - if (side != SIDES[0]) { - VPR_ERROR(VPR_ERROR_ROUTE, "Non-Pin RR node in rr_node_indices found with non-default side %s: %s", - SIDE_STRING[side], - describe_rr_node(inode).c_str()); - } else { - VTR_ASSERT(side == 0); - } + if (y < rr_node.ylow() || y > rr_node.yhigh()) { + VPR_ERROR(VPR_ERROR_ROUTE, "RR node y positions do not agree between rr_nodes (%d <-> %d) and rr_node_indices (%d): %s", + rr_node.ylow(), + rr_node.ylow(), + y, + describe_rr_node(size_t(inode)).c_str()); } + + } else { + VTR_ASSERT(rr_graph.node_type(inode) == IPIN || rr_graph.node_type(inode) == OPIN); + /* As we allow a pin to be indexable on multiple sides, + * This check code should be invalid + * if (rr_node.xlow() != x) { + * VPR_ERROR(VPR_ERROR_ROUTE, "RR node xlow does not match between rr_nodes and rr_node_indices (%d/%d): %s", + * rr_node.xlow(), + * x, + * describe_rr_node(inode).c_str()); + * } + * + * if (rr_node.ylow() != y) { + * VPR_ERROR(VPR_ERROR_ROUTE, "RR node ylow does not match between rr_nodes and rr_node_indices (%d/%d): %s", + * rr_node.ylow(), + * y, + * describe_rr_node(inode).c_str()); + * } + */ + } + + if (rr_type == IPIN || rr_type == OPIN) { + /* As we allow a pin to be indexable on multiple sides, + * This check code should be invalid + * if (rr_node.side() != side) { + * VPR_ERROR(VPR_ERROR_ROUTE, "RR node xlow does not match between rr_nodes and rr_node_indices (%s/%s): %s", + * SIDE_STRING[rr_node.side()], + * SIDE_STRING[side], + * describe_rr_node(inode).c_str()); + * } else { + * VTR_ASSERT(rr_node.side() == side); + * } + */ } } } @@ -1305,12 +1299,12 @@ bool verify_rr_node_indices(const DeviceGrid& grid, const t_rr_node_indices& rr_ } for (auto kv : rr_node_counts) { - int inode = kv.first; + RRNodeId inode = kv.first; int count = kv.second; - auto& rr_node = rr_nodes[inode]; + auto& rr_node = rr_nodes[size_t(inode)]; - if (rr_graph.node_type(RRNodeId(inode)) == SOURCE || rr_graph.node_type(RRNodeId(inode)) == SINK) { + if (rr_graph.node_type(inode) == SOURCE || rr_graph.node_type(inode) == SINK) { int rr_width = (rr_node.xhigh() - rr_node.xlow() + 1); int rr_height = (rr_node.yhigh() - rr_node.ylow() + 1); int rr_area = rr_width * rr_height; @@ -1319,17 +1313,17 @@ bool verify_rr_node_indices(const DeviceGrid& grid, const t_rr_node_indices& rr_ rr_area, rr_node.length(), count, - describe_rr_node(inode).c_str()); + describe_rr_node(size_t(inode)).c_str()); } /* As we allow a pin to be indexable on multiple sides, * This check code should not be applied to input and output pins */ - } else if ((OPIN != rr_graph.node_type(RRNodeId(inode))) && (IPIN != rr_graph.node_type(RRNodeId(inode)))) { + } else if ((OPIN != rr_graph.node_type(inode)) && (IPIN != rr_graph.node_type(inode))) { if (count != rr_node.length() + 1) { VPR_ERROR(VPR_ERROR_ROUTE, "Mismatch between RR node length (%d) and count within rr_node_indices (%d, should be length + 1): %s", rr_node.length(), count, - describe_rr_node(inode).c_str()); + describe_rr_node(size_t(inode)).c_str()); } } } diff --git a/vpr/src/route/rr_graph2.h b/vpr/src/route/rr_graph2.h index 9ec4c0987ec..60099bf4b97 100644 --- a/vpr/src/route/rr_graph2.h +++ b/vpr/src/route/rr_graph2.h @@ -5,6 +5,7 @@ #include "build_switchblocks.h" #include "rr_graph_fwd.h" #include "rr_graph_util.h" +#include "rr_graph_view.h" #include "rr_graph_builder.h" #include "rr_types.h" #include "device_grid.h" @@ -27,7 +28,9 @@ void alloc_and_load_rr_node_indices(RRGraphBuilder& rr_graph_builder, const t_chan_details& chan_details_x, const t_chan_details& chan_details_y); -bool verify_rr_node_indices(const DeviceGrid& grid, const t_rr_node_indices& rr_node_indices, const t_rr_graph_storage& rr_nodes); +bool verify_rr_node_indices(const DeviceGrid& grid, + const RRGraphView& rr_graph, + const t_rr_graph_storage& rr_nodes); //Returns all x-channel or y-channel wires at the specified location std::vector get_rr_node_chan_wires_at_location(const t_rr_node_indices& L_rr_node_indices, From 91174909455e7f5c3fded98eee78060401fc18c3 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Sun, 15 Aug 2021 19:21:48 -0600 Subject: [PATCH 2/3] [VPR] Remove the legacy data structure ``rr_node_indices`` from DeviceContext, as it is now fully shadowed by the data structure ``RRSpatialLookup`` --- vpr/src/base/vpr_context.h | 19 ++++--------------- vpr/src/device/rr_graph_builder.cpp | 10 ++++++---- vpr/src/device/rr_graph_builder.h | 8 +++++--- vpr/src/device/rr_graph_view.h | 3 +-- vpr/src/device/rr_spatial_lookup.cpp | 27 +++++++++++++++++++++++++-- vpr/src/device/rr_spatial_lookup.h | 20 +++++++++----------- vpr/src/route/rr_graph.cpp | 6 ++---- vpr/src/route/rr_graph_util.cpp | 15 +-------------- 8 files changed, 53 insertions(+), 55 deletions(-) diff --git a/vpr/src/base/vpr_context.h b/vpr/src/base/vpr_context.h index c85aeb05245..163f934d82d 100644 --- a/vpr/src/base/vpr_context.h +++ b/vpr/src/base/vpr_context.h @@ -160,26 +160,15 @@ struct DeviceContext : public Context { ///@brief Reverse look-up from RR node to non-configurably connected node set (index into rr_nonconf_node_sets) std::unordered_map rr_node_to_non_config_node_set; - ///@brief The indicies of rr nodes of a given type at a specific x,y grid location - t_rr_node_indices rr_node_indices; // [0..NUM_RR_TYPES-1][0..grid.width()-1][0..grid.width()-1][0..size-1] - - /* TODO: remove this interface from device_context once the code refactoring is completed - * because it should be part of the rr_graph view - * TODO: Currently, we use reference pointers to ensure that the rr_spatial_lookup is always - * synchronized with the rr_node_indices but this causes a lot of confusion for developers - * The temporary fix should be patched as soon as possible. + /* A writeable view of routing resource graph to be the ONLY database + * for routing resource graph builder functions. */ - RRSpatialLookup rr_spatial_lookup{rr_node_indices}; + RRGraphBuilder rr_graph_builder{&rr_nodes}; /* A read-only view of routing resource graph to be the ONLY database * for client functions: GUI, placer, router, timing analyzer etc. */ - RRGraphView rr_graph{rr_nodes, rr_spatial_lookup}; - - /* 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_spatial_lookup}; + RRGraphView rr_graph{rr_nodes, rr_graph_builder.node_lookup()}; ///@brief Autogenerated in build_rr_graph based on switch fan-in. [0..(num_rr_switches-1)] std::vector rr_switch_inf; diff --git a/vpr/src/device/rr_graph_builder.cpp b/vpr/src/device/rr_graph_builder.cpp index f663e6f7551..6cf28ca276c 100644 --- a/vpr/src/device/rr_graph_builder.cpp +++ b/vpr/src/device/rr_graph_builder.cpp @@ -1,10 +1,8 @@ #include "vtr_log.h" #include "rr_graph_builder.h" -RRGraphBuilder::RRGraphBuilder(t_rr_graph_storage* node_storage, - RRSpatialLookup* node_lookup) - : node_storage_(*node_storage) - , node_lookup_(*node_lookup) { +RRGraphBuilder::RRGraphBuilder(t_rr_graph_storage* node_storage) + : node_storage_(*node_storage) { } t_rr_graph_storage& RRGraphBuilder::node_storage() { @@ -48,3 +46,7 @@ void RRGraphBuilder::add_node_to_all_locs(RRNodeId node) { } } } + +void RRGraphBuilder::clear() { + node_lookup_.clear(); +} diff --git a/vpr/src/device/rr_graph_builder.h b/vpr/src/device/rr_graph_builder.h index efaa01c668c..4937cbe709a 100644 --- a/vpr/src/device/rr_graph_builder.h +++ b/vpr/src/device/rr_graph_builder.h @@ -19,8 +19,7 @@ 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, - RRSpatialLookup* node_lookup); + RRGraphBuilder(t_rr_graph_storage* node_storage); /* Disable copy constructors and copy assignment operator * This is to avoid accidental copy because it could be an expensive operation considering that the @@ -49,6 +48,9 @@ class RRGraphBuilder { */ void add_node_to_all_locs(RRNodeId node); + /* Clear all the underlying data storage */ + void clear(); + /* -- Internal data storage -- */ private: /* TODO: When the refactoring effort finishes, @@ -63,7 +65,7 @@ class RRGraphBuilder { /* node-level storage including edge storages */ t_rr_graph_storage& node_storage_; /* Fast look-up for rr nodes */ - RRSpatialLookup& node_lookup_; + RRSpatialLookup node_lookup_; }; #endif diff --git a/vpr/src/device/rr_graph_view.h b/vpr/src/device/rr_graph_view.h index d00e5f35836..1cfad49f165 100644 --- a/vpr/src/device/rr_graph_view.h +++ b/vpr/src/device/rr_graph_view.h @@ -1,8 +1,7 @@ #ifndef RR_GRAPH_VIEW_H #define RR_GRAPH_VIEW_H -#include "rr_graph_storage.h" -#include "rr_spatial_lookup.h" +#include "rr_graph_builder.h" /* An read-only routing resource graph * which is an unified object including pointors to diff --git a/vpr/src/device/rr_spatial_lookup.cpp b/vpr/src/device/rr_spatial_lookup.cpp index 28e67a1e103..dcb501f0469 100644 --- a/vpr/src/device/rr_spatial_lookup.cpp +++ b/vpr/src/device/rr_spatial_lookup.cpp @@ -1,8 +1,7 @@ #include "vtr_assert.h" #include "rr_spatial_lookup.h" -RRSpatialLookup::RRSpatialLookup(t_rr_node_indices& rr_node_indices) - : rr_node_indices_(rr_node_indices) { +RRSpatialLookup::RRSpatialLookup() { } RRNodeId RRSpatialLookup::find_node(int x, @@ -273,3 +272,27 @@ void RRSpatialLookup::resize_nodes(int x, std::max(rr_node_indices_[type].dim_size(2), size_t(side) + 1)}); } } + +void RRSpatialLookup::reorder(const vtr::vector dest_order) { + // update rr_node_indices, a map to optimize rr_index lookups + for (auto& grid : rr_node_indices_) { + for (size_t x = 0; x < grid.dim_size(0); x++) { + for (size_t y = 0; y < grid.dim_size(1); y++) { + for (size_t s = 0; s < grid.dim_size(2); s++) { + for (auto& node : grid[x][y][s]) { + if (node != OPEN) { + node = size_t(dest_order[RRNodeId(node)]); + } + } + } + } + } + } + +} + +void RRSpatialLookup::clear() { + for (auto& data : rr_node_indices_) { + data.clear(); + } +} diff --git a/vpr/src/device/rr_spatial_lookup.h b/vpr/src/device/rr_spatial_lookup.h index 9e30ac6f55c..ab8422a23e6 100644 --- a/vpr/src/device/rr_spatial_lookup.h +++ b/vpr/src/device/rr_spatial_lookup.h @@ -2,6 +2,7 @@ #define RR_SPATIAL_LOOKUP_H #include "vtr_geometry.h" +#include "vtr_vector.h" #include "vpr_types.h" /******************************************************************** @@ -17,7 +18,7 @@ class RRSpatialLookup { /* -- Constructors -- */ public: /* Explicitly define the only way to create an object */ - explicit RRSpatialLookup(t_rr_node_indices& rr_node_indices); + explicit RRSpatialLookup(); /* Disable copy constructors and copy assignment operator * This is to avoid accidental copy because it could be an expensive operation considering that the @@ -185,6 +186,12 @@ class RRSpatialLookup { t_rr_type type, e_side side); + /* Reorder the internal look up to be more memory efficient */ + void reorder(const vtr::vector dest_order); + + /* Clear all the data inside */ + void clear(); + /* -- Internal data queries -- */ private: /* An internal API to find all the nodes in a specific location with a given type @@ -199,17 +206,8 @@ class RRSpatialLookup { /* -- Internal data storage -- */ private: - /* TODO: When the refactoring effort finishes, - * the data structure will be the owner of the data storages. - * That is why the reference is used here. - * It can avoid a lot of code changes once the refactoring is finished - * (there is no function get data directly through the rr_node_indices in DeviceContext). - * If pointers are used, it may cause many codes in client functions - * or inside the data structures to be changed later. - * That explains why the reference is used here temporarily - */ /* Fast look-up: TODO: Should rework the data type. Currently it is based on a 3-dimensional arrqay mater where some dimensions must always be accessed with a specific index. Such limitation should be overcome */ - t_rr_node_indices& rr_node_indices_; + t_rr_node_indices rr_node_indices_; }; #endif diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index a5d1016fd35..78ea48494a5 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -1342,12 +1342,10 @@ void free_rr_graph() { device_ctx.read_rr_graph_filename.clear(); - for (auto& data : device_ctx.rr_node_indices) { - data.clear(); - } - device_ctx.rr_nodes.clear(); + device_ctx.rr_graph_builder.clear(); + device_ctx.rr_indexed_data.clear(); device_ctx.rr_switch_inf.clear(); diff --git a/vpr/src/route/rr_graph_util.cpp b/vpr/src/route/rr_graph_util.cpp index 70344911a2f..8bf48dba5ab 100644 --- a/vpr/src/route/rr_graph_util.cpp +++ b/vpr/src/route/rr_graph_util.cpp @@ -156,20 +156,7 @@ void reorder_rr_graph_nodes(const t_router_opts& router_opts) { graph.reorder(dest_order, src_order); - // update rr_node_indices, a map to optimize rr_index lookups - for (auto& grid : device_ctx.rr_node_indices) { - for (size_t x = 0; x < grid.dim_size(0); x++) { - for (size_t y = 0; y < grid.dim_size(1); y++) { - for (size_t s = 0; s < grid.dim_size(2); s++) { - for (auto& node : grid[x][y][s]) { - if (node != OPEN) { - node = size_t(dest_order[RRNodeId(node)]); - } - } - } - } - } - } + 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) { From a5217eca35e93e17bb5d050e49cfd3cdff3b8473 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Sun, 15 Aug 2021 19:33:24 -0600 Subject: [PATCH 3/3] [VPR] Code format fix --- vpr/src/device/rr_spatial_lookup.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/vpr/src/device/rr_spatial_lookup.cpp b/vpr/src/device/rr_spatial_lookup.cpp index dcb501f0469..6f6bae475d3 100644 --- a/vpr/src/device/rr_spatial_lookup.cpp +++ b/vpr/src/device/rr_spatial_lookup.cpp @@ -288,7 +288,6 @@ void RRSpatialLookup::reorder(const vtr::vector dest_order) } } } - } void RRSpatialLookup::clear() {