Re: [eigen] Alignment issues

[ Thread Index | Date Index | More Archives ]

On 13.02.2014 19:04, Nicola Gigante wrote:
I can’t test that snippet because on OS X memory is always at least aligned at 16 bytes.

Could you try new, new[] and std::vector with (e.g.) a 1024 byte aligned structure? It could be that starting from certain OS versions or for 64bit systems malloc (and new) simply is 16 byte aligned by default (but still don't actually cares about proper alignment). My malloc man page only says "[...] memory that is suitably aligned for any kind of variable.", which seems only to be implemented as 8 bytes.

Please note that, especially regarding C++11 support, clang 3.1 is too old, and that gcc 4.7.0 have terrible bugs, so
everybody have to use at least 4.7.1 anyway.

I do have gcc4.7.1 here (sorry for the inaccuracy), but clang 3.1 is all I have on this machine. I have clang 3.3 on another (which however also is 64bit), I could try out what happens there.

What I’d suggest is to make a survey of the behaviors of various compiler/library/OS combinations, and clarify in the documentation
what is needed with a fully standard-compilant platform (in C++11, I suppose actually nothing) and what instead are workarounds for specific
compiler bugs or limitations.

Yes, I would also assume that the C++11 standard requires new, new[] and std::allocator to meet the alignment requirements.

Could we maybe make a small test program which does all tests? (E.g. calling new, new[] and std::allocate (anything else? Maybe testing stack alignment somehow?) several times for structs with increasing alignment requirements and finding the lowest bit set in the addresses.


Dipl.-Inf., Dipl.-Math. Christoph Hertzberg
Cartesium 0.049
Universität Bremen
Enrique-Schmidt-Straße 5
28359 Bremen

Tel: +49 (421) 218-64252

Mail converted by MHonArc 2.6.19+