Re: [eigen] alignment question

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hello,

I just tried to make a reduced example with no luck, then you are probably right, I might had a different bug that I solved by creating temp objects.
if the issue reappears, I will try first the compiler options -mstackrealign or -mstack-alignment=16 to see.

@Gael, I would like to move away from Vector3 to enable the vectorization, I will have a lot of calculs, better to have everything as vector4 so I don't have any conversion later on. On a negative side, I need to be careful if w() is 1 (Point) or 0 (Vector)...

Best regards,
Sylvain

On Tue, Jan 27, 2015 at 11:27 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
You might also have some luck working around this issue by using these compiler flags, if this is an option for you:
-mstackrealign or -mstack-alignment=16

good luck
Benoit

2015-01-27 16:58 GMT-05:00 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:

I'm surprised that Clang would have trouble aligning return values. Can you share a compilable testcase?
Benoit

2015-01-27 16:56 GMT-05:00 Sylvain Pointeau <sylvain..pointeau@xxxxxxxxx>:

Hi again,

This was it, I created temp objects to hold the result of functions and the alignment issue is gone..
I still have a long road to replace all the Vector3 by Vector4.... 

Do you do the same way? do you have as convention to always use temp variables to hold your function return?

Best regards,
Sylvain

On Tue, Jan 27, 2015 at 5:26 PM, Sylvain Pointeau <sylvain.pointeau@xxxxxxxxx> wrote:
On Tue, Jan 27, 2015 at 2:25 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
This code is fine by itself.
It does rely on a nontrivial assumption: that stack frames are 16-byte aligned. Indeed, the alignment for Vector4f is 16 bytes, and you are placing Vector4f's on the stack in two places: as the return value of ToPoint, and for the local variable v in the third snippet. However, that assumption --- that stack frames are 16-byte aligned --- should be true. What compiler and OS are we talking about?

I use clang from xcode on mac os x yosemite..
 
Can you share a compilable testcase?

I will prepare it tonight. I am not sure it is because of this, but I don't see other options.
 
Benoit

2015-01-27 5:04 GMT-05:00 Sylvain Pointeau <sylvain.pointeau@xxxxxxxxx>:

Dear all,

I currently migrate my application to use Vector4f instead of Vector3f to benefit the vectorisation.
However I face an alignment error at runtime. (I use the latest clang from xcode on mac os x)

Vector4f toPoint(const Vector4f &v) {
  return Vector4f( v.x(), v.y(), v.z(), 1 );
}

void process( const Vector4f &v ) {
  // do process my vector
}

is there an issue with the alignment doing the following?

Vector4f v (1,3,4,0);
process( toPoint(v) );

Please let me know, I have the suspicion that the error comes from there, I wonder if I am right.

Best regards,
Sylvain








Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/