mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-15 17:41:48 +08:00
Guard use of long double on GPU device.
(cherry picked from commit bc5cdc7a675621ce54c4a9277d041d9dd7aae757)
This commit is contained in:
parent
8f1b6198c2
commit
2ce5dc428f
@ -1032,11 +1032,15 @@ template<typename T> EIGEN_DEVICE_FUNC bool isinf_msvc_helper(T x)
|
||||
}
|
||||
|
||||
//MSVC defines a _isnan builtin function, but for double only
|
||||
#ifndef EIGEN_GPU_COMPILE_PHASE
|
||||
EIGEN_DEVICE_FUNC inline bool isnan_impl(const long double& x) { return _isnan(x)!=0; }
|
||||
#endif
|
||||
EIGEN_DEVICE_FUNC inline bool isnan_impl(const double& x) { return _isnan(x)!=0; }
|
||||
EIGEN_DEVICE_FUNC inline bool isnan_impl(const float& x) { return _isnan(x)!=0; }
|
||||
|
||||
#ifndef EIGEN_GPU_COMPILE_PHASE
|
||||
EIGEN_DEVICE_FUNC inline bool isinf_impl(const long double& x) { return isinf_msvc_helper(x); }
|
||||
#endif
|
||||
EIGEN_DEVICE_FUNC inline bool isinf_impl(const double& x) { return isinf_msvc_helper(x); }
|
||||
EIGEN_DEVICE_FUNC inline bool isinf_impl(const float& x) { return isinf_msvc_helper(x); }
|
||||
|
||||
@ -1050,12 +1054,16 @@ EIGEN_DEVICE_FUNC inline bool isinf_impl(const float& x) { return isinf_ms
|
||||
#define EIGEN_TMP_NOOPT_ATTRIB EIGEN_DEVICE_FUNC inline __attribute__((noinline,optimize("no-finite-math-only")))
|
||||
#endif
|
||||
|
||||
#ifndef EIGEN_GPU_COMPILE_PHASE
|
||||
template<> EIGEN_TMP_NOOPT_ATTRIB bool isnan_impl(const long double& x) { return __builtin_isnan(x); }
|
||||
#endif
|
||||
template<> EIGEN_TMP_NOOPT_ATTRIB bool isnan_impl(const double& x) { return __builtin_isnan(x); }
|
||||
template<> EIGEN_TMP_NOOPT_ATTRIB bool isnan_impl(const float& x) { return __builtin_isnan(x); }
|
||||
template<> EIGEN_TMP_NOOPT_ATTRIB bool isinf_impl(const double& x) { return __builtin_isinf(x); }
|
||||
template<> EIGEN_TMP_NOOPT_ATTRIB bool isinf_impl(const float& x) { return __builtin_isinf(x); }
|
||||
#ifndef EIGEN_GPU_COMPILE_PHASE
|
||||
template<> EIGEN_TMP_NOOPT_ATTRIB bool isinf_impl(const long double& x) { return __builtin_isinf(x); }
|
||||
#endif
|
||||
|
||||
#undef EIGEN_TMP_NOOPT_ATTRIB
|
||||
|
||||
@ -1112,6 +1120,8 @@ EIGEN_ALWAYS_INLINE double mini(const double& x, const double& y)
|
||||
{
|
||||
return fmin(x, y);
|
||||
}
|
||||
|
||||
#ifndef EIGEN_GPU_COMPILE_PHASE
|
||||
template<>
|
||||
EIGEN_DEVICE_FUNC
|
||||
EIGEN_ALWAYS_INLINE long double mini(const long double& x, const long double& y)
|
||||
@ -1123,6 +1133,7 @@ EIGEN_ALWAYS_INLINE long double mini(const long double& x, const long double& y)
|
||||
return fminl(x, y);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
EIGEN_DEVICE_FUNC
|
||||
@ -1142,6 +1153,7 @@ EIGEN_ALWAYS_INLINE double maxi(const double& x, const double& y)
|
||||
{
|
||||
return fmax(x, y);
|
||||
}
|
||||
#ifndef EIGEN_GPU_COMPILE_PHASE
|
||||
template<>
|
||||
EIGEN_DEVICE_FUNC
|
||||
EIGEN_ALWAYS_INLINE long double maxi(const long double& x, const long double& y)
|
||||
@ -1154,6 +1166,7 @@ EIGEN_ALWAYS_INLINE long double maxi(const long double& x, const long double& y)
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(SYCL_DEVICE_ONLY)
|
||||
|
||||
@ -1310,8 +1323,8 @@ EIGEN_ALWAYS_INLINE double absdiff(const double& x, const double& y)
|
||||
return fabs(x - y);
|
||||
}
|
||||
|
||||
#if !defined(EIGEN_GPUCC)
|
||||
// HIP and CUDA do not support long double.
|
||||
#ifndef EIGEN_GPU_COMPILE_PHASE
|
||||
template<>
|
||||
EIGEN_DEVICE_FUNC
|
||||
EIGEN_ALWAYS_INLINE long double absdiff(const long double& x, const long double& y) {
|
||||
|
@ -245,6 +245,8 @@ template<> struct NumTraits<double> : GenericNumTraits<double>
|
||||
static inline double dummy_precision() { return 1e-12; }
|
||||
};
|
||||
|
||||
// GPU devices treat `long double` as `double`.
|
||||
#ifndef EIGEN_GPU_COMPILE_PHASE
|
||||
template<> struct NumTraits<long double>
|
||||
: GenericNumTraits<long double>
|
||||
{
|
||||
@ -261,6 +263,7 @@ template<> struct NumTraits<long double>
|
||||
}
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
template<typename _Real> struct NumTraits<std::complex<_Real> >
|
||||
: GenericNumTraits<std::complex<_Real> >
|
||||
|
@ -133,7 +133,10 @@ template<typename T> struct remove_all<T*> { typedef typename remove_all<
|
||||
template<typename T> struct is_arithmetic { enum { value = false }; };
|
||||
template<> struct is_arithmetic<float> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<double> { enum { value = true }; };
|
||||
// GPU devices treat `long double` as `double`.
|
||||
#ifndef EIGEN_GPU_COMPILE_PHASE
|
||||
template<> struct is_arithmetic<long double> { enum { value = true }; };
|
||||
#endif
|
||||
template<> struct is_arithmetic<bool> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<char> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<signed char> { enum { value = true }; };
|
||||
|
Loading…
x
Reference in New Issue
Block a user