Skip to content

Commit 0401d99

Browse files
author
Nathan Shreve
committed
Updated comments
1 parent c44b6ed commit 0401d99

File tree

4 files changed

+101
-82
lines changed

4 files changed

+101
-82
lines changed

libs/librrgraph/src/base/check_rr_graph.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,21 @@ void check_rr_node(const RRGraphView& rr_graph,
389389

390390
switch (rr_type) {
391391
case SOURCE:
392+
if (type == nullptr) {
393+
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
394+
"in check_rr_node: node %d (type %d) is at an illegal clb location (%d, %d).\n", inode, rr_type, xlow, ylow);
395+
}
396+
397+
if (xlow != (xhigh - type->width + 1) || ylow != (yhigh - type->height + 1)) {
398+
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
399+
"in check_rr_node: node %d (type %d) has endpoints (%d,%d) and (%d,%d)\n", inode, rr_type, xlow, ylow, xhigh, yhigh);
400+
}
401+
break;
392402
case SINK:
393403
if (type == nullptr) {
394404
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
395405
"in check_rr_node: node %d (type %d) is at an illegal clb location (%d, %d).\n", inode, rr_type, xlow, ylow);
396406
}
397-
// if (xlow != (xhigh - type->width + 1) || ylow != (yhigh - type->height + 1)) {
398-
// VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
399-
// "in check_rr_node: node %d (type %d) has endpoints (%d,%d) and (%d,%d)\n", inode, rr_type, xlow, ylow, xhigh, yhigh);
400-
// }
401407
break;
402408
case IPIN:
403409
case OPIN:

libs/librrgraph/src/base/rr_graph_utils.cpp

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
2-
/****************************************************************************
3-
* This file include most-utilized functions that manipulate on the
4-
* RRGraph object
5-
***************************************************************************/
61
#include <queue>
72
#include <random>
83

@@ -14,9 +9,9 @@
149
// Add "cluster-edge" IPINs to sink_ipins
1510
static void walk_cluster_recursive(const RRGraphView& rr_graph,
1611
const vtr::vector<RRNodeId, std::vector<RREdgeId>>& fanins,
17-
std::unordered_map<RRNodeId, std::unordered_set<RRNodeId>>& sink_ipins,
18-
RRNodeId curr,
19-
RRNodeId origin) {
12+
std::unordered_set<RRNodeId>& sink_ipins,
13+
const RRNodeId curr,
14+
const RRNodeId origin) {
2015
// Make sure SINK in the same cluster as origin. This might not be the case when we have direct-connect between blocks
2116
int curr_x = rr_graph.node_xlow(curr);
2217
int curr_y = rr_graph.node_ylow(curr);
@@ -37,7 +32,7 @@ static void walk_cluster_recursive(const RRGraphView& rr_graph,
3732

3833
// If the parent node isn't in the origin's cluster, the current node is a "cluster-edge" pin,
3934
// so add it to sink_ipins
40-
sink_ipins[origin].insert(curr);
35+
sink_ipins.insert(curr);
4136
return;
4237
}
4338

@@ -71,9 +66,6 @@ std::vector<RRSwitchId> find_rr_graph_switches(const RRGraph& rr_graph,
7166
}
7267

7368
int seg_index_of_cblock(const RRGraphView& rr_graph, t_rr_type from_rr_type, int to_node) {
74-
/* Returns the segment number (distance along the channel) of the connection *
75-
* box from from_rr_type (CHANX or CHANY) to to_node (IPIN). */
76-
7769
if (from_rr_type == CHANX)
7870
return (rr_graph.node_xlow(RRNodeId(to_node)));
7971
else
@@ -82,13 +74,6 @@ int seg_index_of_cblock(const RRGraphView& rr_graph, t_rr_type from_rr_type, int
8274
}
8375

8476
int seg_index_of_sblock(const RRGraphView& rr_graph, int from_node, int to_node) {
85-
/* Returns the segment number (distance along the channel) of the switch box *
86-
* box from from_node (CHANX or CHANY) to to_node (CHANX or CHANY). The *
87-
* switch box on the left side of a CHANX segment at (i,j) has seg_index = *
88-
* i-1, while the switch box on the right side of that segment has seg_index *
89-
* = i. CHANY stuff works similarly. Hence the range of values returned is *
90-
* 0 to device_ctx.grid.width()-1 (if from_node is a CHANX) or 0 to device_ctx.grid.height()-1 (if from_node is a CHANY). */
91-
9277
t_rr_type from_rr_type, to_rr_type;
9378

9479
from_rr_type = rr_graph.node_type(RRNodeId(from_node));
@@ -158,6 +143,8 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
158143
std::unordered_map<RRNodeId, std::unordered_set<RRNodeId>> sink_ipins;
159144

160145
// Iterate over all nodes and fill sink_ipins
146+
// We fill sink_ipins first and then iterate through it to avoid changing the rr_graph
147+
// before we are done collecting all the data we need
161148
for (size_t node = 0; node < rr_graph.num_nodes(); ++node) {
162149
auto node_id = RRNodeId(node);
163150

@@ -172,10 +159,12 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
172159
continue;
173160

174161
sink_ipins[node_id] = {};
175-
walk_cluster_recursive(rr_graph, node_fanins, sink_ipins, node_id, node_id);
162+
walk_cluster_recursive(rr_graph, node_fanins, sink_ipins[node_id], node_id, node_id);
176163
}
177164

178-
// Set SINK locations based on "cluster-edge" IPINs
165+
// Set SINK locations as average of "cluster-edge" IPINs. Generally, larger blocks do not have
166+
// equivalent IPINs, so each SINK will be connected to only one IPIN, so taking the average is
167+
// redundant.
179168
for (const auto& node_pins : sink_ipins) {
180169
const auto& pin_set = node_pins.second;
181170

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
/**
2+
* @file rr_graph_utils.h
3+
*
4+
* @brief This file includes the most-utilized functions that manipulate the RRGraph object.
5+
*/
6+
17
#ifndef RR_GRAPH_UTILS_H
28
#define RR_GRAPH_UTILS_H
39

410
/* Include header files which include data structures used by
5-
* the function declaration
6-
*/
11+
* the function declaration
12+
*/
713
#include <vector>
814
#include "rr_graph_fwd.h"
915
#include "rr_node_types.h"
@@ -36,42 +42,52 @@ struct t_cluster_pin_chain {
3642
t_cluster_pin_chain& operator=(t_cluster_pin_chain&& other) = default;
3743
};
3844

39-
/* Get node-to-node switches in a RRGraph */
45+
/**
46+
* @brief Get node-to-node switches in a RRGraph
47+
* */
4048
std::vector<RRSwitchId> find_rr_graph_switches(const RRGraph& rr_graph,
4149
const RRNodeId& from_node,
4250
const RRNodeId& to_node);
4351

4452
/**
45-
* @brief This function generates and returns a vector indexed by RRNodeId containing a list of fan-in edges for each node.
46-
* @param rr_graph
47-
* @return node_fan_in_list
48-
*/
53+
* @brief This function generates and returns a vector indexed by RRNodeId containing a list of fan-in edges for each node.
54+
*/
4955
vtr::vector<RRNodeId, std::vector<RREdgeId>> get_fan_in_list(const RRGraphView& rr_graph);
5056

5157
/**
52-
* @brief This function sets better locations for SOURCE and SINK nodes.
53-
*
54-
* @details
55-
* build_rr_graph() sets the location of SINK and SOURCE nodes to span the entire tile they are in. this function:
56-
* - sets the location of SOURCE nodes to be the average coordinate of the OPINs of their cluster block to which they are connected
57-
* - sets the location of SINK nodes to be the average coordinate of the IPINs of their cluster block to which they are connected
58-
*
59-
* Note: only changes nodes in tiles which have dimensions greater than 1x1
60-
*
61-
* @param rr_graph
62-
* @param rr_graph_builder
63-
*/
58+
* @brief This function sets better locations for SINK nodes.
59+
*
60+
* @details
61+
* build_rr_graph() sets the location of SINK nodes to span the entire tile they are in. This function sets the location
62+
* of SINK nodes to be the average coordinate of the IPINs on their cluster block to which they are connected
63+
*
64+
* @note
65+
* This function only changes SINK locations in tiles which have dimensions greater than 1x1
66+
*/
6467
void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder);
6568

69+
/**
70+
* @brief Returns the segment number (distance along the channel) of the connection box from from_rr_type (CHANX or
71+
* CHANY) to to_node (IPIN).
72+
*/
6673
int seg_index_of_cblock(const RRGraphView& rr_graph, t_rr_type from_rr_type, int to_node);
74+
75+
/**
76+
* @breif Returns the segment number (distance along the channel) of the switch box from from_node (CHANX or CHANY) to
77+
* to_node (CHANX or CHANY).
78+
*
79+
* @details
80+
* The switch box on the left side of a CHANX segment at (i,j) has seg_index = i-1, while the switch box on the right
81+
* side of that segment has seg_index = i. CHANY stuff works similarly. Hence the range of values returned is 0 to
82+
* device_ctx.grid.width()-1 (if from_node is a CHANX) or 0 to device_ctx.grid.height()-1 (if from_node is a CHANY).
83+
*/
6784
int seg_index_of_sblock(const RRGraphView& rr_graph, int from_node, int to_node);
6885

6986
/**
70-
* @brief This function checks whether all inter-die connections are form OPINs. Return "true"
71-
* if that is the case. Can be used for multiple purposes. For example, to determine which type of bounding
72-
* box to be used to estimate the wire-length of a net.
73-
* @param rr_graph
74-
* @return limited_to_opin
75-
*/
87+
* @brief This function checks whether all inter-die connections are form OPINs. Return "true"
88+
* if that is the case. Can be used for multiple purposes. For example, to determine which type of bounding
89+
* box to be used to estimate the wire-length of a net.
90+
* @return limited_to_opin
91+
*/
7692
bool inter_layer_connections_limited_to_opin(const RRGraphView& rr_graph);
7793
#endif

vpr/src/route/rr_graph2.cpp

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,26 +1490,23 @@ bool verify_rr_node_indices(const DeviceGrid& grid,
14901490
y,
14911491
describe_rr_node(rr_graph, grid, rr_indexed_data, inode, is_flat).c_str());
14921492
}
1493-
} else if (rr_graph.node_type(inode) == SOURCE || rr_graph.node_type(inode) == SINK) {
1494-
//Sources have co-ordintes covering the entire block they are in -- NOT ANYMORE
1495-
// if (!rr_graph.x_in_node_range(x, inode)) {
1496-
// VPR_ERROR(VPR_ERROR_ROUTE, "RR node x positions do not agree between rr_nodes (%d <-> %d) and rr_node_indices (%d): %s",
1497-
// rr_graph.node_xlow(inode),
1498-
// rr_graph.node_xlow(inode),
1499-
// x,
1500-
// describe_rr_node(rr_graph, grid, rr_indexed_data, inode, is_flat).c_str());
1501-
// }
1502-
//
1503-
// if (!rr_graph.y_in_node_range(y, inode)) {
1504-
// VPR_ERROR(VPR_ERROR_ROUTE, "RR node y positions do not agree between rr_nodes (%d <-> %d) and rr_node_indices (%d): %s",
1505-
// rr_graph.node_ylow(inode),
1506-
// rr_graph.node_ylow(inode),
1507-
// y,
1508-
// describe_rr_node(rr_graph, grid, rr_indexed_data, inode, is_flat).c_str());
1509-
// }
1493+
} else if (rr_graph.node_type(inode) == SOURCE) {
1494+
if (!rr_graph.x_in_node_range(x, inode)) {
1495+
VPR_ERROR(VPR_ERROR_ROUTE, "RR node x positions do not agree between rr_nodes (%d <-> %d) and rr_node_indices (%d): %s",
1496+
rr_graph.node_xlow(inode),
1497+
rr_graph.node_xlow(inode),
1498+
x,
1499+
describe_rr_node(rr_graph, grid, rr_indexed_data, inode, is_flat).c_str());
1500+
}
15101501

1511-
} else {
1512-
VTR_ASSERT(rr_graph.node_type(inode) == IPIN || rr_graph.node_type(inode) == OPIN);
1502+
if (!rr_graph.y_in_node_range(y, inode)) {
1503+
VPR_ERROR(VPR_ERROR_ROUTE, "RR node y positions do not agree between rr_nodes (%d <-> %d) and rr_node_indices (%d): %s",
1504+
rr_graph.node_ylow(inode),
1505+
rr_graph.node_ylow(inode),
1506+
y,
1507+
describe_rr_node(rr_graph, grid, rr_indexed_data, inode, is_flat).c_str());
1508+
}
1509+
} else if (rr_graph.node_type(inode) == IPIN || rr_graph.node_type(inode) == OPIN) {
15131510
/* As we allow a pin to be indexable on multiple sides,
15141511
* This check code should be invalid
15151512
* if (rr_node.xlow() != x) {
@@ -1526,6 +1523,12 @@ bool verify_rr_node_indices(const DeviceGrid& grid,
15261523
* describe_rr_node(rr_graph, grid, rr_indexed_data, inode).c_str());
15271524
* }
15281525
*/
1526+
} else {
1527+
// Previously, SINKs had co-ordinates covering the entire block they are in. Now, their locations
1528+
// are the average of the IPINs they are connected to, so we cannot do the same check that we did
1529+
// for SOURCEs.
1530+
1531+
VTR_ASSERT(rr_graph.node_type(inode) == SINK);
15291532
}
15301533

15311534
if (rr_type == IPIN || rr_type == OPIN) {
@@ -1559,20 +1562,24 @@ bool verify_rr_node_indices(const DeviceGrid& grid,
15591562

15601563
auto& rr_node = rr_nodes[size_t(inode)];
15611564

1562-
if (rr_graph.node_type(inode) == SOURCE || rr_graph.node_type(inode) == SINK) {
1563-
// int rr_width = (rr_graph.node_xhigh(rr_node.id()) - rr_graph.node_xlow(rr_node.id()) + 1);
1564-
// int rr_height = (rr_graph.node_yhigh(rr_node.id()) - rr_graph.node_ylow(rr_node.id()) + 1);
1565-
// int rr_area = rr_width * rr_height;
1566-
// if (count != rr_area) {
1567-
// VPR_ERROR(VPR_ERROR_ROUTE, "Mismatch between RR node size (%d) and count within rr_node_indices (%d): %s",
1568-
// rr_area,
1569-
// rr_node.length(),
1570-
// count,
1571-
// describe_rr_node(rr_graph, grid, rr_indexed_data, inode, is_flat).c_str());
1572-
// }
1573-
/* As we allow a pin to be indexable on multiple sides,
1565+
if (rr_graph.node_type(inode) == SOURCE) {
1566+
int rr_width = (rr_graph.node_xhigh(rr_node.id()) - rr_graph.node_xlow(rr_node.id()) + 1);
1567+
int rr_height = (rr_graph.node_yhigh(rr_node.id()) - rr_graph.node_ylow(rr_node.id()) + 1);
1568+
int rr_area = rr_width * rr_height;
1569+
if (count != rr_area) {
1570+
VPR_ERROR(VPR_ERROR_ROUTE, "Mismatch between RR node size (%d) and count within rr_node_indices (%d): %s",
1571+
rr_area,
1572+
rr_node.length(),
1573+
count,
1574+
describe_rr_node(rr_graph, grid, rr_indexed_data, inode, is_flat).c_str());
1575+
}
1576+
/* As we allow a SOURCE to be indexable on multiple sides,
15741577
* This check code should not be applied to input and output pins
15751578
*/
1579+
} else if (rr_graph.node_type(inode) == SINK) {
1580+
// Previously, SINKs had co-ordinates covering the entire block they are in. Now, their locations
1581+
// are the average of the IPINs they are connected to, so we cannot do the same check that we did
1582+
// for SOURCEs.
15761583
} else if ((OPIN != rr_graph.node_type(inode)) && (IPIN != rr_graph.node_type(inode))) {
15771584
if (count != rr_node.length() + 1) {
15781585
VPR_ERROR(VPR_ERROR_ROUTE, "Mismatch between RR node length (%d) and count within rr_node_indices (%d, should be length + 1): %s",
@@ -1582,8 +1589,9 @@ bool verify_rr_node_indices(const DeviceGrid& grid,
15821589
}
15831590
}
15841591
}
1592+
}
15851593

1586-
return true;
1594+
return true;
15871595
}
15881596

15891597
int get_track_to_pins(RRGraphBuilder& rr_graph_builder,

0 commit comments

Comments
 (0)