- edited description
Performance of Inversion and Matrix Multiplication
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)
-
reporter -
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()
andgetri()
) 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 toS
, this call is without effect.I hope this helps,
Best regards,
Klaus!
-
Hi Esmail!
One correction to the previous post: Blaze does not dispatch to the
getrf()
andgetri()
functions, but to thegesv()
LAPACK function to solve a general linear system of equations (which results fromS*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!
-
reporter Thanks really for your quick response! Sounds good!
-
- changed status to resolved
- Log in to comment