Skip to content

Commit a379afb

Browse files
committed
[vpr][place] add alloc_and_load_for_fast_vertical_cost_update to calculate chanz_place_cost_fac_
1 parent 89823d7 commit a379afb

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

vpr/src/place/net_cost_handler.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ constexpr std::array<float, MAX_FANOUT_CROSSING_COUNT> cross_count = {1.0000, 1.
5555

5656

5757

58+
static void alloc_and_load_for_fast_vertical_cost_update(float place_cost_exp,
59+
vtr::NdOffsetMatrix<float, 4>& chanz_place_cost_fac);
5860

5961
/**
6062
* @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"
@@ -229,6 +231,60 @@ void NetCostHandler::alloc_and_load_chan_w_factors_for_place_cost_(float place_c
229231
chany_place_cost_fac_[high][low] = pow((double)chany_place_cost_fac_[high][low], (double)place_cost_exp);
230232
}
231233
}
234+
235+
alloc_and_load_for_fast_vertical_cost_update(place_cost_exp, chanz_place_cost_fac_);
236+
}
237+
238+
static void alloc_and_load_for_fast_vertical_cost_update(float place_cost_exp, vtr::NdOffsetMatrix<float, 4>& chanz_place_cost_fac) {
239+
const auto& device_ctx = g_vpr_ctx.device();
240+
const auto& rr_graph = device_ctx.rr_graph;
241+
vtr::NdMatrix<float, 2> tile_num_inter_die_conn({device_ctx.grid.width(),
242+
device_ctx.grid.height()}, 0);
243+
244+
for (const auto& src_rr_node : rr_graph.nodes()) {
245+
for (const auto& rr_edge_idx : rr_graph.configurable_edges(src_rr_node)) {
246+
const auto& sink_rr_node = rr_graph.edge_sink_node(src_rr_node, rr_edge_idx);
247+
if (rr_graph.node_layer(src_rr_node) != rr_graph.node_layer(sink_rr_node)) {
248+
int src_x = rr_graph.node_xhigh(src_rr_node);
249+
int src_y = rr_graph.node_yhigh(src_rr_node);
250+
VTR_ASSERT(rr_graph.node_xlow(src_rr_node) == src_x && rr_graph.node_ylow(src_rr_node) == src_y);
251+
252+
tile_num_inter_die_conn[src_x][src_y]++;
253+
}
254+
}
255+
256+
for (const auto& rr_edge_idx : rr_graph.non_configurable_edges(src_rr_node)) {
257+
const auto& sink_rr_node = rr_graph.edge_sink_node(src_rr_node, rr_edge_idx);
258+
if (rr_graph.node_layer(src_rr_node) != rr_graph.node_layer(sink_rr_node)) {
259+
int src_x = rr_graph.node_xhigh(src_rr_node);
260+
VTR_ASSERT(rr_graph.node_xlow(src_rr_node) == src_x && rr_graph.node_xlow(src_rr_node) == src_x);
261+
int src_y = rr_graph.node_yhigh(src_rr_node);
262+
VTR_ASSERT(rr_graph.node_ylow(src_rr_node) == src_y && rr_graph.node_ylow(src_rr_node) == src_y);
263+
tile_num_inter_die_conn[src_x][src_y]++;
264+
}
265+
}
266+
}
267+
268+
for (int x_high = 1; x_high < (int)device_ctx.grid.width(); x_high++) {
269+
for (int y_high = 1; y_high < (int)device_ctx.grid.height(); y_high++) {
270+
for (int x_low = 0; x_low < x_high; x_low++) {
271+
for (int y_low = 0; y_low < y_high; y_low++) {
272+
int num_inter_die_conn = 0;
273+
for (int x = x_low; x <= x_high; x++) {
274+
for (int y = y_low; y <= y_high; y++) {
275+
num_inter_die_conn += tile_num_inter_die_conn[x][y];
276+
}
277+
}
278+
int seen_num_tiles = (x_high - x_low + 1) * (y_high - y_low + 1);
279+
chanz_place_cost_fac[x_high][y_high][x_low][y_low] = seen_num_tiles / static_cast<float>(num_inter_die_conn);
280+
281+
chanz_place_cost_fac[x_high][y_high][x_low][y_low] = pow(
282+
(double)chanz_place_cost_fac[x_high][y_high][x_low][y_low],
283+
(double)place_cost_exp);
284+
}
285+
}
286+
}
287+
}
232288
}
233289

234290
double NetCostHandler::comp_bb_cost(e_cost_methods method) {

0 commit comments

Comments
 (0)