0

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();
Abolfazl
  • 1,047
  • 2
  • 12
  • 29
  • Maybe the matrix should be bigger. Alternatively it my be because of the specialized type. Did you tried with double precision? That being said, you need to enable optimizations for your code to be fast using `-O3`. – Jérôme Richard May 16 '21 at 13:35
  • I have tried everything, It would be better if a working example be available. Does it even work? – Abolfazl May 16 '21 at 15:14
  • At the time of this reply, the same problem still exists. – Ruizhi Apr 21 '23 at 06:41

0 Answers0