Skip to content

Commit 3f70ff2

Browse files
add a private const t_placer_opts& placer_opts_ to NetCostHandler
1 parent cd005be commit 3f70ff2

File tree

4 files changed

+23
-25
lines changed

4 files changed

+23
-25
lines changed

vpr/src/place/move_transactions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct t_pl_moved_block {
3030
* placement. *
3131
* Store the information on the blocks to be moved in a swap during *
3232
* placement, in the form of array of structs instead of struct with *
33-
* arrays for cache effifiency *
33+
* arrays for cache efficiency *
3434
*
3535
* moved blocks: a list of moved blocks data structure with *
3636
* information on the move. *

vpr/src/place/net_cost_handler.cpp

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,13 @@ static double wirelength_crossing_count(size_t fanout);
129129
/******************************* End of Function definitions ************************************/
130130

131131

132-
NetCostHandler::NetCostHandler(PlacerContext& placer_ctx, size_t num_nets, bool cube_bb, float place_cost_exp)
132+
NetCostHandler::NetCostHandler(const t_placer_opts& placer_opts,
133+
PlacerContext& placer_ctx,
134+
size_t num_nets,
135+
bool cube_bb)
133136
: cube_bb_(cube_bb)
134-
, placer_ctx_(placer_ctx) {
137+
, placer_ctx_(placer_ctx)
138+
, placer_opts_(placer_opts) {
135139
const int num_layers = g_vpr_ctx.device().grid.get_num_layers();
136140

137141
// Either 3D BB or per layer BB data structure are used, not both.
@@ -159,7 +163,7 @@ NetCostHandler::NetCostHandler(PlacerContext& placer_ctx, size_t num_nets, bool
159163
* been recomputed. */
160164
bb_update_status_.resize(num_nets, NetUpdateState::NOT_UPDATED_YET);
161165

162-
alloc_and_load_chan_w_factors_for_place_cost_(place_cost_exp);
166+
alloc_and_load_chan_w_factors_for_place_cost_(placer_opts_.place_cost_exp);
163167
}
164168

165169
void NetCostHandler::alloc_and_load_chan_w_factors_for_place_cost_(float place_cost_exp) {
@@ -1500,24 +1504,20 @@ double NetCostHandler::get_net_cost_(ClusterNetId net_id, const t_bb& bb) {
15001504
double NetCostHandler::get_net_layer_bb_wire_cost_(ClusterNetId /* net_id */,
15011505
const std::vector<t_2D_bb>& bb,
15021506
const vtr::NdMatrixProxy<int, 1> layer_pin_sink_count) {
1503-
/* Finds the cost due to one net by looking at its coordinate bounding *
1504-
* box. */
1507+
// Finds the cost due to one net by looking at its coordinate bounding box.
15051508

15061509
double ncost = 0.;
1507-
double crossing = 0.;
15081510
int num_layers = g_vpr_ctx.device().grid.get_num_layers();
15091511

15101512
for (int layer_num = 0; layer_num < num_layers; layer_num++) {
15111513
VTR_ASSERT(layer_pin_sink_count[layer_num] != OPEN);
15121514
if (layer_pin_sink_count[layer_num] == 0) {
15131515
continue;
15141516
}
1515-
/*
1516-
adjust the bounding box half perimeter by the wirelength correction
1517-
factor based on terminal count, which is 1 for the source + the number
1518-
of sinks on this layer.
1519-
*/
1520-
crossing = wirelength_crossing_count(layer_pin_sink_count[layer_num] + 1);
1517+
/* Adjust the bounding box half perimeter by the wirelength correction
1518+
* factor based on terminal count, which is 1 for the source + the number
1519+
* of sinks on this layer. */
1520+
double crossing = wirelength_crossing_count(layer_pin_sink_count[layer_num] + 1);
15211521

15221522
/* Could insert a check for xmin == xmax. In that case, assume *
15231523
* connection will be made with no bends and hence no x-cost. *
@@ -1533,7 +1533,7 @@ double NetCostHandler::get_net_layer_bb_wire_cost_(ClusterNetId /* net_id */,
15331533
* chany_place_cost_fac_[bb[layer_num].xmax][bb[layer_num].xmin - 1];
15341534
}
15351535

1536-
return (ncost);
1536+
return ncost;
15371537
}
15381538

15391539
static double get_net_wirelength_estimate(ClusterNetId net_id, const t_bb& bb) {
@@ -1562,15 +1562,14 @@ static double get_net_wirelength_from_layer_bb(ClusterNetId /* net_id */,
15621562
* its coordinate bounding box. */
15631563

15641564
double ncost = 0.;
1565-
double crossing = 0.;
1566-
int num_layers = g_vpr_ctx.device().grid.get_num_layers();
1565+
const int num_layers = g_vpr_ctx.device().grid.get_num_layers();
15671566

15681567
for (int layer_num = 0; layer_num < num_layers; layer_num++) {
15691568
VTR_ASSERT_SAFE(layer_pin_sink_count[layer_num] != OPEN);
15701569
if (layer_pin_sink_count[layer_num] == 0) {
15711570
continue;
15721571
}
1573-
crossing = wirelength_crossing_count(layer_pin_sink_count[layer_num] + 1);
1572+
double crossing = wirelength_crossing_count(layer_pin_sink_count[layer_num] + 1);
15741573

15751574
/* Could insert a check for xmin == xmax. In that case, assume *
15761575
* connection will be made with no bends and hence no x-cost. *
@@ -1580,11 +1579,10 @@ static double get_net_wirelength_from_layer_bb(ClusterNetId /* net_id */,
15801579
* channel capacity. Do this for x, then y direction and add. */
15811580

15821581
ncost += (bb[layer_num].xmax - bb[layer_num].xmin + 1) * crossing;
1583-
15841582
ncost += (bb[layer_num].ymax - bb[layer_num].ymin + 1) * crossing;
15851583
}
15861584

1587-
return (ncost);
1585+
return ncost;
15881586
}
15891587

15901588
double NetCostHandler::recompute_bb_cost_() {
@@ -1636,10 +1634,9 @@ void NetCostHandler::find_affected_nets_and_update_costs(const t_place_algorithm
16361634
ts_nets_to_update_.resize(0);
16371635

16381636
/* Go through all the blocks moved. */
1639-
for (const auto& block : blocks_affected.moved_blocks) {
1640-
const auto& moving_block_inf = block;
1637+
for (const t_pl_moved_block& moving_block : blocks_affected.moved_blocks) {
16411638
auto& affected_pins = blocks_affected.affected_pins;
1642-
ClusterBlockId blk = block.block_num;
1639+
ClusterBlockId blk = moving_block.block_num;
16431640

16441641
/* Go through all the pins in the moved block. */
16451642
for (ClusterPinId blk_pin : clb_nlist.block_pins(blk)) {
@@ -1653,7 +1650,7 @@ void NetCostHandler::find_affected_nets_and_update_costs(const t_place_algorithm
16531650
criticalities,
16541651
blk,
16551652
blk_pin,
1656-
moving_block_inf,
1653+
moving_block,
16571654
affected_pins,
16581655
timing_delta_c,
16591656
is_src_moving);

vpr/src/place/net_cost_handler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class NetCostHandler {
4444
* @param cube_bb True if the 3D bounding box should be used, false otherwise.
4545
* @param place_cost_exp It is an exponent to which you take the average inverse channel
4646
*/
47-
NetCostHandler(PlacerContext& placer_ctx, size_t num_nets, bool cube_bb, float place_cost_exp);
47+
NetCostHandler(const t_placer_opts& placer_opts, PlacerContext& placer_ctx, size_t num_nets, bool cube_bb);
4848

4949
/**
5050
* @brief Finds the bb cost from scratch.
@@ -120,6 +120,7 @@ class NetCostHandler {
120120
private:
121121
bool cube_bb_ = false;
122122
PlacerContext& placer_ctx_;
123+
const t_placer_opts& placer_opts_;
123124

124125
std::function<double(e_cost_methods method)> comp_bb_cost_functor_;
125126

vpr/src/place/place.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1912,7 +1912,7 @@ static NetCostHandler alloc_and_load_placement_structs(const t_placer_opts& plac
19121912

19131913
place_ctx.compressed_block_grids = create_compressed_block_grids();
19141914

1915-
return {placer_ctx, num_nets, place_ctx.cube_bb, placer_opts.place_cost_exp};
1915+
return {placer_opts, placer_ctx, num_nets, place_ctx.cube_bb};
19161916
}
19171917

19181918
/* Frees the major structures needed by the placer (and not needed *

0 commit comments

Comments
 (0)