mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 19:59:05 +08:00
Add EIGEN_HAS_INTRINSIC_INT128 macro
Add a new EIGEN_HAS_INTRINSIC_INT128 macro, and use this instead of __SIZEOF_INT128__. This fixes related issues with TensorIntDiv.h when building with Clang for Windows, where support for 128-bit integer arithmetic is advertised but broken in practice.
This commit is contained in:
parent
ee404667e2
commit
cc3d0e6a40
@ -757,6 +757,21 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Does the compiler support the __int128 and __uint128_t extensions for 128-bit
|
||||||
|
// integer arithmetic?
|
||||||
|
//
|
||||||
|
// Clang and GCC define __SIZEOF_INT128__ when these extensions are supported,
|
||||||
|
// but we avoid using them in certain cases:
|
||||||
|
//
|
||||||
|
// * Building using Clang for Windows, where the Clang runtime library has
|
||||||
|
// 128-bit support only on LP64 architectures, but Windows is LLP64.
|
||||||
|
#ifndef EIGEN_HAS_BUILTIN_INT128
|
||||||
|
#if defined(__SIZEOF_INT128__) && !(EIGEN_OS_WIN && EIGEN_COMP_CLANG)
|
||||||
|
#define EIGEN_HAS_BUILTIN_INT128 1
|
||||||
|
#else
|
||||||
|
#define EIGEN_HAS_BUILTIN_INT128 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------
|
||||||
// Preprocessor programming helpers
|
// Preprocessor programming helpers
|
||||||
|
@ -105,7 +105,7 @@ namespace {
|
|||||||
return __umul64hi(a, b);
|
return __umul64hi(a, b);
|
||||||
#elif defined(SYCL_DEVICE_ONLY)
|
#elif defined(SYCL_DEVICE_ONLY)
|
||||||
return cl::sycl::mul_hi(a, static_cast<uint64_t>(b));
|
return cl::sycl::mul_hi(a, static_cast<uint64_t>(b));
|
||||||
#elif defined(__SIZEOF_INT128__)
|
#elif EIGEN_HAS_BUILTIN_INT128
|
||||||
__uint128_t v = static_cast<__uint128_t>(a) * static_cast<__uint128_t>(b);
|
__uint128_t v = static_cast<__uint128_t>(a) * static_cast<__uint128_t>(b);
|
||||||
return static_cast<uint64_t>(v >> 64);
|
return static_cast<uint64_t>(v >> 64);
|
||||||
#else
|
#else
|
||||||
@ -124,7 +124,7 @@ namespace {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
struct DividerHelper<64, T> {
|
struct DividerHelper<64, T> {
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE uint64_t computeMultiplier(const int log_div, const T divider) {
|
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE uint64_t computeMultiplier(const int log_div, const T divider) {
|
||||||
#if defined(__SIZEOF_INT128__) && !defined(EIGEN_GPU_COMPILE_PHASE) && !defined(SYCL_DEVICE_ONLY)
|
#if EIGEN_HAS_BUILTIN_INT128 && !defined(EIGEN_GPU_COMPILE_PHASE) && !defined(SYCL_DEVICE_ONLY)
|
||||||
return static_cast<uint64_t>((static_cast<__uint128_t>(1) << (64+log_div)) / static_cast<__uint128_t>(divider) - (static_cast<__uint128_t>(1) << 64) + 1);
|
return static_cast<uint64_t>((static_cast<__uint128_t>(1) << (64+log_div)) / static_cast<__uint128_t>(divider) - (static_cast<__uint128_t>(1) << 64) + 1);
|
||||||
#else
|
#else
|
||||||
const uint64_t shift = 1ULL << log_div;
|
const uint64_t shift = 1ULL << log_div;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user