Registered Member
|
Hello again,
I have a question to a performance issue for a gemv operation:
where y and x are complex vectors and H is a general complex (in my case hermitian) matrix. Here is a snippet from performance testing:
compliled with: $ g++ -O3 -msse2 -DNDEBUG -DEIGEN_NO_DEBUG test.cpp it prints me:
So, if I am comparing properly, the Eigen "vectorized" code runs approx. 2-2.5 times slower than the loop. I suggest, that due to the assignment, some memory reallocations occure, which makes the code slower. Is there a way to optimize the matrix-vector product, in order to be as fast as the loop approach? I have to do such multiplication about 1-2mio times for Dimensions up to 100 for solving a differential equation, so performance matters. Thanks! Matthias |
Moderator
|
I see that you are using extremely small matrices, 2x2. Then using Matrix2xd and Vector2cd type should lead to substantial speed up. noalias() already bypass memory re-allocation. To make the comparison more fair, use .setZero() in the loop-based version, or += in the expression based version.
|
Registered Member
|
With the setZero() enabled I get:
which is still 50% slower. However, with a bigger a Matrix (100,100), eigen performs much better (with 100 instead of 1k repetitions):
I compared the time as function of the matrix size, and it seems, that the vectorized product is faster beginning with sizes > 4. I think that solves my issue, thanks! |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]