3

I am trying to solve a linear system of equations of the form Ax=b with the Eigen BICGSTAB in parallel.

initParallel();
int n=4;
omp_set_num_threads(n);
setNbThreads(n);

BiCGSTAB  <SparseMatrix<double>> solver;
solver.compute(A);
x = solver.solve(b);    

I also enable the OpenMP in the visual studio. but I can't see any increase in CPU usage when I increase the number of thread. As a results I cannot see any enhancement in its performance.

However, When I used LeastSquaresConjugateGradient as a solver, the CPU usage increases when I increase the number of threads, that means I could successfully parallel it, but as I said it does not work for BiCGSTAB.

initParallel();
int n=4;
omp_set_num_threads(n);
setNbThreads(n);

LeastSquaresConjugateGradient <SparseMatrix<double>> solver;
solver.compute(A);
x = solver.solve(b);

anyone can advise me why it is not paralleled for BiCGSTAB and how can do that?

  • 1
    Eigen documentation says that BiCGSTAB can make use of multi-threading with a [row-major sparse matrix format](https://eigen.tuxfamily.org/dox/TopicMultiThreading.html). Is this your case? By default, `SparseMatrix` resovles in the [column-major format](https://eigen.tuxfamily.org/dox/classEigen_1_1SparseMatrix.html). – Daniel Langr Nov 15 '19 at 11:01
  • solved now, I defined the spars matrix as row major as: SparseMatrix A(n, n); but to make it parallel, we have to again call it as row major in BiCGSTAB as : BiCGSTAB > solver; – Morteza amin naji Nov 15 '19 at 12:55
  • Great! Please take some time to write your own answer (as an answer, not as a comment) and mark the question as solved. – Rockcat Nov 15 '19 at 13:05

1 Answers1

0

to parallel the Eigen BICGSTAB:

int n=4;
omp_set_num_threads(n);
setNbThreads(n);

BiCGSTAB  <SparseMatrix<double>,RowMajor> solver;
solver.compute(A);
x = solver.solve(b);