Re: [eigen] alignment question
• To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
• Subject: Re: [eigen] alignment question
• From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
• Date: Tue, 27 Jan 2015 08:25:59 -0500
• Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=8303y5uck5FY5Ffh2ZldWQc4TEUkYjL/13Bso6adqug=; b=iRhcFF43w0Z9iIGhbSCj8UNxG23H/UaMnQMObNf7Zp9NtqR1Bv5aKddTdV3eySYZLz aQ6bkRT7NLwrnMPHGeEFPETfHs8gti5LQvPTbL33YC9Hic1N5GBb9lyQAkmRyoMGxdQd VMNGWPbABP2TjnvkScMHOM72k6HWt6czsYrS5Bz8Djt1oT66Roxd05UE8JJYVddw2M1m 3IwdmdzHof2dwqJdT3GLcxxemg0RK2GRxiMLr99wYfy4O5HwVTgco2SANpRWxwPdo8fM 2VktrcT4V6h9IXHlIjuoKvILzSoyXDp5fPSZ0h713fxvaqcPyDV+oSsiRNlYdjKAg9Co AEGQ==

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 :
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/