diff options
author | Gael Guennebaud <g.gael@free.fr> | 2014-03-10 09:28:00 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2014-03-10 09:28:00 +0100 |
commit | 5c0f294098f628439cf9341edb286d92f7fa138b (patch) | |
tree | f38353aa4775a54e044ea9356a472a97c763540a /Eigen/src | |
parent | cbc572caf7c01854076d6ff84e5ae864b490458a (diff) |
Fix evaluators unit test (i.e., when only EIGEN_ENABLE_EVALUATORS is defined
Diffstat (limited to 'Eigen/src')
-rw-r--r-- | Eigen/src/Core/GeneralProduct.h | 25 | ||||
-rw-r--r-- | Eigen/src/Core/ProductEvaluators.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/products/GeneralMatrixMatrix.h | 6 | ||||
-rw-r--r-- | Eigen/src/Core/products/SelfadjointMatrixMatrix.h | 5 | ||||
-rw-r--r-- | Eigen/src/Core/products/TriangularMatrixMatrix.h | 5 | ||||
-rw-r--r-- | Eigen/src/Core/util/XprHelper.h | 76 |
6 files changed, 67 insertions, 52 deletions
diff --git a/Eigen/src/Core/GeneralProduct.h b/Eigen/src/Core/GeneralProduct.h index c37526b72..f28d2e46c 100644 --- a/Eigen/src/Core/GeneralProduct.h +++ b/Eigen/src/Core/GeneralProduct.h @@ -353,10 +353,13 @@ template<typename Lhs, typename Rhs> struct traits<GeneralProduct<Lhs,Rhs,GemvProduct> > : traits<ProductBase<GeneralProduct<Lhs,Rhs,GemvProduct>, Lhs, Rhs> > {}; -#endif - template<int Side, int StorageOrder, bool BlasCompatible> struct gemv_selector; +#endif +#ifdef EIGEN_ENABLE_EVALUATORS +template<int Side, int StorageOrder, bool BlasCompatible> +struct gemv_dense_sense_selector; +#endif } // end namespace internal @@ -594,23 +597,25 @@ template<> struct gemv_selector<OnTheRight,RowMajor,false> } }; -#else // EIGEN_TEST_EVALUATORS +#endif // EIGEN_TEST_EVALUATORS + +#ifdef EIGEN_ENABLE_EVALUATORS // The vector is on the left => transposition template<int StorageOrder, bool BlasCompatible> -struct gemv_selector<OnTheLeft,StorageOrder,BlasCompatible> +struct gemv_dense_sense_selector<OnTheLeft,StorageOrder,BlasCompatible> { template<typename Lhs, typename Rhs, typename Dest> static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) { Transpose<Dest> destT(dest); enum { OtherStorageOrder = StorageOrder == RowMajor ? ColMajor : RowMajor }; - gemv_selector<OnTheRight,OtherStorageOrder,BlasCompatible> + gemv_dense_sense_selector<OnTheRight,OtherStorageOrder,BlasCompatible> ::run(rhs.transpose(), lhs.transpose(), destT, alpha); } }; -template<> struct gemv_selector<OnTheRight,ColMajor,true> +template<> struct gemv_dense_sense_selector<OnTheRight,ColMajor,true> { template<typename Lhs, typename Rhs, typename Dest> static inline void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) @@ -685,7 +690,7 @@ template<> struct gemv_selector<OnTheRight,ColMajor,true> } }; -template<> struct gemv_selector<OnTheRight,RowMajor,true> +template<> struct gemv_dense_sense_selector<OnTheRight,RowMajor,true> { template<typename Lhs, typename Rhs, typename Dest> static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) @@ -737,7 +742,7 @@ template<> struct gemv_selector<OnTheRight,RowMajor,true> } }; -template<> struct gemv_selector<OnTheRight,ColMajor,false> +template<> struct gemv_dense_sense_selector<OnTheRight,ColMajor,false> { template<typename Lhs, typename Rhs, typename Dest> static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) @@ -750,7 +755,7 @@ template<> struct gemv_selector<OnTheRight,ColMajor,false> } }; -template<> struct gemv_selector<OnTheRight,RowMajor,false> +template<> struct gemv_dense_sense_selector<OnTheRight,RowMajor,false> { template<typename Lhs, typename Rhs, typename Dest> static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) @@ -763,7 +768,7 @@ template<> struct gemv_selector<OnTheRight,RowMajor,false> } }; -#endif // EIGEN_TEST_EVALUATORS +#endif // EIGEN_ENABLE_EVALUATORS } // end namespace internal diff --git a/Eigen/src/Core/ProductEvaluators.h b/Eigen/src/Core/ProductEvaluators.h index 186ae4a34..b16b86d8f 100644 --- a/Eigen/src/Core/ProductEvaluators.h +++ b/Eigen/src/Core/ProductEvaluators.h @@ -304,7 +304,7 @@ struct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,GemvProduct> template<typename Dest> static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha) { - internal::gemv_selector<Side, + internal::gemv_dense_sense_selector<Side, (int(MatrixType::Flags)&RowMajorBit) ? RowMajor : ColMajor, bool(internal::blas_traits<MatrixType>::HasUsableDirectAccess) >::run(lhs, rhs, dst, alpha); diff --git a/Eigen/src/Core/products/GeneralMatrixMatrix.h b/Eigen/src/Core/products/GeneralMatrixMatrix.h index 1c8940e1c..1726f98ed 100644 --- a/Eigen/src/Core/products/GeneralMatrixMatrix.h +++ b/Eigen/src/Core/products/GeneralMatrixMatrix.h @@ -422,7 +422,9 @@ class GeneralProduct<Lhs, Rhs, GemmProduct> internal::parallelize_gemm<(Dest::MaxRowsAtCompileTime>32 || Dest::MaxRowsAtCompileTime==Dynamic)>(GemmFunctor(lhs, rhs, dst, actualAlpha, blocking), this->rows(), this->cols(), Dest::Flags&RowMajorBit); } }; -#else // EIGEN_TEST_EVALUATORS +#endif // EIGEN_TEST_EVALUATORS + +#ifdef EIGEN_ENABLE_EVALUATORS namespace internal { template<typename Lhs, typename Rhs> @@ -477,7 +479,7 @@ struct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,GemmProduct> }; } // end namespace internal -#endif // EIGEN_TEST_EVALUATORS +#endif // EIGEN_ENABLE_EVALUATORS } // end namespace Eigen diff --git a/Eigen/src/Core/products/SelfadjointMatrixMatrix.h b/Eigen/src/Core/products/SelfadjointMatrixMatrix.h index f252aef85..afa8af43c 100644 --- a/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +++ b/Eigen/src/Core/products/SelfadjointMatrixMatrix.h @@ -431,7 +431,8 @@ struct SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,RhsMode,false> ); } }; -#else // EIGEN_TEST_EVALUATORS +#endif // EIGEN_TEST_EVALUATORS +#ifdef EIGEN_ENABLE_EVALUATORS namespace internal { template<typename Lhs, int LhsMode, typename Rhs, int RhsMode> @@ -481,7 +482,7 @@ struct selfadjoint_product_impl<Lhs,LhsMode,false,Rhs,RhsMode,false> } // end namespace internal -#endif +#endif // EIGEN_ENABLE_EVALUATORS } // end namespace Eigen diff --git a/Eigen/src/Core/products/TriangularMatrixMatrix.h b/Eigen/src/Core/products/TriangularMatrixMatrix.h index e654b45b1..3f0618410 100644 --- a/Eigen/src/Core/products/TriangularMatrixMatrix.h +++ b/Eigen/src/Core/products/TriangularMatrixMatrix.h @@ -421,7 +421,8 @@ struct TriangularProduct<Mode,LhsIsTriangular,Lhs,false,Rhs,false> ); } }; -#else // EIGEN_TEST_EVALUATORS +#endif // EIGEN_TEST_EVALUATORS +#ifdef EIGEN_ENABLE_EVALUATORS namespace internal { template<int Mode, bool LhsIsTriangular, typename Lhs, typename Rhs> struct triangular_product_impl<Mode,LhsIsTriangular,Lhs,false,Rhs,false> @@ -471,7 +472,7 @@ struct triangular_product_impl<Mode,LhsIsTriangular,Lhs,false,Rhs,false> }; } // end namespace internal -#endif // EIGEN_TEST_EVALUATORS +#endif // EIGEN_ENABLE_EVALUATORS } // end namespace Eigen diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index 76e979ba0..a4baa921c 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -293,44 +293,10 @@ struct transfer_constness >::type type; }; -#ifdef EIGEN_TEST_EVALUATORS -// When using evaluators, we never evaluate when assembling the expression!! -// TODO: get rid of this nested class since it's just an alias for ref_selector. -template<typename T, int n=1, typename PlainObject = typename eval<T>::type> struct nested -{ - typedef typename ref_selector<T>::type type; -}; -// However, we still need a mechanism to detect whether an expression which is evaluated multiple time -// has to be evaluated into a temporary. -// That's the purpose of this new nested_eval helper: -template<typename T, int n, typename PlainObject = typename eval<T>::type> struct nested_eval -{ - enum { - // For the purpose of this test, to keep it reasonably simple, we arbitrarily choose a value of Dynamic values. - // the choice of 10000 makes it larger than any practical fixed value and even most dynamic values. - // in extreme cases where these assumptions would be wrong, we would still at worst suffer performance issues - // (poor choice of temporaries). - // It's important that this value can still be squared without integer overflowing. - DynamicAsInteger = 10000, - ScalarReadCost = NumTraits<typename traits<T>::Scalar>::ReadCost, - ScalarReadCostAsInteger = ScalarReadCost == Dynamic ? int(DynamicAsInteger) : int(ScalarReadCost), - CoeffReadCost = traits<T>::CoeffReadCost, - CoeffReadCostAsInteger = CoeffReadCost == Dynamic ? int(DynamicAsInteger) : int(CoeffReadCost), - NAsInteger = n == Dynamic ? int(DynamicAsInteger) : n, - CostEvalAsInteger = (NAsInteger+1) * ScalarReadCostAsInteger + CoeffReadCostAsInteger, - CostNoEvalAsInteger = NAsInteger * CoeffReadCostAsInteger - }; - - typedef typename conditional< - int(CostEvalAsInteger) < int(CostNoEvalAsInteger), - PlainObject, - typename ref_selector<T>::type - >::type type; -}; +#ifndef EIGEN_TEST_EVALUATORS -#else /** \internal Determines how a given expression should be nested into another one. * For example, when you do a * (b+c), Eigen will determine how the expression b+c should be * nested into the bigger product expression. The choice is between nesting the expression b+c as-is, or @@ -377,8 +343,48 @@ template<typename T, int n=1, typename PlainObject = typename eval<T>::type> str typename ref_selector<T>::type >::type type; }; + +#else + +// When using evaluators, we never evaluate when assembling the expression!! +// TODO: get rid of this nested class since it's just an alias for ref_selector. +template<typename T, int n=1, typename PlainObject = typename eval<T>::type> struct nested +{ + typedef typename ref_selector<T>::type type; +}; + #endif // EIGEN_TEST_EVALUATORS +#ifdef EIGEN_ENABLE_EVALUATORS +// However, we still need a mechanism to detect whether an expression which is evaluated multiple time +// has to be evaluated into a temporary. +// That's the purpose of this new nested_eval helper: +template<typename T, int n, typename PlainObject = typename eval<T>::type> struct nested_eval +{ + enum { + // For the purpose of this test, to keep it reasonably simple, we arbitrarily choose a value of Dynamic values. + // the choice of 10000 makes it larger than any practical fixed value and even most dynamic values. + // in extreme cases where these assumptions would be wrong, we would still at worst suffer performance issues + // (poor choice of temporaries). + // It's important that this value can still be squared without integer overflowing. + DynamicAsInteger = 10000, + ScalarReadCost = NumTraits<typename traits<T>::Scalar>::ReadCost, + ScalarReadCostAsInteger = ScalarReadCost == Dynamic ? int(DynamicAsInteger) : int(ScalarReadCost), + CoeffReadCost = traits<T>::CoeffReadCost, + CoeffReadCostAsInteger = CoeffReadCost == Dynamic ? int(DynamicAsInteger) : int(CoeffReadCost), + NAsInteger = n == Dynamic ? int(DynamicAsInteger) : n, + CostEvalAsInteger = (NAsInteger+1) * ScalarReadCostAsInteger + CoeffReadCostAsInteger, + CostNoEvalAsInteger = NAsInteger * CoeffReadCostAsInteger + }; + + typedef typename conditional< + int(CostEvalAsInteger) < int(CostNoEvalAsInteger), + PlainObject, + typename ref_selector<T>::type + >::type type; +}; +#endif + template<typename T> EIGEN_DEVICE_FUNC T* const_cast_ptr(const T* ptr) |