Skip to content

Commit 64bab6e

Browse files
author
Nathan Shreve
committed
Fixed issue in method for removing sink locations in RRSpatialLookup
1 parent a18e88b commit 64bab6e

File tree

3 files changed

+34
-24
lines changed

3 files changed

+34
-24
lines changed

libs/librrgraph/src/base/rr_graph_utils.cpp

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ static void walk_cluster_recursive(const RRGraphView& rr_graph,
2626
RRNodeId parent = rr_graph.edge_src_node(edge);
2727
VTR_ASSERT_SAFE(parent != RRNodeId::INVALID());
2828

29-
if (rr_graph.node_type(parent) == e_rr_type::CHANX || rr_graph.node_type(parent) == e_rr_type::CHANY) { /* Outside of origin cluster */
30-
VTR_ASSERT_SAFE(rr_graph.node_type(curr) == e_rr_type::IPIN);
29+
if (rr_graph.node_type(parent) != e_rr_type::IPIN) {
30+
if (rr_graph.node_type(parent) != e_rr_type::CHANX && rr_graph.node_type(parent) != e_rr_type::CHANY)
31+
return;
3132

3233
// If the parent node isn't in the origin's cluster, the current node is a "cluster-edge" pin,
3334
// so add it to sink_ipins
@@ -140,13 +141,20 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
140141
std::unordered_map<t_physical_tile_type_ptr, std::unordered_map<size_t, Offset>> physical_type_offsets;
141142

142143
// Helper fn. to remove old sink locations from RRSpatialLookup
143-
auto remove_sink_locs_from_lookup = [&](Offset bottom_left, Offset top_right, Offset exclude, RRNodeId node, size_t layer, size_t ptc) {
144+
auto remove_sink_locs_from_lookup = [&](Offset bottom_left, Offset top_right, Offset new_sink_loc, RRNodeId node, size_t layer, size_t ptc) {
145+
if (rr_graph_builder.node_lookup().find_node((int)layer, (int)new_sink_loc.x(), (int)new_sink_loc.y(), SINK, (int)ptc) == RRNodeId::INVALID()) {
146+
rr_graph_builder.node_lookup().add_node(node, (int)layer, (int)new_sink_loc.x(), (int)new_sink_loc.y(), SINK, ptc);
147+
}
148+
144149
for (size_t x = bottom_left.x(); x <= top_right.x(); ++x) {
145150
for (size_t y = bottom_left.y(); y <= top_right.y(); ++y) {
146-
if (x == exclude.x() && y == exclude.y()) /* The new sink location */
151+
if (x == new_sink_loc.x() && y == new_sink_loc.y()) /* The new sink location */
147152
continue;
148153

149-
rr_graph_builder.node_lookup().remove_node(node, (int)layer, (int)x, (int)y, SINK, ptc);
154+
if (rr_graph_builder.node_lookup().find_node((int)layer, (int)x, (int)y, SINK, (int)ptc) == RRNodeId::INVALID())
155+
continue;
156+
157+
rr_graph_builder.node_lookup().remove_node(node, (int)layer, (int)x, (int)y, SINK, (int)ptc);
150158
}
151159
}
152160
};
@@ -159,10 +167,16 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
159167
continue;
160168

161169
// Skip 1x1 tiles
162-
size_t tile_xlow = rr_graph.node_xlow(node_id);
163-
size_t tile_ylow = rr_graph.node_ylow(node_id);
164-
size_t tile_xhigh = rr_graph.node_xhigh(node_id);
165-
size_t tile_yhigh = rr_graph.node_yhigh(node_id);
170+
size_t node_xlow = rr_graph.node_xlow(node_id);
171+
size_t node_ylow = rr_graph.node_ylow(node_id);
172+
173+
size_t tile_layer = rr_graph.node_layer(node_id);
174+
t_physical_tile_type_ptr tile_type = grid.get_physical_type({(int)node_xlow, (int)node_ylow, (int)tile_layer});
175+
176+
size_t tile_xlow = node_xlow - grid.get_width_offset({(int)node_xlow, (int)node_ylow, (int)tile_layer});
177+
size_t tile_ylow = node_ylow - grid.get_height_offset({(int)node_xlow, (int)node_ylow, (int)tile_layer});
178+
size_t tile_xhigh = tile_xlow + tile_type->width - 1;
179+
size_t tile_yhigh = tile_ylow + tile_type->height - 1;
166180

167181
size_t tile_width = tile_xhigh - tile_xlow;
168182
size_t tile_height = tile_yhigh - tile_ylow;
@@ -171,9 +185,6 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
171185
continue;
172186

173187
// See if we have encountered this tile type/ptc combo before, and used saved offset if so
174-
size_t tile_layer = rr_graph.node_layer(node_id);
175-
t_physical_tile_type_ptr tile_type = grid.get_physical_type({(int)tile_xlow, (int)tile_ylow, (int)tile_layer});
176-
177188
size_t sink_ptc = rr_graph.node_ptc_num(node_id);
178189

179190
if ((physical_type_offsets.find(tile_type) != physical_type_offsets.end()) && (physical_type_offsets[tile_type].find(sink_ptc) != physical_type_offsets[tile_type].end())) {

vpr/src/route/route_common.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -456,18 +456,15 @@ static vtr::vector<ParentNetId, std::vector<RRNodeId>> load_net_rr_terminals(con
456456

457457
// SINK nodes do not cover their whole tile, so we need to check all coordinates in the tile.
458458
if (pin_count != 0 && inode == RRNodeId::INVALID()) {
459-
ClusterBlockId cluster_block_id;
460-
461-
if (is_flat)
462-
cluster_block_id = atom_to_cluster(AtomBlockId(size_t(block_id)));
463-
else
464-
cluster_block_id = ClusterBlockId(size_t(block_id));
465-
466-
auto tile_type = physical_tile_type(cluster_block_id);
467-
468-
for (int x = blk_loc.loc.x; x < blk_loc.loc.x + tile_type->width; ++x) {
469-
for (int y = blk_loc.loc.y; y < blk_loc.loc.y + tile_type->height; ++y) {
470-
inode = rr_graph.node_lookup().find_node(blk_loc.loc.layer, x, y, SINK, iclass);
459+
auto tile_type = g_vpr_ctx.device().grid.get_physical_type({blk_loc.loc.x, blk_loc.loc.y, blk_loc.loc.layer});
460+
size_t tile_xlow = blk_loc.loc.x - g_vpr_ctx.device().grid.get_width_offset({blk_loc.loc.x, blk_loc.loc.y, blk_loc.loc.layer});
461+
size_t tile_ylow = blk_loc.loc.y - g_vpr_ctx.device().grid.get_height_offset({blk_loc.loc.x, blk_loc.loc.y, blk_loc.loc.layer});
462+
size_t tile_xhigh = tile_xlow + tile_type->width - 1;
463+
size_t tile_yhigh = tile_ylow + tile_type->height - 1;
464+
465+
for (size_t x = tile_xlow; x <= tile_xhigh; ++x) {
466+
for (size_t y = tile_ylow; y <= tile_yhigh; ++y) {
467+
inode = rr_graph.node_lookup().find_node(blk_loc.loc.layer, (int)x, (int)y, SINK, iclass);
471468

472469
if (inode != RRNodeId::INVALID())
473470
break;

vpr/src/route/rr_graph.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,8 @@ static void build_intra_cluster_rr_graph(const t_graph_type graph_type,
15021502

15031503
rr_graph_builder.partition_edges();
15041504

1505+
set_sink_locs(rr_graph, rr_graph_builder, grid);
1506+
15051507
rr_graph_builder.clear_temp_storage();
15061508

15071509
check_rr_graph(device_ctx.rr_graph,

0 commit comments

Comments
 (0)