@@ -97,9 +97,13 @@ vtr::vector<RRNodeId, std::vector<RREdgeId>> get_fan_in_list(const RRGraphView&
97
97
return node_fan_in_list;
98
98
}
99
99
100
- void set_sink_locs (const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder) {
100
+ void set_sink_locs (const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder, const DeviceGrid& grid ) {
101
101
auto node_fanins = get_fan_in_list (rr_graph);
102
102
103
+ // Keep track of offsets for SINKs for each tile type, to avoid repeated
104
+ // calculations
105
+ std::unordered_map<std::string, std::unordered_map<size_t , vtr::Point <int >>> physical_type_offsets;
106
+
103
107
// Iterate over all SINK nodes
104
108
for (size_t node = 0 ; node < rr_graph.num_nodes (); ++node) {
105
109
auto node_id = RRNodeId (node);
@@ -113,6 +117,24 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
113
117
if (tile_width == 0 && tile_height == 0 )
114
118
continue ;
115
119
120
+ // See if we have encountered this tile before
121
+ size_t tile_layer = rr_graph.node_layer (node_id);
122
+ size_t node_x = rr_graph.node_xhigh (node_id);
123
+ size_t node_y = rr_graph.node_yhigh (node_id);
124
+ std::string tile_name = grid.get_physical_type ({(int )node_x, (int )node_y, (int )tile_layer})->name ;
125
+
126
+ size_t sink_ptc = rr_graph.node_ptc_num (node_id);
127
+
128
+ if ((physical_type_offsets.find (tile_name) != physical_type_offsets.end ()) && (physical_type_offsets[tile_name].find (sink_ptc) != physical_type_offsets[tile_name].end ())) { /* We have seen this tile before */
129
+ auto new_x = (short )((int )node_x + physical_type_offsets[tile_name].at (sink_ptc).x ());
130
+ auto new_y = (short )((int )node_y + physical_type_offsets[tile_name].at (sink_ptc).y ());
131
+
132
+ // Set new coordinates
133
+ rr_graph_builder.set_node_coordinates (node_id, new_x, new_y, new_x, new_y);
134
+
135
+ continue ;
136
+ }
137
+
116
138
// The IPINs of the current SINK node
117
139
std::unordered_set<RRNodeId> sink_ipins = {};
118
140
@@ -156,6 +178,13 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
156
178
auto x_avg = (short )round (std::accumulate (x_coords.begin (), x_coords.end (), 0 .f ) / (double )x_coords.size ());
157
179
auto y_avg = (short )round (std::accumulate (y_coords.begin (), y_coords.end (), 0 .f ) / (double )y_coords.size ());
158
180
181
+ // Save offset for this tile type
182
+ if (physical_type_offsets.find (tile_name) == physical_type_offsets.end ())
183
+ physical_type_offsets[tile_name] = {};
184
+
185
+ physical_type_offsets[tile_name].insert ({sink_ptc, {x_avg - (int )node_x, y_avg - (int )node_y}});
186
+
187
+ // Set new coordinates
159
188
rr_graph_builder.set_node_coordinates (node_id, x_avg, y_avg, x_avg, y_avg);
160
189
}
161
190
}
0 commit comments