aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2020-02-02 15:28:11 +0000
committerDavid Shah <dave@ds0.me>2020-02-12 10:41:27 +0000
commit1ff060c5ad066b802db15fb4b8a2270073ec8cf5 (patch)
tree075182dd76af5ef8d3348a025c640e131f29fa2a
parent7bda6f15a9c906f54408b8b35915113e711c887c (diff)
downloadnextpnr-1ff060c5ad066b802db15fb4b8a2270073ec8cf5.tar.gz
nextpnr-1ff060c5ad066b802db15fb4b8a2270073ec8cf5.tar.bz2
nextpnr-1ff060c5ad066b802db15fb4b8a2270073ec8cf5.zip
HeAP: Make solver tolerance arch-configurable
Signed-off-by: David Shah <dave@ds0.me>
-rw-r--r--common/placer_heap.cc7
-rw-r--r--common/placer_heap.h1
2 files changed, 5 insertions, 3 deletions
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 <typename T> struct EquationSystem
void add_rhs(int row, T val) { rhs[row] += val; }
- void solve(std::vector<T> &x)
+ void solve(std::vector<T> &x, float tolerance)
{
using namespace Eigen;
if (x.empty())
@@ -123,7 +123,7 @@ template <typename T> struct EquationSystem
vb[i] = rhs.at(i);
ConjugateGradient<SparseMatrix<T>, 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<double> 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<int>("placerHeap/criticalityExponent", 2);
timingWeight = ctx->setting<int>("placerHeap/timingWeight", 10);
timing_driven = ctx->setting<bool>("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<IdString> ioBufTypes;
};