Re-enable vectorization of LinSpaced, plus some cleaning

This commit is contained in:
Gael Guennebaud 2015-10-08 17:27:01 +02:00
parent f6f6f50272
commit dd934ad057
6 changed files with 12 additions and 15 deletions

View File

@ -321,8 +321,8 @@ struct evaluator<CwiseNullaryOp<NullaryOp,PlainObjectType> >
& ( HereditaryBits & ( HereditaryBits
| (functor_has_linear_access<NullaryOp>::ret ? LinearAccessBit : 0) | (functor_has_linear_access<NullaryOp>::ret ? LinearAccessBit : 0)
| (functor_traits<NullaryOp>::PacketAccess ? PacketAccessBit : 0))) | (functor_traits<NullaryOp>::PacketAccess ? PacketAccessBit : 0)))
| (functor_traits<NullaryOp>::IsRepeatable ? 0 : EvalBeforeNestingBit), // FIXME EvalBeforeNestingBit should be needed anymore | (functor_traits<NullaryOp>::IsRepeatable ? 0 : EvalBeforeNestingBit),
Alignment = 0 // FIXME alignment should not matter here, perhaps we could set it to AlignMax?? Alignment = AlignedMax
}; };
EIGEN_DEVICE_FUNC explicit evaluator(const XprType& n) EIGEN_DEVICE_FUNC explicit evaluator(const XprType& n)

View File

@ -160,7 +160,7 @@ template<> struct product_type_selector<Large,Large,Small> { enum
namespace internal { namespace internal {
template<int Side, int StorageOrder, bool BlasCompatible> template<int Side, int StorageOrder, bool BlasCompatible>
struct gemv_dense_sense_selector; struct gemv_dense_selector;
} // end namespace internal } // end namespace internal
@ -204,19 +204,19 @@ struct gemv_static_vector_if<Scalar,Size,MaxSize,true>
// The vector is on the left => transposition // The vector is on the left => transposition
template<int StorageOrder, bool BlasCompatible> template<int StorageOrder, bool BlasCompatible>
struct gemv_dense_sense_selector<OnTheLeft,StorageOrder,BlasCompatible> struct gemv_dense_selector<OnTheLeft,StorageOrder,BlasCompatible>
{ {
template<typename Lhs, typename Rhs, typename Dest> template<typename Lhs, typename Rhs, typename Dest>
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
{ {
Transpose<Dest> destT(dest); Transpose<Dest> destT(dest);
enum { OtherStorageOrder = StorageOrder == RowMajor ? ColMajor : RowMajor }; enum { OtherStorageOrder = StorageOrder == RowMajor ? ColMajor : RowMajor };
gemv_dense_sense_selector<OnTheRight,OtherStorageOrder,BlasCompatible> gemv_dense_selector<OnTheRight,OtherStorageOrder,BlasCompatible>
::run(rhs.transpose(), lhs.transpose(), destT, alpha); ::run(rhs.transpose(), lhs.transpose(), destT, alpha);
} }
}; };
template<> struct gemv_dense_sense_selector<OnTheRight,ColMajor,true> template<> struct gemv_dense_selector<OnTheRight,ColMajor,true>
{ {
template<typename Lhs, typename Rhs, typename Dest> template<typename Lhs, typename Rhs, typename Dest>
static inline void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) static inline void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
@ -292,7 +292,7 @@ template<> struct gemv_dense_sense_selector<OnTheRight,ColMajor,true>
} }
}; };
template<> struct gemv_dense_sense_selector<OnTheRight,RowMajor,true> template<> struct gemv_dense_selector<OnTheRight,RowMajor,true>
{ {
template<typename Lhs, typename Rhs, typename Dest> template<typename Lhs, typename Rhs, typename Dest>
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
@ -345,7 +345,7 @@ template<> struct gemv_dense_sense_selector<OnTheRight,RowMajor,true>
} }
}; };
template<> struct gemv_dense_sense_selector<OnTheRight,ColMajor,false> template<> struct gemv_dense_selector<OnTheRight,ColMajor,false>
{ {
template<typename Lhs, typename Rhs, typename Dest> template<typename Lhs, typename Rhs, typename Dest>
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
@ -357,7 +357,7 @@ template<> struct gemv_dense_sense_selector<OnTheRight,ColMajor,false>
} }
}; };
template<> struct gemv_dense_sense_selector<OnTheRight,RowMajor,false> template<> struct gemv_dense_selector<OnTheRight,RowMajor,false>
{ {
template<typename Lhs, typename Rhs, typename Dest> template<typename Lhs, typename Rhs, typename Dest>
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)

View File

@ -12,8 +12,6 @@
namespace Eigen { namespace Eigen {
// TODO move the general declaration in Core, and rename this file DenseInverseImpl.h, or something like this...
template<typename XprType,typename StorageKind> class InverseImpl; template<typename XprType,typename StorageKind> class InverseImpl;
namespace internal { namespace internal {

View File

@ -313,7 +313,7 @@ struct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,GemvProduct>
template<typename Dest> template<typename Dest>
static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha) static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha)
{ {
internal::gemv_dense_sense_selector<Side, internal::gemv_dense_selector<Side,
(int(MatrixType::Flags)&RowMajorBit) ? RowMajor : ColMajor, (int(MatrixType::Flags)&RowMajorBit) ? RowMajor : ColMajor,
bool(internal::blas_traits<MatrixType>::HasUsableDirectAccess) bool(internal::blas_traits<MatrixType>::HasUsableDirectAccess)
>::run(lhs, rhs, dst, alpha); >::run(lhs, rhs, dst, alpha);

View File

@ -26,7 +26,6 @@ struct scalar_constant_op {
}; };
template<typename Scalar> template<typename Scalar>
struct functor_traits<scalar_constant_op<Scalar> > struct functor_traits<scalar_constant_op<Scalar> >
// FIXME replace this packet test by a safe one
{ enum { Cost = 1, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = true }; }; { enum { Cost = 1, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = true }; };
template<typename Scalar> struct scalar_identity_op { template<typename Scalar> struct scalar_identity_op {
@ -135,14 +134,12 @@ template <typename Scalar, typename PacketType, bool RandomAccess> struct linspa
// This proxy object handles the actual required temporaries, the different // This proxy object handles the actual required temporaries, the different
// implementations (random vs. sequential access) as well as the // implementations (random vs. sequential access) as well as the
// correct piping to size 2/4 packet operations. // correct piping to size 2/4 packet operations.
// TODO find a way to make the packet type configurable
const linspaced_op_impl<Scalar,PacketType,RandomAccess> impl; const linspaced_op_impl<Scalar,PacketType,RandomAccess> impl;
}; };
// all functors allow linear access, except scalar_identity_op. So we fix here a quick meta // all functors allow linear access, except scalar_identity_op. So we fix here a quick meta
// to indicate whether a functor allows linear access, just always answering 'yes' except for // to indicate whether a functor allows linear access, just always answering 'yes' except for
// scalar_identity_op. // scalar_identity_op.
// FIXME move this to functor_traits adding a functor_default
template<typename Functor> struct functor_has_linear_access { enum { ret = 1 }; }; template<typename Functor> struct functor_has_linear_access { enum { ret = 1 }; };
template<typename Scalar> struct functor_has_linear_access<scalar_identity_op<Scalar> > { enum { ret = 0 }; }; template<typename Scalar> struct functor_has_linear_access<scalar_identity_op<Scalar> > { enum { ret = 0 }; };

View File

@ -123,6 +123,8 @@ void test_nullary()
CALL_SUBTEST_6( testVectorType(Vector3d()) ); CALL_SUBTEST_6( testVectorType(Vector3d()) );
CALL_SUBTEST_7( testVectorType(VectorXf(internal::random<int>(1,300))) ); CALL_SUBTEST_7( testVectorType(VectorXf(internal::random<int>(1,300))) );
CALL_SUBTEST_8( testVectorType(Vector3f()) ); CALL_SUBTEST_8( testVectorType(Vector3f()) );
CALL_SUBTEST_8( testVectorType(Vector4f()) );
CALL_SUBTEST_8( testVectorType(Matrix<float,8,1>()) );
CALL_SUBTEST_8( testVectorType(Matrix<float,1,1>()) ); CALL_SUBTEST_8( testVectorType(Matrix<float,1,1>()) );
} }
} }