2009-01-08 06:20:03 +08:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
2009-05-23 02:25:33 +08:00
|
|
|
// for linear algebra.
|
2009-01-08 06:20:03 +08:00
|
|
|
//
|
2010-06-25 05:21:58 +08:00
|
|
|
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
|
2009-01-08 06:20:03 +08:00
|
|
|
//
|
2012-07-14 02:42:47 +08:00
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2009-01-08 06:20:03 +08:00
|
|
|
|
2010-02-28 08:04:22 +08:00
|
|
|
#define EIGEN_DEBUG_ASSIGN
|
2009-01-08 06:20:03 +08:00
|
|
|
#include "main.h"
|
|
|
|
#include <typeinfo>
|
|
|
|
|
2010-07-09 05:30:16 +08:00
|
|
|
std::string demangle_traversal(int t)
|
|
|
|
{
|
|
|
|
if(t==DefaultTraversal) return "DefaultTraversal";
|
|
|
|
if(t==LinearTraversal) return "LinearTraversal";
|
|
|
|
if(t==InnerVectorizedTraversal) return "InnerVectorizedTraversal";
|
|
|
|
if(t==LinearVectorizedTraversal) return "LinearVectorizedTraversal";
|
|
|
|
if(t==SliceVectorizedTraversal) return "SliceVectorizedTraversal";
|
|
|
|
return "?";
|
|
|
|
}
|
|
|
|
std::string demangle_unrolling(int t)
|
|
|
|
{
|
|
|
|
if(t==NoUnrolling) return "NoUnrolling";
|
|
|
|
if(t==InnerUnrolling) return "InnerUnrolling";
|
|
|
|
if(t==CompleteUnrolling) return "CompleteUnrolling";
|
|
|
|
return "?";
|
|
|
|
}
|
2014-03-13 01:14:58 +08:00
|
|
|
std::string demangle_flags(int f)
|
|
|
|
{
|
|
|
|
std::string res;
|
2014-09-15 01:38:49 +08:00
|
|
|
if(f&RowMajorBit) res += " | RowMajor";
|
|
|
|
if(f&PacketAccessBit) res += " | Packet";
|
|
|
|
if(f&LinearAccessBit) res += " | Linear";
|
|
|
|
if(f&LvalueBit) res += " | Lvalue";
|
|
|
|
if(f&DirectAccessBit) res += " | Direct";
|
|
|
|
if(f&NestByRefBit) res += " | NestByRef";
|
|
|
|
if(f&NoPreferredStorageOrderBit) res += " | NoPreferredStorageOrderBit";
|
|
|
|
|
2014-03-13 01:14:58 +08:00
|
|
|
return res;
|
|
|
|
}
|
2010-07-09 05:30:16 +08:00
|
|
|
|
2009-01-08 06:20:03 +08:00
|
|
|
template<typename Dst, typename Src>
|
2009-11-19 00:57:07 +08:00
|
|
|
bool test_assign(const Dst&, const Src&, int traversal, int unrolling)
|
2009-01-08 06:20:03 +08:00
|
|
|
{
|
2014-03-13 01:14:58 +08:00
|
|
|
typedef internal::copy_using_evaluator_traits<internal::evaluator<Dst>,internal::evaluator<Src>, internal::assign_op<typename Dst::Scalar> > traits;
|
|
|
|
bool res = traits::Traversal==traversal && traits::Unrolling==unrolling;
|
2010-07-09 05:30:16 +08:00
|
|
|
if(!res)
|
|
|
|
{
|
2014-03-13 01:14:58 +08:00
|
|
|
std::cerr << "Src: " << demangle_flags(Src::Flags) << std::endl;
|
|
|
|
std::cerr << " " << demangle_flags(internal::evaluator<Src>::Flags) << std::endl;
|
|
|
|
std::cerr << "Dst: " << demangle_flags(Dst::Flags) << std::endl;
|
|
|
|
std::cerr << " " << demangle_flags(internal::evaluator<Dst>::Flags) << std::endl;
|
|
|
|
traits::debug();
|
2010-07-09 05:30:16 +08:00
|
|
|
std::cerr << " Expected Traversal == " << demangle_traversal(traversal)
|
2014-03-13 01:14:58 +08:00
|
|
|
<< " got " << demangle_traversal(traits::Traversal) << "\n";
|
2010-07-09 05:30:16 +08:00
|
|
|
std::cerr << " Expected Unrolling == " << demangle_unrolling(unrolling)
|
2014-03-13 01:14:58 +08:00
|
|
|
<< " got " << demangle_unrolling(traits::Unrolling) << "\n";
|
2010-07-09 05:30:16 +08:00
|
|
|
}
|
|
|
|
return res;
|
2009-01-08 06:20:03 +08:00
|
|
|
}
|
|
|
|
|
2010-02-27 09:12:51 +08:00
|
|
|
template<typename Dst, typename Src>
|
|
|
|
bool test_assign(int traversal, int unrolling)
|
|
|
|
{
|
2014-03-13 01:14:58 +08:00
|
|
|
typedef internal::copy_using_evaluator_traits<internal::evaluator<Dst>,internal::evaluator<Src>, internal::assign_op<typename Dst::Scalar> > traits;
|
|
|
|
bool res = traits::Traversal==traversal && traits::Unrolling==unrolling;
|
2010-07-09 05:30:16 +08:00
|
|
|
if(!res)
|
|
|
|
{
|
2014-03-13 01:14:58 +08:00
|
|
|
std::cerr << "Src: " << demangle_flags(Src::Flags) << std::endl;
|
|
|
|
std::cerr << " " << demangle_flags(internal::evaluator<Src>::Flags) << std::endl;
|
|
|
|
std::cerr << "Dst: " << demangle_flags(Dst::Flags) << std::endl;
|
|
|
|
std::cerr << " " << demangle_flags(internal::evaluator<Dst>::Flags) << std::endl;
|
|
|
|
traits::debug();
|
2010-07-09 05:30:16 +08:00
|
|
|
std::cerr << " Expected Traversal == " << demangle_traversal(traversal)
|
2014-03-13 01:14:58 +08:00
|
|
|
<< " got " << demangle_traversal(traits::Traversal) << "\n";
|
2010-07-09 05:30:16 +08:00
|
|
|
std::cerr << " Expected Unrolling == " << demangle_unrolling(unrolling)
|
2014-03-13 01:14:58 +08:00
|
|
|
<< " got " << demangle_unrolling(traits::Unrolling) << "\n";
|
2010-07-09 05:30:16 +08:00
|
|
|
}
|
|
|
|
return res;
|
2010-02-27 09:12:51 +08:00
|
|
|
}
|
|
|
|
|
2009-01-08 06:20:03 +08:00
|
|
|
template<typename Xpr>
|
2009-11-19 00:57:07 +08:00
|
|
|
bool test_redux(const Xpr&, int traversal, int unrolling)
|
2009-01-08 06:20:03 +08:00
|
|
|
{
|
2014-03-13 01:14:58 +08:00
|
|
|
typedef internal::redux_traits<internal::scalar_sum_op<typename Xpr::Scalar>,internal::redux_evaluator<Xpr> > traits;
|
|
|
|
|
2010-07-09 05:30:16 +08:00
|
|
|
bool res = traits::Traversal==traversal && traits::Unrolling==unrolling;
|
|
|
|
if(!res)
|
|
|
|
{
|
2014-03-13 01:14:58 +08:00
|
|
|
std::cerr << demangle_flags(Xpr::Flags) << std::endl;
|
|
|
|
std::cerr << demangle_flags(internal::evaluator<Xpr>::Flags) << std::endl;
|
|
|
|
traits::debug();
|
|
|
|
|
2010-07-09 05:30:16 +08:00
|
|
|
std::cerr << " Expected Traversal == " << demangle_traversal(traversal)
|
|
|
|
<< " got " << demangle_traversal(traits::Traversal) << "\n";
|
|
|
|
std::cerr << " Expected Unrolling == " << demangle_unrolling(unrolling)
|
|
|
|
<< " got " << demangle_unrolling(traits::Unrolling) << "\n";
|
|
|
|
}
|
|
|
|
return res;
|
2009-01-08 06:20:03 +08:00
|
|
|
}
|
|
|
|
|
2015-08-08 02:05:31 +08:00
|
|
|
template<typename Scalar, bool Enable = internal::packet_traits<Scalar>::Vectorizable>
|
|
|
|
struct vectorization_logic
|
2010-07-09 05:30:16 +08:00
|
|
|
{
|
2014-07-14 20:36:20 +08:00
|
|
|
typedef internal::packet_traits<Scalar> PacketTraits;
|
2015-08-08 02:05:31 +08:00
|
|
|
|
|
|
|
typedef typename internal::packet_traits<Scalar>::type PacketType;
|
|
|
|
typedef typename internal::unpacket_traits<PacketType>::half HalfPacketType;
|
2010-07-09 05:30:16 +08:00
|
|
|
enum {
|
2015-08-08 02:05:31 +08:00
|
|
|
PacketSize = internal::unpacket_traits<PacketType>::size,
|
|
|
|
HalfPacketSize = internal::unpacket_traits<HalfPacketType>::size
|
2010-07-09 05:30:16 +08:00
|
|
|
};
|
|
|
|
static void run()
|
|
|
|
{
|
|
|
|
|
|
|
|
typedef Matrix<Scalar,PacketSize,1> Vector1;
|
|
|
|
typedef Matrix<Scalar,Dynamic,1> VectorX;
|
|
|
|
typedef Matrix<Scalar,Dynamic,Dynamic> MatrixXX;
|
|
|
|
typedef Matrix<Scalar,PacketSize,PacketSize> Matrix11;
|
|
|
|
typedef Matrix<Scalar,2*PacketSize,2*PacketSize> Matrix22;
|
2011-01-04 21:18:07 +08:00
|
|
|
typedef Matrix<Scalar,(Matrix11::Flags&RowMajorBit)?16:4*PacketSize,(Matrix11::Flags&RowMajorBit)?4*PacketSize:16> Matrix44;
|
|
|
|
typedef Matrix<Scalar,(Matrix11::Flags&RowMajorBit)?16:4*PacketSize,(Matrix11::Flags&RowMajorBit)?4*PacketSize:16,DontAlign|EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION> Matrix44u;
|
2014-04-19 03:14:40 +08:00
|
|
|
typedef Matrix<Scalar,4*PacketSize,4*PacketSize,ColMajor> Matrix44c;
|
|
|
|
typedef Matrix<Scalar,4*PacketSize,4*PacketSize,RowMajor> Matrix44r;
|
2010-07-09 05:30:16 +08:00
|
|
|
|
|
|
|
typedef Matrix<Scalar,
|
|
|
|
(PacketSize==8 ? 4 : PacketSize==4 ? 2 : PacketSize==2 ? 1 : /*PacketSize==1 ?*/ 1),
|
|
|
|
(PacketSize==8 ? 2 : PacketSize==4 ? 2 : PacketSize==2 ? 2 : /*PacketSize==1 ?*/ 1)
|
|
|
|
> Matrix1;
|
|
|
|
|
|
|
|
typedef Matrix<Scalar,
|
|
|
|
(PacketSize==8 ? 4 : PacketSize==4 ? 2 : PacketSize==2 ? 1 : /*PacketSize==1 ?*/ 1),
|
|
|
|
(PacketSize==8 ? 2 : PacketSize==4 ? 2 : PacketSize==2 ? 2 : /*PacketSize==1 ?*/ 1),
|
|
|
|
DontAlign|((Matrix1::Flags&RowMajorBit)?RowMajor:ColMajor)> Matrix1u;
|
|
|
|
|
2011-01-04 21:18:07 +08:00
|
|
|
// this type is made such that it can only be vectorized when viewed as a linear 1D vector
|
2010-07-09 05:30:16 +08:00
|
|
|
typedef Matrix<Scalar,
|
2011-01-04 21:18:07 +08:00
|
|
|
(PacketSize==8 ? 4 : PacketSize==4 ? 6 : PacketSize==2 ? ((Matrix11::Flags&RowMajorBit)?2:3) : /*PacketSize==1 ?*/ 1),
|
|
|
|
(PacketSize==8 ? 6 : PacketSize==4 ? 2 : PacketSize==2 ? ((Matrix11::Flags&RowMajorBit)?3:2) : /*PacketSize==1 ?*/ 3)
|
2010-07-09 05:30:16 +08:00
|
|
|
> Matrix3;
|
2011-05-20 03:52:40 +08:00
|
|
|
|
|
|
|
#if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT
|
2010-07-09 05:30:16 +08:00
|
|
|
VERIFY(test_assign(Vector1(),Vector1(),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
VERIFY(test_assign(Vector1(),Vector1()+Vector1(),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
VERIFY(test_assign(Vector1(),Vector1().cwiseProduct(Vector1()),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
VERIFY(test_assign(Vector1(),Vector1().template cast<Scalar>(),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
|
|
|
|
|
|
|
|
VERIFY(test_assign(Vector1(),Vector1(),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
VERIFY(test_assign(Vector1(),Vector1()+Vector1(),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
VERIFY(test_assign(Vector1(),Vector1().cwiseProduct(Vector1()),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_assign(Matrix44(),Matrix44()+Matrix44(),
|
|
|
|
InnerVectorizedTraversal,InnerUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_assign(Matrix44u(),Matrix44()+Matrix44(),
|
|
|
|
LinearTraversal,NoUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_assign(Matrix1u(),Matrix1()+Matrix1(),
|
|
|
|
LinearTraversal,CompleteUnrolling));
|
|
|
|
|
2010-07-23 22:29:29 +08:00
|
|
|
VERIFY(test_assign(Matrix44c().col(1),Matrix44c().col(2)+Matrix44c().col(3),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_assign(Matrix44r().row(2),Matrix44r().row(1)+Matrix44r().row(1),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
|
2010-07-09 05:30:16 +08:00
|
|
|
if(PacketSize>1)
|
|
|
|
{
|
2010-07-23 22:29:29 +08:00
|
|
|
typedef Matrix<Scalar,3,3,ColMajor> Matrix33c;
|
|
|
|
VERIFY(test_assign(Matrix33c().row(2),Matrix33c().row(1)+Matrix33c().row(1),
|
|
|
|
LinearTraversal,CompleteUnrolling));
|
|
|
|
VERIFY(test_assign(Matrix33c().col(0),Matrix33c().col(1)+Matrix33c().col(1),
|
|
|
|
LinearTraversal,CompleteUnrolling));
|
2014-04-19 03:14:40 +08:00
|
|
|
|
2010-07-09 05:30:16 +08:00
|
|
|
VERIFY(test_assign(Matrix3(),Matrix3().cwiseQuotient(Matrix3()),
|
2014-07-14 20:36:20 +08:00
|
|
|
PacketTraits::HasDiv ? LinearVectorizedTraversal : LinearTraversal,CompleteUnrolling));
|
2015-08-08 02:05:31 +08:00
|
|
|
|
2010-07-09 05:30:16 +08:00
|
|
|
VERIFY(test_assign(Matrix<Scalar,17,17>(),Matrix<Scalar,17,17>()+Matrix<Scalar,17,17>(),
|
2015-08-08 02:05:31 +08:00
|
|
|
HalfPacketSize==1 ? InnerVectorizedTraversal : LinearTraversal,NoUnrolling));
|
2014-04-19 03:14:40 +08:00
|
|
|
|
|
|
|
VERIFY(test_assign(Matrix11(),Matrix<Scalar,17,17>().template block<PacketSize,PacketSize>(2,3)+Matrix<Scalar,17,17>().template block<PacketSize,PacketSize>(8,4),
|
|
|
|
DefaultTraversal,PacketSize>4?InnerUnrolling:CompleteUnrolling));
|
2010-07-09 05:30:16 +08:00
|
|
|
}
|
2011-05-20 03:52:40 +08:00
|
|
|
|
|
|
|
VERIFY(test_redux(Matrix3(),
|
|
|
|
LinearVectorizedTraversal,CompleteUnrolling));
|
2010-07-09 05:30:16 +08:00
|
|
|
|
2011-05-20 03:52:40 +08:00
|
|
|
VERIFY(test_redux(Matrix44(),
|
|
|
|
LinearVectorizedTraversal,NoUnrolling));
|
2010-07-09 05:30:16 +08:00
|
|
|
|
2011-05-20 03:52:40 +08:00
|
|
|
VERIFY(test_redux(Matrix44().template block<(Matrix1::Flags&RowMajorBit)?4:PacketSize,(Matrix1::Flags&RowMajorBit)?PacketSize:4>(1,2),
|
|
|
|
DefaultTraversal,CompleteUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_redux(Matrix44c().template block<2*PacketSize,1>(1,2),
|
|
|
|
LinearVectorizedTraversal,CompleteUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_redux(Matrix44r().template block<1,2*PacketSize>(2,1),
|
|
|
|
LinearVectorizedTraversal,CompleteUnrolling));
|
2014-04-19 03:14:40 +08:00
|
|
|
|
2010-07-09 05:30:16 +08:00
|
|
|
VERIFY((test_assign<
|
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.
2015-08-06 21:31:07 +08:00
|
|
|
Map<Matrix22, AlignedMax, OuterStride<3*PacketSize> >,
|
2010-07-09 05:30:16 +08:00
|
|
|
Matrix22
|
|
|
|
>(InnerVectorizedTraversal,CompleteUnrolling)));
|
|
|
|
|
|
|
|
VERIFY((test_assign<
|
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.
2015-08-06 21:31:07 +08:00
|
|
|
Map<Matrix<Scalar,EIGEN_PLAIN_ENUM_MAX(2,PacketSize),EIGEN_PLAIN_ENUM_MAX(2,PacketSize)>, AlignedMax, InnerStride<3*PacketSize> >,
|
2014-04-19 03:14:40 +08:00
|
|
|
Matrix<Scalar,EIGEN_PLAIN_ENUM_MAX(2,PacketSize),EIGEN_PLAIN_ENUM_MAX(2,PacketSize)>
|
2010-07-09 05:30:16 +08:00
|
|
|
>(DefaultTraversal,CompleteUnrolling)));
|
|
|
|
|
2014-04-19 03:14:40 +08:00
|
|
|
VERIFY((test_assign(Matrix11(), Matrix<Scalar,PacketSize,EIGEN_PLAIN_ENUM_MIN(2,PacketSize)>()*Matrix<Scalar,EIGEN_PLAIN_ENUM_MIN(2,PacketSize),PacketSize>(),
|
2015-03-14 04:15:50 +08:00
|
|
|
InnerVectorizedTraversal, CompleteUnrolling)));
|
2011-05-20 03:52:40 +08:00
|
|
|
#endif
|
2011-01-03 01:07:39 +08:00
|
|
|
|
2011-05-20 03:52:40 +08:00
|
|
|
VERIFY(test_assign(MatrixXX(10,10),MatrixXX(20,20).block(10,10,2,3),
|
|
|
|
SliceVectorizedTraversal,NoUnrolling));
|
2010-07-09 05:30:16 +08:00
|
|
|
|
2011-05-20 03:52:40 +08:00
|
|
|
VERIFY(test_redux(VectorX(10),
|
2010-07-09 05:30:16 +08:00
|
|
|
LinearVectorizedTraversal,NoUnrolling));
|
2015-08-08 02:05:31 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename Scalar> struct vectorization_logic<Scalar,false>
|
|
|
|
{
|
|
|
|
static void run() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename Scalar, bool Enable = !internal::is_same<typename internal::unpacket_traits<typename internal::packet_traits<Scalar>::type>::half,
|
|
|
|
typename internal::packet_traits<Scalar>::type>::value >
|
|
|
|
struct vectorization_logic_half
|
|
|
|
{
|
|
|
|
typedef internal::packet_traits<Scalar> PacketTraits;
|
|
|
|
typedef typename internal::unpacket_traits<typename internal::packet_traits<Scalar>::type>::half PacketType;
|
|
|
|
enum {
|
|
|
|
PacketSize = internal::unpacket_traits<PacketType>::size
|
|
|
|
};
|
|
|
|
static void run()
|
|
|
|
{
|
|
|
|
|
|
|
|
typedef Matrix<Scalar,PacketSize,1> Vector1;
|
|
|
|
typedef Matrix<Scalar,PacketSize,PacketSize> Matrix11;
|
|
|
|
typedef Matrix<Scalar,5*PacketSize,7,ColMajor> Matrix57;
|
|
|
|
typedef Matrix<Scalar,5*PacketSize,7,DontAlign|ColMajor> Matrix57u;
|
|
|
|
// typedef Matrix<Scalar,(Matrix11::Flags&RowMajorBit)?16:4*PacketSize,(Matrix11::Flags&RowMajorBit)?4*PacketSize:16> Matrix44;
|
|
|
|
// typedef Matrix<Scalar,(Matrix11::Flags&RowMajorBit)?16:4*PacketSize,(Matrix11::Flags&RowMajorBit)?4*PacketSize:16,DontAlign|EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION> Matrix44u;
|
|
|
|
// typedef Matrix<Scalar,4*PacketSize,4*PacketSize,ColMajor> Matrix44c;
|
|
|
|
// typedef Matrix<Scalar,4*PacketSize,4*PacketSize,RowMajor> Matrix44r;
|
|
|
|
|
|
|
|
typedef Matrix<Scalar,
|
|
|
|
(PacketSize==8 ? 4 : PacketSize==4 ? 2 : PacketSize==2 ? 1 : /*PacketSize==1 ?*/ 1),
|
|
|
|
(PacketSize==8 ? 2 : PacketSize==4 ? 2 : PacketSize==2 ? 2 : /*PacketSize==1 ?*/ 1)
|
|
|
|
> Matrix1;
|
|
|
|
|
|
|
|
typedef Matrix<Scalar,
|
|
|
|
(PacketSize==8 ? 4 : PacketSize==4 ? 2 : PacketSize==2 ? 1 : /*PacketSize==1 ?*/ 1),
|
|
|
|
(PacketSize==8 ? 2 : PacketSize==4 ? 2 : PacketSize==2 ? 2 : /*PacketSize==1 ?*/ 1),
|
|
|
|
DontAlign|((Matrix1::Flags&RowMajorBit)?RowMajor:ColMajor)> Matrix1u;
|
2010-07-09 05:30:16 +08:00
|
|
|
|
2015-08-08 02:05:31 +08:00
|
|
|
// this type is made such that it can only be vectorized when viewed as a linear 1D vector
|
|
|
|
typedef Matrix<Scalar,
|
|
|
|
(PacketSize==8 ? 4 : PacketSize==4 ? 6 : PacketSize==2 ? ((Matrix11::Flags&RowMajorBit)?2:3) : /*PacketSize==1 ?*/ 1),
|
|
|
|
(PacketSize==8 ? 6 : PacketSize==4 ? 2 : PacketSize==2 ? ((Matrix11::Flags&RowMajorBit)?3:2) : /*PacketSize==1 ?*/ 3)
|
|
|
|
> Matrix3;
|
2011-05-20 03:52:40 +08:00
|
|
|
|
2015-08-08 02:05:31 +08:00
|
|
|
#if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT
|
|
|
|
VERIFY(test_assign(Vector1(),Vector1(),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
VERIFY(test_assign(Vector1(),Vector1()+Vector1(),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
VERIFY(test_assign(Vector1(),Vector1().cwiseProduct(Vector1()),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
VERIFY(test_assign(Vector1(),Vector1().template cast<Scalar>(),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
|
|
|
|
|
|
|
|
VERIFY(test_assign(Vector1(),Vector1(),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
VERIFY(test_assign(Vector1(),Vector1()+Vector1(),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
VERIFY(test_assign(Vector1(),Vector1().cwiseProduct(Vector1()),
|
|
|
|
InnerVectorizedTraversal,CompleteUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_assign(Matrix57(),Matrix57()+Matrix57(),
|
|
|
|
InnerVectorizedTraversal,InnerUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_assign(Matrix57u(),Matrix57()+Matrix57(),
|
|
|
|
LinearTraversal,NoUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_assign(Matrix1u(),Matrix1()+Matrix1(),
|
|
|
|
LinearTraversal,CompleteUnrolling));
|
|
|
|
|
|
|
|
if(PacketSize>1)
|
|
|
|
{
|
|
|
|
typedef Matrix<Scalar,3,3,ColMajor> Matrix33c;
|
|
|
|
VERIFY(test_assign(Matrix33c().row(2),Matrix33c().row(1)+Matrix33c().row(1),
|
|
|
|
LinearTraversal,CompleteUnrolling));
|
|
|
|
VERIFY(test_assign(Matrix33c().col(0),Matrix33c().col(1)+Matrix33c().col(1),
|
|
|
|
LinearTraversal,CompleteUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_assign(Matrix3(),Matrix3().cwiseQuotient(Matrix3()),
|
|
|
|
PacketTraits::HasDiv ? LinearVectorizedTraversal : LinearTraversal,CompleteUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_assign(Matrix<Scalar,17,17>(),Matrix<Scalar,17,17>()+Matrix<Scalar,17,17>(),
|
|
|
|
LinearTraversal,NoUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_assign(Matrix11(),Matrix<Scalar,17,17>().template block<PacketSize,PacketSize>(2,3)+Matrix<Scalar,17,17>().template block<PacketSize,PacketSize>(8,4),
|
|
|
|
DefaultTraversal,PacketSize>4?InnerUnrolling:CompleteUnrolling));
|
|
|
|
}
|
|
|
|
|
|
|
|
VERIFY(test_redux(Matrix3(),
|
|
|
|
LinearVectorizedTraversal,CompleteUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_redux(Matrix57(),
|
|
|
|
LinearVectorizedTraversal,CompleteUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_redux(Matrix57().template block<PacketSize,3>(1,0),
|
|
|
|
DefaultTraversal,CompleteUnrolling));
|
|
|
|
|
|
|
|
VERIFY((test_assign<
|
|
|
|
Map<Matrix<Scalar,EIGEN_PLAIN_ENUM_MAX(2,PacketSize),EIGEN_PLAIN_ENUM_MAX(2,PacketSize)>, AlignedMax, InnerStride<3*PacketSize> >,
|
|
|
|
Matrix<Scalar,EIGEN_PLAIN_ENUM_MAX(2,PacketSize),EIGEN_PLAIN_ENUM_MAX(2,PacketSize)>
|
|
|
|
>(DefaultTraversal,CompleteUnrolling)));
|
|
|
|
|
|
|
|
VERIFY((test_assign(Matrix57(), Matrix<Scalar,5*PacketSize,3>()*Matrix<Scalar,3,7>(),
|
|
|
|
InnerVectorizedTraversal, CompleteUnrolling)));
|
|
|
|
#endif
|
2010-07-09 05:30:16 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-08-08 02:05:31 +08:00
|
|
|
template<typename Scalar> struct vectorization_logic_half<Scalar,false>
|
2010-07-09 05:30:16 +08:00
|
|
|
{
|
|
|
|
static void run() {}
|
|
|
|
};
|
|
|
|
|
2009-01-08 06:20:03 +08:00
|
|
|
void test_vectorization_logic()
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef EIGEN_VECTORIZE
|
|
|
|
|
2014-07-14 20:36:20 +08:00
|
|
|
CALL_SUBTEST( vectorization_logic<int>::run() );
|
2011-05-20 03:52:40 +08:00
|
|
|
CALL_SUBTEST( vectorization_logic<float>::run() );
|
|
|
|
CALL_SUBTEST( vectorization_logic<double>::run() );
|
|
|
|
CALL_SUBTEST( vectorization_logic<std::complex<float> >::run() );
|
|
|
|
CALL_SUBTEST( vectorization_logic<std::complex<double> >::run() );
|
2010-07-09 05:30:16 +08:00
|
|
|
|
2015-08-08 02:05:31 +08:00
|
|
|
CALL_SUBTEST( vectorization_logic_half<int>::run() );
|
|
|
|
CALL_SUBTEST( vectorization_logic_half<float>::run() );
|
|
|
|
CALL_SUBTEST( vectorization_logic_half<double>::run() );
|
|
|
|
CALL_SUBTEST( vectorization_logic_half<std::complex<float> >::run() );
|
|
|
|
CALL_SUBTEST( vectorization_logic_half<std::complex<double> >::run() );
|
|
|
|
|
2010-10-25 22:15:22 +08:00
|
|
|
if(internal::packet_traits<float>::Vectorizable)
|
2010-07-09 05:30:16 +08:00
|
|
|
{
|
|
|
|
VERIFY(test_assign(Matrix<float,3,3>(),Matrix<float,3,3>()+Matrix<float,3,3>(),
|
|
|
|
LinearTraversal,CompleteUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_redux(Matrix<float,5,2>(),
|
|
|
|
DefaultTraversal,CompleteUnrolling));
|
|
|
|
}
|
|
|
|
|
2010-10-25 22:15:22 +08:00
|
|
|
if(internal::packet_traits<double>::Vectorizable)
|
2010-07-09 05:30:16 +08:00
|
|
|
{
|
|
|
|
VERIFY(test_assign(Matrix<double,3,3>(),Matrix<double,3,3>()+Matrix<double,3,3>(),
|
|
|
|
LinearTraversal,CompleteUnrolling));
|
|
|
|
|
|
|
|
VERIFY(test_redux(Matrix<double,7,3>(),
|
|
|
|
DefaultTraversal,CompleteUnrolling));
|
|
|
|
}
|
2009-01-08 06:20:03 +08:00
|
|
|
#endif // EIGEN_VECTORIZE
|
|
|
|
|
|
|
|
}
|