Skip to content

Commit a6c0049

Browse files
use (x, y) convention for CHANX instead of (y, x)
1 parent 328efee commit a6c0049

File tree

6 files changed

+39
-71
lines changed

6 files changed

+39
-71
lines changed

libs/librrgraph/src/base/rr_graph_builder.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,29 @@ void RRGraphBuilder::add_node_to_all_locs(RRNodeId node) {
3131
short node_layer = node_storage_.node_layer(node);
3232
short node_twist = node_storage_.node_ptc_twist(node);
3333
int node_offset = 0;
34+
3435
for (int ix = node_storage_.node_xlow(node); ix <= node_storage_.node_xhigh(node); ix++) {
3536
for (int iy = node_storage_.node_ylow(node); iy <= node_storage_.node_yhigh(node); iy++) {
3637
node_ptc_num += node_twist * node_offset;
3738
node_offset++;
39+
3840
switch (node_type) {
3941
case e_rr_type::SOURCE:
4042
case e_rr_type::SINK:
4143
case e_rr_type::CHANY:
42-
node_lookup_.add_node(node, node_layer, ix, iy, node_type, node_ptc_num, TOTAL_2D_SIDES[0]);
43-
break;
4444
case e_rr_type::CHANX:
45-
/* Currently need to swap x and y for CHANX because of chan, seg convention
46-
* TODO: Once the builders is reworked for use consistent (x, y) convention,
47-
* the following swapping can be removed
48-
*/
49-
node_lookup_.add_node(node, node_layer, iy, ix, node_type, node_ptc_num, TOTAL_2D_SIDES[0]);
45+
node_lookup_.add_node(node, node_layer, ix, iy, node_type, node_ptc_num, TOTAL_2D_SIDES[0]);
5046
break;
47+
5148
case e_rr_type::OPIN:
5249
case e_rr_type::IPIN:
53-
for (const e_side& side : TOTAL_2D_SIDES) {
50+
for (const e_side side : TOTAL_2D_SIDES) {
5451
if (node_storage_.is_node_on_specific_side(node, side)) {
5552
node_lookup_.add_node(node,node_layer, ix, iy, node_type, node_ptc_num, side);
5653
}
5754
}
5855
break;
56+
5957
default:
6058
VTR_LOG_ERROR("Invalid node type for node '%lu' in the routing resource graph file", size_t(node));
6159
break;

libs/librrgraph/src/base/rr_spatial_lookup.cpp

+8-32
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@ RRNodeId RRSpatialLookup::find_node(int layer,
3333
return RRNodeId::INVALID();
3434
}
3535

36-
/* Currently need to swap x and y for CHANX because of chan, seg convention
37-
* This is due to that the fast look-up builders uses (y, x) coordinate when
38-
* registering a CHANX node in the look-up
39-
* TODO: Once the builders is reworked for use consistent (x, y) convention,
40-
* the following swapping can be removed
41-
*/
42-
size_t node_x = x;
43-
size_t node_y = y;
44-
if (type == e_rr_type::CHANX) {
45-
std::swap(node_x, node_y);
46-
}
47-
4836
VTR_ASSERT_SAFE(4 == rr_node_indices_[type].ndims());
4937

5038
/* Sanity check to ensure the layer, x, y, side and ptc are in range
@@ -59,23 +47,23 @@ RRNodeId RRSpatialLookup::find_node(int layer,
5947
return RRNodeId::INVALID();
6048
}
6149

62-
if (node_x >= rr_node_indices_[type].dim_size(1)) {
50+
if (x >= rr_node_indices_[type].dim_size(1)) {
6351
return RRNodeId::INVALID();
6452
}
6553

66-
if(node_y >= rr_node_indices_[type].dim_size(2)){
54+
if(y >= rr_node_indices_[type].dim_size(2)){
6755
return RRNodeId::INVALID();
6856
}
6957

7058
if (node_side >= rr_node_indices_[type].dim_size(3)) {
7159
return RRNodeId::INVALID();
7260
}
7361

74-
if (size_t(ptc) >= rr_node_indices_[type][layer][node_x][node_y][node_side].size()) {
62+
if (size_t(ptc) >= rr_node_indices_[type][layer][x][y][node_side].size()) {
7563
return RRNodeId::INVALID();
7664
}
7765

78-
return rr_node_indices_[type][layer][node_x][node_y][node_side][ptc];
66+
return rr_node_indices_[type][layer][x][y][node_side][ptc];
7967
}
8068

8169
std::vector<RRNodeId> RRSpatialLookup::find_nodes_in_range(int layer,
@@ -114,18 +102,6 @@ std::vector<RRNodeId> RRSpatialLookup::find_nodes(int layer,
114102
return nodes;
115103
}
116104

117-
/* Currently need to swap x and y for CHANX because of chan, seg convention
118-
* This is due to that the fast look-up builders uses (y, x) coordinate when
119-
* registering a CHANX node in the look-up
120-
* TODO: Once the builders is reworked for use consistent (x, y) convention,
121-
* the following swapping can be removed
122-
*/
123-
size_t node_x = x;
124-
size_t node_y = y;
125-
if (type == e_rr_type::CHANX) {
126-
std::swap(node_x, node_y);
127-
}
128-
129105
VTR_ASSERT_SAFE(4 == rr_node_indices_[type].ndims());
130106

131107
/* Sanity check to ensure the x, y, side are in range
@@ -140,11 +116,11 @@ std::vector<RRNodeId> RRSpatialLookup::find_nodes(int layer,
140116
return nodes;
141117
}
142118

143-
if (node_x >= rr_node_indices_[type].dim_size(1)) {
119+
if (x >= rr_node_indices_[type].dim_size(1)) {
144120
return nodes;
145121
}
146122

147-
if(node_y >= rr_node_indices_[type].dim_size(2)){
123+
if(y >= rr_node_indices_[type].dim_size(2)){
148124
return nodes;
149125
}
150126

@@ -154,14 +130,14 @@ std::vector<RRNodeId> RRSpatialLookup::find_nodes(int layer,
154130

155131
/* Reserve space to avoid memory fragmentation */
156132
size_t num_nodes = 0;
157-
for (const auto& node : rr_node_indices_[type][layer][node_x][node_y][side]) {
133+
for (const auto& node : rr_node_indices_[type][layer][x][y][side]) {
158134
if (node.is_valid()) {
159135
num_nodes++;
160136
}
161137
}
162138

163139
nodes.reserve(num_nodes);
164-
for (const auto& node : rr_node_indices_[type][layer][node_x][node_y][side]) {
140+
for (const auto& node : rr_node_indices_[type][layer][x][y][side]) {
165141
if (node.is_valid()) {
166142
nodes.emplace_back(node);
167143
}

vpr/src/route/clock_network_builders.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,7 @@ int ClockRib::create_chanx_wire(int layer,
372372
/* TODO: Will replace these codes with an API add_node_to_all_locs() of RRGraphBuilder */
373373
for (int ix = rr_graph.node_xlow(chanx_node); ix <= rr_graph.node_xhigh(chanx_node); ++ix) {
374374
for (int iy = rr_graph.node_ylow(chanx_node); iy <= rr_graph.node_yhigh(chanx_node); ++iy) {
375-
//TODO: CHANX uses odd swapped x/y indices here. Will rework once rr_node_indices is shadowed
376-
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));
375+
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));
377376
}
378377
}
379378

vpr/src/route/rr_graph.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1336,11 +1336,10 @@ static void build_rr_graph(e_graph_type graph_type,
13361336
*/
13371337
if (grid.get_num_layers() > 1 && sb_type == CUSTOM) {
13381338
//keep how many nodes each switchblock requires for each x,y location
1339-
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);
1339+
vtr::NdMatrix<int, 2> 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);
13401340
//allocate new nodes in each switchblocks
1341-
alloc_and_load_inter_die_rr_node_indices(device_ctx.rr_graph_builder, &nodes_per_chan, grid, extra_nodes_per_switchblock, &num_rr_nodes);
1341+
alloc_and_load_inter_die_rr_node_indices(device_ctx.rr_graph_builder, nodes_per_chan, grid, extra_nodes_per_switchblock, &num_rr_nodes);
13421342
device_ctx.rr_graph_builder.resize_nodes(num_rr_nodes);
1343-
extra_nodes_per_switchblock.clear();
13441343
}
13451344

13461345
/* START IPIN MAP */

vpr/src/route/rr_graph2.cpp

+20-24
Original file line numberDiff line numberDiff line change
@@ -1103,19 +1103,19 @@ static void load_chan_rr_indices(const int max_chan_width,
11031103
const auto& device_ctx = g_vpr_ctx.device();
11041104

11051105
for (int layer = 0; layer < grid.get_num_layers(); layer++) {
1106-
/* Skip the current die if architecture file specifies that it doesn't require global resource routing */
1106+
// Skip the current die if architecture file specifies that it doesn't require global resource routing
11071107
if (!device_ctx.inter_cluster_prog_routing_resources.at(layer)) {
11081108
continue;
11091109
}
11101110

11111111
for (int chan = 0; chan < num_chans - 1; ++chan) {
11121112
for (int seg = 1; seg < chan_len - 1; ++seg) {
1113-
/* Assign an inode to the starts of tracks */
1114-
int x = type == e_rr_type::CHANX ? seg : chan;
1115-
int y = type == e_rr_type::CHANX ? chan : seg;
1113+
// Assign an inode to the starts of tracks
1114+
const int x = (type == e_rr_type::CHANX) ? seg : chan;
1115+
const int y = (type == e_rr_type::CHANX) ? chan : seg;
11161116
const t_chan_seg_details* seg_details = chan_details[x][y].data();
11171117

1118-
/* Reserve nodes in lookup to save memory */
1118+
// Reserve nodes in lookup to save memory
11191119
rr_graph_builder.node_lookup().reserve_nodes(layer, chan, seg, type, max_chan_width);
11201120

11211121
for (int track = 0; track < max_chan_width; ++track) {
@@ -1124,24 +1124,19 @@ static void load_chan_rr_indices(const int max_chan_width,
11241124
continue;
11251125

11261126
int start = get_seg_start(seg_details, track, chan, seg);
1127+
int node_start_x = (type == e_rr_type::CHANX) ? start : chan;
1128+
int node_start_y = (type == e_rr_type::CHANX) ? chan : start;
11271129

1128-
/* TODO: Now we still use the (y, x) convention here for CHANX. Should rework later */
1129-
int node_x = chan;
1130-
int node_y = start;
1131-
if (e_rr_type::CHANX == type) {
1132-
std::swap(node_x, node_y);
1133-
}
1134-
1135-
// If the start of the wire doesn't have an inode, assign one to it.
1136-
RRNodeId inode = rr_graph_builder.node_lookup().find_node(layer, node_x, node_y, type, track);
1130+
// If the start of the wire doesn't have an RRNodeId, assign one to it.
1131+
RRNodeId inode = rr_graph_builder.node_lookup().find_node(layer, node_start_x, node_start_y, type, track);
11371132
if (!inode) {
11381133
inode = RRNodeId(*index);
11391134
++(*index);
11401135
rr_graph_builder.node_lookup().add_node(inode, layer, chan, start, type, track);
11411136
}
11421137

1143-
/* Assign inode of start of wire to current position */
1144-
rr_graph_builder.node_lookup().add_node(inode, layer, chan, seg, type, track);
1138+
// Assign RRNodeId of start of wire to current position
1139+
rr_graph_builder.node_lookup().add_node(inode, layer, x, y, type, track);
11451140
}
11461141
}
11471142
}
@@ -1219,7 +1214,7 @@ vtr::NdMatrix<int, 2> get_number_track_to_track_inter_die_conn(t_sb_connection_m
12191214
}
12201215

12211216
void alloc_and_load_inter_die_rr_node_indices(RRGraphBuilder& rr_graph_builder,
1222-
const t_chan_width* nodes_per_chan,
1217+
const t_chan_width& nodes_per_chan,
12231218
const DeviceGrid& grid,
12241219
const vtr::NdMatrix<int, 2>& extra_nodes_per_switchblock,
12251220
int* index) {
@@ -1232,31 +1227,32 @@ void alloc_and_load_inter_die_rr_node_indices(RRGraphBuilder& rr_graph_builder,
12321227
* 3) ptc = [max_chanx_width:max_chanx_width+number_of_connection-1]
12331228
* 4) direction = NONE
12341229
*/
1235-
auto& device_ctx = g_vpr_ctx.device();
1230+
const auto& device_ctx = g_vpr_ctx.device();
12361231

12371232
for (int layer = 0; layer < grid.get_num_layers(); layer++) {
12381233
/* Skip the current die if architecture file specifies that it doesn't have global resource routing */
12391234
if (!device_ctx.inter_cluster_prog_routing_resources.at(layer)) {
12401235
continue;
12411236
}
1237+
12421238
for (size_t y = 0; y < grid.height() - 1; ++y) {
12431239
for (size_t x = 1; x < grid.width() - 1; ++x) {
1244-
//count how many track-to-track connection go from current layer to other layers
1240+
// count how many track-to-track connection go from current layer to other layers
12451241
int conn_count = extra_nodes_per_switchblock[x][y];
12461242

1247-
//skip if no connection is required
1243+
// skip if no connection is required
12481244
if (conn_count == 0) {
12491245
continue;
12501246
}
12511247

1252-
//reserve extra nodes for inter-die track-to-track connection
1253-
rr_graph_builder.node_lookup().reserve_nodes(layer, y, x, e_rr_type::CHANX, conn_count + nodes_per_chan->max);
1248+
// reserve extra nodes for inter-die track-to-track connection
1249+
rr_graph_builder.node_lookup().reserve_nodes(layer, x, y, e_rr_type::CHANX, conn_count + nodes_per_chan.max);
12541250
for (int rr_node_offset = 0; rr_node_offset < conn_count; rr_node_offset++) {
1255-
RRNodeId inode = rr_graph_builder.node_lookup().find_node(layer, x, y, e_rr_type::CHANX, nodes_per_chan->max + rr_node_offset);
1251+
RRNodeId inode = rr_graph_builder.node_lookup().find_node(layer, x, y, e_rr_type::CHANX, nodes_per_chan.max + rr_node_offset);
12561252
if (!inode) {
12571253
inode = RRNodeId(*index);
12581254
++(*index);
1259-
rr_graph_builder.node_lookup().add_node(inode, layer, y, x, e_rr_type::CHANX, nodes_per_chan->max + rr_node_offset);
1255+
rr_graph_builder.node_lookup().add_node(inode, layer, x, y, e_rr_type::CHANX, nodes_per_chan.max + rr_node_offset);
12601256
}
12611257
}
12621258
}

vpr/src/route/rr_graph2.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void alloc_and_load_rr_node_indices(RRGraphBuilder& rr_graph_builder,
2929

3030

3131
/**
32-
* @brief allocates extra nodes within the RR graph to support 3D custom switch blocks for multi-die FPGAs
32+
* @brief Allocates extra nodes within the RR graph to support 3D custom switch blocks for multi-die FPGAs
3333
*
3434
* @param rr_graph_builder RRGraphBuilder data structure which allows data modification on a routing resource graph
3535
* @param nodes_per_chan number of tracks per channel (x, y)
@@ -39,7 +39,7 @@ void alloc_and_load_rr_node_indices(RRGraphBuilder& rr_graph_builder,
3939
* @param index RRNodeId that should be assigned to add a new RR node to the RR graph
4040
*/
4141
void alloc_and_load_inter_die_rr_node_indices(RRGraphBuilder& rr_graph_builder,
42-
const t_chan_width* nodes_per_chan,
42+
const t_chan_width& nodes_per_chan,
4343
const DeviceGrid& grid,
4444
const vtr::NdMatrix<int, 2>& extra_nodes_per_switchblock,
4545
int* index);

0 commit comments

Comments
 (0)