Skip to content

Commit 36ceeca

Browse files
committed
vpr: place: pass num_sink_per_layer to get_net_cost
1 parent 1c10e7d commit 36ceeca

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

vpr/src/place/place.cpp

+30-8
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,9 @@ static void update_placement_cost_normalization_factors(t_placer_costs* costs, c
455455

456456
static double get_total_cost(t_placer_costs* costs, const t_placer_opts& placer_opts, const t_noc_opts& noc_opts);
457457

458-
static double get_net_cost(ClusterNetId net_id, const t_bb& bbptr);
458+
static double get_net_cost(ClusterNetId net_id,
459+
const t_bb& bbptr,
460+
const vtr::Matrix<int>& num_sink_per_layer);
459461

460462
static double get_net_layer_cost(ClusterNetId /* net_id */,
461463
const std::vector<t_2D_bb>& bbptr,
@@ -2086,10 +2088,10 @@ static int find_affected_nets_and_update_costs(
20862088
for (int inet_affected = 0; inet_affected < num_affected_nets;
20872089
inet_affected++) {
20882090
ClusterNetId net_id = ts_nets_to_update[inet_affected];
2089-
20902091
if (cube_bb) {
20912092
proposed_net_cost[net_id] = get_net_cost(net_id,
2092-
ts_bb_coord_new[net_id]);
2093+
ts_bb_coord_new[net_id],
2094+
ts_layer_sink_pin_count);
20932095
} else {
20942096
proposed_net_cost[net_id] = get_net_layer_cost(net_id,
20952097
layer_ts_bb_coord_new[net_id],
@@ -2579,7 +2581,9 @@ static double comp_bb_cost(e_cost_methods method) {
25792581
place_move_ctx.num_sink_pin_layer[size_t(net_id)]);
25802582
}
25812583

2582-
net_cost[net_id] = get_net_cost(net_id, place_move_ctx.bb_coords[net_id]);
2584+
net_cost[net_id] = get_net_cost(net_id,
2585+
place_move_ctx.bb_coords[net_id],
2586+
place_move_ctx.num_sink_pin_layer);
25832587
cost += net_cost[net_id];
25842588
if (method == CHECK)
25852589
expected_wirelength += get_net_wirelength_estimate(net_id, place_move_ctx.bb_coords[net_id]);
@@ -3095,13 +3099,16 @@ static double get_net_layer_wirelength_estimate(ClusterNetId /* net_id */,
30953099
return (ncost);
30963100
}
30973101

3098-
static double get_net_cost(ClusterNetId net_id, const t_bb& bbptr) {
3102+
static double get_net_cost(ClusterNetId net_id,
3103+
const t_bb& bbptr,
3104+
const vtr::Matrix<int>& num_sink_per_layer) {
30993105
/* Finds the cost due to one net by looking at its coordinate bounding *
31003106
* box. */
31013107

31023108
double ncost, crossing;
31033109
auto& cluster_ctx = g_vpr_ctx.clustering();
3104-
const bool is_multi_layer = (g_vpr_ctx.device().grid.get_num_layers() > 1);
3110+
const int num_layers = g_vpr_ctx.device().grid.get_num_layers();
3111+
const bool is_multi_layer = (num_layers > 1);
31053112

31063113
crossing = wirelength_crossing_count(
31073114
cluster_ctx.clb_nlist.net_pins(net_id).size());
@@ -3120,7 +3127,17 @@ static double get_net_cost(ClusterNetId net_id, const t_bb& bbptr) {
31203127
* chany_place_cost_fac[bbptr.xmax][bbptr.xmin - 1];
31213128

31223129
if (is_multi_layer) {
3123-
ncost += (bbptr.layer_max - bbptr.layer_min) * crossing
3130+
const auto& move_ctx = g_placer_ctx.move();
3131+
int src_layer = 0;
3132+
int num_cross_layer_sink = OPEN;
3133+
if (num_sink_per_layer[(size_t)net_id][0] > num_sink_per_layer[(size_t)net_id][1]) {
3134+
num_cross_layer_sink = num_sink_per_layer[(size_t)net_id][1];
3135+
} else {
3136+
num_cross_layer_sink = num_sink_per_layer[(size_t)net_id][0];
3137+
}
3138+
VTR_ASSERT_DEBUG(num_cross_layer_sink >= 0);
3139+
3140+
ncost += (bbptr.layer_max - bbptr.layer_min) * num_cross_layer_sink
31243141
* chanz_place_cost_fac[bbptr.layer_max][bbptr.xmax][bbptr.ymax][bbptr.layer_min][bbptr.xmin][bbptr.ymin];
31253142
}
31263143

@@ -3905,7 +3922,12 @@ static void alloc_and_load_for_fast_cost_update(float place_cost_exp) {
39053922

39063923
chanx_place_cost_fac.resize({device_ctx.grid.height(), device_ctx.grid.height() + 1});
39073924
chany_place_cost_fac.resize({device_ctx.grid.width(), device_ctx.grid.width() + 1});
3908-
chanz_place_cost_fac.resize({device_ctx.grid.width(), device_ctx.grid.width() + 1});
3925+
chanz_place_cost_fac.resize({static_cast<size_t>(device_ctx.grid.get_num_layers()),
3926+
device_ctx.grid.width(),
3927+
device_ctx.grid.height(),
3928+
static_cast<size_t>(device_ctx.grid.get_num_layers()),
3929+
device_ctx.grid.width(),
3930+
device_ctx.grid.height()});
39093931

39103932
/* First compute the number of tracks between channel high and channel *
39113933
* low, inclusive, in an efficient manner. */

0 commit comments

Comments
 (0)