diff --git a/common/placer_heap.cc b/common/placer_heap.cc index f336f6e4..46b572c6 100644 --- a/common/placer_heap.cc +++ b/common/placer_heap.cc @@ -97,7 +97,7 @@ template struct EquationSystem void add_rhs(int row, T val) { rhs[row] += val; } - void solve(std::vector &x) + void solve(std::vector &x, float tolerance) { using namespace Eigen; if (x.empty()) @@ -123,7 +123,7 @@ template struct EquationSystem vb[i] = rhs.at(i); ConjugateGradient, Lower | Upper> solver; - solver.setTolerance(1e-5); + solver.setTolerance(tolerance); VectorXd xr = solver.compute(mat).solveWithGuess(vb, vx); for (int i = 0; i < int(x.size()); i++) x.at(i) = xr[i]; @@ -712,7 +712,7 @@ class HeAPPlacer auto cell_pos = [&](CellInfo *cell) { return yaxis ? cell_locs.at(cell->name).y : cell_locs.at(cell->name).x; }; std::vector vals; std::transform(solve_cells.begin(), solve_cells.end(), std::back_inserter(vals), cell_pos); - es.solve(vals); + es.solve(vals, cfg.solverTolerance); for (size_t i = 0; i < vals.size(); i++) if (yaxis) { cell_locs.at(solve_cells.at(i)->name).rawy = vals.at(i); @@ -1610,6 +1610,7 @@ PlacerHeapCfg::PlacerHeapCfg(Context *ctx) criticalityExponent = ctx->setting("placerHeap/criticalityExponent", 2); timingWeight = ctx->setting("placerHeap/timingWeight", 10); timing_driven = ctx->setting("timing_driven"); + solverTolerance = 1e-5; } NEXTPNR_NAMESPACE_END diff --git a/common/placer_heap.h b/common/placer_heap.h index a018aef8..94ac5229 100644 --- a/common/placer_heap.h +++ b/common/placer_heap.h @@ -39,6 +39,7 @@ struct PlacerHeapCfg float criticalityExponent; float timingWeight; bool timing_driven; + float solverTolerance; std::unordered_set ioBufTypes; };