@@ -97,11 +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
- // We could keep track of xy-"offsets" by tile and ptc number; however, this results
104
- // in a ~10% increase in runtime to build the RR graph (on vtr benchmarks)
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;
105
107
106
108
// Iterate over all SINK nodes
107
109
for (size_t node = 0 ; node < rr_graph.num_nodes (); ++node) {
@@ -110,17 +112,36 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
110
112
if (rr_graph.node_type ((RRNodeId)node_id) != e_rr_type::SINK)
111
113
continue ;
112
114
113
- int tile_xlow = rr_graph.node_xlow (node_id);
114
- int tile_xhigh = rr_graph.node_xhigh (node_id);
115
- int tile_ylow = rr_graph.node_ylow (node_id);
116
- int tile_yhigh = rr_graph.node_yhigh (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);
117
120
118
- int tile_width = tile_xhigh - tile_xlow;
119
- int tile_height = tile_yhigh - tile_ylow;
121
+ size_t tile_width = tile_xhigh - tile_xlow;
122
+ size_t tile_height = tile_yhigh - tile_ylow;
120
123
121
124
if (tile_width == 0 && tile_height == 0 )
122
125
continue ;
123
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
+
124
145
// The IPINs of the current SINK node
125
146
std::unordered_set<RRNodeId> sink_ipins = {};
126
147
@@ -132,8 +153,8 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
132
153
VTR_ASSERT_SAFE (rr_graph.node_type (pin) == e_rr_type::IPIN);
133
154
134
155
// Make sure IPIN in the same cluster as origin
135
- int curr_x = rr_graph.node_xlow (pin);
136
- int curr_y = rr_graph.node_ylow (pin);
156
+ size_t curr_x = rr_graph.node_xlow (pin);
157
+ size_t curr_y = rr_graph.node_ylow (pin);
137
158
if ((curr_x < tile_xlow) || (curr_x > tile_xhigh) || (curr_y < tile_ylow) || (curr_y > tile_yhigh))
138
159
continue ;
139
160
@@ -151,8 +172,8 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
151
172
152
173
// Add coordinates of each "cluster-edge" pin to vectors
153
174
for (const auto & pin : sink_ipins) {
154
- int pin_x = rr_graph.node_xlow (pin);
155
- 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);
156
177
157
178
VTR_ASSERT_SAFE (pin_x == rr_graph.node_xhigh (pin));
158
179
VTR_ASSERT_SAFE (pin_y == rr_graph.node_yhigh (pin));
@@ -177,6 +198,13 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
177
198
}
178
199
}
179
200
201
+ // Save offset for this tile/ptc combo
202
+ if (physical_type_offsets.find (tile_type) == physical_type_offsets.end ())
203
+ physical_type_offsets[tile_type] = {};
204
+
205
+ physical_type_offsets[tile_type].insert ({sink_ptc, {x_avg - tile_xlow, y_avg - tile_ylow}});
206
+
207
+ // Set new coordinates
180
208
rr_graph_builder.set_node_coordinates (node_id, x_avg, y_avg, x_avg, y_avg);
181
209
}
182
210
}
0 commit comments