Re: [eigen] Alignment issues

[ Thread Index | Date Index | More Archives ]

On 14.02.2014 03:26, Nicola Gigante wrote:

So if you’re requesting a 32bytes alignment and the program compiles, operator new must return a 32bytes aligned address. If not,
the compiler has a bug. So, again, I think it would be useful to make a mapping of behavior/bugs of actual compiler/arch/OS combinations.

Ok, that's not as bad (or useless) as I originally thought. Another question for clarification: Is the compilation supposed to fail immediatly, or if and only if operator new/new[] is used at some point? The former would make some working Eigen code not compile anymore (namely code with classes containing Eigen types, that are never new-allocated).

Of course, nothing guarantees that C++11 alignas() semantics apply to the GNU and VC++ attributes, especially the guarantee that
unsupported requirements gives to compilation errors. So it might be a win to use alignas() when supported, instead of the attributes,
to get precise guarantees (modulo bugs, again). Then in the documentation you can say “in C++11 mode we take care about alignment issues for you, unless you have a buggy compiler, in which case do as you would in C++98”.

I think it would rather be:
"In (fully compliant) C++11 mode, alignment works automatically or your code will fail to compile. To be safe add EIGEN_MAKE_ALIGNED_OPERATOR_NEW to all classes containing Eigen types."
But essentially, we already seem to be at the "works automatically" point on 64bit systems (until, if ever, we require higher alignments). Maybe we could make EMAON automatically fall back to the default if alignof(std::max_align_t)>=16, but I think that falls into the code cosmetics category.

If I find the time, I could setup a battery of virtual machines to make extensive comparisons.

That would be nice, but from Eigen's POV we already found some compilers/libstdc++s (which we want to support for a while) that require work-arounds anyway.


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+