@@ -129,12 +129,16 @@ NetCostHandler::NetCostHandler(const t_placer_opts& placer_opts,
129
129
comp_bb_cost_functor_ = std::bind (&NetCostHandler::comp_cube_bb_cost_, this , std::placeholders::_1);
130
130
update_bb_functor_ = std::bind (&NetCostHandler::update_bb_, this , std::placeholders::_1, std::placeholders::_2,
131
131
std::placeholders::_3, std::placeholders::_4);
132
+ get_net_bb_cost_functor_ = std::bind (&NetCostHandler::get_net_cube_bb_cost_, this , std::placeholders::_1, /* use_ts=*/ true );
133
+ get_non_updatable_bb_functor_ = std::bind (&NetCostHandler::get_non_updatable_cube_bb_, this , std::placeholders::_1, /* use_ts=*/ true );
132
134
} else {
133
135
layer_ts_bb_edge_new_.resize (num_nets, std::vector<t_2D_bb>(num_layers, t_2D_bb ()));
134
136
layer_ts_bb_coord_new_.resize (num_nets, std::vector<t_2D_bb>(num_layers, t_2D_bb ()));
135
137
comp_bb_cost_functor_ = std::bind (&NetCostHandler::comp_per_layer_bb_cost_, this , std::placeholders::_1);
136
138
update_bb_functor_ = std::bind (&NetCostHandler::update_layer_bb_, this , std::placeholders::_1, std::placeholders::_2,
137
139
std::placeholders::_3, std::placeholders::_4);
140
+ get_net_bb_cost_functor_ = std::bind (&NetCostHandler::get_net_per_layer_bb_cost_, this , std::placeholders::_1, /* use_ts=*/ true );
141
+ get_non_updatable_bb_functor_ = std::bind (&NetCostHandler::get_non_updatable_per_layer_bb_, this , std::placeholders::_1, /* use_ts=*/ true );
138
142
}
139
143
140
144
/* This initializes the whole matrix to OPEN which is an invalid value*/
@@ -262,12 +266,10 @@ double NetCostHandler::comp_cube_bb_cost_(e_cost_methods method) {
262
266
place_move_ctx.bb_num_on_edges [net_id],
263
267
place_move_ctx.num_sink_pin_layer [size_t (net_id)]);
264
268
} else {
265
- get_non_updatable_cube_bb_ (net_id,
266
- place_move_ctx.bb_coords [net_id],
267
- place_move_ctx.num_sink_pin_layer [size_t (net_id)]);
269
+ get_non_updatable_cube_bb_ (net_id, /* use_ts=*/ false );
268
270
}
269
271
270
- net_cost_[net_id] = get_net_cube_bb_cost_ (net_id, place_move_ctx. bb_coords [net_id] );
272
+ net_cost_[net_id] = get_net_cube_bb_cost_ (net_id, /* use_ts= */ false );
271
273
cost += net_cost_[net_id];
272
274
if (method == e_cost_methods::CHECK) {
273
275
expected_wirelength += get_net_wirelength_estimate (net_id, place_move_ctx.bb_coords [net_id]);
@@ -301,14 +303,10 @@ double NetCostHandler::comp_per_layer_bb_cost_(e_cost_methods method) {
301
303
place_move_ctx.layer_bb_coords [net_id],
302
304
place_move_ctx.num_sink_pin_layer [size_t (net_id)]);
303
305
} else {
304
- get_non_updatable_per_layer_bb_ (net_id,
305
- place_move_ctx.layer_bb_coords [net_id],
306
- place_move_ctx.num_sink_pin_layer [size_t (net_id)]);
306
+ get_non_updatable_per_layer_bb_ (net_id, /* use_ts=*/ false );
307
307
}
308
308
309
- net_cost_[net_id] = get_net_per_layer_bb_cost_ (net_id,
310
- place_move_ctx.layer_bb_coords [net_id],
311
- place_move_ctx.num_sink_pin_layer [size_t (net_id)]);
309
+ net_cost_[net_id] = get_net_per_layer_bb_cost_ (net_id, /* use_ts=*/ false );
312
310
cost += net_cost_[net_id];
313
311
if (method == e_cost_methods::CHECK) {
314
312
expected_wirelength += get_net_wirelength_from_layer_bb_ (net_id);
@@ -336,7 +334,7 @@ void NetCostHandler::update_net_bb_(const ClusterNetId net,
336
334
// For small nets brute-force bounding box update is faster
337
335
338
336
if (bb_update_status_[net] == NetUpdateState::NOT_UPDATED_YET) { // Only once per-net
339
- get_non_updatable_bb_ (net);
337
+ get_non_updatable_bb_functor_ (net);
340
338
}
341
339
} else {
342
340
// For large nets, update bounding box incrementally
@@ -500,13 +498,15 @@ void NetCostHandler::update_net_info_on_pin_move_(const PlaceDelayModel* delay_m
500
498
}
501
499
}
502
500
503
- void NetCostHandler::get_non_updatable_cube_bb_ (ClusterNetId net_id,
504
- t_bb& bb_coord_new,
505
- vtr::NdMatrixProxy<int , 1 > num_sink_pin_layer) {
501
+ void NetCostHandler::get_non_updatable_cube_bb_ (ClusterNetId net_id, bool use_ts) {
506
502
// TODO: account for multiple physical pin instances per logical pin
507
- auto & cluster_ctx = g_vpr_ctx.clustering ();
508
- auto & device_ctx = g_vpr_ctx.device ();
509
- auto & block_locs = placer_state_.block_locs ();
503
+ const auto & cluster_ctx = g_vpr_ctx.clustering ();
504
+ const auto & device_ctx = g_vpr_ctx.device ();
505
+ const auto & block_locs = placer_state_.block_locs ();
506
+ auto & move_ctx = placer_state_.mutable_move ();
507
+
508
+ t_bb& bb_coord_new = use_ts ? ts_bb_coord_new_[net_id] : move_ctx.bb_coords [net_id];
509
+ vtr::NdMatrixProxy<int , 1 > num_sink_pin_layer = use_ts ? ts_layer_sink_pin_count_[size_t (net_id)] : move_ctx.num_sink_pin_layer [size_t (net_id)];
510
510
511
511
ClusterBlockId bnum = cluster_ctx.clb_nlist .net_driver_block (net_id);
512
512
int pnum = placer_state_.blk_loc_registry ().net_pin_to_tile_pin_index (net_id, 0 );
@@ -572,13 +572,15 @@ void NetCostHandler::get_non_updatable_cube_bb_(ClusterNetId net_id,
572
572
bb_coord_new.layer_max = max (min<int >(layer_max, device_ctx.grid .get_num_layers () - 1 ), 0 );
573
573
}
574
574
575
- void NetCostHandler::get_non_updatable_per_layer_bb_ (ClusterNetId net_id,
576
- std::vector<t_2D_bb>& bb_coord_new,
577
- vtr::NdMatrixProxy<int , 1 > num_sink_layer) {
575
+ void NetCostHandler::get_non_updatable_per_layer_bb_ (ClusterNetId net_id, bool use_ts) {
578
576
// TODO: account for multiple physical pin instances per logical pin
579
577
auto & device_ctx = g_vpr_ctx.device ();
580
578
auto & cluster_ctx = g_vpr_ctx.clustering ();
581
579
auto & block_locs = placer_state_.block_locs ();
580
+ auto & move_ctx = placer_state_.mutable_move ();
581
+
582
+ std::vector<t_2D_bb>& bb_coord_new = use_ts ? layer_ts_bb_coord_new_[net_id] : move_ctx.layer_bb_coords [net_id];
583
+ vtr::NdMatrixProxy<int , 1 > num_sink_layer = use_ts ? ts_layer_sink_pin_count_[size_t (net_id)] : move_ctx.num_sink_pin_layer [size_t (net_id)];
582
584
583
585
const int num_layers = device_ctx.grid .get_num_layers ();
584
586
VTR_ASSERT_DEBUG (bb_coord_new.size () == num_layers);
@@ -1456,10 +1458,12 @@ void NetCostHandler::get_layer_bb_from_scratch_(ClusterNetId net_id,
1456
1458
}
1457
1459
}
1458
1460
1459
- double NetCostHandler::get_net_cube_bb_cost_ (ClusterNetId net_id, const t_bb& bb ) {
1461
+ double NetCostHandler::get_net_cube_bb_cost_ (ClusterNetId net_id, bool use_ts ) {
1460
1462
// Finds the cost due to one net by looking at its coordinate bounding box.
1461
1463
auto & cluster_ctx = g_vpr_ctx.clustering ();
1462
1464
1465
+ const t_bb& bb = use_ts ? ts_bb_coord_new_[net_id] : placer_state_.move ().bb_coords [net_id];
1466
+
1463
1467
double crossing = wirelength_crossing_count (cluster_ctx.clb_nlist .net_pins (net_id).size ());
1464
1468
1465
1469
/* Could insert a check for xmin == xmax. In that case, assume *
@@ -1476,14 +1480,17 @@ double NetCostHandler::get_net_cube_bb_cost_(ClusterNetId net_id, const t_bb& bb
1476
1480
return ncost;
1477
1481
}
1478
1482
1479
- double NetCostHandler::get_net_per_layer_bb_cost_ (ClusterNetId /* net_id */ ,
1480
- const std::vector<t_2D_bb>& bb,
1481
- const vtr::NdMatrixProxy< int , 1 > layer_pin_sink_count) {
1482
- // Finds the cost due to one net by looking at its coordinate bounding box.
1483
+ double NetCostHandler::get_net_per_layer_bb_cost_ (ClusterNetId net_id , bool use_ts) {
1484
+ const auto & move_ctx = placer_state_. move ();
1485
+ const std::vector<t_2D_bb>& bb = use_ts ? layer_ts_bb_coord_new_[net_id] : move_ctx. layer_bb_coords [net_id];
1486
+ const vtr::NdMatrixProxy< int , 1 > layer_pin_sink_count = use_ts ? ts_layer_sink_pin_count_[ size_t (net_id)] : move_ctx. num_sink_pin_layer [ size_t (net_id)];
1483
1487
1488
+ // Finds the cost due to one net by looking at its coordinate bounding box
1484
1489
double ncost = 0 .;
1485
1490
int num_layers = g_vpr_ctx.device ().grid .get_num_layers ();
1486
1491
1492
+
1493
+
1487
1494
for (int layer_num = 0 ; layer_num < num_layers; layer_num++) {
1488
1495
VTR_ASSERT (layer_pin_sink_count[layer_num] != OPEN);
1489
1496
if (layer_pin_sink_count[layer_num] == 0 ) {
@@ -1592,7 +1599,7 @@ void NetCostHandler::set_bb_delta_cost_(double& bb_delta_c) {
1592
1599
for (const ClusterNetId ts_net: ts_nets_to_update_) {
1593
1600
ClusterNetId net_id = ts_net;
1594
1601
1595
- proposed_net_cost_[net_id] = get_net_bb_cost_ (net_id);
1602
+ proposed_net_cost_[net_id] = get_net_bb_cost_functor_ (net_id);
1596
1603
1597
1604
bb_delta_c += proposed_net_cost_[net_id] - net_cost_[net_id];
1598
1605
}
@@ -1734,27 +1741,6 @@ void NetCostHandler::recompute_costs_from_scratch(const t_noc_opts& noc_opts,
1734
1741
}
1735
1742
}
1736
1743
1737
- void NetCostHandler::get_non_updatable_bb_ (const ClusterNetId net) {
1738
- if (cube_bb_) {
1739
- get_non_updatable_cube_bb_ (net,
1740
- ts_bb_coord_new_[net],
1741
- ts_layer_sink_pin_count_[size_t (net)]);
1742
- }
1743
- else {
1744
- get_non_updatable_per_layer_bb_ (net,
1745
- layer_ts_bb_coord_new_[net],
1746
- ts_layer_sink_pin_count_[size_t (net)]);
1747
- }
1748
- }
1749
-
1750
- double NetCostHandler::get_net_bb_cost_ (const ClusterNetId net_id) {
1751
- if (cube_bb_) {
1752
- return get_net_cube_bb_cost_ (net_id, ts_bb_coord_new_[net_id]);
1753
- } else {
1754
- return get_net_per_layer_bb_cost_ (net_id, layer_ts_bb_coord_new_[net_id], ts_layer_sink_pin_count_[size_t (net_id)]);
1755
- }
1756
- }
1757
-
1758
1744
void NetCostHandler::set_ts_bb_coord_ (const ClusterNetId net_id) {
1759
1745
auto & place_move_ctx = placer_state_.mutable_move ();
1760
1746
if (cube_bb_) {
0 commit comments