I want to use OpenMP with Eigen BiCGSTAB solver.
The documentation of Eigen says it is supported, but I cannot figure out why it’s not reducing the time of solving linear equations.
This is the snippet of code I am using:
SparseMatrix<double, RowMajor> A(n, n);
// filling in A matrix
int n_t = 8;
omp_set_num_threads(n_t);
BiCGSTAB<SparseMatrix<double, RowMajor>> solver;
solver.setTolerance(1e-10);
solver.setMaxIterations(1000);
solver.compute(A);
VectorXd x = solver.solve(b);
I am compiling the code with following settings:
g++ -I "C:/CPP/eigen-3.4.0" -o parallel_solve -O3 -fopenmp solver_test_parallel.cpp
I am performing a test for the matrix size n=1e6
and both serial and OpenMP version take around 15s to solve the set of equations.
I am compiling the code on Windows.
I have tried using different ways of setting number of threads, downloaded once again eigen but nothing helped. Also, I know there are similar threads about this issue on stack, but none of the solutions helped me.
Piotr Pierwocha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.