Registered Member
|
I'm trying to add Eigen into kind of quick-and-dirty SGEMM profiler of mine. Basically, I'm allocating three n*n arrays, am then initializing first two of them, and finally am calling corresponding matrix mutliplication routines. Here is one I wrote for using Eigen:
However, results returned by this routine seem to be wrong; so I guess I'm not using Map<> properly - any hint here? Just in case, here is this code put together with the test code I'm using, so that this one is complete program to try:
I'm on 64-bit Slackware 13.0, Eigen is last update available for my distro (and that would be 2.0.10), gcc is 4.4.3. |
Registered Member
|
I confirm that you're using Map correctly. Can't say much more, sorry
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
I tried with simpler code example:
So I'm multiplying matrices (in Matlab notation) [1 1; 2 2] and [1 2; 1 2], and the result should be matrix [2 4; 4 8], but the code above is producing result [5 5; 5 5]. So I'd suspect Map<> is supposing column-major order of underlying data - is that correct? |
Registered Member
|
Map<MatrixXf> interpretes the array as the storage of a MatrixXf, and that is column-major.
If you want to map an array as a row-major matrix, you can do:
and then use
If you use Map on row-major matrix types, you are strongly encouraged to upgrade to the latest revision of the 2.0 branch (to become 2.0.12) as grave bugs exactly in this area were just fixed: http://eigen.tuxfamily.org/index.php?ti ... e#Download http://bitbucket.org/eigen/eigen/get/2.0.tar.bz2 You can even tell Matrix to default to row-major order, hence MatrixXf be row-major, by defining the EIGEN_DEFAULT_TO_ROW_MAJOR token. Finally, since you're measuring performance, note that the development branch would be much faster there, for 2 reasons, 1) matrix-matrix product is faster there, 2) it allows you to map a 16-byte aligned array and tell Eigen that it is aligned, which further helps with SSE vectorization.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
Thanks bjacob, that worked for me.
Performance related question: for example on Core 2 Duo machine - is Eigen able to utilize both SSE units? With my quick measurings, as above, Eigen performance is approximately half of GFLOPS available for given machine... |
Registered Member
|
Eigen doesn't do any parallelization at the moment. So each thread that uses Eigen, uses only one of your 2 cores. Eigen doesn't spawn threads by itself.
On the flip side, Eigen is completely stateless so in particular it is completely thread-safe, so if you have 2 independent computations to run, you can run them simultaneously in 2 separate threads.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
Hi,
Using the same idea I tried this:
Now, my function goes like that:
Yet using Eiegn 3.3.2 and Visual Studio it creates error. Any idea? |
Moderator
|
What are the errors? This should work. (unless mClusterCentroids turns out to be const)
|
Registered Member
|
It just crashes.
Nothing is const (I write my Code in C Style, so no const). |
Moderator
|
ah, then check the backtrace, and also make sure to try it in debug mode to get Eigen's assertions. There is nothing wrong in your code snippet.
|
Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]