From 2ef2d2b2cb7cb2e54f8a0d8d5476e361ec5e68ea Mon Sep 17 00:00:00 2001 From: David Shah Date: Fri, 7 Dec 2018 18:18:24 +0000 Subject: [PATCH] placer1: Bugfixes Signed-off-by: David Shah --- common/placer1.cc | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/common/placer1.cc b/common/placer1.cc index 9b5352e0..baddf4eb 100644 --- a/common/placer1.cc +++ b/common/placer1.cc @@ -193,7 +193,8 @@ class SAPlacer last_wirelen_cost = curr_wirelen_cost; last_timing_cost = curr_timing_cost; - double avg_metric = curr_metric(), min_metric = curr_metric(); + wirelen_t avg_wirelen = curr_wirelen_cost; + wirelen_t min_wirelen = curr_wirelen_cost; int n_no_progress = 0; temp = 10000; @@ -220,8 +221,8 @@ class SAPlacer } } - if (curr_metric() < min_metric) { - min_metric = curr_metric(); + if (curr_wirelen_cost < min_wirelen) { + min_wirelen = curr_wirelen_cost; improved = true; } @@ -243,9 +244,9 @@ class SAPlacer int M = std::max(max_x, max_y) + 1; double upper = 0.6, lower = 0.4; - - if (curr_metric() < 0.95 * avg_metric && curr_metric > 0) { - avg_metric = 0.8 * avg_metric + 0.2 * curr_metric(); + + if (curr_wirelen_cost < 0.95 * avg_wirelen && curr_wirelen_cost > 0) { + avg_wirelen = 0.8 * avg_wirelen + 0.2 * curr_wirelen_cost; } else { if (Raccept >= 0.8) { temp *= 0.7; @@ -295,6 +296,8 @@ class SAPlacer // accumulating over time curr_wirelen_cost = total_wirelen_cost(); curr_timing_cost = total_timing_cost(); + last_wirelen_cost = curr_wirelen_cost; + last_timing_cost = curr_timing_cost; // Let the UI show visualization updates. ctx->yield(); } @@ -401,17 +404,18 @@ class SAPlacer ctx->unbindBel(newBel); } + ctx->bindBel(newBel, cell, STRENGTH_WEAK); + + if (other_cell != nullptr) { + ctx->bindBel(oldBel, other_cell, STRENGTH_WEAK); + } + add_move_cell(moveChange, cell, oldBel); if (other_cell != nullptr) { add_move_cell(moveChange, other_cell, newBel); } - ctx->bindBel(newBel, cell, STRENGTH_WEAK); - - if (other_cell != nullptr) { - ctx->bindBel(oldBel, other_cell, STRENGTH_WEAK); - } if (!ctx->isBelLocationValid(newBel) || ((other_cell != nullptr && !ctx->isBelLocationValid(oldBel)))) { ctx->unbindBel(newBel); if (other_cell != nullptr) @@ -430,7 +434,7 @@ class SAPlacer delta += (cfg.constraintWeight / temp) * (new_dist - old_dist); n_move++; // SA acceptance criterea - if (delta < 0 || (temp > 1e-6 && (ctx->rng() / float(0x3fffffff)) <= std::exp(-delta / temp))) { + if (delta < 0 || (temp > 1e-6 && (ctx->rng() / float(0x0fffffff)) <= std::exp(-delta / temp))) { n_accept++; } else { if (other_cell != nullptr)