Generalize first_aligned to take the requested alignment as a template parameter, and add a first_default_aligned variante calling first_aligned with the requirement of the largest packet for the given scalar type.

This commit is contained in:
Gael Guennebaud
2015-08-06 17:52:01 +02:00
parent 1f5024332e
commit 2afdef6a54
14 changed files with 69 additions and 48 deletions

View File

@@ -13,7 +13,7 @@ template<typename Scalar>
void test_first_aligned_helper(Scalar *array, int size)
{
const int packet_size = sizeof(Scalar) * internal::packet_traits<Scalar>::size;
VERIFY(((size_t(array) + sizeof(Scalar) * internal::first_aligned(array, size)) % packet_size) == 0);
VERIFY(((size_t(array) + sizeof(Scalar) * internal::first_default_aligned(array, size)) % packet_size) == 0);
}
template<typename Scalar>
@@ -21,7 +21,7 @@ void test_none_aligned_helper(Scalar *array, int size)
{
EIGEN_UNUSED_VARIABLE(array);
EIGEN_UNUSED_VARIABLE(size);
VERIFY(internal::packet_traits<Scalar>::size == 1 || internal::first_aligned(array, size) == size);
VERIFY(internal::packet_traits<Scalar>::size == 1 || internal::first_default_aligned(array, size) == size);
}
struct some_non_vectorizable_type { float x; };