Add missing EIGEN_DEVICE_FUNC in a few places when called by asserts.

This commit is contained in:
Antonio Sánchez 2023-01-15 02:06:17 +00:00 committed by Rasmus Munk Larsen
parent 4aca06f63a
commit 2e61c0c6b4
5 changed files with 21 additions and 33 deletions

View File

@ -937,7 +937,7 @@ void call_assignment_no_alias_no_transpose(Dst& dst, const Src& src)
} }
// forward declaration // forward declaration
template<typename Dst, typename Src> void check_for_aliasing(const Dst &dst, const Src &src); template<typename Dst, typename Src> EIGEN_DEVICE_FUNC void check_for_aliasing(const Dst &dst, const Src &src);
// Generic Dense to Dense assignment // Generic Dense to Dense assignment
// Note that the last template argument "Weak" is needed to make it possible to perform // Note that the last template argument "Weak" is needed to make it possible to perform

View File

@ -54,18 +54,6 @@ struct plain_array
#if defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT) #if defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)
#define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask)
#elif EIGEN_COMP_GNUC
// GCC 4.7 is too aggressive in its optimizations and remove the alignment test based on the fact the array is declared to be aligned.
// See this bug report: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53900
// Hiding the origin of the array pointer behind a function argument seems to do the trick even if the function is inlined:
template<typename PtrType>
EIGEN_ALWAYS_INLINE PtrType eigen_unaligned_array_assert_workaround_gcc47(PtrType array) { return array; }
#define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \
eigen_assert((internal::is_constant_evaluated() \
|| (internal::UIntPtr(eigen_unaligned_array_assert_workaround_gcc47(array)) & (sizemask)) == 0) \
&& "this assertion is explained here: " \
"http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \
" **** READ THIS WEB PAGE !!! ****");
#else #else
#define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \ #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \
eigen_assert((internal::is_constant_evaluated() || (internal::UIntPtr(array) & (sizemask)) == 0) \ eigen_assert((internal::is_constant_evaluated() || (internal::UIntPtr(array) & (sizemask)) == 0) \

View File

@ -402,7 +402,7 @@ struct check_transpose_aliasing_compile_time_selector<DestIsTransposed,CwiseBina
template<typename Scalar, bool DestIsTransposed, typename OtherDerived> template<typename Scalar, bool DestIsTransposed, typename OtherDerived>
struct check_transpose_aliasing_run_time_selector struct check_transpose_aliasing_run_time_selector
{ {
static bool run(const Scalar* dest, const OtherDerived& src) EIGEN_DEVICE_FUNC static bool run(const Scalar* dest, const OtherDerived& src)
{ {
return (bool(blas_traits<OtherDerived>::IsTransposed) != DestIsTransposed) && (dest!=0 && dest==(const Scalar*)extract_data(src)); return (bool(blas_traits<OtherDerived>::IsTransposed) != DestIsTransposed) && (dest!=0 && dest==(const Scalar*)extract_data(src));
} }
@ -411,7 +411,7 @@ struct check_transpose_aliasing_run_time_selector
template<typename Scalar, bool DestIsTransposed, typename BinOp, typename DerivedA, typename DerivedB> template<typename Scalar, bool DestIsTransposed, typename BinOp, typename DerivedA, typename DerivedB>
struct check_transpose_aliasing_run_time_selector<Scalar,DestIsTransposed,CwiseBinaryOp<BinOp,DerivedA,DerivedB> > struct check_transpose_aliasing_run_time_selector<Scalar,DestIsTransposed,CwiseBinaryOp<BinOp,DerivedA,DerivedB> >
{ {
static bool run(const Scalar* dest, const CwiseBinaryOp<BinOp,DerivedA,DerivedB>& src) EIGEN_DEVICE_FUNC static bool run(const Scalar* dest, const CwiseBinaryOp<BinOp,DerivedA,DerivedB>& src)
{ {
return ((blas_traits<DerivedA>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(const Scalar*)extract_data(src.lhs()))) return ((blas_traits<DerivedA>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(const Scalar*)extract_data(src.lhs())))
|| ((blas_traits<DerivedB>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(const Scalar*)extract_data(src.rhs()))); || ((blas_traits<DerivedB>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(const Scalar*)extract_data(src.rhs())));
@ -431,7 +431,7 @@ template<typename Derived, typename OtherDerived,
> >
struct checkTransposeAliasing_impl struct checkTransposeAliasing_impl
{ {
static void run(const Derived& dst, const OtherDerived& other) EIGEN_DEVICE_FUNC static void run(const Derived& dst, const OtherDerived& other)
{ {
eigen_assert((!check_transpose_aliasing_run_time_selector eigen_assert((!check_transpose_aliasing_run_time_selector
<typename Derived::Scalar,blas_traits<Derived>::IsTransposed,OtherDerived> <typename Derived::Scalar,blas_traits<Derived>::IsTransposed,OtherDerived>
@ -445,13 +445,13 @@ struct checkTransposeAliasing_impl
template<typename Derived, typename OtherDerived> template<typename Derived, typename OtherDerived>
struct checkTransposeAliasing_impl<Derived, OtherDerived, false> struct checkTransposeAliasing_impl<Derived, OtherDerived, false>
{ {
static void run(const Derived&, const OtherDerived&) EIGEN_DEVICE_FUNC static void run(const Derived&, const OtherDerived&)
{ {
} }
}; };
template<typename Dst, typename Src> template<typename Dst, typename Src>
void check_for_aliasing(const Dst &dst, const Src &src) EIGEN_DEVICE_FUNC inline void check_for_aliasing(const Dst &dst, const Src &src)
{ {
if((!Dst::IsVectorAtCompileTime) && dst.rows()>1 && dst.cols()>1) if((!Dst::IsVectorAtCompileTime) && dst.rows()>1 && dst.cols()>1)
internal::checkTransposeAliasing_impl<Dst, Src>::run(dst, src); internal::checkTransposeAliasing_impl<Dst, Src>::run(dst, src);

View File

@ -478,8 +478,8 @@ template<typename XprType> struct blas_traits
ExtractType, ExtractType,
typename ExtractType_::PlainObject typename ExtractType_::PlainObject
> DirectLinearAccessType; > DirectLinearAccessType;
static inline EIGEN_DEVICE_FUNC ExtractType extract(const XprType& x) { return x; } EIGEN_DEVICE_FUNC static inline EIGEN_DEVICE_FUNC ExtractType extract(const XprType& x) { return x; }
static inline EIGEN_DEVICE_FUNC const Scalar extractScalarFactor(const XprType&) { return Scalar(1); } EIGEN_DEVICE_FUNC static inline EIGEN_DEVICE_FUNC const Scalar extractScalarFactor(const XprType&) { return Scalar(1); }
}; };
// pop conjugate // pop conjugate
@ -495,8 +495,8 @@ struct blas_traits<CwiseUnaryOp<scalar_conjugate_op<Scalar>, NestedXpr> >
IsComplex = NumTraits<Scalar>::IsComplex, IsComplex = NumTraits<Scalar>::IsComplex,
NeedToConjugate = Base::NeedToConjugate ? 0 : IsComplex NeedToConjugate = Base::NeedToConjugate ? 0 : IsComplex
}; };
static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); } EIGEN_DEVICE_FUNC static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); }
static inline Scalar extractScalarFactor(const XprType& x) { return conj(Base::extractScalarFactor(x.nestedExpression())); } EIGEN_DEVICE_FUNC static inline Scalar extractScalarFactor(const XprType& x) { return conj(Base::extractScalarFactor(x.nestedExpression())); }
}; };
// pop scalar multiple // pop scalar multiple
@ -510,8 +510,8 @@ struct blas_traits<CwiseBinaryOp<scalar_product_op<Scalar>, const CwiseNullaryOp
typedef blas_traits<NestedXpr> Base; typedef blas_traits<NestedXpr> Base;
typedef CwiseBinaryOp<scalar_product_op<Scalar>, const CwiseNullaryOp<scalar_constant_op<Scalar>,Plain>, NestedXpr> XprType; typedef CwiseBinaryOp<scalar_product_op<Scalar>, const CwiseNullaryOp<scalar_constant_op<Scalar>,Plain>, NestedXpr> XprType;
typedef typename Base::ExtractType ExtractType; typedef typename Base::ExtractType ExtractType;
static inline EIGEN_DEVICE_FUNC ExtractType extract(const XprType& x) { return Base::extract(x.rhs()); } EIGEN_DEVICE_FUNC static inline EIGEN_DEVICE_FUNC ExtractType extract(const XprType& x) { return Base::extract(x.rhs()); }
static inline EIGEN_DEVICE_FUNC Scalar extractScalarFactor(const XprType& x) EIGEN_DEVICE_FUNC static inline EIGEN_DEVICE_FUNC Scalar extractScalarFactor(const XprType& x)
{ return x.lhs().functor().m_other * Base::extractScalarFactor(x.rhs()); } { return x.lhs().functor().m_other * Base::extractScalarFactor(x.rhs()); }
}; };
template<typename Scalar, typename NestedXpr, typename Plain> template<typename Scalar, typename NestedXpr, typename Plain>
@ -524,8 +524,8 @@ struct blas_traits<CwiseBinaryOp<scalar_product_op<Scalar>, NestedXpr, const Cwi
typedef blas_traits<NestedXpr> Base; typedef blas_traits<NestedXpr> Base;
typedef CwiseBinaryOp<scalar_product_op<Scalar>, NestedXpr, const CwiseNullaryOp<scalar_constant_op<Scalar>,Plain> > XprType; typedef CwiseBinaryOp<scalar_product_op<Scalar>, NestedXpr, const CwiseNullaryOp<scalar_constant_op<Scalar>,Plain> > XprType;
typedef typename Base::ExtractType ExtractType; typedef typename Base::ExtractType ExtractType;
static inline ExtractType extract(const XprType& x) { return Base::extract(x.lhs()); } EIGEN_DEVICE_FUNC static inline ExtractType extract(const XprType& x) { return Base::extract(x.lhs()); }
static inline Scalar extractScalarFactor(const XprType& x) EIGEN_DEVICE_FUNC static inline Scalar extractScalarFactor(const XprType& x)
{ return Base::extractScalarFactor(x.lhs()) * x.rhs().functor().m_other; } { return Base::extractScalarFactor(x.lhs()) * x.rhs().functor().m_other; }
}; };
template<typename Scalar, typename Plain1, typename Plain2> template<typename Scalar, typename Plain1, typename Plain2>
@ -545,8 +545,8 @@ struct blas_traits<CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> >
typedef blas_traits<NestedXpr> Base; typedef blas_traits<NestedXpr> Base;
typedef CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> XprType; typedef CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> XprType;
typedef typename Base::ExtractType ExtractType; typedef typename Base::ExtractType ExtractType;
static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); } EIGEN_DEVICE_FUNC static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); }
static inline Scalar extractScalarFactor(const XprType& x) EIGEN_DEVICE_FUNC static inline Scalar extractScalarFactor(const XprType& x)
{ return - Base::extractScalarFactor(x.nestedExpression()); } { return - Base::extractScalarFactor(x.nestedExpression()); }
}; };
@ -567,8 +567,8 @@ struct blas_traits<Transpose<NestedXpr> >
enum { enum {
IsTransposed = Base::IsTransposed ? 0 : 1 IsTransposed = Base::IsTransposed ? 0 : 1
}; };
static inline ExtractType extract(const XprType& x) { return ExtractType(Base::extract(x.nestedExpression())); } EIGEN_DEVICE_FUNC static inline ExtractType extract(const XprType& x) { return ExtractType(Base::extract(x.nestedExpression())); }
static inline Scalar extractScalarFactor(const XprType& x) { return Base::extractScalarFactor(x.nestedExpression()); } EIGEN_DEVICE_FUNC static inline Scalar extractScalarFactor(const XprType& x) { return Base::extractScalarFactor(x.nestedExpression()); }
}; };
template<typename T> template<typename T>

View File

@ -876,7 +876,7 @@
#ifdef EIGEN_INTERNAL_DEBUGGING #ifdef EIGEN_INTERNAL_DEBUGGING
#define eigen_internal_assert(x) eigen_assert(x) #define eigen_internal_assert(x) eigen_assert(x)
#else #else
#define eigen_internal_assert(x) #define eigen_internal_assert(x) ((void)0)
#endif #endif
#ifdef EIGEN_NO_DEBUG #ifdef EIGEN_NO_DEBUG
@ -1238,10 +1238,10 @@ namespace Eigen {
namespace Eigen { namespace Eigen {
namespace internal { namespace internal {
inline bool all(){ return true; } EIGEN_DEVICE_FUNC inline bool all(){ return true; }
template<typename T, typename ...Ts> template<typename T, typename ...Ts>
bool all(T t, Ts ... ts){ return t && all(ts...); } EIGEN_DEVICE_FUNC bool all(T t, Ts ... ts){ return t && all(ts...); }
} }
} }