Skip to content

Commit b2d9046

Browse files
authored
Merge pull request #1873 from ethanroj23/rr_graph_node_type_string
RRGraphView node_type_string(), node_side_string() Implementation
2 parents 92556fe + 15859c1 commit b2d9046

14 files changed

+45
-51
lines changed

vpr/src/base/read_route.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ static void process_nodes(std::ifstream& fp, ClusterNetId inet, const char* file
258258
}
259259

260260
/*Check node types if match rr graph*/
261-
if (tokens[2] != node.type_string()) {
261+
if (tokens[2] != rr_graph.node_type_string(RRNodeId(inode))) {
262262
vpr_throw(VPR_ERROR_ROUTE, filename, lineno,
263263
"Node %d has a type that does not match the RR graph", inode);
264264
}

vpr/src/base/vpr_api.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,8 @@ RouteStatus vpr_route_flow(t_vpr_setup& vpr_setup, const t_arch& arch) {
701701

702702
const auto& router_opts = vpr_setup.RouterOpts;
703703
const auto& filename_opts = vpr_setup.FileNameOpts;
704+
const auto& device_ctx = g_vpr_ctx.device();
705+
const auto& rr_graph = device_ctx.rr_graph;
704706

705707
if (router_opts.doRouting == STAGE_SKIP) {
706708
//Assume successful
@@ -762,7 +764,7 @@ RouteStatus vpr_route_flow(t_vpr_setup& vpr_setup, const t_arch& arch) {
762764
//Otherwise, remind the user of this possible report option
763765
if (router_opts.generate_rr_node_overuse_report) {
764766
VTR_LOG("See report_overused_nodes.rpt for a detailed report on the RR node overuse information.\n");
765-
report_overused_nodes();
767+
report_overused_nodes(rr_graph);
766768
} else {
767769
VTR_LOG("For a detailed report on the RR node overuse information (report_overused_nodes.rpt), specify --generate_rr_node_overuse_report on.\n");
768770
}

vpr/src/device/rr_graph_view.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ class RRGraphView {
244244
return node_storage_.is_node_on_specific_side(node, side);
245245
}
246246

247+
/** @brief Get the side string of a routing resource node. This function is inlined for runtime optimization. */
248+
inline const char* node_side_string(RRNodeId node) const {
249+
return node_storage_.node_side_string(node);
250+
}
251+
247252
/** @brief Get the cost index of a routing resource node. This function is inlined for runtime optimization. */
248253
RRIndexedDataId node_cost_index(RRNodeId node) const {
249254
return node_storage_.node_cost_index(node);

vpr/src/route/check_rr_graph.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,26 +236,26 @@ void check_rr_graph(const t_graph_type graph_type,
236236
if (!is_chain && !is_fringe && !is_wire) {
237237
if (rr_graph.node_type(rr_node) == IPIN || rr_graph.node_type(rr_node) == OPIN) {
238238
if (has_adjacent_channel(node, device_ctx.grid)) {
239-
auto block_type = device_ctx.grid[rr_graph.node_xlow(node.id())][rr_graph.node_ylow(node.id())].type;
239+
auto block_type = device_ctx.grid[rr_graph.node_xlow(rr_node)][rr_graph.node_ylow(rr_node)].type;
240240
std::string pin_name = block_type_pin_index_to_name(block_type, node.pin_num());
241241
/* Print error messages for all the sides that a node may appear */
242242
for (const e_side& node_side : SIDES) {
243-
if (!rr_graph.is_node_on_specific_side(RRNodeId(rr_node), node_side)) {
243+
if (!rr_graph.is_node_on_specific_side(rr_node, node_side)) {
244244
continue;
245245
}
246246
VTR_LOG_ERROR("in check_rr_graph: node %d (%s) at (%d,%d) block=%s side=%s pin=%s has no fanin.\n",
247-
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());
247+
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());
248248
}
249249
}
250250
} else {
251251
VTR_LOG_ERROR("in check_rr_graph: node %d (%s) has no fanin.\n",
252-
inode, device_ctx.rr_nodes[inode].type_string());
252+
inode, rr_graph.node_type_string(rr_node));
253253
}
254254
} else if (!is_chain && !is_fringe_warning_sent) {
255255
VTR_LOG_WARN(
256256
"in check_rr_graph: fringe node %d %s at (%d,%d) has no fanin.\n"
257257
"\t This is possible on a fringe node based on low Fc_out, N, and certain lengths.\n",
258-
inode, device_ctx.rr_nodes[inode].type_string(), rr_graph.node_xlow(rr_node), rr_graph.node_ylow(rr_node));
258+
inode, rr_graph.node_type_string(rr_node), rr_graph.node_xlow(rr_node), rr_graph.node_ylow(rr_node));
259259
is_fringe_warning_sent = true;
260260
}
261261
}

vpr/src/route/overuse_report.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ void log_overused_nodes_status(int max_logged_overused_rr_nodes) {
5959
* This report will be generated only if the last routing attempt fails, which
6060
* causes the whole VPR flow to fail.
6161
*/
62-
void report_overused_nodes() {
63-
const auto& device_ctx = g_vpr_ctx.device();
64-
const auto& rr_graph = device_ctx.rr_graph;
62+
void report_overused_nodes(const RRGraphView& rr_graph) {
6563
const auto& route_ctx = g_vpr_ctx.routing();
6664

6765
/* Generate overuse info lookup table */
@@ -85,11 +83,11 @@ void report_overused_nodes() {
8583
os << "Overused RR node #" << inode << '\n';
8684
os << "Node id = " << size_t(node_id) << '\n';
8785
os << "Occupancy = " << route_ctx.rr_node_route_inf[size_t(node_id)].occ() << '\n';
88-
os << "Capacity = " << device_ctx.rr_nodes.node_capacity(node_id) << "\n\n";
86+
os << "Capacity = " << rr_graph.node_capacity(node_id) << "\n\n";
8987

9088
/* Report selective info based on the rr node type */
9189
auto node_type = rr_graph.node_type(node_id);
92-
os << "Node type = " << device_ctx.rr_nodes.node_type_string(node_id) << '\n';
90+
os << "Node type = " << rr_graph.node_type_string(node_id) << '\n';
9391

9492
switch (node_type) {
9593
case IPIN:
@@ -162,7 +160,7 @@ static void report_overused_ipin_opin(std::ostream& os, RRNodeId node_id) {
162160
"Non-track RR node should not span across multiple grid blocks.");
163161

164162
os << "Pin number = " << device_ctx.rr_nodes.node_pin_num(node_id) << '\n';
165-
os << "Side = " << device_ctx.rr_nodes.node_side_string(node_id) << "\n\n";
163+
os << "Side = " << rr_graph.node_side_string(node_id) << "\n\n";
166164

167165
//Add block type for IPINs/OPINs in overused rr-node report
168166
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)
268266
VTR_LOG(" %10d", route_ctx.rr_node_route_inf[size_t(node_id)].occ());
269267

270268
//Capacity
271-
VTR_LOG(" %9d", device_ctx.rr_nodes.node_capacity(node_id));
269+
VTR_LOG(" %9d", rr_graph.node_capacity(node_id));
272270

273271
//RR node type
274-
VTR_LOG(" %8s", device_ctx.rr_nodes.node_type_string(node_id));
272+
VTR_LOG(" %8s", rr_graph.node_type_string(node_id));
275273

276274
//Direction
277275
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)
282280

283281
//Side
284282
if (node_type == e_rr_type::IPIN || node_type == e_rr_type::OPIN) {
285-
VTR_LOG(" %7s", device_ctx.rr_nodes.node_side_string(node_id));
283+
VTR_LOG(" %7s", rr_graph.node_side_string(node_id));
286284
} else {
287285
VTR_LOG(" %7s", "N/A");
288286
}

vpr/src/route/overuse_report.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include "rr_graph_storage.h"
4+
#include "rr_graph_view.h"
45
#include <map>
56

67
/**
@@ -21,7 +22,7 @@
2122
void log_overused_nodes_status(int max_logged_overused_rr_nodes);
2223

2324
///@brief Print out RR node overuse info in a post-VPR report file.
24-
void report_overused_nodes();
25+
void report_overused_nodes(const RRGraphView& rr_graph);
2526

2627
///@brief Generate a overused RR nodes to congested nets lookup table.
2728
void generate_overused_nodes_to_congested_net_lookup(std::map<RRNodeId, std::set<ClusterNetId>>& nodes_to_nets_lookup);

vpr/src/route/route_common.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,17 +1235,18 @@ void print_route(FILE* fp, const vtr::vector<ClusterNetId, t_traceback>& traceba
12351235

12361236
while (tptr != nullptr) {
12371237
int inode = tptr->index;
1238-
t_rr_type rr_type = rr_graph.node_type(RRNodeId(inode));
1239-
int ilow = rr_graph.node_xlow(RRNodeId(inode));
1240-
int jlow = rr_graph.node_ylow(RRNodeId(inode));
1238+
auto rr_node = RRNodeId(inode);
1239+
t_rr_type rr_type = rr_graph.node_type(rr_node);
1240+
int ilow = rr_graph.node_xlow(rr_node);
1241+
int jlow = rr_graph.node_ylow(rr_node);
12411242

12421243
fprintf(fp, "Node:\t%d\t%6s (%d,%d) ", inode,
1243-
device_ctx.rr_nodes[inode].type_string(), ilow, jlow);
1244+
rr_graph.node_type_string(rr_node), ilow, jlow);
12441245

1245-
if ((ilow != rr_graph.node_xhigh(RRNodeId(inode)))
1246-
|| (jlow != rr_graph.node_yhigh(RRNodeId(inode))))
1247-
fprintf(fp, "to (%d,%d) ", rr_graph.node_xhigh(RRNodeId(inode)),
1248-
rr_graph.node_yhigh(RRNodeId(inode)));
1246+
if ((ilow != rr_graph.node_xhigh(rr_node))
1247+
|| (jlow != rr_graph.node_yhigh(rr_node)))
1248+
fprintf(fp, "to (%d,%d) ", rr_graph.node_xhigh(rr_node),
1249+
rr_graph.node_yhigh(rr_node));
12491250

12501251
switch (rr_type) {
12511252
case IPIN:
@@ -1274,7 +1275,7 @@ void print_route(FILE* fp, const vtr::vector<ClusterNetId, t_traceback>& traceba
12741275
default:
12751276
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
12761277
"in print_route: Unexpected traceback element type: %d (%s).\n",
1277-
rr_type, device_ctx.rr_nodes[inode].type_string());
1278+
rr_type, rr_graph.node_type_string(rr_node));
12781279
break;
12791280
}
12801281

@@ -1656,7 +1657,7 @@ void print_rr_node_route_inf_dot() {
16561657
VTR_LOG("\tnode[shape=record]\n");
16571658
for (size_t inode = 0; inode < route_ctx.rr_node_route_inf.size(); ++inode) {
16581659
if (!std::isinf(route_ctx.rr_node_route_inf[inode].path_cost)) {
1659-
VTR_LOG("\tnode%zu[label=\"{%zu (%s)", inode, inode, device_ctx.rr_nodes[inode].type_string());
1660+
VTR_LOG("\tnode%zu[label=\"{%zu (%s)", inode, inode, rr_graph.node_type_string(RRNodeId(inode)));
16601661
if (route_ctx.rr_node_route_inf[inode].occ() > rr_graph.node_capacity(RRNodeId(inode))) {
16611662
VTR_LOG(" x");
16621663
}

vpr/src/route/route_tree_timing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ void print_route_tree(const t_rt_node* rt_node, int depth) {
692692
auto& device_ctx = g_vpr_ctx.device();
693693
const auto& rr_graph = device_ctx.rr_graph;
694694
VTR_LOG("%srt_node: %d (%s) \t ipin: %d \t R: %g \t C: %g \t delay: %g",
695-
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);
695+
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);
696696

697697
if (rt_node->parent_switch != OPEN) {
698698
bool parent_edge_configurable = device_ctx.rr_switch_inf[rt_node->parent_switch].configurable();

vpr/src/route/router_delay_profiling.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ bool RouterDelayProfiler::calculate_delay(int source_node, int sink_node, const
3232
auto& route_ctx = g_vpr_ctx.routing();
3333

3434
//vtr::ScopedStartFinishTimer t(vtr::string_fmt("Profiling Delay from %s at %d,%d (%s) to %s at %d,%d (%s)",
35-
//device_ctx.rr_nodes[source_node].type_string(),
35+
//rr_graph.node_type_string(RRNodeId(source_node)),
3636
//rr_graph.node_xlow(RRNodeId(source_node)),
3737
//rr_graph.node_ylow(RRNodeId(source_node)),
3838
//rr_node_arch_name(source_node).c_str(),
39-
//device_ctx.rr_nodes[sink_node].type_string(),
39+
//rr_graph.node_type_string(RRNodeId(sink_node)),
4040
//rr_graph.node_xlow(RRNodeId(sink_node)),
4141
//rr_graph.node_ylow(RRNodeId(sink_node)),
4242
//rr_node_arch_name(sink_node).c_str()));

vpr/src/route/router_lookahead_extended_map.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ std::pair<float, float> ExtendedMapLookahead::get_expected_delay_and_cong(RRNode
175175
}
176176

177177
auto& device_ctx = g_vpr_ctx.device();
178-
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
179-
auto& rr_graph = device_ctx.rr_nodes;
178+
const auto& rr_graph = device_ctx.rr_graph;
180179

181180
int from_x = rr_graph.node_xlow(from_node);
182181
int from_y = rr_graph.node_ylow(from_node);
@@ -188,7 +187,7 @@ std::pair<float, float> ExtendedMapLookahead::get_expected_delay_and_cong(RRNode
188187
dx = to_x - from_x;
189188
dy = to_y - from_y;
190189

191-
e_rr_type from_type = temp_rr_graph.node_type(from_node);
190+
e_rr_type from_type = rr_graph.node_type(from_node);
192191
if (from_type == SOURCE || from_type == OPIN) {
193192
return this->get_src_opin_cost(from_node, dx, dy, params);
194193
} else if (from_type == IPIN) {
@@ -202,8 +201,8 @@ std::pair<float, float> ExtendedMapLookahead::get_expected_delay_and_cong(RRNode
202201
// there is no route
203202
VTR_LOGV_DEBUG(f_router_debug,
204203
"Not connected %d (%s, %d) -> %d (%s)\n",
205-
size_t(from_node), device_ctx.rr_nodes[size_t(from_node)].type_string(), from_seg_index,
206-
size_t(to_node), device_ctx.rr_nodes[size_t(to_node)].type_string());
204+
size_t(from_node), rr_graph.node_type_string(from_node), from_seg_index,
205+
size_t(to_node), rr_graph.node_type_string(to_node));
207206
float infinity = std::numeric_limits<float>::infinity();
208207
return std::make_pair(infinity, infinity);
209208
}
@@ -265,7 +264,7 @@ bool ExtendedMapLookahead::add_paths(RRNodeId start_node,
265264
const std::vector<util::Search_Path>& paths,
266265
util::RoutingCosts* routing_costs) {
267266
auto& device_ctx = g_vpr_ctx.device();
268-
auto& rr_graph = device_ctx.rr_nodes;
267+
auto& rr_graph = device_ctx.rr_graph;
269268

270269
RRNodeId node = current.rr_node;
271270

vpr/src/route/rr_graph_indexed_data.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ static void load_rr_indexed_data_T_values() {
450450
*/
451451
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) {
452452
auto& device_ctx = g_vpr_ctx.device();
453+
const auto& rr_graph = device_ctx.rr_graph;
453454
const auto& rr_nodes = device_ctx.rr_nodes.view();
454455

455456
auto node = RRNodeId(inode);
@@ -461,7 +462,7 @@ static void calculate_average_switch(int inode, double& avg_switch_R, double& av
461462
buffered = UNDEFINED;
462463
for (const auto& edge : fan_in_list[node]) {
463464
/* want to get C/R/Tdel/Cinternal of switches that connect this track segment to other track segments */
464-
if (rr_nodes.node_type(node) == CHANX || rr_nodes.node_type(node) == CHANY) {
465+
if (rr_graph.node_type(node) == CHANX || rr_graph.node_type(node) == CHANY) {
465466
int switch_index = rr_nodes.edge_switch(edge);
466467

467468
if (device_ctx.rr_switch_inf[switch_index].type() == SwitchType::SHORT) continue;

vpr/src/route/rr_node.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@
33
#include "globals.h"
44
#include "vpr_error.h"
55

6-
/* Member function of "t_rr_node" used to retrieve a routing *
7-
* resource type string by its index, which is defined by *
8-
* "t_rr_type type". */
9-
10-
const char* t_rr_node::type_string() const {
11-
// ESR API The contents of this function have been temporarily replaced
12-
// Once the RRGraphView API is complete, this function will be removed completely
13-
return rr_node_typename[g_vpr_ctx.device().rr_graph.node_type(id_)];
14-
}
15-
166
//Returns the max 'length' over the x or y direction
177
short t_rr_node::length() const {
188
return std::max(

vpr/src/route/rr_node.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ class t_rr_node {
7777
, id_(id) {}
7878

7979
public: //Accessors
80-
//t_rr_type type() const; // ESR API This function has been replaced by RRGraphView::node_type()
81-
const char* type_string() const; /* Retrieve type as a string */
82-
8380
edge_idx_range edges() const;
8481
edge_idx_range configurable_edges() const;
8582
edge_idx_range non_configurable_edges() const;

vpr/src/util/vpr_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ std::string rr_node_arch_name(int inode) {
205205
auto type = device_ctx.grid[rr_graph.node_xlow(rr_node.id())][rr_graph.node_ylow(rr_node.id())].type;
206206
auto pin_names = block_type_class_index_to_pin_names(type, rr_node.ptc_num());
207207
if (pin_names.size() > 1) {
208-
rr_node_arch_name += rr_node.type_string();
208+
rr_node_arch_name += rr_graph.node_type_string(RRNodeId(inode));
209209
rr_node_arch_name += " connected to ";
210210
rr_node_arch_name += "{";
211211
rr_node_arch_name += vtr::join(pin_names, ", ");

0 commit comments

Comments
 (0)