bug #1580: Fix cuda clang build. STL is not supported, so std::equal_to and std::not_equal breaks compilation.

Update the definition of EIGEN_CONSTEXPR_ARE_DEVICE_FUNC to exclude clang.
See also PR 450.
This commit is contained in:
Rasmus Munk Larsen 2018-08-01 12:36:24 -07:00
parent bcb29f890c
commit 7f8b53fd0e
2 changed files with 12 additions and 10 deletions

View File

@ -571,20 +571,19 @@
// Does the compiler fully support const expressions? (as in c++14) // Does the compiler fully support const expressions? (as in c++14)
#ifndef EIGEN_HAS_CONSTEXPR #ifndef EIGEN_HAS_CONSTEXPR
#if defined(EIGEN_CUDACC) #if defined(EIGEN_CUDACC)
// Const expressions are supported provided that c++11 is enabled and we're using either clang or nvcc 7.5 or above // Const expressions are supported provided that c++11 is enabled and we're using either clang or nvcc 7.5 or above
#if EIGEN_MAX_CPP_VER>=14 && (__cplusplus > 199711L && (EIGEN_COMP_CLANG || EIGEN_CUDACC_VER >= 70500)) #if EIGEN_MAX_CPP_VER>=14 && (__cplusplus > 199711L && (EIGEN_COMP_CLANG || EIGEN_CUDACC_VER >= 70500))
#define EIGEN_HAS_CONSTEXPR 1 #define EIGEN_HAS_CONSTEXPR 1
#endif #endif
#elif EIGEN_MAX_CPP_VER>=14 && (__has_feature(cxx_relaxed_constexpr) || (defined(__cplusplus) && __cplusplus >= 201402L) || \ #elif EIGEN_MAX_CPP_VER>=14 && (__has_feature(cxx_relaxed_constexpr) || (defined(__cplusplus) && __cplusplus >= 201402L) || \
(EIGEN_GNUC_AT_LEAST(4,8) && (__cplusplus > 199711L)) || \ (EIGEN_GNUC_AT_LEAST(4,8) && (__cplusplus > 199711L)) || \
(EIGEN_COMP_CLANG >= 306 && (__cplusplus > 199711L))) (EIGEN_COMP_CLANG >= 306 && (__cplusplus > 199711L)))
#define EIGEN_HAS_CONSTEXPR 1 #define EIGEN_HAS_CONSTEXPR 1
#endif #endif
#ifndef EIGEN_HAS_CONSTEXPR #ifndef EIGEN_HAS_CONSTEXPR
#define EIGEN_HAS_CONSTEXPR 0 #define EIGEN_HAS_CONSTEXPR 0
#endif #endif
#endif // EIGEN_HAS_CONSTEXPR #endif // EIGEN_HAS_CONSTEXPR
@ -643,9 +642,12 @@
#ifdef __CUDACC_RELAXED_CONSTEXPR__ #ifdef __CUDACC_RELAXED_CONSTEXPR__
#define EIGEN_CONSTEXPR_ARE_DEVICE_FUNC #define EIGEN_CONSTEXPR_ARE_DEVICE_FUNC
#endif #endif
#elif defined(__clang__) && defined(__CUDA__) // See bug 1580: clang/CUDA fails to make the following calls
// clang++ always considers constexpr functions as implicitly __host__ __device__ // to constexpr bool std::equal_to::operator() even when
#define EIGEN_CONSTEXPR_ARE_DEVICE_FUNC // EIGEN_CONSTEXPR_ARE_DEVICE_FUNC is defined in c++14 only.
// #elif defined(__clang__) && defined(__CUDA__) && EIGEN_HAS_CONSTEXPR == 1
// // clang++ always considers constexpr functions as implicitly __host__ __device__
// #define EIGEN_CONSTEXPR_ARE_DEVICE_FUNC
#endif #endif
#endif #endif

View File

@ -569,7 +569,7 @@ template<typename T, typename U> struct scalar_product_traits
} // end namespace internal } // end namespace internal
namespace numext { namespace numext {
#if defined(EIGEN_GPU_COMPILE_PHASE) #if defined(EIGEN_GPU_COMPILE_PHASE)
template<typename T> EIGEN_DEVICE_FUNC void swap(T &a, T &b) { T tmp = b; b = a; a = tmp; } template<typename T> EIGEN_DEVICE_FUNC void swap(T &a, T &b) { T tmp = b; b = a; a = tmp; }
#else #else