diff options
Diffstat (limited to 'common/placer1.cc')
-rw-r--r-- | common/placer1.cc | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/common/placer1.cc b/common/placer1.cc index 619bfbc8..c8b0d385 100644 --- a/common/placer1.cc +++ b/common/placer1.cc @@ -42,6 +42,7 @@ #include "fast_bels.h" #include "log.h" #include "place_common.h" +#include "scope_lock.h" #include "timing.h" #include "util.h" @@ -77,7 +78,7 @@ class SAPlacer public: SAPlacer(Context *ctx, Placer1Cfg cfg) - : ctx(ctx), fast_bels(ctx, /*check_bel_available=*/false, cfg.minBelsForGridPick), cfg(cfg) + : ctx(ctx), fast_bels(ctx, /*check_bel_available=*/false, cfg.minBelsForGridPick), cfg(cfg), tmg(ctx) { for (auto bel : ctx->getBels()) { Loc loc = ctx->getBelLocation(bel); @@ -142,7 +143,8 @@ class SAPlacer bool place(bool refine = false) { log_break(); - ctx->lock(); + + nextpnr::ScopeLock<Context> lock(ctx); size_t placed_cells = 0; std::vector<CellInfo *> autoplaced; @@ -239,8 +241,9 @@ class SAPlacer auto saplace_start = std::chrono::high_resolution_clock::now(); // Invoke timing analysis to obtain criticalities + tmg.setup_only = true; if (!cfg.budgetBased) - get_criticalities(ctx, &net_crit); + tmg.setup(); // Calculate costs after initial placement setup_costs(); @@ -377,7 +380,7 @@ class SAPlacer // Invoke timing analysis to obtain criticalities if (!cfg.budgetBased && cfg.timing_driven) - get_criticalities(ctx, &net_crit); + tmg.run(); // Need to rebuild costs after criticalities change setup_costs(); // Reset incremental bounds @@ -421,7 +424,7 @@ class SAPlacer log_error("constraint satisfaction check failed for cell '%s' at Bel '%s'\n", cell.first.c_str(ctx), ctx->nameOfBel(cell.second->bel)); timing_analysis(ctx); - ctx->unlock(); + return true; } @@ -834,11 +837,9 @@ class SAPlacer double delay = ctx->getDelayNS(ctx->predictDelay(net, net->users.at(user))); return std::min(10.0, std::exp(delay - ctx->getDelayNS(net->users.at(user).budget) / 10)); } else { - auto crit = net_crit.find(net->name); - if (crit == net_crit.end() || crit->second.criticality.empty()) - return 0; + float crit = tmg.get_criticality(CellPortKey(net->users.at(user))); double delay = ctx->getDelayNS(ctx->predictDelay(net, net->users.at(user))); - return delay * std::pow(crit->second.criticality.at(user), crit_exp); + return delay * std::pow(crit, crit_exp); } } @@ -1214,9 +1215,6 @@ class SAPlacer wirelen_t last_wirelen_cost, curr_wirelen_cost; double last_timing_cost, curr_timing_cost; - // Criticality data from timing analysis - NetCriticalityMap net_crit; - Context *ctx; float temp = 10; float crit_exp = 8; @@ -1233,6 +1231,8 @@ class SAPlacer bool require_legal = true; const int legalise_dia = 4; Placer1Cfg cfg; + + TimingAnalyser tmg; }; Placer1Cfg::Placer1Cfg(Context *ctx) @@ -1263,9 +1263,10 @@ bool placer1(Context *ctx, Placer1Cfg cfg) return true; } catch (log_execution_error_exception) { #ifndef NDEBUG + ctx->lock(); ctx->check(); -#endif ctx->unlock(); +#endif return false; } } @@ -1284,9 +1285,10 @@ bool placer1_refine(Context *ctx, Placer1Cfg cfg) return true; } catch (log_execution_error_exception) { #ifndef NDEBUG + ctx->lock(); ctx->check(); -#endif ctx->unlock(); +#endif return false; } } |