31
31
#include " placer_state.h"
32
32
#include " move_utils.h"
33
33
#include " place_timing_update.h"
34
- #include " noc_place_utils.h"
35
34
#include " vtr_math.h"
35
+ #include " vtr_ndmatrix.h"
36
+ #include " vtr_ndoffsetmatrix.h"
36
37
37
38
#include < array>
38
39
@@ -53,9 +54,6 @@ constexpr std::array<float, MAX_FANOUT_CROSSING_COUNT> cross_count = {1.0000, 1.
53
54
2.5610 , 2.5864 , 2.6117 , 2.6371 , 2.6625 , 2.6887 , 2.7148 , 2.7410 ,
54
55
2.7671 , 2.7933 };
55
56
56
-
57
-
58
-
59
57
/* *
60
58
* @brief If the moving pin is of type type SINK, update bb_pin_sink_count_new which stores the number of sink pins on each layer of "net_id"
61
59
* @param pin_old_loc Old location of the moving pin
@@ -229,6 +227,70 @@ void NetCostHandler::alloc_and_load_chan_w_factors_for_place_cost_(float place_c
229
227
chany_place_cost_fac_[high][low] = pow ((double )chany_place_cost_fac_[high][low], (double )place_cost_exp);
230
228
}
231
229
}
230
+
231
+ if (device_ctx.grid .get_num_layers () > 1 ) {
232
+ alloc_and_load_for_fast_vertical_cost_update_ (place_cost_exp);
233
+ }
234
+ }
235
+
236
+ void NetCostHandler::alloc_and_load_for_fast_vertical_cost_update_ (float place_cost_exp) {
237
+ const auto & device_ctx = g_vpr_ctx.device ();
238
+ const auto & rr_graph = device_ctx.rr_graph ;
239
+
240
+ const size_t grid_height = device_ctx.grid .height ();
241
+ const size_t grid_width = device_ctx.grid .width ();
242
+
243
+
244
+ chanz_place_cost_fac_ = vtr::NdMatrix<float , 4 >({grid_width, grid_height, grid_width, grid_height}, 0 .);
245
+
246
+ vtr::NdMatrix<float , 2 > tile_num_inter_die_conn ({grid_width, grid_height}, 0 .);
247
+
248
+ for (const auto & src_rr_node : rr_graph.nodes ()) {
249
+ for (const auto & rr_edge_idx : rr_graph.configurable_edges (src_rr_node)) {
250
+ const auto & sink_rr_node = rr_graph.edge_sink_node (src_rr_node, rr_edge_idx);
251
+ if (rr_graph.node_layer (src_rr_node) != rr_graph.node_layer (sink_rr_node)) {
252
+ // We assume that the nodes driving the inter-layer connection or being driven by it
253
+ // are not streched across multiple tiles
254
+ int src_x = rr_graph.node_xhigh (src_rr_node);
255
+ int src_y = rr_graph.node_yhigh (src_rr_node);
256
+ VTR_ASSERT (rr_graph.node_xlow (src_rr_node) == src_x && rr_graph.node_ylow (src_rr_node) == src_y);
257
+
258
+ tile_num_inter_die_conn[src_x][src_y]++;
259
+ }
260
+ }
261
+
262
+ for (const auto & rr_edge_idx : rr_graph.non_configurable_edges (src_rr_node)) {
263
+ const auto & sink_rr_node = rr_graph.edge_sink_node (src_rr_node, rr_edge_idx);
264
+ if (rr_graph.node_layer (src_rr_node) != rr_graph.node_layer (sink_rr_node)) {
265
+ int src_x = rr_graph.node_xhigh (src_rr_node);
266
+ VTR_ASSERT (rr_graph.node_xlow (src_rr_node) == src_x && rr_graph.node_xlow (src_rr_node) == src_x);
267
+ int src_y = rr_graph.node_yhigh (src_rr_node);
268
+ VTR_ASSERT (rr_graph.node_ylow (src_rr_node) == src_y && rr_graph.node_ylow (src_rr_node) == src_y);
269
+ tile_num_inter_die_conn[src_x][src_y]++;
270
+ }
271
+ }
272
+ }
273
+
274
+ for (int x_high = 0 ; x_high < (int )device_ctx.grid .width (); x_high++) {
275
+ for (int y_high = 0 ; y_high < (int )device_ctx.grid .height (); y_high++) {
276
+ for (int x_low = 0 ; x_low <= x_high; x_low++) {
277
+ for (int y_low = 0 ; y_low <= y_high; y_low++) {
278
+ int num_inter_die_conn = 0 ;
279
+ for (int x = x_low; x <= x_high; x++) {
280
+ for (int y = y_low; y <= y_high; y++) {
281
+ num_inter_die_conn += tile_num_inter_die_conn[x][y];
282
+ }
283
+ }
284
+ int seen_num_tiles = (x_high - x_low + 1 ) * (y_high - y_low + 1 );
285
+ chanz_place_cost_fac_[x_high][y_high][x_low][y_low] = seen_num_tiles / static_cast <float >(num_inter_die_conn);
286
+
287
+ chanz_place_cost_fac_[x_high][y_high][x_low][y_low] = pow (
288
+ (double )chanz_place_cost_fac_[x_high][y_high][x_low][y_low],
289
+ (double )place_cost_exp);
290
+ }
291
+ }
292
+ }
293
+ }
232
294
}
233
295
234
296
double NetCostHandler::comp_bb_cost (e_cost_methods method) {
@@ -1395,6 +1457,8 @@ double NetCostHandler::get_net_cube_bb_cost_(ClusterNetId net_id, bool use_ts) {
1395
1457
1396
1458
const t_bb& bb = use_ts ? ts_bb_coord_new_[net_id] : placer_state_.move ().bb_coords [net_id];
1397
1459
1460
+ const bool is_multi_layer = (g_vpr_ctx.device ().grid .get_num_layers () > 1 );
1461
+
1398
1462
double crossing = wirelength_crossing_count (cluster_ctx.clb_nlist .net_pins (net_id).size ());
1399
1463
1400
1464
/* Could insert a check for xmin == xmax. In that case, assume *
@@ -1413,6 +1477,9 @@ double NetCostHandler::get_net_cube_bb_cost_(ClusterNetId net_id, bool use_ts) {
1413
1477
double ncost;
1414
1478
ncost = (bb.xmax - bb.xmin + 1 ) * crossing * chanx_place_cost_fac_[bb.ymax ][bb.ymin - 1 ];
1415
1479
ncost += (bb.ymax - bb.ymin + 1 ) * crossing * chany_place_cost_fac_[bb.xmax ][bb.xmin - 1 ];
1480
+ if (is_multi_layer) {
1481
+ ncost += (bb.layer_max - bb.layer_min ) * crossing * chanz_place_cost_fac_[bb.xmax ][bb.ymax ][bb.xmin ][bb.ymin ];
1482
+ }
1416
1483
1417
1484
return ncost;
1418
1485
}
0 commit comments