mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
First part of a big refactoring of alignment control to enable the handling of arbitrarily aligned buffers. It includes:
- AlignedBit flag is deprecated. Alignment is now specified by the evaluator through the 'Alignment' enum, e.g., evaluator<Xpr>::Alignment. Its value is in Bytes. - Add several enums to specify alignment: Aligned8, Aligned16, Aligned32, Aligned64, Aligned128. AlignedMax corresponds to EIGEN_MAX_ALIGN_BYTES. Such enums are used to define the above Alignment value, and as the 'Options' template parameter of Map<> and Ref<>. - The Aligned enum is now deprecated. It is now an alias for Aligned16. - Currently, traits<Matrix<>>, traits<Array<>>, traits<Ref<>>, traits<Map<>>, and traits<Block<>> also expose the Alignment enum.
This commit is contained in:
@@ -25,15 +25,15 @@ template<typename VectorType> void map_class_vector(const VectorType& m)
|
||||
Scalar* array1 = internal::aligned_new<Scalar>(size);
|
||||
Scalar* array2 = internal::aligned_new<Scalar>(size);
|
||||
Scalar* array3 = new Scalar[size+1];
|
||||
Scalar* array3unaligned = size_t(array3)%EIGEN_MAX_ALIGN_BYTES == 0 ? array3+1 : array3;
|
||||
Scalar* array3unaligned = (std::size_t(array3)%EIGEN_MAX_ALIGN_BYTES) == 0 ? array3+1 : array3;
|
||||
Scalar array4[EIGEN_TESTMAP_MAX_SIZE];
|
||||
|
||||
Map<VectorType, Aligned>(array1, size) = VectorType::Random(size);
|
||||
Map<VectorType, Aligned>(array2, size) = Map<VectorType,Aligned>(array1, size);
|
||||
Map<VectorType, AlignedMax>(array1, size) = VectorType::Random(size);
|
||||
Map<VectorType, AlignedMax>(array2, size) = Map<VectorType,AlignedMax>(array1, size);
|
||||
Map<VectorType>(array3unaligned, size) = Map<VectorType>(array1, size);
|
||||
Map<VectorType>(array4, size) = Map<VectorType,Aligned>(array1, size);
|
||||
VectorType ma1 = Map<VectorType, Aligned>(array1, size);
|
||||
VectorType ma2 = Map<VectorType, Aligned>(array2, size);
|
||||
Map<VectorType>(array4, size) = Map<VectorType,AlignedMax>(array1, size);
|
||||
VectorType ma1 = Map<VectorType, AlignedMax>(array1, size);
|
||||
VectorType ma2 = Map<VectorType, AlignedMax>(array2, size);
|
||||
VectorType ma3 = Map<VectorType>(array3unaligned, size);
|
||||
VectorType ma4 = Map<VectorType>(array4, size);
|
||||
VERIFY_IS_EQUAL(ma1, ma2);
|
||||
@@ -41,7 +41,7 @@ template<typename VectorType> void map_class_vector(const VectorType& m)
|
||||
VERIFY_IS_EQUAL(ma1, ma4);
|
||||
#ifdef EIGEN_VECTORIZE
|
||||
if(internal::packet_traits<Scalar>::Vectorizable)
|
||||
VERIFY_RAISES_ASSERT((Map<VectorType,Aligned>(array3unaligned, size)))
|
||||
VERIFY_RAISES_ASSERT((Map<VectorType,AlignedMax>(array3unaligned, size)))
|
||||
#endif
|
||||
|
||||
internal::aligned_delete(array1, size);
|
||||
@@ -71,7 +71,7 @@ template<typename MatrixType> void map_class_matrix(const MatrixType& m)
|
||||
for(int i = 0; i < size; i++) array4[i] = Scalar(1);
|
||||
|
||||
Map<MatrixType> map1(array1, rows, cols);
|
||||
Map<MatrixType, Aligned> map2(array2, rows, cols);
|
||||
Map<MatrixType, AlignedMax> map2(array2, rows, cols);
|
||||
Map<MatrixType> map3(array3unaligned, rows, cols);
|
||||
Map<MatrixType> map4(array4, rows, cols);
|
||||
|
||||
@@ -154,9 +154,9 @@ template<typename PlainObjectType> void check_const_correctness(const PlainObjec
|
||||
// verify that map-to-const don't have LvalueBit
|
||||
typedef typename internal::add_const<PlainObjectType>::type ConstPlainObjectType;
|
||||
VERIFY( !(internal::traits<Map<ConstPlainObjectType> >::Flags & LvalueBit) );
|
||||
VERIFY( !(internal::traits<Map<ConstPlainObjectType, Aligned> >::Flags & LvalueBit) );
|
||||
VERIFY( !(internal::traits<Map<ConstPlainObjectType, AlignedMax> >::Flags & LvalueBit) );
|
||||
VERIFY( !(Map<ConstPlainObjectType>::Flags & LvalueBit) );
|
||||
VERIFY( !(Map<ConstPlainObjectType, Aligned>::Flags & LvalueBit) );
|
||||
VERIFY( !(Map<ConstPlainObjectType, AlignedMax>::Flags & LvalueBit) );
|
||||
}
|
||||
|
||||
template<typename Scalar>
|
||||
|
||||
Reference in New Issue
Block a user