Registered Member
|
I tested Eigen matrix inverse with 2, 4 or 8 threads but the wall time is almost same for the three situations.
So I want to ask if Eigen matrix inverse use multi-threads in calculation? Thank you. |
Moderator
|
Only if you compile with openmp enabled ( -fopenmp with gcc).
|
Registered Member
|
I tried to compile Eigen with -fopenmp -march=native -O2.
But the running time for matrix inverse is till similar, e.g. 31-36 seconds with matrix of size 5000, whatever I used 1, 2 or 4 threads. When the matrix inverse program run, I found at first Eigen use multi-threads, but late just one thread. Is there any special setting for Eigen to run multi-threads? |
Moderator
|
Indeed, currently only matrix-matrix products is multi-threaded. To compute the inverse, we first start by computing a LU factorization that is dominated by matrix-matrix products. Then the U^1 * L^1 * I is performed, but since this step do rely on matrix-matrix products it does not exploit multithreading.
btw, in general nobody explicitly compute the inverse of a matrix A but rather compute its factorization (e.g. LU) and them perform calls to the solve method to efficiently apply A^1. |
Registered Member
|
My question is how i can do LU factorization first and then do solve using LU? Thank you!
|
Moderator
|
x = A.lu().solve(b);
or if you want to apply A^-1 multiple times: PartialPivLU<MatrixXd> lu(A); x = lu.solve(b); y = lu.solve(c); |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]