mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-23 14:53:13 +08:00
Guard use of long double on GPU device.
This commit is contained in:
parent
e4598fedbe
commit
bc5cdc7a67
@ -1015,11 +1015,15 @@ template<typename T> EIGEN_DEVICE_FUNC bool isinf_msvc_helper(T x)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//MSVC defines a _isnan builtin function, but for double only
|
//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; }
|
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 double& x) { return _isnan(x)!=0; }
|
||||||
EIGEN_DEVICE_FUNC inline bool isnan_impl(const float& 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); }
|
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 double& x) { return isinf_msvc_helper(x); }
|
||||||
EIGEN_DEVICE_FUNC inline bool isinf_impl(const float& x) { return isinf_msvc_helper(x); }
|
EIGEN_DEVICE_FUNC inline bool isinf_impl(const float& x) { return isinf_msvc_helper(x); }
|
||||||
|
|
||||||
@ -1033,12 +1037,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")))
|
#define EIGEN_TMP_NOOPT_ATTRIB EIGEN_DEVICE_FUNC inline __attribute__((noinline,optimize("no-finite-math-only")))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef EIGEN_GPU_COMPILE_PHASE
|
||||||
template<> EIGEN_TMP_NOOPT_ATTRIB bool isnan_impl(const long double& x) { return __builtin_isnan(x); }
|
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 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 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 double& x) { return __builtin_isinf(x); }
|
||||||
template<> EIGEN_TMP_NOOPT_ATTRIB bool isinf_impl(const float& 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); }
|
template<> EIGEN_TMP_NOOPT_ATTRIB bool isinf_impl(const long double& x) { return __builtin_isinf(x); }
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef EIGEN_TMP_NOOPT_ATTRIB
|
#undef EIGEN_TMP_NOOPT_ATTRIB
|
||||||
|
|
||||||
@ -1095,6 +1103,8 @@ EIGEN_ALWAYS_INLINE double mini(const double& x, const double& y)
|
|||||||
{
|
{
|
||||||
return fmin(x, y);
|
return fmin(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef EIGEN_GPU_COMPILE_PHASE
|
||||||
template<>
|
template<>
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_ALWAYS_INLINE long double mini(const long double& x, const long double& y)
|
EIGEN_ALWAYS_INLINE long double mini(const long double& x, const long double& y)
|
||||||
@ -1106,6 +1116,7 @@ EIGEN_ALWAYS_INLINE long double mini(const long double& x, const long double& y)
|
|||||||
return fminl(x, y);
|
return fminl(x, y);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
@ -1125,6 +1136,7 @@ EIGEN_ALWAYS_INLINE double maxi(const double& x, const double& y)
|
|||||||
{
|
{
|
||||||
return fmax(x, y);
|
return fmax(x, y);
|
||||||
}
|
}
|
||||||
|
#ifndef EIGEN_GPU_COMPILE_PHASE
|
||||||
template<>
|
template<>
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_ALWAYS_INLINE long double maxi(const long double& x, const long double& y)
|
EIGEN_ALWAYS_INLINE long double maxi(const long double& x, const long double& y)
|
||||||
@ -1137,6 +1149,7 @@ EIGEN_ALWAYS_INLINE long double maxi(const long double& x, const long double& y)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(SYCL_DEVICE_ONLY)
|
#if defined(SYCL_DEVICE_ONLY)
|
||||||
|
|
||||||
@ -1300,8 +1313,8 @@ EIGEN_ALWAYS_INLINE double absdiff(const double& x, const double& y)
|
|||||||
return fabs(x - y);
|
return fabs(x - y);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(EIGEN_GPUCC)
|
|
||||||
// HIP and CUDA do not support long double.
|
// HIP and CUDA do not support long double.
|
||||||
|
#ifndef EIGEN_GPU_COMPILE_PHASE
|
||||||
template<>
|
template<>
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_ALWAYS_INLINE long double absdiff(const long double& x, const long double& y) {
|
EIGEN_ALWAYS_INLINE long double absdiff(const long double& x, const long double& y) {
|
||||||
|
@ -243,6 +243,8 @@ template<> struct NumTraits<double> : GenericNumTraits<double>
|
|||||||
static inline double dummy_precision() { return 1e-12; }
|
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>
|
template<> struct NumTraits<long double>
|
||||||
: GenericNumTraits<long double>
|
: GenericNumTraits<long double>
|
||||||
{
|
{
|
||||||
@ -259,6 +261,7 @@ template<> struct NumTraits<long double>
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename Real_> struct NumTraits<std::complex<Real_> >
|
template<typename Real_> struct NumTraits<std::complex<Real_> >
|
||||||
: GenericNumTraits<std::complex<Real_> >
|
: GenericNumTraits<std::complex<Real_> >
|
||||||
|
@ -135,7 +135,10 @@ using remove_all_t = typename remove_all<T>::type;
|
|||||||
template<typename T> struct is_arithmetic { enum { value = false }; };
|
template<typename T> struct is_arithmetic { enum { value = false }; };
|
||||||
template<> struct is_arithmetic<float> { enum { value = true }; };
|
template<> struct is_arithmetic<float> { enum { value = true }; };
|
||||||
template<> struct is_arithmetic<double> { 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 }; };
|
template<> struct is_arithmetic<long double> { enum { value = true }; };
|
||||||
|
#endif
|
||||||
template<> struct is_arithmetic<bool> { enum { value = true }; };
|
template<> struct is_arithmetic<bool> { enum { value = true }; };
|
||||||
template<> struct is_arithmetic<char> { enum { value = true }; };
|
template<> struct is_arithmetic<char> { enum { value = true }; };
|
||||||
template<> struct is_arithmetic<signed char> { enum { value = true }; };
|
template<> struct is_arithmetic<signed char> { enum { value = true }; };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user