diff --git a/vpr/src/base/read_route.cpp b/vpr/src/base/read_route.cpp index 3c3900ef48a..e895cf88d92 100644 --- a/vpr/src/base/read_route.cpp +++ b/vpr/src/base/read_route.cpp @@ -258,7 +258,7 @@ static void process_nodes(std::ifstream& fp, ClusterNetId inet, const char* file } /*Check node types if match rr graph*/ - if (tokens[2] != node.type_string()) { + if (tokens[2] != rr_graph.node_type_string(RRNodeId(inode))) { vpr_throw(VPR_ERROR_ROUTE, filename, lineno, "Node %d has a type that does not match the RR graph", inode); } diff --git a/vpr/src/base/vpr_api.cpp b/vpr/src/base/vpr_api.cpp index 3250a12cbe1..f57ae6f736c 100644 --- a/vpr/src/base/vpr_api.cpp +++ b/vpr/src/base/vpr_api.cpp @@ -701,6 +701,8 @@ RouteStatus vpr_route_flow(t_vpr_setup& vpr_setup, const t_arch& arch) { const auto& router_opts = vpr_setup.RouterOpts; const auto& filename_opts = vpr_setup.FileNameOpts; + const auto& device_ctx = g_vpr_ctx.device(); + const auto& rr_graph = device_ctx.rr_graph; if (router_opts.doRouting == STAGE_SKIP) { //Assume successful @@ -762,7 +764,7 @@ RouteStatus vpr_route_flow(t_vpr_setup& vpr_setup, const t_arch& arch) { //Otherwise, remind the user of this possible report option if (router_opts.generate_rr_node_overuse_report) { VTR_LOG("See report_overused_nodes.rpt for a detailed report on the RR node overuse information.\n"); - report_overused_nodes(); + report_overused_nodes(rr_graph); } else { VTR_LOG("For a detailed report on the RR node overuse information (report_overused_nodes.rpt), specify --generate_rr_node_overuse_report on.\n"); } diff --git a/vpr/src/device/rr_graph_view.h b/vpr/src/device/rr_graph_view.h index 2c3dc7839f2..7267f1c394f 100644 --- a/vpr/src/device/rr_graph_view.h +++ b/vpr/src/device/rr_graph_view.h @@ -244,6 +244,11 @@ class RRGraphView { return node_storage_.is_node_on_specific_side(node, side); } + /** @brief Get the side string of a routing resource node. This function is inlined for runtime optimization. */ + inline const char* node_side_string(RRNodeId node) const { + return node_storage_.node_side_string(node); + } + /** @brief Get the cost index of a routing resource node. This function is inlined for runtime optimization. */ RRIndexedDataId node_cost_index(RRNodeId node) const { return node_storage_.node_cost_index(node); diff --git a/vpr/src/route/check_rr_graph.cpp b/vpr/src/route/check_rr_graph.cpp index 3dd18a2638e..7d71ec917aa 100644 --- a/vpr/src/route/check_rr_graph.cpp +++ b/vpr/src/route/check_rr_graph.cpp @@ -236,26 +236,26 @@ void check_rr_graph(const t_graph_type graph_type, if (!is_chain && !is_fringe && !is_wire) { if (rr_graph.node_type(rr_node) == IPIN || rr_graph.node_type(rr_node) == OPIN) { if (has_adjacent_channel(node, device_ctx.grid)) { - auto block_type = device_ctx.grid[rr_graph.node_xlow(node.id())][rr_graph.node_ylow(node.id())].type; + auto block_type = device_ctx.grid[rr_graph.node_xlow(rr_node)][rr_graph.node_ylow(rr_node)].type; std::string pin_name = block_type_pin_index_to_name(block_type, node.pin_num()); /* Print error messages for all the sides that a node may appear */ for (const e_side& node_side : SIDES) { - if (!rr_graph.is_node_on_specific_side(RRNodeId(rr_node), node_side)) { + if (!rr_graph.is_node_on_specific_side(rr_node, node_side)) { continue; } VTR_LOG_ERROR("in check_rr_graph: node %d (%s) at (%d,%d) block=%s side=%s pin=%s has no fanin.\n", - inode, node.type_string(), rr_graph.node_xlow(node.id()), rr_graph.node_ylow(node.id()), block_type->name, SIDE_STRING[node_side], pin_name.c_str()); + inode, rr_graph.node_type_string(rr_node), rr_graph.node_xlow(rr_node), rr_graph.node_ylow(rr_node), block_type->name, SIDE_STRING[node_side], pin_name.c_str()); } } } else { VTR_LOG_ERROR("in check_rr_graph: node %d (%s) has no fanin.\n", - inode, device_ctx.rr_nodes[inode].type_string()); + inode, rr_graph.node_type_string(rr_node)); } } else if (!is_chain && !is_fringe_warning_sent) { VTR_LOG_WARN( "in check_rr_graph: fringe node %d %s at (%d,%d) has no fanin.\n" "\t This is possible on a fringe node based on low Fc_out, N, and certain lengths.\n", - inode, device_ctx.rr_nodes[inode].type_string(), rr_graph.node_xlow(rr_node), rr_graph.node_ylow(rr_node)); + inode, rr_graph.node_type_string(rr_node), rr_graph.node_xlow(rr_node), rr_graph.node_ylow(rr_node)); is_fringe_warning_sent = true; } } diff --git a/vpr/src/route/overuse_report.cpp b/vpr/src/route/overuse_report.cpp index 9bb67ab28cd..5f9ff9cec9e 100644 --- a/vpr/src/route/overuse_report.cpp +++ b/vpr/src/route/overuse_report.cpp @@ -59,9 +59,7 @@ void log_overused_nodes_status(int max_logged_overused_rr_nodes) { * This report will be generated only if the last routing attempt fails, which * causes the whole VPR flow to fail. */ -void report_overused_nodes() { - const auto& device_ctx = g_vpr_ctx.device(); - const auto& rr_graph = device_ctx.rr_graph; +void report_overused_nodes(const RRGraphView& rr_graph) { const auto& route_ctx = g_vpr_ctx.routing(); /* Generate overuse info lookup table */ @@ -85,11 +83,11 @@ void report_overused_nodes() { os << "Overused RR node #" << inode << '\n'; os << "Node id = " << size_t(node_id) << '\n'; os << "Occupancy = " << route_ctx.rr_node_route_inf[size_t(node_id)].occ() << '\n'; - os << "Capacity = " << device_ctx.rr_nodes.node_capacity(node_id) << "\n\n"; + os << "Capacity = " << rr_graph.node_capacity(node_id) << "\n\n"; /* Report selective info based on the rr node type */ auto node_type = rr_graph.node_type(node_id); - os << "Node type = " << device_ctx.rr_nodes.node_type_string(node_id) << '\n'; + os << "Node type = " << rr_graph.node_type_string(node_id) << '\n'; switch (node_type) { case IPIN: @@ -162,7 +160,7 @@ static void report_overused_ipin_opin(std::ostream& os, RRNodeId node_id) { "Non-track RR node should not span across multiple grid blocks."); os << "Pin number = " << device_ctx.rr_nodes.node_pin_num(node_id) << '\n'; - os << "Side = " << device_ctx.rr_nodes.node_side_string(node_id) << "\n\n"; + os << "Side = " << rr_graph.node_side_string(node_id) << "\n\n"; //Add block type for IPINs/OPINs in overused rr-node report const auto& clb_nlist = g_vpr_ctx.clustering().clb_nlist; @@ -268,10 +266,10 @@ static void log_single_overused_node_status(int overuse_index, RRNodeId node_id) VTR_LOG(" %10d", route_ctx.rr_node_route_inf[size_t(node_id)].occ()); //Capacity - VTR_LOG(" %9d", device_ctx.rr_nodes.node_capacity(node_id)); + VTR_LOG(" %9d", rr_graph.node_capacity(node_id)); //RR node type - VTR_LOG(" %8s", device_ctx.rr_nodes.node_type_string(node_id)); + VTR_LOG(" %8s", rr_graph.node_type_string(node_id)); //Direction if (node_type == e_rr_type::CHANX || node_type == e_rr_type::CHANY) { @@ -282,7 +280,7 @@ static void log_single_overused_node_status(int overuse_index, RRNodeId node_id) //Side if (node_type == e_rr_type::IPIN || node_type == e_rr_type::OPIN) { - VTR_LOG(" %7s", device_ctx.rr_nodes.node_side_string(node_id)); + VTR_LOG(" %7s", rr_graph.node_side_string(node_id)); } else { VTR_LOG(" %7s", "N/A"); } diff --git a/vpr/src/route/overuse_report.h b/vpr/src/route/overuse_report.h index 9961056cc5f..557c6f91c42 100644 --- a/vpr/src/route/overuse_report.h +++ b/vpr/src/route/overuse_report.h @@ -1,6 +1,7 @@ #pragma once #include "rr_graph_storage.h" +#include "rr_graph_view.h" #include /** @@ -21,7 +22,7 @@ void log_overused_nodes_status(int max_logged_overused_rr_nodes); ///@brief Print out RR node overuse info in a post-VPR report file. -void report_overused_nodes(); +void report_overused_nodes(const RRGraphView& rr_graph); ///@brief Generate a overused RR nodes to congested nets lookup table. void generate_overused_nodes_to_congested_net_lookup(std::map>& nodes_to_nets_lookup); \ No newline at end of file diff --git a/vpr/src/route/route_common.cpp b/vpr/src/route/route_common.cpp index 062fd257ab6..5dac97ce0f2 100644 --- a/vpr/src/route/route_common.cpp +++ b/vpr/src/route/route_common.cpp @@ -1235,17 +1235,18 @@ void print_route(FILE* fp, const vtr::vector& traceba while (tptr != nullptr) { int inode = tptr->index; - t_rr_type rr_type = rr_graph.node_type(RRNodeId(inode)); - int ilow = rr_graph.node_xlow(RRNodeId(inode)); - int jlow = rr_graph.node_ylow(RRNodeId(inode)); + auto rr_node = RRNodeId(inode); + t_rr_type rr_type = rr_graph.node_type(rr_node); + int ilow = rr_graph.node_xlow(rr_node); + int jlow = rr_graph.node_ylow(rr_node); fprintf(fp, "Node:\t%d\t%6s (%d,%d) ", inode, - device_ctx.rr_nodes[inode].type_string(), ilow, jlow); + rr_graph.node_type_string(rr_node), ilow, jlow); - if ((ilow != rr_graph.node_xhigh(RRNodeId(inode))) - || (jlow != rr_graph.node_yhigh(RRNodeId(inode)))) - fprintf(fp, "to (%d,%d) ", rr_graph.node_xhigh(RRNodeId(inode)), - rr_graph.node_yhigh(RRNodeId(inode))); + if ((ilow != rr_graph.node_xhigh(rr_node)) + || (jlow != rr_graph.node_yhigh(rr_node))) + fprintf(fp, "to (%d,%d) ", rr_graph.node_xhigh(rr_node), + rr_graph.node_yhigh(rr_node)); switch (rr_type) { case IPIN: @@ -1274,7 +1275,7 @@ void print_route(FILE* fp, const vtr::vector& traceba default: VPR_FATAL_ERROR(VPR_ERROR_ROUTE, "in print_route: Unexpected traceback element type: %d (%s).\n", - rr_type, device_ctx.rr_nodes[inode].type_string()); + rr_type, rr_graph.node_type_string(rr_node)); break; } @@ -1656,7 +1657,7 @@ void print_rr_node_route_inf_dot() { VTR_LOG("\tnode[shape=record]\n"); for (size_t inode = 0; inode < route_ctx.rr_node_route_inf.size(); ++inode) { if (!std::isinf(route_ctx.rr_node_route_inf[inode].path_cost)) { - VTR_LOG("\tnode%zu[label=\"{%zu (%s)", inode, inode, device_ctx.rr_nodes[inode].type_string()); + VTR_LOG("\tnode%zu[label=\"{%zu (%s)", inode, inode, rr_graph.node_type_string(RRNodeId(inode))); if (route_ctx.rr_node_route_inf[inode].occ() > rr_graph.node_capacity(RRNodeId(inode))) { VTR_LOG(" x"); } diff --git a/vpr/src/route/route_tree_timing.cpp b/vpr/src/route/route_tree_timing.cpp index 77657ea4da9..7cb35ca7aea 100644 --- a/vpr/src/route/route_tree_timing.cpp +++ b/vpr/src/route/route_tree_timing.cpp @@ -692,7 +692,7 @@ void print_route_tree(const t_rt_node* rt_node, int depth) { auto& device_ctx = g_vpr_ctx.device(); const auto& rr_graph = device_ctx.rr_graph; VTR_LOG("%srt_node: %d (%s) \t ipin: %d \t R: %g \t C: %g \t delay: %g", - indent.c_str(), rt_node->inode, device_ctx.rr_nodes[rt_node->inode].type_string(), rt_node->net_pin_index, rt_node->R_upstream, rt_node->C_downstream, rt_node->Tdel); + indent.c_str(), rt_node->inode, rr_graph.node_type_string(RRNodeId(rt_node->inode)), rt_node->net_pin_index, rt_node->R_upstream, rt_node->C_downstream, rt_node->Tdel); if (rt_node->parent_switch != OPEN) { bool parent_edge_configurable = device_ctx.rr_switch_inf[rt_node->parent_switch].configurable(); diff --git a/vpr/src/route/router_delay_profiling.cpp b/vpr/src/route/router_delay_profiling.cpp index d53ce31ea1d..e123f509d00 100644 --- a/vpr/src/route/router_delay_profiling.cpp +++ b/vpr/src/route/router_delay_profiling.cpp @@ -32,11 +32,11 @@ bool RouterDelayProfiler::calculate_delay(int source_node, int sink_node, const auto& route_ctx = g_vpr_ctx.routing(); //vtr::ScopedStartFinishTimer t(vtr::string_fmt("Profiling Delay from %s at %d,%d (%s) to %s at %d,%d (%s)", - //device_ctx.rr_nodes[source_node].type_string(), + //rr_graph.node_type_string(RRNodeId(source_node)), //rr_graph.node_xlow(RRNodeId(source_node)), //rr_graph.node_ylow(RRNodeId(source_node)), //rr_node_arch_name(source_node).c_str(), - //device_ctx.rr_nodes[sink_node].type_string(), + //rr_graph.node_type_string(RRNodeId(sink_node)), //rr_graph.node_xlow(RRNodeId(sink_node)), //rr_graph.node_ylow(RRNodeId(sink_node)), //rr_node_arch_name(sink_node).c_str())); diff --git a/vpr/src/route/router_lookahead_extended_map.cpp b/vpr/src/route/router_lookahead_extended_map.cpp index 3411a5bfddd..0e5ea06d0f5 100644 --- a/vpr/src/route/router_lookahead_extended_map.cpp +++ b/vpr/src/route/router_lookahead_extended_map.cpp @@ -175,8 +175,7 @@ std::pair ExtendedMapLookahead::get_expected_delay_and_cong(RRNode } auto& device_ctx = g_vpr_ctx.device(); - const auto& temp_rr_graph = device_ctx.rr_graph; //TODO Once the uses of rr_graph in the next line are removed, this will be renamed to rr_graph from temp_rr_graph - auto& rr_graph = device_ctx.rr_nodes; + const auto& rr_graph = device_ctx.rr_graph; int from_x = rr_graph.node_xlow(from_node); int from_y = rr_graph.node_ylow(from_node); @@ -188,7 +187,7 @@ std::pair ExtendedMapLookahead::get_expected_delay_and_cong(RRNode dx = to_x - from_x; dy = to_y - from_y; - e_rr_type from_type = temp_rr_graph.node_type(from_node); + e_rr_type from_type = rr_graph.node_type(from_node); if (from_type == SOURCE || from_type == OPIN) { return this->get_src_opin_cost(from_node, dx, dy, params); } else if (from_type == IPIN) { @@ -202,8 +201,8 @@ std::pair ExtendedMapLookahead::get_expected_delay_and_cong(RRNode // there is no route VTR_LOGV_DEBUG(f_router_debug, "Not connected %d (%s, %d) -> %d (%s)\n", - size_t(from_node), device_ctx.rr_nodes[size_t(from_node)].type_string(), from_seg_index, - size_t(to_node), device_ctx.rr_nodes[size_t(to_node)].type_string()); + size_t(from_node), rr_graph.node_type_string(from_node), from_seg_index, + size_t(to_node), rr_graph.node_type_string(to_node)); float infinity = std::numeric_limits::infinity(); return std::make_pair(infinity, infinity); } @@ -265,7 +264,7 @@ bool ExtendedMapLookahead::add_paths(RRNodeId start_node, const std::vector& paths, util::RoutingCosts* routing_costs) { auto& device_ctx = g_vpr_ctx.device(); - auto& rr_graph = device_ctx.rr_nodes; + auto& rr_graph = device_ctx.rr_graph; RRNodeId node = current.rr_node; diff --git a/vpr/src/route/rr_graph_indexed_data.cpp b/vpr/src/route/rr_graph_indexed_data.cpp index 85c751b3614..12d3e26f3e4 100644 --- a/vpr/src/route/rr_graph_indexed_data.cpp +++ b/vpr/src/route/rr_graph_indexed_data.cpp @@ -450,6 +450,7 @@ static void load_rr_indexed_data_T_values() { */ static void calculate_average_switch(int inode, double& avg_switch_R, double& avg_switch_T, double& avg_switch_Cinternal, int& num_switches, short& buffered, vtr::vector>& fan_in_list) { auto& device_ctx = g_vpr_ctx.device(); + const auto& rr_graph = device_ctx.rr_graph; const auto& rr_nodes = device_ctx.rr_nodes.view(); auto node = RRNodeId(inode); @@ -461,7 +462,7 @@ static void calculate_average_switch(int inode, double& avg_switch_R, double& av buffered = UNDEFINED; for (const auto& edge : fan_in_list[node]) { /* want to get C/R/Tdel/Cinternal of switches that connect this track segment to other track segments */ - if (rr_nodes.node_type(node) == CHANX || rr_nodes.node_type(node) == CHANY) { + if (rr_graph.node_type(node) == CHANX || rr_graph.node_type(node) == CHANY) { int switch_index = rr_nodes.edge_switch(edge); if (device_ctx.rr_switch_inf[switch_index].type() == SwitchType::SHORT) continue; diff --git a/vpr/src/route/rr_node.cpp b/vpr/src/route/rr_node.cpp index 4cf8a1d8684..2aecb0c9776 100644 --- a/vpr/src/route/rr_node.cpp +++ b/vpr/src/route/rr_node.cpp @@ -3,16 +3,6 @@ #include "globals.h" #include "vpr_error.h" -/* Member function of "t_rr_node" used to retrieve a routing * - * resource type string by its index, which is defined by * - * "t_rr_type type". */ - -const char* t_rr_node::type_string() const { - // ESR API The contents of this function have been temporarily replaced - // Once the RRGraphView API is complete, this function will be removed completely - return rr_node_typename[g_vpr_ctx.device().rr_graph.node_type(id_)]; -} - //Returns the max 'length' over the x or y direction short t_rr_node::length() const { return std::max( diff --git a/vpr/src/route/rr_node.h b/vpr/src/route/rr_node.h index c239deb463b..3af4823f34e 100644 --- a/vpr/src/route/rr_node.h +++ b/vpr/src/route/rr_node.h @@ -77,9 +77,6 @@ class t_rr_node { , id_(id) {} public: //Accessors - //t_rr_type type() const; // ESR API This function has been replaced by RRGraphView::node_type() - const char* type_string() const; /* Retrieve type as a string */ - edge_idx_range edges() const; edge_idx_range configurable_edges() const; edge_idx_range non_configurable_edges() const; diff --git a/vpr/src/util/vpr_utils.cpp b/vpr/src/util/vpr_utils.cpp index ca4fc716e66..36077bd7e2d 100644 --- a/vpr/src/util/vpr_utils.cpp +++ b/vpr/src/util/vpr_utils.cpp @@ -205,7 +205,7 @@ std::string rr_node_arch_name(int inode) { auto type = device_ctx.grid[rr_graph.node_xlow(rr_node.id())][rr_graph.node_ylow(rr_node.id())].type; auto pin_names = block_type_class_index_to_pin_names(type, rr_node.ptc_num()); if (pin_names.size() > 1) { - rr_node_arch_name += rr_node.type_string(); + rr_node_arch_name += rr_graph.node_type_string(RRNodeId(inode)); rr_node_arch_name += " connected to "; rr_node_arch_name += "{"; rr_node_arch_name += vtr::join(pin_names, ", ");