diff options
author | Keith Rothman <537074+litghost@users.noreply.github.com> | 2021-01-29 11:11:05 -0800 |
---|---|---|
committer | Keith Rothman <537074+litghost@users.noreply.github.com> | 2021-02-02 07:34:56 -0800 |
commit | 8d9390fc460bf98932afa5ef8362f932b48cf744 (patch) | |
tree | 537cb3d7ed9bf5e75fb035a5c91d26857c729b21 | |
parent | 16394d3158f6dc608f8fcbbcac96f851824915bd (diff) | |
download | nextpnr-8d9390fc460bf98932afa5ef8362f932b48cf744.tar.gz nextpnr-8d9390fc460bf98932afa5ef8362f932b48cf744.tar.bz2 nextpnr-8d9390fc460bf98932afa5ef8362f932b48cf744.zip |
Fix regression in use of FastBels.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
-rw-r--r-- | common/fast_bels.h | 9 | ||||
-rw-r--r-- | common/placer1.cc | 17 | ||||
-rw-r--r-- | common/placer_heap.cc | 22 |
3 files changed, 38 insertions, 10 deletions
diff --git a/common/fast_bels.h b/common/fast_bels.h index bc8e39bf..33eb4952 100644 --- a/common/fast_bels.h +++ b/common/fast_bels.h @@ -33,7 +33,7 @@ struct FastBels { int number_of_possible_bels; }; - FastBels(Context *ctx, int minBelsForGridPick) : ctx(ctx), minBelsForGridPick(minBelsForGridPick) {} + FastBels(Context *ctx, bool check_bel_available, int minBelsForGridPick) : ctx(ctx), check_bel_available(check_bel_available), minBelsForGridPick(minBelsForGridPick) {} void addCellType(IdString cell_type) { auto iter = cell_types.find(cell_type); @@ -58,7 +58,7 @@ struct FastBels { } for (auto bel : ctx->getBels()) { - if(!ctx->checkBelAvail(bel)) { + if(check_bel_available && !ctx->checkBelAvail(bel)) { continue; } @@ -106,7 +106,7 @@ struct FastBels { } for (auto bel : ctx->getBels()) { - if(!ctx->checkBelAvail(bel)) { + if(check_bel_available && !ctx->checkBelAvail(bel)) { continue; } @@ -162,7 +162,8 @@ struct FastBels { } Context *ctx; - int minBelsForGridPick; + const bool check_bel_available; + const int minBelsForGridPick; std::unordered_map<IdString, TypeData> cell_types; std::vector<FastBelsData> fast_bels_by_cell_type; diff --git a/common/placer1.cc b/common/placer1.cc index e2c3dd22..2d63ea42 100644 --- a/common/placer1.cc +++ b/common/placer1.cc @@ -76,7 +76,7 @@ class SAPlacer }; public: - SAPlacer(Context *ctx, Placer1Cfg cfg) : ctx(ctx), fast_bels(ctx, cfg.minBelsForGridPick), cfg(cfg) + SAPlacer(Context *ctx, Placer1Cfg cfg) : ctx(ctx), fast_bels(ctx, /*check_bel_available=*/false, cfg.minBelsForGridPick), cfg(cfg) { for (auto bel : ctx->getBels()) { Loc loc = ctx->getBelLocation(bel); @@ -85,6 +85,16 @@ class SAPlacer } diameter = std::max(max_x, max_y) + 1; + std::unordered_set<IdString> cell_types_in_use; + for (auto cell : sorted(ctx->cells)) { + IdString cell_type = cell.second->type; + cell_types_in_use.insert(cell_type); + } + + for(auto cell_type : cell_types_in_use) { + fast_bels.addCellType(cell_type); + } + net_bounds.resize(ctx->nets.size()); net_arc_tcost.resize(ctx->nets.size()); old_udata.reserve(ctx->nets.size()); @@ -711,11 +721,12 @@ class SAPlacer curr_loc.y = std::min(region_bounds[cell->region->name].y1, curr_loc.y); } + FastBels::FastBelsData *bel_data; + auto type_cnt = fast_bels.getBelsForCellType(targetType, &bel_data); + while (true) { int nx = ctx->rng(2 * dx + 1) + std::max(curr_loc.x - dx, 0); int ny = ctx->rng(2 * dy + 1) + std::max(curr_loc.y - dy, 0); - FastBels::FastBelsData *bel_data; - auto type_cnt = fast_bels.getBelsForCellType(targetType, &bel_data); if (cfg.minBelsForGridPick >= 0 && type_cnt < cfg.minBelsForGridPick) nx = ny = 0; if (nx >= int(bel_data->size())) diff --git a/common/placer_heap.cc b/common/placer_heap.cc index cc9f5c36..00700388 100644 --- a/common/placer_heap.cc +++ b/common/placer_heap.cc @@ -138,7 +138,7 @@ template <typename T> struct EquationSystem class HeAPPlacer { public: - HeAPPlacer(Context *ctx, PlacerHeapCfg cfg) : ctx(ctx), cfg(cfg), fast_bels(ctx, -1) { Eigen::initParallel(); } + HeAPPlacer(Context *ctx, PlacerHeapCfg cfg) : ctx(ctx), cfg(cfg), fast_bels(ctx, /*check_bel_available=*/true, -1) { Eigen::initParallel(); } bool place() { @@ -146,7 +146,7 @@ class HeAPPlacer ctx->lock(); place_constraints(); - setup_grid(); + build_fast_bels(); seed_placement(); update_all_chains(); wirelen_t hpwl = total_hpwl(); @@ -410,7 +410,7 @@ class HeAPPlacer ctx->yield(); } - void setup_grid() + void build_fast_bels() { for (auto bel : ctx->getBels()) { if (!ctx->checkBelAvail(bel)) @@ -420,6 +420,22 @@ class HeAPPlacer max_y = std::max(max_y, loc.y); } + std::unordered_set<IdString> cell_types_in_use; + std::unordered_set<PartitionId> partitions_in_use; + for (auto cell : sorted(ctx->cells)) { + IdString cell_type = cell.second->type; + cell_types_in_use.insert(cell_type); + PartitionId partition = ctx->getPartitionForCellType(cell_type); + partitions_in_use.insert(partition); + } + + for(auto cell_type : cell_types_in_use) { + fast_bels.addCellType(cell_type); + } + for(auto partition : partitions_in_use) { + fast_bels.addPartition(partition); + } + // Determine bounding boxes of region constraints for (auto ®ion : sorted(ctx->region)) { Region *r = region.second; |