From a3ec89b5bd46bca1c5f445ea63520a2910673072 Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Thu, 9 Jan 2020 21:06:34 +0000 Subject: [PATCH] Add missing EIGEN_DEVICE_FUNC annotations in MathFunctions.h. --- Eigen/src/Core/MathFunctions.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 42e952c81..cca968d2e 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -402,6 +402,7 @@ inline NewType cast(const OldType& x) #if EIGEN_HAS_CXX11_MATH template struct round_impl { + EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) { EIGEN_STATIC_ASSERT((!NumTraits::IsComplex), NUMERIC_TYPE_MUST_BE_REAL) @@ -413,6 +414,7 @@ inline NewType cast(const OldType& x) template struct round_impl { + EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) { EIGEN_STATIC_ASSERT((!NumTraits::IsComplex), NUMERIC_TYPE_MUST_BE_REAL) @@ -435,6 +437,7 @@ struct round_retval template struct rint_impl { + EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) { EIGEN_STATIC_ASSERT((!NumTraits::IsComplex), NUMERIC_TYPE_MUST_BE_REAL) @@ -448,6 +451,7 @@ struct rint_impl { #if !EIGEN_HAS_CXX11_MATH template<> struct rint_impl { + EIGEN_DEVICE_FUNC static inline float run(const float& x) { return rintf(x); @@ -468,6 +472,7 @@ struct rint_retval #if EIGEN_HAS_CXX11_MATH template struct arg_impl { + EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) { #if defined(EIGEN_HIP_DEVICE_COMPILE) @@ -695,16 +700,18 @@ struct random_retval typedef Scalar type; }; -template inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y); -template inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(); +template EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y); +template EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(); template struct random_default_impl { + EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x, const Scalar& y) { return x + (y-x) * Scalar(std::rand()) / Scalar(RAND_MAX); } + EIGEN_DEVICE_FUNC static inline Scalar run() { return run(Scalar(NumTraits::IsSigned ? -1 : 0), Scalar(1)); @@ -761,6 +768,7 @@ struct meta_floor_log2 template struct random_default_impl { + EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x, const Scalar& y) { if (y <= x) @@ -788,6 +796,7 @@ struct random_default_impl return Scalar(ScalarX(x) + offset); } + EIGEN_DEVICE_FUNC static inline Scalar run() { #ifdef EIGEN_MAKING_DOCS @@ -806,11 +815,13 @@ struct random_default_impl template struct random_default_impl { + EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x, const Scalar& y) { return Scalar(random(x.real(), y.real()), random(x.imag(), y.imag())); } + EIGEN_DEVICE_FUNC static inline Scalar run() { typedef typename NumTraits::Real RealScalar; @@ -819,12 +830,14 @@ struct random_default_impl }; template +EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y) { return EIGEN_MATHFUNC_IMPL(random, Scalar)::run(x, y); } template +EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random() { return EIGEN_MATHFUNC_IMPL(random, Scalar)::run(); @@ -1801,6 +1814,7 @@ inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, template<> struct random_impl { + EIGEN_DEVICE_FUNC static inline bool run() { return random(0,1)==0 ? false : true;