@@ -97,22 +97,51 @@ 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
+ using Offset = vtr::Point <size_t >;
106
+ std::unordered_map<t_physical_tile_type_ptr, std::unordered_map<size_t , Offset>> physical_type_offsets;
107
+
103
108
// Iterate over all SINK nodes
104
109
for (size_t node = 0 ; node < rr_graph.num_nodes (); ++node) {
105
110
auto node_id = RRNodeId (node);
106
111
107
112
if (rr_graph.node_type ((RRNodeId)node_id) != e_rr_type::SINK)
108
113
continue ;
109
114
110
- int tile_width = rr_graph.node_xhigh (node_id) - rr_graph.node_xlow (node_id);
111
- int tile_height = rr_graph.node_yhigh (node_id) - rr_graph.node_ylow (node_id);
115
+ // Skip 1x1 tiles
116
+ size_t tile_xlow = rr_graph.node_xlow (node_id);
117
+ size_t tile_ylow = rr_graph.node_ylow (node_id);
118
+ size_t tile_xhigh = rr_graph.node_xhigh (node_id);
119
+ size_t tile_yhigh = rr_graph.node_yhigh (node_id);
120
+
121
+ size_t tile_width = tile_xhigh - tile_xlow;
122
+ size_t tile_height = tile_yhigh - tile_ylow;
112
123
113
124
if (tile_width == 0 && tile_height == 0 )
114
125
continue ;
115
126
127
+ // See if we have encountered this tile type/ptc combo before, and used saved offset if so
128
+ size_t tile_layer = rr_graph.node_layer (node_id);
129
+ t_physical_tile_type_ptr tile_type = grid.get_physical_type ({(int )tile_xlow, (int )tile_ylow, (int )tile_layer});
130
+
131
+ size_t sink_ptc = rr_graph.node_ptc_num (node_id);
132
+
133
+ 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 ())) {
134
+ auto new_x = (short )((int )tile_xlow + physical_type_offsets[tile_type].at (sink_ptc).x ());
135
+ auto new_y = (short )((int )tile_ylow + physical_type_offsets[tile_type].at (sink_ptc).y ());
136
+
137
+ // Set new coordinates
138
+ rr_graph_builder.set_node_coordinates (node_id, new_x, new_y, new_x, new_y);
139
+
140
+ continue ;
141
+ }
142
+
143
+ /* We have not seen this tile type/ptc combo before */
144
+
116
145
// The IPINs of the current SINK node
117
146
std::unordered_set<RRNodeId> sink_ipins = {};
118
147
@@ -124,9 +153,9 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
124
153
VTR_ASSERT_SAFE (rr_graph.node_type (pin) == e_rr_type::IPIN);
125
154
126
155
// Make sure IPIN in the same cluster as origin
127
- int curr_x = rr_graph.node_xlow (pin);
128
- int curr_y = rr_graph.node_ylow (pin);
129
- if ((curr_x < rr_graph. node_xlow (node_id)) || (curr_x > rr_graph. node_xhigh (node_id)) || (curr_y < rr_graph. node_ylow (node_id)) || (curr_y > rr_graph. node_yhigh (node_id) ))
156
+ size_t curr_x = rr_graph.node_xlow (pin);
157
+ size_t curr_y = rr_graph.node_ylow (pin);
158
+ if ((curr_x < tile_xlow) || (curr_x > tile_xhigh) || (curr_y < tile_ylow) || (curr_y > tile_yhigh ))
130
159
continue ;
131
160
132
161
sink_ipins.insert (pin);
@@ -143,8 +172,8 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
143
172
144
173
// Add coordinates of each "cluster-edge" pin to vectors
145
174
for (const auto & pin : sink_ipins) {
146
- int pin_x = rr_graph.node_xlow (pin);
147
- int pin_y = rr_graph.node_ylow (pin);
175
+ size_t pin_x = rr_graph.node_xlow (pin);
176
+ size_t pin_y = rr_graph.node_ylow (pin);
148
177
149
178
VTR_ASSERT_SAFE (pin_x == rr_graph.node_xhigh (pin));
150
179
VTR_ASSERT_SAFE (pin_y == rr_graph.node_yhigh (pin));
@@ -156,6 +185,13 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
156
185
auto x_avg = (short )round (std::accumulate (x_coords.begin (), x_coords.end (), 0 .f ) / (double )x_coords.size ());
157
186
auto y_avg = (short )round (std::accumulate (y_coords.begin (), y_coords.end (), 0 .f ) / (double )y_coords.size ());
158
187
188
+ // Save offset for this tile/ptc combo
189
+ if (physical_type_offsets.find (tile_type) == physical_type_offsets.end ())
190
+ physical_type_offsets[tile_type] = {};
191
+
192
+ physical_type_offsets[tile_type].insert ({sink_ptc, {x_avg - tile_xlow, y_avg - tile_ylow}});
193
+
194
+ // Set new coordinates
159
195
rr_graph_builder.set_node_coordinates (node_id, x_avg, y_avg, x_avg, y_avg);
160
196
}
161
197
}
0 commit comments