Registered Member
|
Hello,
I want to do operations that involves columns of a matrix and i consistently find that the speed using eigen is about 5 time slower that a loop based implementation using pointers. What am i doing wrong ? is the method .col() doing a copy ? if yes why ? Using the code below i get these timings: b=A.col(idcol)*5.0 Eigen : 50ms Loop : 8ms
|
Moderator
|
.col(i) does not make any copy. You should get similar performance. Make sure you complied with the optimizations.
|
Registered Member
|
I had optimizations enabled(Maximize Speed (/O2) in visual studio 2010 ) I compiled using SSE2 instructions and augmented the number of loops to 10000000 (100x more) and i get these timings Eigen : 686ms Loop : 531ms Eigen is still slower than the loop implementation despite it uses SSE2 instructions (the loop implementation does not) Am i doing something wrong? |
Moderator
|
Here Eigen is faster (gcc):
Eigen : 5.488ms Loop : 7.081ms Note that your example is memory bound (1 load+1 store for only one operation), this is the worst case scenario to get significant gain from vectorization. Check for instance X = X*3.3 + Y*2.9; the speedup will be much higher and probably close to 2 for double and in-cache matrices/vectors. |
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]