Skip to content

Commit 00cf6ec

Browse files
std::array for sb_loc instead of two vars
1 parent 620ded6 commit 00cf6ec

File tree

2 files changed

+48
-46
lines changed

2 files changed

+48
-46
lines changed

vpr/src/route/rr_graph_generation/rr_graph_chan_chan_edges.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,21 @@ static void get_switchblocks_edges(RRGraphBuilder& rr_graph_builder,
8585
t_rr_edge_info_set& rr_edges_to_create,
8686
int& edge_count);
8787

88-
/// Adds the fan-out edges from wire segment at (chan, seg, track) to adjacent blocks along the wire's length
89-
static int get_track_to_pins(RRGraphBuilder& rr_graph_builder,
90-
int layer,
91-
int seg,
92-
int chan,
93-
int track,
94-
int tracks_per_chan,
95-
RRNodeId from_rr_node,
96-
t_rr_edge_info_set& rr_edges_to_create,
97-
const t_track_to_pin_lookup& track_to_pin_lookup,
98-
const t_chan_seg_details* seg_details,
99-
e_rr_type chan_type,
100-
int chan_length,
101-
int wire_to_ipin_switch,
102-
e_directionality directionality);
88+
/// Adds the fan-out edges from wire segment at (chan, seg, track) to adjacent IPINs along the wire's length
89+
static int get_track_to_ipins(RRGraphBuilder& rr_graph_builder,
90+
int layer,
91+
int seg,
92+
int chan,
93+
int track,
94+
int tracks_per_chan,
95+
RRNodeId from_rr_node,
96+
t_rr_edge_info_set& rr_edges_to_create,
97+
const t_track_to_pin_lookup& track_to_pin_lookup,
98+
const t_chan_seg_details* seg_details,
99+
e_rr_type chan_type,
100+
int chan_length,
101+
int wire_to_ipin_switch,
102+
e_directionality directionality);
103103

104104
//Returns how the switch type for the switch block at the specified location should be created
105105
// from_chan_coord: The horizontal or vertical channel index (i.e. x-coord for CHANY, y-coord for CHANX)
@@ -239,9 +239,9 @@ static void build_rr_chan(RRGraphBuilder& rr_graph_builder,
239239
}
240240

241241
// Add the edges from this track to all it's connected pins into the list
242-
get_track_to_pins(rr_graph_builder, layer, start, chan_coord, track, tracks_per_chan, node, rr_edges_to_create,
243-
track_to_pin_lookup, seg_details, chan_type, seg_dimension,
244-
wire_to_ipin_switch, directionality);
242+
get_track_to_ipins(rr_graph_builder, layer, start, chan_coord, track, tracks_per_chan, node, rr_edges_to_create,
243+
track_to_pin_lookup, seg_details, chan_type, seg_dimension,
244+
wire_to_ipin_switch, directionality);
245245

246246
// Add edges going from the current track into channel segments which are perpendicular to it
247247
if (chan_coord > 0) {
@@ -297,7 +297,7 @@ static void build_rr_chan(RRGraphBuilder& rr_graph_builder,
297297
}
298298
if (target_seg > 0 && target_seg < seg_dimension + 1) {
299299
const t_chan_seg_details* to_seg_details;
300-
// AA: Same channel width for straight through connections assuming uniform width distributions along the axis
300+
// Same channel width for straight through connections assuming uniform width distributions along the axis
301301
int max_chan_width = 0;
302302
if (chan_type == e_rr_type::CHANX) {
303303
to_seg_details = chan_details_x[target_seg][y_coord].data();
@@ -319,7 +319,7 @@ static void build_rr_chan(RRGraphBuilder& rr_graph_builder,
319319
}
320320

321321
// Edge arrays have now been built up. Do everything else.
322-
// AA: The cost_index should be w.r.t the index of the segment to its **parallel** segment_inf vector.
322+
// The cost_index should be w.r.t the index of the segment to its **parallel** segment_inf vector.
323323
// Note that when building channels, we use the indices w.r.t segment_inf_x and segment_inf_y as
324324
// computed earlier in build_rr_graph so it's fine to use .index() for to get the correct index.
325325
rr_graph_builder.set_node_cost_index(node, RRIndexedDataId(cost_index_offset + seg_details[track].index()));
@@ -692,7 +692,7 @@ static void get_switchblocks_edges(RRGraphBuilder& rr_graph_builder,
692692
}
693693
}
694694

695-
static int get_track_to_pins(RRGraphBuilder& rr_graph_builder,
695+
static int get_track_to_ipins(RRGraphBuilder& rr_graph_builder,
696696
int layer,
697697
int seg,
698698
int chan,
@@ -729,7 +729,7 @@ static int get_track_to_pins(RRGraphBuilder& rr_graph_builder,
729729
side = (0 == pass ? RIGHT : LEFT);
730730
}
731731

732-
/* PAJ - if the pointed to is an EMPTY then shouldn't look for ipins */
732+
// if the pointed to is an EMPTY then shouldn't look for ipins
733733
t_physical_tile_type_ptr type = device_ctx.grid.get_physical_type({x, y, layer});
734734
if (type == device_ctx.EMPTY_PHYSICAL_TILE_TYPE)
735735
continue;

vpr/src/route/rr_graph_generation/rr_graph_sg.cpp

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -118,26 +118,28 @@ void add_edges_opin_chanz_per_side(const RRGraphView& rr_graph,
118118

119119
std::vector<RRNodeId> opin_nodes = node_lookup.find_pin_nodes_at_side(layer, x, y, e_rr_type::OPIN, side);
120120

121-
t_physical_tile_loc sb_loc0, sb_loc1;
121+
// Two switch-block location adjacent to this channel segment
122+
std::array<t_physical_tile_loc, 2> adjacent_sb_loc;
123+
122124
switch (side) {
123125
case TOP:
124-
sb_loc0 = {x, y, layer};
125-
sb_loc1 = {x - 1, y, layer};
126+
adjacent_sb_loc[0] = {x, y, layer};
127+
adjacent_sb_loc[1] = {x - 1, y, layer};
126128
break;
127129

128130
case BOTTOM:
129-
sb_loc0 = {x, y - 1, layer};
130-
sb_loc1 = {x - 1, y - 1, layer};
131+
adjacent_sb_loc[0] = {x, y - 1, layer};
132+
adjacent_sb_loc[1] = {x - 1, y - 1, layer};
131133
break;
132134

133135
case RIGHT:
134-
sb_loc0 = {x, y, layer};
135-
sb_loc1 = {x, y - 1, layer};
136+
adjacent_sb_loc[0] = {x, y, layer};
137+
adjacent_sb_loc[1] = {x, y - 1, layer};
136138
break;
137139

138140
case LEFT:
139-
sb_loc0 = {x - 1, y, layer};
140-
sb_loc1 = {x - 1, y - 1, layer};
141+
adjacent_sb_loc[0] = {x - 1, y, layer};
142+
adjacent_sb_loc[1] = {x - 1, y - 1, layer};
141143
break;
142144

143145
default:
@@ -147,11 +149,11 @@ void add_edges_opin_chanz_per_side(const RRGraphView& rr_graph,
147149
const int grid_width = grid.width();
148150
const int grid_height = grid.height();
149151

150-
sb_loc0.x = std::clamp(sb_loc0.x, 0, grid_width - 1);
151-
sb_loc0.y = std::clamp(sb_loc0.y, 0, grid_height - 1);
152+
adjacent_sb_loc[0].x = std::clamp(adjacent_sb_loc[0].x, 0, grid_width - 1);
153+
adjacent_sb_loc[0].y = std::clamp(adjacent_sb_loc[0].y, 0, grid_height - 1);
152154

153-
sb_loc1.x = std::clamp(sb_loc1.x, 0, grid_width - 1);
154-
sb_loc1.y = std::clamp(sb_loc1.y, 0, grid_height - 1);
155+
adjacent_sb_loc[1].x = std::clamp(adjacent_sb_loc[1].x, 0, grid_width - 1);
156+
adjacent_sb_loc[1].y = std::clamp(adjacent_sb_loc[1].y, 0, grid_height - 1);
155157

156158
std::vector<std::pair<RRNodeId, short>> selected_chanz_nodes0;
157159
std::vector<std::pair<RRNodeId, short>> selected_chanz_nodes1;
@@ -163,19 +165,19 @@ void add_edges_opin_chanz_per_side(const RRGraphView& rr_graph,
163165
}
164166

165167
selected_chanz_nodes0.clear();
166-
for (size_t track_num = 0; track_num < interdie_3d_links[sb_loc0.x][sb_loc0.y].size(); track_num++) {
167-
const t_bottleneck_link& bottleneck_link = interdie_3d_links[sb_loc0.x][sb_loc0.y][track_num];
168+
for (size_t track_num = 0; track_num < interdie_3d_links[adjacent_sb_loc[0].x][adjacent_sb_loc[0].y].size(); track_num++) {
169+
const t_bottleneck_link& bottleneck_link = interdie_3d_links[adjacent_sb_loc[0].x][adjacent_sb_loc[0].y][track_num];
168170
if (bottleneck_link.parallel_segment_index == seg_index && bottleneck_link.gather_loc.layer_num == layer) {
169-
RRNodeId node_id = node_lookup.find_node(sb_loc0.layer_num, sb_loc0.x, sb_loc0.y, e_rr_type::CHANZ, track_num);
171+
RRNodeId node_id = node_lookup.find_node(adjacent_sb_loc[0].layer_num, adjacent_sb_loc[0].x, adjacent_sb_loc[0].y, e_rr_type::CHANZ, track_num);
170172
selected_chanz_nodes0.emplace_back(node_id, bottleneck_link.arch_wire_switch);
171173
}
172174
}
173175

174176
selected_chanz_nodes1.clear();
175-
for (size_t track_num = 0; track_num < interdie_3d_links[sb_loc1.x][sb_loc1.y].size(); track_num++) {
176-
const t_bottleneck_link& bottleneck_link = interdie_3d_links[sb_loc1.x][sb_loc1.y][track_num];
177+
for (size_t track_num = 0; track_num < interdie_3d_links[adjacent_sb_loc[1].x][adjacent_sb_loc[1].y].size(); track_num++) {
178+
const t_bottleneck_link& bottleneck_link = interdie_3d_links[adjacent_sb_loc[1].x][adjacent_sb_loc[1].y][track_num];
177179
if (bottleneck_link.parallel_segment_index == seg_index && bottleneck_link.gather_loc.layer_num == layer) {
178-
RRNodeId node_id = node_lookup.find_node(sb_loc1.layer_num, sb_loc1.x, sb_loc1.y, e_rr_type::CHANZ, track_num);
180+
RRNodeId node_id = node_lookup.find_node(adjacent_sb_loc[1].layer_num, adjacent_sb_loc[1].x, adjacent_sb_loc[1].y, e_rr_type::CHANZ, track_num);
179181
selected_chanz_nodes1.emplace_back(node_id, bottleneck_link.arch_wire_switch);
180182
}
181183
}
@@ -188,16 +190,16 @@ void add_edges_opin_chanz_per_side(const RRGraphView& rr_graph,
188190

189191
RRNodeId chanz_node_id;
190192
short switch_id;
191-
if (Fc_zofs[sb_loc0.x][sb_loc0.y][seg_index] < Fc_zofs[sb_loc1.x][sb_loc1.y][seg_index]) {
192-
int chanz_idx = Fc_zofs[sb_loc0.x][sb_loc0.y][seg_index];
193+
if (Fc_zofs[adjacent_sb_loc[0].x][adjacent_sb_loc[0].y][seg_index] < Fc_zofs[adjacent_sb_loc[1].x][adjacent_sb_loc[1].y][seg_index]) {
194+
int chanz_idx = Fc_zofs[adjacent_sb_loc[0].x][adjacent_sb_loc[0].y][seg_index];
193195
chanz_node_id = selected_chanz_nodes0[chanz_idx % selected_chanz_nodes0.size()].first;
194196
switch_id = selected_chanz_nodes0[chanz_idx % selected_chanz_nodes0.size()].second;
195-
Fc_zofs[sb_loc0.x][sb_loc0.y][seg_index]++;
197+
Fc_zofs[adjacent_sb_loc[0].x][adjacent_sb_loc[0].y][seg_index]++;
196198
} else {
197-
int chanz_idx = Fc_zofs[sb_loc1.x][sb_loc1.y][seg_index];
199+
int chanz_idx = Fc_zofs[adjacent_sb_loc[1].x][adjacent_sb_loc[1].y][seg_index];
198200
chanz_node_id = selected_chanz_nodes1[chanz_idx % selected_chanz_nodes1.size()].first;
199201
switch_id = selected_chanz_nodes1[chanz_idx % selected_chanz_nodes1.size()].second;
200-
Fc_zofs[sb_loc1.x][sb_loc1.y][seg_index]++;
202+
Fc_zofs[adjacent_sb_loc[1].x][adjacent_sb_loc[1].y][seg_index]++;
201203
}
202204

203205
rr_edges_to_create.emplace_back(opin_node_id, chanz_node_id, switch_id, false);

0 commit comments

Comments
 (0)