placer1: Allow scaling HPWL differently in each direction

Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
David Shah 2020-02-02 15:25:20 +00:00
parent ca73356187
commit 7bda6f15a9
2 changed files with 14 additions and 6 deletions

View File

@ -68,7 +68,10 @@ class SAPlacer
int x0 = 0, x1 = 0, y0 = 0, y1 = 0; int x0 = 0, x1 = 0, y0 = 0, y1 = 0;
// Number of cells at each extremity // Number of cells at each extremity
int nx0 = 0, nx1 = 0, ny0 = 0, ny1 = 0; int nx0 = 0, nx1 = 0, ny0 = 0, ny1 = 0;
wirelen_t hpwl() const { return wirelen_t((x1 - x0) + (y1 - y0)); } wirelen_t hpwl(const Placer1Cfg &cfg) const
{
return wirelen_t(cfg.hpwl_scale_x * (x1 - x0) + cfg.hpwl_scale_y * (y1 - y0));
}
}; };
public: public:
@ -689,8 +692,10 @@ class SAPlacer
int dx = diameter, dy = diameter; int dx = diameter, dy = diameter;
if (cell->region != nullptr && cell->region->constr_bels) { if (cell->region != nullptr && cell->region->constr_bels) {
dx = std::min(diameter, (region_bounds[cell->region->name].x1 - region_bounds[cell->region->name].x0) + 1); dx = std::min(cfg.hpwl_scale_x * diameter,
dy = std::min(diameter, (region_bounds[cell->region->name].y1 - region_bounds[cell->region->name].y0) + 1); (region_bounds[cell->region->name].x1 - region_bounds[cell->region->name].x0) + 1);
dy = std::min(cfg.hpwl_scale_y * diameter,
(region_bounds[cell->region->name].y1 - region_bounds[cell->region->name].y0) + 1);
// Clamp location to within bounds // Clamp location to within bounds
curr_loc.x = std::max(region_bounds[cell->region->name].x0, curr_loc.x); curr_loc.x = std::max(region_bounds[cell->region->name].x0, curr_loc.x);
curr_loc.x = std::min(region_bounds[cell->region->name].x1, curr_loc.x); curr_loc.x = std::min(region_bounds[cell->region->name].x1, curr_loc.x);
@ -820,7 +825,7 @@ class SAPlacer
{ {
wirelen_t cost = 0; wirelen_t cost = 0;
for (const auto &net : net_bounds) for (const auto &net : net_bounds)
cost += net.hpwl(); cost += net.hpwl(cfg);
return cost; return cost;
} }
@ -1061,10 +1066,10 @@ class SAPlacer
} }
for (const auto &bc : md.bounds_changed_nets_x) for (const auto &bc : md.bounds_changed_nets_x)
md.wirelen_delta += md.new_net_bounds[bc].hpwl() - net_bounds[bc].hpwl(); md.wirelen_delta += md.new_net_bounds[bc].hpwl(cfg) - net_bounds[bc].hpwl(cfg);
for (const auto &bc : md.bounds_changed_nets_y) for (const auto &bc : md.bounds_changed_nets_y)
if (md.already_bounds_changed_x[bc] == MoveChangeData::NO_CHANGE) if (md.already_bounds_changed_x[bc] == MoveChangeData::NO_CHANGE)
md.wirelen_delta += md.new_net_bounds[bc].hpwl() - net_bounds[bc].hpwl(); md.wirelen_delta += md.new_net_bounds[bc].hpwl(cfg) - net_bounds[bc].hpwl(cfg);
if (cfg.timing_driven) { if (cfg.timing_driven) {
for (const auto &tc : md.changed_arcs) { for (const auto &tc : md.changed_arcs) {
@ -1145,6 +1150,8 @@ Placer1Cfg::Placer1Cfg(Context *ctx)
timingFanoutThresh = std::numeric_limits<int>::max(); timingFanoutThresh = std::numeric_limits<int>::max();
timing_driven = ctx->setting<bool>("timing_driven"); timing_driven = ctx->setting<bool>("timing_driven");
slack_redist_iter = ctx->setting<int>("slack_redist_iter"); slack_redist_iter = ctx->setting<int>("slack_redist_iter");
hpwl_scale_x = 1;
hpwl_scale_y = 1;
} }
bool placer1(Context *ctx, Placer1Cfg cfg) bool placer1(Context *ctx, Placer1Cfg cfg)

View File

@ -34,6 +34,7 @@ struct Placer1Cfg
int timingFanoutThresh; int timingFanoutThresh;
bool timing_driven; bool timing_driven;
int slack_redist_iter; int slack_redist_iter;
int hpwl_scale_x, hpwl_scale_y;
}; };
extern bool placer1(Context *ctx, Placer1Cfg cfg); extern bool placer1(Context *ctx, Placer1Cfg cfg);