Performance of Inversion and Matrix Multiplication

Issue #403 resolved
Esmail Abdul Fattah created an issue

Hi Klaus,

I am implementing a formula and it is taking much time. Inverse is almost 0.3-0.4 second and other operations exceeds 0.8 seconds.

   blaze::SymmetricMatrix< blaze::DynamicMatrix<double,blaze::columnMajor>> invA(2500),B(2500);
   //initialize invA and B
   blaze::IdentityMatrix<double> I(2500);
   blaze::DynamicMatrix<double,blaze::columnMajor> S = invA*B; // this doesn't necessarily to be symmetric
   S = blaze::declsym(blaze::eval(blaze::eval(S*inv(I + S))*invA));
   invA -= S;

Should thresholds be changed?

Thanks & appreciate suggestions,

Esmail

Comments (5)

  1. Klaus Iglberger

    Hi Esmail!

    I took the time to look at the individual steps of the expressions. All operations are properly performed by either BLAS calls (dgemm()) or LAPACK calls (getrf() and getri()) due to the size of the matrices. Therefore for this example Blaze mainly acts as a wrapper and dispatches to the BLAS/LAPACK kernels. Since both the matrix multiplication and the matrix inversion are O(N^3) operations, the runtime is indeed expected.

    The only change that I would suggest is to drop the call to declsym(). Since you’re not assigning to a symmetric matrix, but to S, this call is without effect.

    I hope this helps,

    Best regards,

    Klaus!

  2. Klaus Iglberger

    Hi Esmail!

    One correction to the previous post: Blaze does not dispatch to the getrf() and getri() functions, but to the gesv() LAPACK function to solve a general linear system of equations (which results from S*inv(I+S)). That choice already improves performance by approx. 10-20%. That is also why I unfortunately don’t have any suggestions on how to further improve the performance.

    Best regards,

    Klaus!

  3. Log in to comment