@@ -455,7 +455,9 @@ static void update_placement_cost_normalization_factors(t_placer_costs* costs, c
455
455
456
456
static double get_total_cost (t_placer_costs* costs, const t_placer_opts& placer_opts, const t_noc_opts& noc_opts);
457
457
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);
459
461
460
462
static double get_net_layer_cost (ClusterNetId /* net_id */ ,
461
463
const std::vector<t_2D_bb>& bbptr,
@@ -2086,10 +2088,10 @@ static int find_affected_nets_and_update_costs(
2086
2088
for (int inet_affected = 0 ; inet_affected < num_affected_nets;
2087
2089
inet_affected++) {
2088
2090
ClusterNetId net_id = ts_nets_to_update[inet_affected];
2089
-
2090
2091
if (cube_bb) {
2091
2092
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);
2093
2095
} else {
2094
2096
proposed_net_cost[net_id] = get_net_layer_cost (net_id,
2095
2097
layer_ts_bb_coord_new[net_id],
@@ -2579,7 +2581,9 @@ static double comp_bb_cost(e_cost_methods method) {
2579
2581
place_move_ctx.num_sink_pin_layer [size_t (net_id)]);
2580
2582
}
2581
2583
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 );
2583
2587
cost += net_cost[net_id];
2584
2588
if (method == CHECK)
2585
2589
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 */,
3095
3099
return (ncost);
3096
3100
}
3097
3101
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) {
3099
3105
/* Finds the cost due to one net by looking at its coordinate bounding *
3100
3106
* box. */
3101
3107
3102
3108
double ncost, crossing;
3103
3109
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 );
3105
3112
3106
3113
crossing = wirelength_crossing_count (
3107
3114
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) {
3120
3127
* chany_place_cost_fac[bbptr.xmax ][bbptr.xmin - 1 ];
3121
3128
3122
3129
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
3124
3141
* chanz_place_cost_fac[bbptr.layer_max ][bbptr.xmax ][bbptr.ymax ][bbptr.layer_min ][bbptr.xmin ][bbptr.ymin ];
3125
3142
}
3126
3143
@@ -3905,7 +3922,12 @@ static void alloc_and_load_for_fast_cost_update(float place_cost_exp) {
3905
3922
3906
3923
chanx_place_cost_fac.resize ({device_ctx.grid .height (), device_ctx.grid .height () + 1 });
3907
3924
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 ()});
3909
3931
3910
3932
/* First compute the number of tracks between channel high and channel *
3911
3933
* low, inclusive, in an efficient manner. */
0 commit comments