Fix regression in use of FastBels.

Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
This commit is contained in:
Keith Rothman 2021-01-29 11:11:05 -08:00
parent 16394d3158
commit 8d9390fc46
3 changed files with 38 additions and 10 deletions

View File

@ -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;

View File

@ -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()))

View File

@ -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 &region : sorted(ctx->region)) {
Region *r = region.second;