Skip to content

Commit a18e88b

Browse files
author
Nathan Shreve
committed
Fixed issue where RRSpatialLookup not updated correctly
1 parent 1c7f7d6 commit a18e88b

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

libs/librrgraph/src/base/rr_graph_utils.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
139139
using Offset = vtr::Point<size_t>;
140140
std::unordered_map<t_physical_tile_type_ptr, std::unordered_map<size_t, Offset>> physical_type_offsets;
141141

142+
// 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+
for (size_t x = bottom_left.x(); x <= top_right.x(); ++x) {
145+
for (size_t y = bottom_left.y(); y <= top_right.y(); ++y) {
146+
if (x == exclude.x() && y == exclude.y()) /* The new sink location */
147+
continue;
148+
149+
rr_graph_builder.node_lookup().remove_node(node, (int)layer, (int)x, (int)y, SINK, ptc);
150+
}
151+
}
152+
};
153+
142154
// Iterate over all SINK nodes
143155
for (size_t node = 0; node < rr_graph.num_nodes(); ++node) {
144156
auto node_id = RRNodeId(node);
@@ -168,6 +180,9 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
168180
auto new_x = (short)((int)tile_xlow + physical_type_offsets[tile_type].at(sink_ptc).x());
169181
auto new_y = (short)((int)tile_ylow + physical_type_offsets[tile_type].at(sink_ptc).y());
170182

183+
// Remove old locations from lookup
184+
remove_sink_locs_from_lookup({tile_xlow, tile_ylow}, {tile_xhigh, tile_yhigh}, {(size_t)new_x, (size_t)new_y}, node_id, tile_layer, sink_ptc);
185+
171186
// Set new coordinates
172187
rr_graph_builder.set_node_coordinates(node_id, new_x, new_y, new_x, new_y);
173188

@@ -204,15 +219,8 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
204219
auto x_avg = (short)round(std::accumulate(x_coords.begin(), x_coords.end(), 0.f) / (double)x_coords.size());
205220
auto y_avg = (short)round(std::accumulate(y_coords.begin(), y_coords.end(), 0.f) / (double)y_coords.size());
206221

207-
// Remove old indices from RRSpatialLookup
208-
for (size_t x = tile_xlow; x <= tile_xhigh; ++x) {
209-
for (size_t y = tile_ylow; y <= tile_yhigh; ++y) {
210-
if (x == (size_t)x_avg && y == (size_t)y_avg)
211-
continue;
212-
213-
rr_graph_builder.node_lookup().remove_node(node_id, (int)tile_layer, (int)x, (int)y, SINK, sink_ptc);
214-
}
215-
}
222+
// Remove old locations from lookup
223+
remove_sink_locs_from_lookup({tile_xlow, tile_ylow}, {tile_xhigh, tile_yhigh}, {(size_t)x_avg, (size_t)y_avg}, node_id, tile_layer, sink_ptc);
216224

217225
// Save offset for this tile/ptc combo
218226
if (physical_type_offsets.find(tile_type) == physical_type_offsets.end())

0 commit comments

Comments
 (0)