Skip to content

Commit bea400e

Browse files
committed
[vpr][place][net_cost] get_chanz_cost_factor impl
1 parent 8bead96 commit bea400e

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

vpr/src/place/net_cost_handler.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,6 +1604,32 @@ double NetCostHandler::get_net_wirelength_from_layer_bb_(ClusterNetId net_id) {
16041604
return ncost;
16051605
}
16061606

1607+
float NetCostHandler::get_chanz_cost_factor(const t_bb& bounding_box, float place_cost_exp) {
1608+
int x_high = bounding_box.xmax;
1609+
int x_low = bounding_box.xmin;
1610+
int y_high = bounding_box.ymax;
1611+
int y_low = bounding_box.ymin;
1612+
1613+
int num_inter_dir_conn = acc_tile_num_inter_die_conn_[x_high][y_high] - \
1614+
acc_tile_num_inter_die_conn_[x_low-1][y_high] - \
1615+
acc_tile_num_inter_die_conn_[x_high][y_low-1] + \
1616+
acc_tile_num_inter_die_conn_[x_low-1][y_low-1];
1617+
1618+
int bb_num_tiles = (x_high - x_low + 1) * (y_high - y_low + 1);
1619+
1620+
float z_cost_factor;
1621+
if (num_inter_dir_conn == 0) {
1622+
return 1.0f;
1623+
} else {
1624+
z_cost_factor = bb_num_tiles / static_cast<float>(num_inter_dir_conn);
1625+
z_cost_factor = pow((double)z_cost_factor, (double)place_cost_exp);
1626+
1627+
}
1628+
1629+
return z_cost_factor;
1630+
1631+
}
1632+
16071633
double NetCostHandler::recompute_bb_cost_() {
16081634
double cost = 0;
16091635

vpr/src/place/net_cost_handler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class NetCostHandler {
201201
* but applies to the height of the bounding box. The chanZ factor is calculated during block placement because storing it in the
202202
* same way as the X and Y cost factors would require a 4D array and population it is an O(n^2) operation.
203203
*/
204-
vtr::NdMatrix<float, 2> acc_tile_num_inter_die_conn_;
204+
vtr::NdMatrix<int, 2> acc_tile_num_inter_die_conn_;
205205

206206

207207
private:
@@ -519,6 +519,6 @@ class NetCostHandler {
519519
* @param bounding_box Bounding box of the net which chanz cost factor is to be calculated
520520
* @return ChanZ cost factor
521521
*/
522-
float get_chanz_cost_factor(const t_bb& bounding_box);
522+
float get_chanz_cost_factor(const t_bb& bounding_box, float place_cost_exp);
523523

524524
};

0 commit comments

Comments
 (0)