[eigen] Performance of SparseMatrix |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
Dear Eigen community!
First of all I'd like to thank you for your efforts in continuously
developing and improving Eigen.
Eigen is used extensively within OPM [1], and I've recently taken a look
at how the master branch of Eigen performs in preparation for the 3.3
release you are planning. I've identified one particular case which
performs significantly worse, and would like to raise this concern with you.
The following example
const int nx = 300000;
DiagonalMatrix a = generateDiagonalMatrix(nx);
SparseMatrix b = generateSparseMatrix(nx);
SparseMatrix c;
for (int j=0; j<1000; ++j) {
c = a*b;
}
takes about 2.1 seconds using -O3 on my computer with gcc-4.9 and the
"old" Eigen (3.2.0 / 3.2.5), whilst it takes about 6.3 seconds with the
"new" Eigen (commit e7cfc657dffc990a7fca8ad1d25cbd27f12c38e0). The full
source is available from [2].
I've also experimented with different variants to explore the issue, and
from my profiling and benchmarking it appears that
SparseMatrixBase<Derived>::operator=(...) and
assign_sparse_to_sparse(...) within SparseAssign.h are the culprits.
Can you reproduce these findings, and if so, do you perhaps know how
this can be improved?
Kind regards,
André R. Brodtkorb
[1] OPM: Open Porous Media - http://opm-project.org/
[2] Minimal working example:
https://raw.githubusercontent.com/babrodtk/opm-eigen_testing/master/src/eigen_slow_sparse.cpp