Re: [eigen] alignment question

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


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? Can you share a compilable testcase?
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/