diff options
author | Gael Guennebaud <g.gael@free.fr> | 2015-07-29 10:22:25 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2015-07-29 10:22:25 +0200 |
commit | 175ed636ea3ac5b1b807642421a036f8a9a10f1f (patch) | |
tree | fd6d7126ebef659a12a78e8f18c2d40b2cd3e2bd /Eigen/src/Core/DenseStorage.h | |
parent | 76874b128ec7b191cc986e15ef28c34771120e82 (diff) |
bug #973: update macro-level control of alignement by introducing user-controllable EIGEN_MAX_ALIGN_BYTES and EIGEN_MAX_STATIC_ALIGN_BYTES macros. This changeset also removes EIGEN_ALIGN (replaced by EIGEN_MAX_ALIGN_BYTES>0), EIGEN_ALIGN_STATICALLY (replaced by EIGEN_MAX_STATIC_ALIGN_BYTES>0), EIGEN_USER_ALIGN*, EIGEN_ALIGN_DEFAULT (replaced by EIGEN_ALIGN_MAX).
Diffstat (limited to 'Eigen/src/Core/DenseStorage.h')
-rw-r--r-- | Eigen/src/Core/DenseStorage.h | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/Eigen/src/Core/DenseStorage.h b/Eigen/src/Core/DenseStorage.h index 5eb434c6d..5edf8a4ee 100644 --- a/Eigen/src/Core/DenseStorage.h +++ b/Eigen/src/Core/DenseStorage.h @@ -34,26 +34,25 @@ void check_static_allocation_size() #endif } -template<typename T, int Size, typename Packet = typename packet_traits<T>::type, - bool Match = bool((Size%unpacket_traits<Packet>::size)==0), - bool TryHalf = bool(int(unpacket_traits<Packet>::size) > 1) - && bool(int(unpacket_traits<Packet>::size) > int(unpacket_traits<typename unpacket_traits<Packet>::half>::size)) > +template<int ArrayBytes, int AlignmentBytes, + bool Match = bool((ArrayBytes%AlignmentBytes)==0), + bool TryHalf = bool(AlignmentBytes>EIGEN_MIN_ALIGN_BYTES) > struct compute_default_alignment { enum { value = 0 }; }; -template<typename T, int Size, typename Packet, bool TryHalf> -struct compute_default_alignment<T, Size, Packet, true, TryHalf> // Match +template<int ArrayBytes, int AlignmentBytes, bool TryHalf> +struct compute_default_alignment<ArrayBytes, AlignmentBytes, true, TryHalf> // Match { - enum { value = sizeof(T) * unpacket_traits<Packet>::size }; + enum { value = AlignmentBytes }; }; -template<typename T, int Size, typename Packet> -struct compute_default_alignment<T, Size, Packet, false, true> // Try-half +template<int ArrayBytes, int AlignmentBytes> +struct compute_default_alignment<ArrayBytes, AlignmentBytes, false, true> // Try-half { // current packet too large, try with an half-packet - enum { value = compute_default_alignment<T, Size, typename unpacket_traits<Packet>::half>::value }; + enum { value = compute_default_alignment<ArrayBytes, AlignmentBytes/2>::value }; }; /** \internal @@ -62,7 +61,7 @@ struct compute_default_alignment<T, Size, Packet, false, true> // Try-half */ template <typename T, int Size, int MatrixOrArrayOptions, int Alignment = (MatrixOrArrayOptions&DontAlign) ? 0 - : compute_default_alignment<T,Size>::value > + : compute_default_alignment<Size*sizeof(T), EIGEN_PLAIN_ENUM_MAX(packet_traits<T>::size*sizeof(T), EIGEN_MAX_STATIC_ALIGN_BYTES) >::value > struct plain_array { T array[Size]; @@ -180,7 +179,7 @@ struct plain_array<T, Size, MatrixOrArrayOptions, 64> template <typename T, int MatrixOrArrayOptions, int Alignment> struct plain_array<T, 0, MatrixOrArrayOptions, Alignment> { - EIGEN_USER_ALIGN_DEFAULT T array[1]; + T array[1]; EIGEN_DEVICE_FUNC plain_array() {} EIGEN_DEVICE_FUNC plain_array(constructor_without_unaligned_array_assert) {} }; |