Registered Member
|
Hi All,
I am using Eigen for building C++ library on co-clustering algorithms. I am comparing performance with MATLAB codes, and my C++ library is about 10 times faster on small matrices. But as the data size increases the time consumption becomes comparable, worst is my library is slower for even larger size matrix data. I Figured out that performance is mainly depending on speed of matrix multiplication and MATLAB is faster than Eigen when matrix size is big. Here is exemplar timing for multiplication of two square matrices of size 5000x5000 Eigen(with optimization -O3) : 21.19 seconds Matlab(multi-threading disabled, also result is not cached meaning it is actually evaluated): 10.66 seconds Please kindly let me know if it is possible that Eigen is optimizing matrix multiplication for small size matrices only (as also indicated by Benchmark http://eigen.tuxfamily.org/index.php?title=Benchmark where comparison only upto 1000 is shown). If not, please let me know if i am missing something.. Many thanks. I am looking forward for replies.. Sincerely, Parmeet |
Registered Member
|
are you using matrices with static or dynamic size in Eigen?
|
Registered Member
|
|
Registered Member
|
Can you post your code please?
|
Moderator
|
the benchmark goes up to 3000 (log scale !). MatLab is actually using MKL for the matrix multiplication, so you actually benchmarking Eigen versus MKL. The speedup factor 2 is probably because you have a recent CPU with AVX instructions (exploited by MKL) while currently Eigen only exploits SSE. AVX supports should come within a few months.
|
Registered Member
|
Thanks for the comments..Yes indeed it is 3000! But our aim is to tackle much larger matrices (and potentially get big gain in speed by shifting from MATLAB to C++).. Is it possible that we might loose some optimization in matrix multiplication using Eigen when dealing with large size dynamic matrices as compared to MATLAB ?
Here is rather naive code to measure time consumption of matrix multiplication using static matrices:
|
Moderator
|
MAtLab is extremely slow when dealing with small matrices because of the overhead induced by each call, etc. MatLab is also not very good for component-wise operations. Matlab is also limited to double while float can be twice as fast. However, thanks to the use of MKL, MatLab very good when dealing with large matrices for matrix products, decompositions or linear solving.
|
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]