Re: [eigen] Performance of SparseMatrix

[ Thread Index | Date Index | More Archives ]


thank you for the detailed feedback. Performance regressions occurred at different places and are fixed by the following changesets:
Summary:     Add missing specialization of evaluator of sub-sparse-matrices that can be seen as a SparseCompressedBase. This changeset enable faster iterator for such expressions.
Summary:     Remove duplicated temporary in Sparse to Sparse assignment
Summary:     Simplify implementation of the evaluation's iterator of Sparse*Diagonal products to help the compiler to generate better code.


On Thu, Aug 27, 2015 at 10:20 AM, "André R. Brodtkorb" <Andre.Brodtkorb@xxxxxxxxx> wrote:
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 -
[2] Minimal working example:

Mail converted by MHonArc 2.6.19+