diff options
author | Gael Guennebaud <g.gael@free.fr> | 2014-04-18 21:14:40 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2014-04-18 21:14:40 +0200 |
commit | 2606abed535744fcaa41b923c71338a06b8ed3fa (patch) | |
tree | cafa7c6567e2982d1395e2db63b692f34cdb1e1d /test/unalignedassert.cpp | |
parent | a7d20038df1dc160e282e824052ff5bcf5ba2c9a (diff) |
Fix 128bit packet size assumptions in unit tests.
Diffstat (limited to 'test/unalignedassert.cpp')
-rw-r--r-- | test/unalignedassert.cpp | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/test/unalignedassert.cpp b/test/unalignedassert.cpp index 601dbf214..d8815263a 100644 --- a/test/unalignedassert.cpp +++ b/test/unalignedassert.cpp @@ -9,6 +9,8 @@ #include "main.h" +typedef Matrix<float,8,1> Vector8f; + struct TestNew1 { MatrixXd m; // good: m will allocate its own array, taking care of alignment. @@ -69,7 +71,7 @@ void construct_at_boundary(int boundary) { char buf[sizeof(T)+256]; size_t _buf = reinterpret_cast<size_t>(buf); - _buf += (16 - (_buf % 16)); // make 16-byte aligned + _buf += (EIGEN_ALIGN_BYTES - (_buf % EIGEN_ALIGN_BYTES)); // make 16/32-byte aligned _buf += boundary; // make exact boundary-aligned T *x = ::new(reinterpret_cast<void*>(_buf)) T; x[0].setZero(); // just in order to silence warnings @@ -85,18 +87,18 @@ void unalignedassert() construct_at_boundary<Vector4f>(16); construct_at_boundary<Matrix2f>(16); construct_at_boundary<Matrix3f>(4); - construct_at_boundary<Matrix4f>(16); + construct_at_boundary<Matrix4f>(EIGEN_ALIGN_BYTES); construct_at_boundary<Vector2d>(16); construct_at_boundary<Vector3d>(4); - construct_at_boundary<Vector4d>(16); - construct_at_boundary<Matrix2d>(16); + construct_at_boundary<Vector4d>(EIGEN_ALIGN_BYTES); + construct_at_boundary<Matrix2d>(EIGEN_ALIGN_BYTES); construct_at_boundary<Matrix3d>(4); - construct_at_boundary<Matrix4d>(16); + construct_at_boundary<Matrix4d>(EIGEN_ALIGN_BYTES); construct_at_boundary<Vector2cf>(16); construct_at_boundary<Vector3cf>(4); - construct_at_boundary<Vector2cd>(16); + construct_at_boundary<Vector2cd>(EIGEN_ALIGN_BYTES); construct_at_boundary<Vector3cd>(16); #endif @@ -110,14 +112,21 @@ void unalignedassert() check_unalignedassert_good<Depends<true> >(); #if EIGEN_ALIGN_STATICALLY - VERIFY_RAISES_ASSERT(construct_at_boundary<Vector4f>(8)); - VERIFY_RAISES_ASSERT(construct_at_boundary<Matrix4f>(8)); - VERIFY_RAISES_ASSERT(construct_at_boundary<Vector2d>(8)); - VERIFY_RAISES_ASSERT(construct_at_boundary<Vector4d>(8)); - VERIFY_RAISES_ASSERT(construct_at_boundary<Matrix2d>(8)); - VERIFY_RAISES_ASSERT(construct_at_boundary<Matrix4d>(8)); - VERIFY_RAISES_ASSERT(construct_at_boundary<Vector2cf>(8)); - VERIFY_RAISES_ASSERT(construct_at_boundary<Vector2cd>(8)); + if(EIGEN_ALIGN_BYTES==16) + { + VERIFY_RAISES_ASSERT(construct_at_boundary<Vector4f>(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary<Vector2d>(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary<Vector2cf>(8)); + } + for(int b=8; b<EIGEN_ALIGN_BYTES; b+=8) + { + VERIFY_RAISES_ASSERT(construct_at_boundary<Vector8f>(b)); + VERIFY_RAISES_ASSERT(construct_at_boundary<Matrix4f>(b)); + VERIFY_RAISES_ASSERT(construct_at_boundary<Vector4d>(b)); + VERIFY_RAISES_ASSERT(construct_at_boundary<Matrix2d>(b)); + VERIFY_RAISES_ASSERT(construct_at_boundary<Matrix4d>(b)); + VERIFY_RAISES_ASSERT(construct_at_boundary<Vector2cd>(b)); + } #endif } |