Timeline for Optimizing matrix-vector multiplication for many small matrices
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 19, 2014 at 4:11 | comment | added | Damien | If the matrices are very small (e.g. 4x4), try giving one of the templated libraries a go - it may remove a lot of function call overhead. Eigen is a good candidate. | |
Jan 14, 2014 at 22:38 | comment | added | Bill Barth | The matmul for a NxN multiplying an Nx1 should have $O(N^2)$ operations. How did you get to $O(N^3)$? | |
Jan 14, 2014 at 21:41 | comment | added | Aurelius | @BillBarth we did test this and it's not the function call overhead as we were getting big speed-ups with our own function. Matmul is N^2(2N-1)=225 operations which should be considerably more expensive than a function call. Without knowing the guts of MKL though it's impossible for us to say much more. | |
Jan 14, 2014 at 13:10 | comment | added | Bill Barth | 5x5 is small enough that the function-call overhead itself could get in the way. It's worth an experiment. | |
Jan 14, 2014 at 2:38 | comment | added | Aurelius | Bill, a co-worker of mine ran into this same problem. The conclusion was that either there was some non-negligible overhead in the MKL call or it was otherwise not well optimized for small matrices. Either way, a hand-written matmul was considerably faster when doing a very large number of 5x5 matrix multiplications. | |
Jan 12, 2014 at 14:52 | comment | added | Bill Barth | I'm not entirely surprised by that, but I'd have to see the code to know for sure. There are a number of issues to worry about. I'd would have to suggest checking the alignment of your arrays before writing off the MKL, but at these small sizes, the MKL MATVEC may not be higly optimized. | |
Jan 12, 2014 at 6:04 | comment | added | tpg2114 | Interestingly the BLAS routines run slower than the MATMUL intrinsic function in Fortran, even with MKL and hardware-specific implementations. | |
Jan 11, 2014 at 14:33 | history | answered | Bill Barth | CC BY-SA 3.0 |