Skip to content

Commit 7f476f9

Browse files
move driven_by_moved_block() from net_cost_handler to t_pl_blocks_to_be_moved
1 parent 0b7bfa7 commit 7f476f9

File tree

4 files changed

+53
-56
lines changed

4 files changed

+53
-56
lines changed

vpr/src/place/move_transactions.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,19 @@ void t_pl_blocks_to_be_moved::clear_move_blocks() {
165165

166166
affected_pins.clear();
167167
}
168+
169+
bool t_pl_blocks_to_be_moved::driven_by_moved_block(const ClusterNetId net) const {
170+
auto& clb_nlist = g_vpr_ctx.clustering().clb_nlist;
171+
172+
bool is_driven_by_move_blk = false;
173+
ClusterBlockId net_driver_block = clb_nlist.net_driver_block(net);
174+
175+
for (const t_pl_moved_block& block : moved_blocks) {
176+
if (net_driver_block == block.block_num) {
177+
is_driven_by_move_blk = true;
178+
break;
179+
}
180+
}
181+
182+
return is_driven_by_move_blk;
183+
}

vpr/src/place/move_transactions.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,23 @@ struct t_pl_blocks_to_be_moved {
4848
t_pl_blocks_to_be_moved(const t_pl_blocks_to_be_moved&) = delete;
4949
t_pl_blocks_to_be_moved(t_pl_blocks_to_be_moved&&) = delete;
5050

51-
/**
52-
* @brief This function increments the size of the moved_blocks vector and return the index
53-
* of the newly added last elements.
54-
*/
51+
/**
52+
* @brief This function increments the size of the moved_blocks vector and return the index
53+
* of the newly added last elements.
54+
*/
5555
size_t get_size_and_increment();
5656

57-
/**
58-
* @brief This function clears all data structures of this struct.
59-
*/
57+
/**
58+
* @brief This function clears all data structures of this struct.
59+
*/
6060
void clear_move_blocks();
6161

62+
/**
63+
* @param net The unique identifier of the net of interest.
64+
* @return True if the driver block of the net is among the moving blocks.
65+
*/
66+
bool driven_by_moved_block(const ClusterNetId net) const;
67+
6268

6369
e_block_move_result record_block_move(ClusterBlockId blk,
6470
t_pl_loc to,

vpr/src/place/net_cost_handler.cpp

Lines changed: 16 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include "noc_place_utils.h"
3535
#include "vtr_math.h"
3636

37+
#include <array>
38+
3739
using std::max;
3840
using std::min;
3941

@@ -47,32 +49,14 @@ static constexpr int MAX_FANOUT_CROSSING_COUNT = 50;
4749
* for higher fanout nets. Each entry is the correction factor for the
4850
* fanout index-1
4951
*/
50-
static const float cross_count[MAX_FANOUT_CROSSING_COUNT] = {/* [0..49] */ 1.0, 1.0, 1.0, 1.0828,
51-
1.1536, 1.2206, 1.2823, 1.3385, 1.3991, 1.4493, 1.4974, 1.5455, 1.5937,
52-
1.6418, 1.6899, 1.7304, 1.7709, 1.8114, 1.8519, 1.8924, 1.9288, 1.9652,
53-
2.0015, 2.0379, 2.0743, 2.1061, 2.1379, 2.1698, 2.2016, 2.2334, 2.2646,
54-
2.2958, 2.3271, 2.3583, 2.3895, 2.4187, 2.4479, 2.4772, 2.5064, 2.5356,
55-
2.5610, 2.5864, 2.6117, 2.6371, 2.6625, 2.6887, 2.7148, 2.7410, 2.7671,
56-
2.7933};
52+
constexpr std::array<float, MAX_FANOUT_CROSSING_COUNT> cross_count = {1.0000, 1.0000, 1.0000, 1.0828, 1.1536, 1.2206, 1.2823, 1.3385,
53+
1.3991, 1.4493, 1.4974, 1.5455, 1.5937, 1.6418, 1.6899, 1.7304,
54+
1.7709, 1.8114, 1.8519, 1.8924, 1.9288, 1.9652, 2.0015, 2.0379,
55+
2.0743, 2.1061, 2.1379, 2.1698, 2.2016, 2.2334, 2.2646, 2.2958,
56+
2.3271, 2.3583, 2.3895, 2.4187, 2.4479, 2.4772, 2.5064, 2.5356,
57+
2.5610, 2.5864, 2.6117, 2.6371, 2.6625, 2.6887, 2.7148, 2.7410,
58+
2.7671, 2.7933};
5759

58-
/**
59-
* @param net The unique identifier of the net of interest.
60-
* @param moved_blocks A vector of moving clustered blocks.
61-
* @return True if the driver block of the net is among the moving blocks.
62-
*/
63-
static bool driven_by_moved_block(const ClusterNetId net,
64-
const std::vector<t_pl_moved_block>& moved_blocks);
65-
66-
/**
67-
* @brief Given the per-layer BB, calculate the wire-length estimate of the net on each layer
68-
* and return the sum of the lengths
69-
* @param net_id ID of the net which wirelength estimate is requested
70-
* @param bb Bounding box of the net
71-
* @return Wirelength estimate of the net
72-
*/
73-
static double get_net_wirelength_from_layer_bb(ClusterNetId /*net_id*/,
74-
const std::vector<t_2D_bb>& bb,
75-
const vtr::NdMatrixProxy<int, 1> layer_pin_sink_count);
7660

7761

7862

@@ -327,9 +311,7 @@ double NetCostHandler::comp_per_layer_bb_cost_(e_cost_methods method) {
327311
place_move_ctx.num_sink_pin_layer[size_t(net_id)]);
328312
cost += net_cost_[net_id];
329313
if (method == e_cost_methods::CHECK) {
330-
expected_wirelength += get_net_wirelength_from_layer_bb(net_id,
331-
place_move_ctx.layer_bb_coords[net_id],
332-
place_move_ctx.num_sink_pin_layer[size_t(net_id)]);
314+
expected_wirelength += get_net_wirelength_from_layer_bb_(net_id);
333315
}
334316
}
335317
}
@@ -1545,12 +1527,14 @@ static double get_net_wirelength_estimate(ClusterNetId net_id, const t_bb& bb) {
15451527
return ncost;
15461528
}
15471529

1548-
static double get_net_wirelength_from_layer_bb(ClusterNetId /* net_id */,
1549-
const std::vector<t_2D_bb>& bb,
1550-
const vtr::NdMatrixProxy<int, 1> layer_pin_sink_count) {
1530+
double NetCostHandler::get_net_wirelength_from_layer_bb_(ClusterNetId net_id) {
15511531
/* WMF: Finds the estimate of wirelength due to one net by looking at *
15521532
* its coordinate bounding box. */
15531533

1534+
const auto& move_ctx = placer_state_.move();
1535+
const std::vector<t_2D_bb>& bb = move_ctx.layer_bb_coords[net_id];
1536+
const auto& layer_pin_sink_count = move_ctx.num_sink_pin_layer[size_t(net_id)];
1537+
15541538
double ncost = 0.;
15551539
const int num_layers = g_vpr_ctx.device().grid.get_num_layers();
15561540

@@ -1632,7 +1616,7 @@ void NetCostHandler::find_affected_nets_and_update_costs(const PlaceDelayModel*
16321616
bool is_src_moving = false;
16331617
if (clb_nlist.pin_type(blk_pin) == PinType::SINK) {
16341618
ClusterNetId net_id = clb_nlist.pin_net(blk_pin);
1635-
is_src_moving = driven_by_moved_block(net_id, blocks_affected.moved_blocks);
1619+
is_src_moving = blocks_affected.driven_by_moved_block(net_id);
16361620
}
16371621
update_net_info_on_pin_move_(delay_model,
16381622
criticalities,
@@ -1785,20 +1769,3 @@ void NetCostHandler::set_ts_edge_(const ClusterNetId net_id) {
17851769
place_move_ctx.layer_bb_num_on_edges[net_id] = layer_ts_bb_edge_new_[net_id];
17861770
}
17871771
}
1788-
1789-
1790-
static bool driven_by_moved_block(const ClusterNetId net,
1791-
const std::vector<t_pl_moved_block>& moved_blocks) {
1792-
auto& clb_nlist = g_vpr_ctx.clustering().clb_nlist;
1793-
bool is_driven_by_move_blk = false;
1794-
ClusterBlockId net_driver_block = clb_nlist.net_driver_block(net);
1795-
1796-
for (const t_pl_moved_block& block : moved_blocks) {
1797-
if (net_driver_block == block.block_num) {
1798-
is_driven_by_move_blk = true;
1799-
break;
1800-
}
1801-
}
1802-
1803-
return is_driven_by_move_blk;
1804-
}

vpr/src/place/net_cost_handler.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,4 +460,12 @@ class NetCostHandler {
460460
const std::vector<t_2D_bb>& bb,
461461
const vtr::NdMatrixProxy<int, 1> layer_pin_sink_count);
462462

463+
/**
464+
* @brief Given the per-layer BB, calculate the wire-length estimate of the net on each layer
465+
* and return the sum of the lengths
466+
* @param net_id ID of the net which wirelength estimate is requested
467+
* @return Wirelength estimate of the net
468+
*/
469+
double get_net_wirelength_from_layer_bb_(ClusterNetId net_id);
470+
463471
};

0 commit comments

Comments
 (0)