I am using BiCGSTAB to solve a sparse system of equations. I have used MPFR for multiprecision and the following code, but the code is running sequentially. I followed the Make Eigen run in parallel.
using MatrixXmp = Eigen::Matrix<mpfr::mpreal, Eigen::Dynamic, Eigen::Dynamic>;
using VectorXmp = Eigen::Matrix<mpfr::mpreal, Eigen::Dynamic, 1>;
...
omp_set_num_threads(num_threads);
Eigen::setNbThreads(num_threads);
mpfr::mpreal::set_default_prec(128);
Eigen::BiCGSTAB<Eigen::SparseMatrix<mpfr::mpreal, Eigen::RowMajor>> solver;
solver.setTolerance(tol);
solver.setMaxIterations(maxiter);
solver.compute(A);
xx = solver.solve(b);
compile:
g++ -o solver main.cpp -lmpfr -lgmp -fopenmp
I check top
for cpu usage. My OS is Ubuntu 20.04.
I have seen this post which is almost the same but I still have the sequential running issue.
Edit: I fill matrix A
like this:
Eigen::SparseMatrix<mpfr::mpreal, Eigen::RowMajor> A(num_rows, num_rows);
A.reserve(Eigen::RowVectorXi::Constant(num_elements, 3));
for (int i = 0; i < num_elements; i++)
{
A.insert(rows[i], cols[i]) = data[i];
}
A.makeCompressed();