diff --git a/libs/librrgraph/src/base/rr_graph_builder.cpp b/libs/librrgraph/src/base/rr_graph_builder.cpp index 48852706c5..4bf9680322 100644 --- a/libs/librrgraph/src/base/rr_graph_builder.cpp +++ b/libs/librrgraph/src/base/rr_graph_builder.cpp @@ -31,31 +31,29 @@ void RRGraphBuilder::add_node_to_all_locs(RRNodeId node) { short node_layer = node_storage_.node_layer(node); short node_twist = node_storage_.node_ptc_twist(node); int node_offset = 0; + for (int ix = node_storage_.node_xlow(node); ix <= node_storage_.node_xhigh(node); ix++) { for (int iy = node_storage_.node_ylow(node); iy <= node_storage_.node_yhigh(node); iy++) { node_ptc_num += node_twist * node_offset; node_offset++; + switch (node_type) { case e_rr_type::SOURCE: case e_rr_type::SINK: case e_rr_type::CHANY: - node_lookup_.add_node(node, node_layer, ix, iy, node_type, node_ptc_num, TOTAL_2D_SIDES[0]); - break; case e_rr_type::CHANX: - /* Currently need to swap x and y for CHANX because of chan, seg convention - * TODO: Once the builders is reworked for use consistent (x, y) convention, - * the following swapping can be removed - */ - node_lookup_.add_node(node, node_layer, iy, ix, node_type, node_ptc_num, TOTAL_2D_SIDES[0]); + node_lookup_.add_node(node, node_layer, ix, iy, node_type, node_ptc_num, TOTAL_2D_SIDES[0]); break; + case e_rr_type::OPIN: case e_rr_type::IPIN: - for (const e_side& side : TOTAL_2D_SIDES) { + for (const e_side side : TOTAL_2D_SIDES) { if (node_storage_.is_node_on_specific_side(node, side)) { node_lookup_.add_node(node,node_layer, ix, iy, node_type, node_ptc_num, side); } } break; + default: VTR_LOG_ERROR("Invalid node type for node '%lu' in the routing resource graph file", size_t(node)); break; diff --git a/libs/librrgraph/src/base/rr_graph_view.h b/libs/librrgraph/src/base/rr_graph_view.h index e420e46ddd..49a3f92bf9 100644 --- a/libs/librrgraph/src/base/rr_graph_view.h +++ b/libs/librrgraph/src/base/rr_graph_view.h @@ -351,7 +351,7 @@ class RRGraphView { start_x = " (" + std::to_string(node_xhigh(node)) + ","; //start coordinates have large value start_y = std::to_string(node_yhigh(node)) + ","; - start_layer_str = std::to_string(node_layer_num); + start_layer_str = std::to_string(node_layer_num) + ")"; end_x = " (" + std::to_string(node_xlow(node)) + ","; //end coordinates have smaller value end_y = std::to_string(node_ylow(node)) + ","; end_layer_str = std::to_string(node_layer_num) + ")"; @@ -360,7 +360,7 @@ class RRGraphView { else { // signal travels in increasing direction, stays at same point, or can travel both directions start_x = " (" + std::to_string(node_xlow(node)) + ","; //start coordinates have smaller value start_y = std::to_string(node_ylow(node)) + ","; - start_layer_str = std::to_string(node_layer_num); + start_layer_str = std::to_string(node_layer_num) + ")"; end_x = " (" + std::to_string(node_xhigh(node)) + ","; //end coordinates have larger value end_y = std::to_string(node_yhigh(node)) + ","; end_layer_str = std::to_string(node_layer_num) + ")"; //layer number diff --git a/libs/librrgraph/src/base/rr_spatial_lookup.cpp b/libs/librrgraph/src/base/rr_spatial_lookup.cpp index aa9e17a1d5..731dc147fd 100644 --- a/libs/librrgraph/src/base/rr_spatial_lookup.cpp +++ b/libs/librrgraph/src/base/rr_spatial_lookup.cpp @@ -1,9 +1,6 @@ #include "vtr_assert.h" #include "rr_spatial_lookup.h" -RRSpatialLookup::RRSpatialLookup() { -} - RRNodeId RRSpatialLookup::find_node(int layer, int x, int y, @@ -33,18 +30,6 @@ RRNodeId RRSpatialLookup::find_node(int layer, return RRNodeId::INVALID(); } - /* Currently need to swap x and y for CHANX because of chan, seg convention - * This is due to that the fast look-up builders uses (y, x) coordinate when - * registering a CHANX node in the look-up - * TODO: Once the builders is reworked for use consistent (x, y) convention, - * the following swapping can be removed - */ - size_t node_x = x; - size_t node_y = y; - if (type == e_rr_type::CHANX) { - std::swap(node_x, node_y); - } - VTR_ASSERT_SAFE(4 == rr_node_indices_[type].ndims()); /* Sanity check to ensure the layer, x, y, side and ptc are in range @@ -59,11 +44,11 @@ RRNodeId RRSpatialLookup::find_node(int layer, return RRNodeId::INVALID(); } - if (node_x >= rr_node_indices_[type].dim_size(1)) { + if (size_t(x) >= rr_node_indices_[type].dim_size(1)) { return RRNodeId::INVALID(); } - if(node_y >= rr_node_indices_[type].dim_size(2)){ + if (size_t(y) >= rr_node_indices_[type].dim_size(2)){ return RRNodeId::INVALID(); } @@ -71,11 +56,11 @@ RRNodeId RRSpatialLookup::find_node(int layer, return RRNodeId::INVALID(); } - if (size_t(ptc) >= rr_node_indices_[type][layer][node_x][node_y][node_side].size()) { + if (size_t(ptc) >= rr_node_indices_[type][layer][x][y][node_side].size()) { return RRNodeId::INVALID(); } - return rr_node_indices_[type][layer][node_x][node_y][node_side][ptc]; + return rr_node_indices_[type][layer][x][y][node_side][ptc]; } std::vector RRSpatialLookup::find_nodes_in_range(int layer, @@ -114,18 +99,6 @@ std::vector RRSpatialLookup::find_nodes(int layer, return nodes; } - /* Currently need to swap x and y for CHANX because of chan, seg convention - * This is due to that the fast look-up builders uses (y, x) coordinate when - * registering a CHANX node in the look-up - * TODO: Once the builders is reworked for use consistent (x, y) convention, - * the following swapping can be removed - */ - size_t node_x = x; - size_t node_y = y; - if (type == e_rr_type::CHANX) { - std::swap(node_x, node_y); - } - VTR_ASSERT_SAFE(4 == rr_node_indices_[type].ndims()); /* Sanity check to ensure the x, y, side are in range @@ -140,11 +113,11 @@ std::vector RRSpatialLookup::find_nodes(int layer, return nodes; } - if (node_x >= rr_node_indices_[type].dim_size(1)) { + if (size_t(x) >= rr_node_indices_[type].dim_size(1)) { return nodes; } - if(node_y >= rr_node_indices_[type].dim_size(2)){ + if (size_t(y) >= rr_node_indices_[type].dim_size(2)){ return nodes; } @@ -154,14 +127,14 @@ std::vector RRSpatialLookup::find_nodes(int layer, /* Reserve space to avoid memory fragmentation */ size_t num_nodes = 0; - for (const auto& node : rr_node_indices_[type][layer][node_x][node_y][side]) { + for (RRNodeId node : rr_node_indices_[type][layer][x][y][side]) { if (node.is_valid()) { num_nodes++; } } nodes.reserve(num_nodes); - for (const auto& node : rr_node_indices_[type][layer][node_x][node_y][side]) { + for (RRNodeId node : rr_node_indices_[type][layer][x][y][side]) { if (node.is_valid()) { nodes.emplace_back(node); } @@ -338,7 +311,7 @@ void RRSpatialLookup::resize_nodes(int layer, || (x >= int(rr_node_indices_[type].dim_size(1))) || (y >= int(rr_node_indices_[type].dim_size(2))) || (size_t(side) >= rr_node_indices_[type].dim_size(3))) { - rr_node_indices_[type].resize({std::max(rr_node_indices_[type].dim_size(0),size_t(layer)+1), + rr_node_indices_[type].resize({std::max(rr_node_indices_[type].dim_size(0), size_t(layer)+1), std::max(rr_node_indices_[type].dim_size(1), size_t(x) + 1), std::max(rr_node_indices_[type].dim_size(2), size_t(y) + 1), std::max(rr_node_indices_[type].dim_size(3), size_t(side) + 1)}); @@ -352,7 +325,7 @@ void RRSpatialLookup::reorder(const vtr::vector& dest_order) for (size_t x = 0; x < grid.dim_size(1); x++) { for (size_t y = 0; y < grid.dim_size(2); y++) { for (size_t s = 0; s < grid.dim_size(3); s++) { - for (auto &node: grid[l][x][y][s]) { + for (RRNodeId &node: grid[l][x][y][s]) { if (node.is_valid()) { node = dest_order[node]; } diff --git a/libs/librrgraph/src/base/rr_spatial_lookup.h b/libs/librrgraph/src/base/rr_spatial_lookup.h index 1af0b6652a..c69f34b791 100644 --- a/libs/librrgraph/src/base/rr_spatial_lookup.h +++ b/libs/librrgraph/src/base/rr_spatial_lookup.h @@ -1,5 +1,4 @@ -#ifndef RR_SPATIAL_LOOKUP_H -#define RR_SPATIAL_LOOKUP_H +#pragma once /** * @file @@ -25,7 +24,7 @@ class RRSpatialLookup { /* -- Constructors -- */ public: /* Explicitly define the only way to create an object */ - explicit RRSpatialLookup(); + explicit RRSpatialLookup() = default; /* Disable copy constructors and copy assignment operator * This is to avoid accidental copy because it could be an expensive operation considering that the @@ -293,5 +292,3 @@ class RRSpatialLookup { /* Fast look-up: TODO: Should rework the data type. Currently it is based on a 3-dimensional array mater where some dimensions must always be accessed with a specific index. Such limitation should be overcome */ t_rr_node_indices rr_node_indices_; }; - -#endif diff --git a/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h b/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h index 1ee3676dda..fe3f5a6693 100644 --- a/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h +++ b/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h @@ -1848,16 +1848,11 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { /* Alloc the lookup table */ for (e_rr_type rr_type : RR_TYPES) { - if (rr_type == e_rr_type::CHANX) { - rr_graph_builder.node_lookup().resize_nodes(grid_.get_num_layers(), grid_.height(), grid_.width(), rr_type, NUM_2D_SIDES); - } else { - rr_graph_builder.node_lookup().resize_nodes(grid_.get_num_layers(), grid_.width(), grid_.height(), rr_type, NUM_2D_SIDES); - } + rr_graph_builder.node_lookup().resize_nodes(grid_.get_num_layers(), grid_.width(), grid_.height(), rr_type, NUM_2D_SIDES); } /* Add the correct node into the vector */ - for (size_t inode = 0; inode < rr_nodes_->size(); inode++) { - auto node = (*rr_nodes_)[inode]; + for (const t_rr_node& node : *rr_nodes_) { rr_graph_builder.add_node_to_all_locs(node.id()); } } diff --git a/vpr/src/route/clock_network_builders.cpp b/vpr/src/route/clock_network_builders.cpp index 9347cf28cd..73932d99f3 100644 --- a/vpr/src/route/clock_network_builders.cpp +++ b/vpr/src/route/clock_network_builders.cpp @@ -372,8 +372,7 @@ int ClockRib::create_chanx_wire(int layer, /* TODO: Will replace these codes with an API add_node_to_all_locs() of RRGraphBuilder */ for (int ix = rr_graph.node_xlow(chanx_node); ix <= rr_graph.node_xhigh(chanx_node); ++ix) { for (int iy = rr_graph.node_ylow(chanx_node); iy <= rr_graph.node_yhigh(chanx_node); ++iy) { - //TODO: CHANX uses odd swapped x/y indices here. Will rework once rr_node_indices is shadowed - rr_graph_builder.node_lookup().add_node(chanx_node, layer, iy, ix, rr_graph.node_type(chanx_node), rr_graph.node_track_num(chanx_node)); + rr_graph_builder.node_lookup().add_node(chanx_node, layer, ix, iy, rr_graph.node_type(chanx_node), rr_graph.node_track_num(chanx_node)); } } diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index 718a21ca9f..3f77949d96 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -1250,12 +1250,11 @@ static void build_rr_graph(e_graph_type graph_type, // Add routing resources to rr_graph lookup table alloc_and_load_rr_node_indices(device_ctx.rr_graph_builder, - &nodes_per_chan, + nodes_per_chan, grid, &num_rr_nodes, chan_details_x, - chan_details_y, - is_flat); + chan_details_y); size_t expected_node_count = num_rr_nodes; if (clock_modeling == DEDICATED_NETWORK) { @@ -1337,11 +1336,10 @@ static void build_rr_graph(e_graph_type graph_type, */ if (grid.get_num_layers() > 1 && sb_type == CUSTOM) { //keep how many nodes each switchblock requires for each x,y location - auto extra_nodes_per_switchblock = get_number_track_to_track_inter_die_conn(sb_conn_map, custom_3d_sb_fanin_fanout, device_ctx.rr_graph_builder); + vtr::NdMatrix extra_nodes_per_switchblock = get_number_track_to_track_inter_die_conn(sb_conn_map, custom_3d_sb_fanin_fanout, device_ctx.rr_graph_builder); //allocate new nodes in each switchblocks - alloc_and_load_inter_die_rr_node_indices(device_ctx.rr_graph_builder, &nodes_per_chan, grid, extra_nodes_per_switchblock, &num_rr_nodes); + alloc_and_load_inter_die_rr_node_indices(device_ctx.rr_graph_builder, nodes_per_chan, grid, extra_nodes_per_switchblock, &num_rr_nodes); device_ctx.rr_graph_builder.resize_nodes(num_rr_nodes); - extra_nodes_per_switchblock.clear(); } /* START IPIN MAP */ diff --git a/vpr/src/route/rr_graph2.cpp b/vpr/src/route/rr_graph2.cpp index 0c716b8dc3..7bc71b57a7 100644 --- a/vpr/src/route/rr_graph2.cpp +++ b/vpr/src/route/rr_graph2.cpp @@ -33,10 +33,21 @@ static void load_chan_rr_indices(const int max_chan_width, RRGraphBuilder& rr_graph_builder, int* index); +/** + * @brief Assigns and loads rr_node indices for block-level routing resources (SOURCE, SINK, IPIN, OPIN). + * + * This function walks through the device grid and assigns unique rr_node indices to the routing resources + * associated with each block (tiles). + * + * For SINKs and SOURCEs, it uses side 0 by convention (since they have no geometric side). For IPINs and OPINs, + * it determines the correct sides based on the tile's position in the grid, following special rules for + * edge and corner tiles. + * + * The index counter is passed and updated as rr_nodes are added. + */ static void load_block_rr_indices(RRGraphBuilder& rr_graph_builder, const DeviceGrid& grid, - int* index, - bool is_flat); + int* index); static void add_pins_spatial_lookup(RRGraphBuilder& rr_graph_builder, t_physical_tile_type_ptr physical_type_ptr, @@ -1079,6 +1090,7 @@ void dump_track_to_pin_map(t_track_to_pin_lookup& track_to_pin_map, } } } + static void load_chan_rr_indices(const int max_chan_width, const DeviceGrid& grid, const int chan_len, @@ -1090,19 +1102,20 @@ static void load_chan_rr_indices(const int max_chan_width, const auto& device_ctx = g_vpr_ctx.device(); for (int layer = 0; layer < grid.get_num_layers(); layer++) { - /* Skip the current die if architecture file specifies that it doesn't require global resource routing */ + // Skip the current die if architecture file specifies that it doesn't require global resource routing if (!device_ctx.inter_cluster_prog_routing_resources.at(layer)) { continue; } + for (int chan = 0; chan < num_chans - 1; ++chan) { for (int seg = 1; seg < chan_len - 1; ++seg) { - /* Assign an inode to the starts of tracks */ - int x = (type == e_rr_type::CHANX ? seg : chan); - int y = (type == e_rr_type::CHANX ? chan : seg); + // Assign an inode to the starts of tracks + const int x = (type == e_rr_type::CHANX) ? seg : chan; + const int y = (type == e_rr_type::CHANX) ? chan : seg; const t_chan_seg_details* seg_details = chan_details[x][y].data(); - /* Reserve nodes in lookup to save memory */ - rr_graph_builder.node_lookup().reserve_nodes(layer, chan, seg, type, max_chan_width); + // Reserve nodes in lookup to save memory + rr_graph_builder.node_lookup().reserve_nodes(layer, x, y, type, max_chan_width); for (int track = 0; track < max_chan_width; ++track) { /* TODO: May let the length() == 0 case go through, to model muxes */ @@ -1110,25 +1123,19 @@ static void load_chan_rr_indices(const int max_chan_width, continue; int start = get_seg_start(seg_details, track, chan, seg); + int node_start_x = (type == e_rr_type::CHANX) ? start : chan; + int node_start_y = (type == e_rr_type::CHANX) ? chan : start; - /* TODO: Now we still use the (y, x) convention here for CHANX. Should rework later */ - int node_x = chan; - int node_y = start; - if (e_rr_type::CHANX == type) { - std::swap(node_x, node_y); - } - - /* If the start of the wire doesn't have an inode, - * assign one to it. */ - RRNodeId inode = rr_graph_builder.node_lookup().find_node(layer, node_x, node_y, type, track); + // If the start of the wire doesn't have an RRNodeId, assign one to it. + RRNodeId inode = rr_graph_builder.node_lookup().find_node(layer, node_start_x, node_start_y, type, track); if (!inode) { inode = RRNodeId(*index); ++(*index); - rr_graph_builder.node_lookup().add_node(inode, layer, chan, start, type, track); + rr_graph_builder.node_lookup().add_node(inode, layer, node_start_x, node_start_y, type, track); } - /* Assign inode of start of wire to current position */ - rr_graph_builder.node_lookup().add_node(inode, layer, chan, seg, type, track); + // Assign RRNodeId of start of wire to current position + rr_graph_builder.node_lookup().add_node(inode, layer, x, y, type, track); } } } @@ -1206,7 +1213,7 @@ vtr::NdMatrix get_number_track_to_track_inter_die_conn(t_sb_connection_m } void alloc_and_load_inter_die_rr_node_indices(RRGraphBuilder& rr_graph_builder, - const t_chan_width* nodes_per_chan, + const t_chan_width& nodes_per_chan, const DeviceGrid& grid, const vtr::NdMatrix& extra_nodes_per_switchblock, int* index) { @@ -1219,31 +1226,32 @@ void alloc_and_load_inter_die_rr_node_indices(RRGraphBuilder& rr_graph_builder, * 3) ptc = [max_chanx_width:max_chanx_width+number_of_connection-1] * 4) direction = NONE */ - auto& device_ctx = g_vpr_ctx.device(); + const auto& device_ctx = g_vpr_ctx.device(); for (int layer = 0; layer < grid.get_num_layers(); layer++) { /* Skip the current die if architecture file specifies that it doesn't have global resource routing */ if (!device_ctx.inter_cluster_prog_routing_resources.at(layer)) { continue; } + for (size_t y = 0; y < grid.height() - 1; ++y) { for (size_t x = 1; x < grid.width() - 1; ++x) { - //count how many track-to-track connection go from current layer to other layers + // count how many track-to-track connection go from current layer to other layers int conn_count = extra_nodes_per_switchblock[x][y]; - //skip if no connection is required + // skip if no connection is required if (conn_count == 0) { continue; } - //reserve extra nodes for inter-die track-to-track connection - rr_graph_builder.node_lookup().reserve_nodes(layer, y, x, e_rr_type::CHANX, conn_count + nodes_per_chan->max); + // reserve extra nodes for inter-die track-to-track connection + rr_graph_builder.node_lookup().reserve_nodes(layer, x, y, e_rr_type::CHANX, conn_count + nodes_per_chan.max); for (int rr_node_offset = 0; rr_node_offset < conn_count; rr_node_offset++) { - RRNodeId inode = rr_graph_builder.node_lookup().find_node(layer, x, y, e_rr_type::CHANX, nodes_per_chan->max + rr_node_offset); + RRNodeId inode = rr_graph_builder.node_lookup().find_node(layer, x, y, e_rr_type::CHANX, nodes_per_chan.max + rr_node_offset); if (!inode) { inode = RRNodeId(*index); ++(*index); - rr_graph_builder.node_lookup().add_node(inode, layer, y, x, e_rr_type::CHANX, nodes_per_chan->max + rr_node_offset); + rr_graph_builder.node_lookup().add_node(inode, layer, x, y, e_rr_type::CHANX, nodes_per_chan.max + rr_node_offset); } } } @@ -1256,8 +1264,7 @@ void alloc_and_load_inter_die_rr_node_indices(RRGraphBuilder& rr_graph_builder, */ static void load_block_rr_indices(RRGraphBuilder& rr_graph_builder, const DeviceGrid& grid, - int* index, - bool /*is_flat*/) { + int* index) { //Walk through the grid assigning indices to SOURCE/SINK IPIN/OPIN for (int layer = 0; layer < grid.get_num_layers(); layer++) { for (int x = 0; x < (int)grid.width(); x++) { @@ -1347,6 +1354,7 @@ static void load_block_rr_indices(RRGraphBuilder& rr_graph_builder, } } } + static void add_pins_spatial_lookup(RRGraphBuilder& rr_graph_builder, t_physical_tile_type_ptr physical_type_ptr, const std::vector& pin_num_vec, @@ -1439,34 +1447,24 @@ static void add_classes_spatial_lookup(RRGraphBuilder& rr_graph_builder, } } -/* As the rr_indices builders modify a local copy of indices, use the local copy in the builder */ void alloc_and_load_rr_node_indices(RRGraphBuilder& rr_graph_builder, - const t_chan_width* nodes_per_chan, + const t_chan_width& nodes_per_chan, const DeviceGrid& grid, int* index, const t_chan_details& chan_details_x, - const t_chan_details& chan_details_y, - bool is_flat) { - /* Allocates and loads all the structures needed for fast lookups of the - * index of an rr_node. rr_node_indices is a matrix containing the index - * of the *first* rr_node at a given (i,j) location. */ - + const t_chan_details& chan_details_y) { /* Alloc the lookup table */ for (e_rr_type rr_type : RR_TYPES) { - if (rr_type == e_rr_type::CHANX) { - rr_graph_builder.node_lookup().resize_nodes(grid.get_num_layers(), grid.height(), grid.width(), rr_type, NUM_2D_SIDES); - } else { - rr_graph_builder.node_lookup().resize_nodes(grid.get_num_layers(), grid.width(), grid.height(), rr_type, NUM_2D_SIDES); - } + rr_graph_builder.node_lookup().resize_nodes(grid.get_num_layers(), grid.width(), grid.height(), rr_type, NUM_2D_SIDES); } /* Assign indices for block nodes */ - load_block_rr_indices(rr_graph_builder, grid, index, is_flat); + load_block_rr_indices(rr_graph_builder, grid, index); /* Load the data for x and y channels */ - load_chan_rr_indices(nodes_per_chan->x_max, grid, grid.width(), grid.height(), + load_chan_rr_indices(nodes_per_chan.x_max, grid, grid.width(), grid.height(), e_rr_type::CHANX, chan_details_x, rr_graph_builder, index); - load_chan_rr_indices(nodes_per_chan->y_max, grid, grid.height(), grid.width(), + load_chan_rr_indices(nodes_per_chan.y_max, grid, grid.height(), grid.width(), e_rr_type::CHANY, chan_details_y, rr_graph_builder, index); } @@ -1518,15 +1516,6 @@ void alloc_and_load_intra_cluster_rr_node_indices(RRGraphBuilder& rr_graph_build } } -/** - * 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 vtr::vector& rr_indexed_data, @@ -1549,6 +1538,7 @@ bool verify_rr_node_indices(const DeviceGrid& grid, } else { nodes_from_lookup = rr_graph.node_lookup().find_grid_nodes_at_all_sides(l, x, y, rr_type); } + for (RRNodeId inode : nodes_from_lookup) { rr_node_counts[inode]++; diff --git a/vpr/src/route/rr_graph2.h b/vpr/src/route/rr_graph2.h index b783e993d6..05e723470e 100644 --- a/vpr/src/route/rr_graph2.h +++ b/vpr/src/route/rr_graph2.h @@ -1,5 +1,5 @@ -#ifndef RR_GRAPH2_H -#define RR_GRAPH2_H +#pragma once + #include #include "build_switchblocks.h" @@ -14,16 +14,21 @@ /******************* Subroutines exported by rr_graph2.c *********************/ +/** + * @brief Allocates and populates data structures for efficient rr_node index lookups. + * + * This function sets up the `rr_node_indices` structure, which maps a physical location + * and type to the index of the first corresponding rr_node. + */ void alloc_and_load_rr_node_indices(RRGraphBuilder& rr_graph_builder, - const t_chan_width* nodes_per_chan, + const t_chan_width& nodes_per_chan, const DeviceGrid& grid, int* index, const t_chan_details& chan_details_x, - const t_chan_details& chan_details_y, - bool is_flat); + const t_chan_details& chan_details_y); /** - * @brief allocates extra nodes within the RR graph to support 3D custom switch blocks for multi-die FPGAs + * @brief Allocates extra nodes within the RR graph to support 3D custom switch blocks for multi-die FPGAs * * @param rr_graph_builder RRGraphBuilder data structure which allows data modification on a routing resource graph * @param nodes_per_chan number of tracks per channel (x, y) @@ -33,7 +38,7 @@ void alloc_and_load_rr_node_indices(RRGraphBuilder& rr_graph_builder, * @param index RRNodeId that should be assigned to add a new RR node to the RR graph */ void alloc_and_load_inter_die_rr_node_indices(RRGraphBuilder& rr_graph_builder, - const t_chan_width* nodes_per_chan, + const t_chan_width& nodes_per_chan, const DeviceGrid& grid, const vtr::NdMatrix& extra_nodes_per_switchblock, int* index); @@ -51,6 +56,15 @@ void alloc_and_load_intra_cluster_rr_node_indices(RRGraphBuilder& rr_graph_build const vtr::vector>& pin_chains_num, int* index); +/** + * 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 vtr::vector& rr_indexed_data, @@ -252,4 +266,3 @@ void dump_track_to_pin_map(t_track_to_pin_lookup& track_to_pin_map, FILE* fp); inline int get_chan_width(enum e_side side, const t_chan_width& nodes_per_channel); -#endif