0

I'm trying to use Eigen (3.3.1 or 3.3.2) with INTEL's MKL PardisoLU solver. I'm using EIGEN_USE_MKL_ALL flag and have IntelSWTools 2017 installed. Currently tried it only on Win10 with VS C++, but this is not the target platform.

The solver itself looks to work significantly faster than the SparseLU which is nice (I'm interesting using a very large matrices). However in a parallel scenario it doesn't solve my problem correctly. There is no such problem with SparseLU or when I remove the upper level parallelism (commenting the pragma parallel for below).

The PardisoLU itself supposed to be thread safe, so what am i doing wrong?

The scenario is very briefly as the following

#include <Eigen/PardisoSupport>

#define N = 100000                   

typedef Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor> FullMatrix;

typedef Eigen::SparseMatrix<Complex, Eigen::ColMajor, long long> SparseMatrix; 

typedef Eigen::PardisoLU<SparseMatrix> Solver;
//typedef Eigen::SparseLU<SparseMatrix, Eigen::COLAMDOrdering< long long>> Solver;

Eigen::initParallel();

SparseMatrix A = CreateA();

Solver S;
S.analyzePattern(A);
S.factorize(A);

FullMatrix Q(A.rows(),N);

#pragma omp parallel for  
for (int n = 0; n < N; ++n)
{
     SparseMatrix Rhs = getRhs(n);
     Q.col(n) = S.Solve(Rhs);
}
  • the `solve()` function performs a call to `pardiso(pt, 1, 1, &type, 33, &n, a, ia, ja, perm, &nrhs, iparm, &msglvl, b, x, &error);` with pt, type, n, a, ia, ja, iparm, and msglvl shared among the threads, so you could check in pardiso's doc one of these arguments is modified in the solve phase (33), and if so we could make it local to fix the race condition. There is also a pb regarding `PardisoLU::solve` that modifies PardisoLU::m_info to return potential errors, but that cannot explain your issue. – ggael Apr 19 '17 at 12:11
  • just in case, is the following is still relevant after 4 years? http://stackoverflow.com/questions/20715475/calling-multithreaded-mkl-in-from-openmp-parallel-region?rq=1 – Michael Medvinsky Apr 19 '17 at 20:13
  • Good finding. That's certainly it. – ggael Apr 22 '17 at 22:53

0 Answers0