Skip to content

Commit b6ca82e

Browse files
committed
vpr: Store calculated placer delta costs in double to reduce round-off
1 parent 564038b commit b6ca82e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

vpr/src/place/place.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -373,20 +373,20 @@ static bool driven_by_moved_block(const ClusterNetId net);
373373

374374
static void comp_td_costs(const PlaceDelayModel& delay_model, double* timing_cost);
375375

376-
static e_swap_result assess_swap(float delta_c, float t);
376+
static e_swap_result assess_swap(double delta_c, double t);
377377

378378
static bool find_to(t_type_ptr type, float rlim, const t_pl_loc from, t_pl_loc& to);
379379

380380
static void get_non_updateable_bb(ClusterNetId net_id, t_bb* bb_coord_new);
381381

382382
static void update_bb(ClusterNetId net_id, t_bb* bb_coord_new, t_bb* bb_edge_new, int xold, int yold, int xnew, int ynew);
383383

384-
static int find_affected_nets_and_update_costs(e_place_algorithm place_algorithm, const PlaceDelayModel& delay_model, float& bb_delta_c, float& timing_delta_c);
384+
static int find_affected_nets_and_update_costs(e_place_algorithm place_algorithm, const PlaceDelayModel& delay_model, double& bb_delta_c, double& timing_delta_c);
385385

386386
static void record_affected_net(const ClusterNetId net, int& num_affected_nets);
387387

388388
static void update_net_bb(const ClusterNetId net, int iblk, const ClusterBlockId blk, const ClusterPinId blk_pin);
389-
static void update_td_delta_costs(const PlaceDelayModel& delay_model, const ClusterNetId net, const ClusterPinId pin, float& delta_timing_cost);
389+
static void update_td_delta_costs(const PlaceDelayModel& delay_model, const ClusterNetId net, const ClusterPinId pin, double& delta_timing_cost);
390390

391391
static float get_net_cost(ClusterNetId net_id, t_bb* bb_ptr);
392392

@@ -1723,9 +1723,9 @@ static e_swap_result try_swap(float t,
17231723
/* I'm using negative values of temp_net_cost as a flag, so DO NOT *
17241724
* use cost functions that can go negative. */
17251725

1726-
float delta_c = 0; /* Change in cost due to this swap. */
1727-
float bb_delta_c = 0;
1728-
float timing_delta_c = 0;
1726+
double delta_c = 0; /* Change in cost due to this swap. */
1727+
double bb_delta_c = 0;
1728+
double timing_delta_c = 0;
17291729

17301730
/* Pick a random block to be swapped with another random block. */
17311731
ClusterBlockId b_from = pick_from_block();
@@ -1881,7 +1881,7 @@ static ClusterBlockId pick_from_block() {
18811881
//and updates their bounding box.
18821882
//
18831883
//Returns the number of affected nets.
1884-
static int find_affected_nets_and_update_costs(e_place_algorithm place_algorithm, const PlaceDelayModel& delay_model, float& bb_delta_c, float& timing_delta_c) {
1884+
static int find_affected_nets_and_update_costs(e_place_algorithm place_algorithm, const PlaceDelayModel& delay_model, double& bb_delta_c, double& timing_delta_c) {
18851885
VTR_ASSERT_SAFE(bb_delta_c == 0.);
18861886
VTR_ASSERT_SAFE(timing_delta_c == 0.);
18871887
auto& cluster_ctx = g_vpr_ctx.clustering();
@@ -1968,7 +1968,7 @@ static void update_net_bb(const ClusterNetId net, int iblk, const ClusterBlockId
19681968
}
19691969
}
19701970

1971-
static void update_td_delta_costs(const PlaceDelayModel& delay_model, const ClusterNetId net, const ClusterPinId pin, float& delta_timing_cost) {
1971+
static void update_td_delta_costs(const PlaceDelayModel& delay_model, const ClusterNetId net, const ClusterPinId pin, double& delta_timing_cost) {
19721972
auto& cluster_ctx = g_vpr_ctx.clustering();
19731973

19741974
if (cluster_ctx.clb_nlist.pin_type(pin) == PinType::DRIVER) {
@@ -2133,7 +2133,7 @@ static bool find_to(t_type_ptr type, float rlim, const t_pl_loc from, t_pl_loc&
21332133
return true;
21342134
}
21352135

2136-
static e_swap_result assess_swap(float delta_c, float t) {
2136+
static e_swap_result assess_swap(double delta_c, double t) {
21372137
/* Returns: 1 -> move accepted, 0 -> rejected. */
21382138
if (delta_c <= 0) {
21392139
return ACCEPTED;
@@ -2144,7 +2144,7 @@ static e_swap_result assess_swap(float delta_c, float t) {
21442144
}
21452145

21462146
float fnum = vtr::frand();
2147-
float prob_fac = exp(-delta_c / t);
2147+
float prob_fac = std::exp(-delta_c / t);
21482148
if (prob_fac > fnum) {
21492149
return ACCEPTED;
21502150
}

0 commit comments

Comments
 (0)