@@ -139,6 +139,18 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
139
139
using Offset = vtr::Point <size_t >;
140
140
std::unordered_map<t_physical_tile_type_ptr, std::unordered_map<size_t , Offset>> physical_type_offsets;
141
141
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
+
142
154
// Iterate over all SINK nodes
143
155
for (size_t node = 0 ; node < rr_graph.num_nodes (); ++node) {
144
156
auto node_id = RRNodeId (node);
@@ -168,6 +180,9 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
168
180
auto new_x = (short )((int )tile_xlow + physical_type_offsets[tile_type].at (sink_ptc).x ());
169
181
auto new_y = (short )((int )tile_ylow + physical_type_offsets[tile_type].at (sink_ptc).y ());
170
182
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
+
171
186
// Set new coordinates
172
187
rr_graph_builder.set_node_coordinates (node_id, new_x, new_y, new_x, new_y);
173
188
@@ -204,15 +219,8 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
204
219
auto x_avg = (short )round (std::accumulate (x_coords.begin (), x_coords.end (), 0 .f ) / (double )x_coords.size ());
205
220
auto y_avg = (short )round (std::accumulate (y_coords.begin (), y_coords.end (), 0 .f ) / (double )y_coords.size ());
206
221
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);
216
224
217
225
// Save offset for this tile/ptc combo
218
226
if (physical_type_offsets.find (tile_type) == physical_type_offsets.end ())
0 commit comments