Skip to content

RRGraphView node_type_string(), node_side_string() Implementation #1873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vpr/src/base/read_route.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion vpr/src/base/vpr_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
}
Expand Down
5 changes: 5 additions & 0 deletions vpr/src/device/rr_graph_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions vpr/src/route/check_rr_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
16 changes: 7 additions & 9 deletions vpr/src/route/overuse_report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel good to see this function longer uses the rr_nodes data structure, it would be good to add the rr_graph to the argument list rather than fetching it from device_ctx. If it is too much for you, I can let @baberali-rs to follow up on this function.

Copy link
Contributor Author

@ethanroj23 ethanroj23 Oct 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we add const RRGraphView& rr_graph to the argument list, every function that calls report_overused_nodes() has to have a reference to the rr_graph. Currently, the call tree is like: main()->vpr_flow()->vpr_route_flow()->report_overused_nodes() How high up in the call tree do we want to go before we access the rr_graph from device_ctx? @vaughnbetz Do you have a preference on what to do here?

Additionally, if we pass the rr_graph all the way down from main(), each of the functions along the call tree will have rr_graph as an extra argument

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tangxifan I have added RRGraphView to the argument list of report_overused_nodes() and now VTR Nightly Tests Part 1 is failing qor. I will try running the full qor regression, but it's possible we may have to leave things how they were. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tangxifan now that this branch is passing, are we good to merge it in? I don't have write access, so I can't do that myself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I merge now. All concerns resolved.


/* 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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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");
}
Expand Down
3 changes: 2 additions & 1 deletion vpr/src/route/overuse_report.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "rr_graph_storage.h"
#include "rr_graph_view.h"
#include <map>

/**
Expand All @@ -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<RRNodeId, std::set<ClusterNetId>>& nodes_to_nets_lookup);
21 changes: 11 additions & 10 deletions vpr/src/route/route_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1235,17 +1235,18 @@ void print_route(FILE* fp, const vtr::vector<ClusterNetId, t_traceback>& 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:
Expand Down Expand Up @@ -1274,7 +1275,7 @@ void print_route(FILE* fp, const vtr::vector<ClusterNetId, t_traceback>& 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;
}

Expand Down Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/route/route_tree_timing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my last comment, it would be good to add the rr_graph to the argument list rather than fetching it from device_ctx. If it is too much for you, I can let @baberali-rs to follow up on this function.


if (rt_node->parent_switch != OPEN) {
bool parent_edge_configurable = device_ctx.rr_switch_inf[rt_node->parent_switch].configurable();
Expand Down
4 changes: 2 additions & 2 deletions vpr/src/route/router_delay_profiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
11 changes: 5 additions & 6 deletions vpr/src/route/router_lookahead_extended_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ std::pair<float, float> 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);
Expand All @@ -188,7 +187,7 @@ std::pair<float, float> 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) {
Expand All @@ -202,8 +201,8 @@ std::pair<float, float> 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<float>::infinity();
return std::make_pair(infinity, infinity);
}
Expand Down Expand Up @@ -265,7 +264,7 @@ bool ExtendedMapLookahead::add_paths(RRNodeId start_node,
const std::vector<util::Search_Path>& 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;

Expand Down
3 changes: 2 additions & 1 deletion vpr/src/route/rr_graph_indexed_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<RRNodeId, std::vector<RREdgeId>>& 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);
Expand All @@ -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;
Expand Down
10 changes: 0 additions & 10 deletions vpr/src/route/rr_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 0 additions & 3 deletions vpr/src/route/rr_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/util/vpr_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, ", ");
Expand Down