Registered Member
|
I understand that small vectors in Eigen are aligned in memory. Now, the default for Maps is Unaligned (according to the documentation).
As far as I understand it is always desirable to have aligned memory so Eigen can use SSE vectorization for performance. My questions then are: should I instantiate Map's to be aligned (and then Map<Matrix<int,2,4>, Aligned> ) for better performance? and if my "C" array is dynamically allocated, is there a way I can ensure it is aligned for Eigen? Say I have a large "C" array that then I access with Maps pointing to different locations within this array. Is there a way to allocate this array to be aligned? I guess my question is what the standard way to do this is. Thank you in advance. |
Moderator
|
If you can guarantee that your pointer is aligned, then yes it is recommended to use Aligned-Maps.
To allocate aligned buffer you can use Eigen's aligned_allocator: http://eigen.tuxfamily.org/dox/classEig ... cator.html |
Registered Member
|
Would you please elaborate what is the additional overhead if
a map with associated memory aligned already NOT being declared as Aligned-Map? Is it merely the cost for run-time alignment check? In another case, if the memory is actually NOT aligned. For this case, computation with the unaligned map would cost more? But what exactly the additional cost is? I assume that the run-time check still applies and there might be additional non-SSE computation for the beginning few bytes? But no matter whether the aligned or not the underlying memory the last few bytes are always computed with non-SSE?? Thanks, |
Moderator
|
That depends on your actual architecture. On recent Intel CPUs, the overhead of unaligned loads/stores is very small, so there is usually no need to bother much about alignment. On the other hand, on old core2 for instance, unaligned stores was a non go (like 5 times slower IIRC), and unaliagned loads were about 2 times slower.
|
Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]