Skip to content

Commit 1deb8b0

Browse files
added update_bb_functor_
1 parent dc9c018 commit 1deb8b0

File tree

2 files changed

+34
-57
lines changed

2 files changed

+34
-57
lines changed

vpr/src/place/net_cost_handler.cpp

Lines changed: 27 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,14 @@ NetCostHandler::NetCostHandler(const t_placer_opts& placer_opts,
143143
ts_bb_edge_new_.resize(num_nets, t_bb());
144144
ts_bb_coord_new_.resize(num_nets, t_bb());
145145
comp_bb_cost_functor_ = std::bind(&NetCostHandler::comp_3d_bb_cost_, this, std::placeholders::_1);
146+
update_bb_functor_ = std::bind(&NetCostHandler::update_bb_, this, std::placeholders::_1, std::placeholders::_2,
147+
std::placeholders::_3, std::placeholders::_4);
146148
} else {
147149
layer_ts_bb_edge_new_.resize(num_nets, std::vector<t_2D_bb>(num_layers, t_2D_bb()));
148150
layer_ts_bb_coord_new_.resize(num_nets, std::vector<t_2D_bb>(num_layers, t_2D_bb()));
149151
comp_bb_cost_functor_ = std::bind(&NetCostHandler::comp_per_layer_bb_cost_, this, std::placeholders::_1);
152+
update_bb_functor_ = std::bind(&NetCostHandler::update_layer_bb_, this, std::placeholders::_1, std::placeholders::_2,
153+
std::placeholders::_3, std::placeholders::_4);
150154
}
151155

152156
/* This initializes the whole matrix to OPEN which is an invalid value*/
@@ -363,14 +367,14 @@ void NetCostHandler::update_net_bb_(const ClusterNetId net,
363367
bool is_driver = cluster_ctx.clb_nlist.pin_type(blk_pin) == PinType::DRIVER;
364368

365369
//Incremental bounding box update
366-
update_bb_(net,
367-
{pl_moved_block.old_loc.x + pin_width_offset,
368-
pl_moved_block.old_loc.y + pin_height_offset,
369-
pl_moved_block.old_loc.layer},
370-
{pl_moved_block.new_loc.x + pin_width_offset,
371-
pl_moved_block.new_loc.y + pin_height_offset,
372-
pl_moved_block.new_loc.layer},
373-
is_driver);
370+
update_bb_functor_(net,
371+
{pl_moved_block.old_loc.x + pin_width_offset,
372+
pl_moved_block.old_loc.y + pin_height_offset,
373+
pl_moved_block.old_loc.layer},
374+
{pl_moved_block.new_loc.x + pin_width_offset,
375+
pl_moved_block.new_loc.y + pin_height_offset,
376+
pl_moved_block.new_loc.layer},
377+
is_driver);
374378
}
375379
}
376380

@@ -649,12 +653,9 @@ void NetCostHandler::get_non_updatable_layer_bb_(ClusterNetId net_id,
649653
}
650654

651655
void NetCostHandler::update_bb_(ClusterNetId net_id,
652-
t_bb& bb_edge_new,
653-
t_bb& bb_coord_new,
654-
vtr::NdMatrixProxy<int, 1> num_sink_pin_layer_new,
655-
t_physical_tile_loc pin_old_loc,
656-
t_physical_tile_loc pin_new_loc,
657-
bool src_pin) {
656+
t_physical_tile_loc pin_old_loc,
657+
t_physical_tile_loc pin_new_loc,
658+
bool src_pin) {
658659
//TODO: account for multiple physical pin instances per logical pin
659660
const t_bb *curr_bb_edge, *curr_bb_coord;
660661

@@ -663,6 +664,10 @@ void NetCostHandler::update_bb_(ClusterNetId net_id,
663664

664665
const int num_layers = device_ctx.grid.get_num_layers();
665666

667+
t_bb& bb_edge_new = ts_bb_edge_new_[net_id];
668+
t_bb& bb_coord_new = ts_bb_coord_new_[net_id];
669+
vtr::NdMatrixProxy<int, 1> num_sink_pin_layer_new = ts_layer_sink_pin_count_[size_t(net_id)];
670+
666671
pin_new_loc.x = max(min<int>(pin_new_loc.x, device_ctx.grid.width() - 2), 1); //-2 for no perim channels
667672
pin_new_loc.y = max(min<int>(pin_new_loc.y, device_ctx.grid.height() - 2), 1); //-2 for no perim channels
668673
pin_new_loc.layer_num = max(min<int>(pin_new_loc.layer_num, device_ctx.grid.get_num_layers() - 1), 0);
@@ -921,12 +926,9 @@ void NetCostHandler::update_bb_(ClusterNetId net_id,
921926
}
922927

923928
void NetCostHandler::update_layer_bb_(ClusterNetId net_id,
924-
std::vector<t_2D_bb>& bb_edge_new,
925-
std::vector<t_2D_bb>& bb_coord_new,
926-
vtr::NdMatrixProxy<int, 1> bb_pin_sink_count_new,
927-
t_physical_tile_loc pin_old_loc,
928-
t_physical_tile_loc pin_new_loc,
929-
bool is_output_pin) {
929+
t_physical_tile_loc pin_old_loc,
930+
t_physical_tile_loc pin_new_loc,
931+
bool is_output_pin) {
930932
auto& device_ctx = g_vpr_ctx.device();
931933
auto& place_move_ctx = placer_ctx_.move();
932934

@@ -935,6 +937,10 @@ void NetCostHandler::update_layer_bb_(ClusterNetId net_id,
935937
pin_old_loc.x = max(min<int>(pin_old_loc.x, device_ctx.grid.width() - 2), 1); //-2 for no perim channels
936938
pin_old_loc.y = max(min<int>(pin_old_loc.y, device_ctx.grid.height() - 2), 1); //-2 for no perim channels
937939

940+
std::vector<t_2D_bb>& bb_edge_new = layer_ts_bb_edge_new_[net_id];
941+
std::vector<t_2D_bb>& bb_coord_new = layer_ts_bb_coord_new_[net_id];
942+
vtr::NdMatrixProxy<int, 1> bb_pin_sink_count_new = ts_layer_sink_pin_count_[size_t(net_id)];
943+
938944
/* Check if the net had been updated before. */
939945
if (bb_update_status_[net_id] == NetUpdateState::GOT_FROM_SCRATCH) {
940946
/* The net had been updated from scratch, DO NOT update again! */
@@ -1753,32 +1759,10 @@ void NetCostHandler::get_non_updatable_bb_(const ClusterNetId net) {
17531759
}
17541760
}
17551761

1756-
void NetCostHandler::update_bb_(ClusterNetId net_id, t_physical_tile_loc pin_old_loc, t_physical_tile_loc pin_new_loc, bool is_driver) {
1757-
if (cube_bb_) {
1758-
update_bb_(net_id,
1759-
ts_bb_edge_new_[net_id],
1760-
ts_bb_coord_new_[net_id],
1761-
ts_layer_sink_pin_count_[size_t(net_id)],
1762-
pin_old_loc,
1763-
pin_new_loc,
1764-
is_driver);
1765-
}
1766-
else {
1767-
update_layer_bb_(net_id,
1768-
layer_ts_bb_edge_new_[net_id],
1769-
layer_ts_bb_coord_new_[net_id],
1770-
ts_layer_sink_pin_count_[size_t(net_id)],
1771-
pin_old_loc,
1772-
pin_new_loc,
1773-
is_driver);
1774-
}
1775-
}
1776-
17771762
double NetCostHandler::get_net_cost_(const ClusterNetId net_id) {
17781763
if (cube_bb_) {
17791764
return get_net_cost_(net_id, ts_bb_coord_new_[net_id]);
1780-
}
1781-
else {
1765+
} else {
17821766
return get_net_layer_bb_wire_cost_(net_id, layer_ts_bb_coord_new_[net_id], ts_layer_sink_pin_count_[size_t(net_id)]);
17831767
}
17841768
}

vpr/src/place/net_cost_handler.h

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class NetCostHandler {
120120
const t_placer_opts& placer_opts_;
121121

122122
std::function<double(e_cost_methods method)> comp_bb_cost_functor_;
123+
std::function<void(ClusterNetId net_id, t_physical_tile_loc pin_old_loc, t_physical_tile_loc pin_new_loc, bool is_driver)> update_bb_functor_;
123124

124125
/**
125126
* @brief for the states of the bounding box.
@@ -251,8 +252,6 @@ class NetCostHandler {
251252

252253
void get_non_updatable_bb_(const ClusterNetId net);
253254

254-
void update_bb_(ClusterNetId net_id, t_physical_tile_loc pin_old_loc, t_physical_tile_loc pin_new_loc, bool is_driver);
255-
256255
double get_net_cost_(const ClusterNetId net_id);
257256

258257
void set_ts_bb_coord_(const ClusterNetId net_id);
@@ -328,12 +327,9 @@ class NetCostHandler {
328327
* @param src_pin Is the moving pin driving the net
329328
*/
330329
void update_bb_(ClusterNetId net_id,
331-
t_bb& bb_edge_new,
332-
t_bb& bb_coord_new,
333-
vtr::NdMatrixProxy<int, 1> num_sink_pin_layer_new,
334-
t_physical_tile_loc pin_old_loc,
335-
t_physical_tile_loc pin_new_loc,
336-
bool src_pin);
330+
t_physical_tile_loc pin_old_loc,
331+
t_physical_tile_loc pin_new_loc,
332+
bool src_pin);
337333

338334
/**
339335
* @brief Update the per-layer bounding box of "net_id" incrementally based on the old and new locations of a pin on that net
@@ -352,12 +348,9 @@ class NetCostHandler {
352348
* @param is_output_pin Is the moving pin of the type output
353349
*/
354350
void update_layer_bb_(ClusterNetId net_id,
355-
std::vector<t_2D_bb>& bb_edge_new,
356-
std::vector<t_2D_bb>& bb_coord_new,
357-
vtr::NdMatrixProxy<int, 1> bb_pin_sink_count_new,
358-
t_physical_tile_loc pin_old_loc,
359-
t_physical_tile_loc pin_new_loc,
360-
bool is_output_pin);
351+
t_physical_tile_loc pin_old_loc,
352+
t_physical_tile_loc pin_new_loc,
353+
bool is_output_pin);
361354

362355
/**
363356
* @brief Update the data structure for large nets that keep track of

0 commit comments

Comments
 (0)