From 6be3e78b3e81175a4f4a4541df8bb0664cf9784c Mon Sep 17 00:00:00 2001 From: Bernhard Manfred Gruber Date: Fri, 31 Jan 2025 15:32:02 +0100 Subject: [PATCH] Backport to 2.8: Deprecate and replace `CUB_IS_INT128_ENABLED` (#3427) (#3629) Co-authored-by: Federico Busato <50413820+fbusato@users.noreply.github.com> --- cub/cub/detail/fast_modulo_division.cuh | 6 +++--- .../device/dispatch/dispatch_histogram.cuh | 12 +++++------ .../tuning/tuning_run_length_encode.cuh | 8 ++++---- .../device/dispatch/tuning/tuning_scan.cuh | 4 ++-- .../dispatch/tuning/tuning_scan_by_key.cuh | 20 +++++++++---------- .../dispatch/tuning/tuning_select_if.cuh | 16 +++++++-------- cub/cub/util_ptx.cuh | 2 +- cub/cub/util_type.cuh | 13 ++---------- .../catch2_test_device_for_each_in_extents.cu | 4 ++-- cub/test/catch2_test_printing.cu | 2 +- cub/test/internal/catch2_test_fast_div_mod.cu | 2 +- cub/test/test_util.h | 2 +- .../cuda/std/__cccl/extended_data_types.h | 2 +- 13 files changed, 42 insertions(+), 51 deletions(-) diff --git a/cub/cub/detail/fast_modulo_division.cuh b/cub/cub/detail/fast_modulo_division.cuh index 2ae65400e71..14d1fae32a1 100644 --- a/cub/cub/detail/fast_modulo_division.cuh +++ b/cub/cub/detail/fast_modulo_division.cuh @@ -38,7 +38,7 @@ #endif // no system header #include // implicit_prom_t -#include // CUB_IS_INT128_ENABLED +#include // _CCCL_HAS_INT128() #include // cuda::std::ceil_div #include // std::has_single_bit @@ -79,7 +79,7 @@ struct larger_unsigned_type using type = ::cuda::std::uint64_t; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template struct larger_unsigned_type::type> @@ -87,7 +87,7 @@ struct larger_unsigned_type using type = __uint128_t; }; -#endif // CUB_IS_INT128_ENABLED +#endif // _CCCL_HAS_INT128() template using larger_unsigned_type_t = typename larger_unsigned_type::type; diff --git a/cub/cub/device/dispatch/dispatch_histogram.cuh b/cub/cub/device/dispatch/dispatch_histogram.cuh index 32ef0b7e5d9..d4bc8306eca 100644 --- a/cub/cub/device/dispatch/dispatch_histogram.cuh +++ b/cub/cub/device/dispatch/dispatch_histogram.cuh @@ -646,27 +646,27 @@ public: using IntArithmeticT = ::cuda::std::_If< // sizeof(SampleT) + sizeof(CommonT) <= sizeof(uint32_t), // uint32_t, // -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() ::cuda::std::_If< // (::cuda::std::is_same::value || // ::cuda::std::is_same::value), // CommonT, // uint64_t> // -#else // ^^^ CUB_IS_INT128_ENABLED ^^^ / vvv !CUB_IS_INT128_ENABLED vvv +#else // ^^^ _CCCL_HAS_INT128() ^^^ / vvv !_CCCL_HAS_INT128() vvv uint64_t -#endif // !CUB_IS_INT128_ENABLED +#endif // !_CCCL_HAS_INT128() >; // Alias template that excludes __[u]int128 from the integral types template using is_integral_excl_int128 = -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() ::cuda::std::_If<::cuda::std::is_same::value&& ::cuda::std::is_same::value, ::cuda::std::false_type, ::cuda::std::is_integral>; -#else // ^^^ CUB_IS_INT128_ENABLED ^^^ / vvv !CUB_IS_INT128_ENABLED vvv +#else // ^^^ _CCCL_HAS_INT128() ^^^ / vvv !_CCCL_HAS_INT128() vvv ::cuda::std::is_integral; -#endif // !CUB_IS_INT128_ENABLED +#endif // !_CCCL_HAS_INT128() union ScaleT { diff --git a/cub/cub/device/dispatch/tuning/tuning_run_length_encode.cuh b/cub/cub/device/dispatch/tuning/tuning_run_length_encode.cuh index 87631d1199e..a2d62e6ab2b 100644 --- a/cub/cub/device/dispatch/tuning/tuning_run_length_encode.cuh +++ b/cub/cub/device/dispatch/tuning/tuning_run_length_encode.cuh @@ -156,7 +156,7 @@ struct sm80_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template struct sm80_tuning { @@ -216,7 +216,7 @@ struct sm90_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template struct sm90_tuning { @@ -349,7 +349,7 @@ struct sm80_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template struct sm80_tuning { @@ -414,7 +414,7 @@ struct sm90_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template struct sm90_tuning { diff --git a/cub/cub/device/dispatch/tuning/tuning_scan.cuh b/cub/cub/device/dispatch/tuning/tuning_scan.cuh index 1c76064da1d..1a0fac5db26 100644 --- a/cub/cub/device/dispatch/tuning/tuning_scan.cuh +++ b/cub/cub/device/dispatch/tuning/tuning_scan.cuh @@ -186,7 +186,7 @@ struct sm80_tuning struct sm80_tuning<__int128_t, primitive_op::yes, primitive_accum::no, accum_size::_16> { @@ -218,7 +218,7 @@ template struct sm90_tuning struct sm90_tuning : tuning {}; template <> struct sm90_tuning : tuning {}; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template <> struct sm90_tuning<__int128_t, primitive_op::yes, primitive_accum::no, accum_size::_16> : tuning<__int128_t, 576, 21, 860, 630> {}; template <> struct sm90_tuning<__uint128_t, primitive_op::yes, primitive_accum::no, accum_size::_16> diff --git a/cub/cub/device/dispatch/tuning/tuning_scan_by_key.cuh b/cub/cub/device/dispatch/tuning/tuning_scan_by_key.cuh index cdd2468dc38..419aa059c08 100644 --- a/cub/cub/device/dispatch/tuning/tuning_scan_by_key.cuh +++ b/cub/cub/device/dispatch/tuning/tuning_scan_by_key.cuh @@ -172,7 +172,7 @@ struct sm80_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template struct sm80_tuning { @@ -229,7 +229,7 @@ struct sm80_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template struct sm80_tuning { @@ -286,7 +286,7 @@ struct sm80_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template struct sm80_tuning { @@ -343,7 +343,7 @@ struct sm80_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template struct sm80_tuning { @@ -400,7 +400,7 @@ struct sm80_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template struct sm80_tuning { @@ -465,7 +465,7 @@ struct sm90_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template struct sm90_tuning { @@ -522,7 +522,7 @@ struct sm90_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template struct sm90_tuning { @@ -579,7 +579,7 @@ struct sm90_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template struct sm90_tuning { @@ -636,7 +636,7 @@ struct sm90_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template struct sm90_tuning { @@ -693,7 +693,7 @@ struct sm90_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template struct sm90_tuning { diff --git a/cub/cub/device/dispatch/tuning/tuning_select_if.cuh b/cub/cub/device/dispatch/tuning/tuning_select_if.cuh index 792b1669fa1..6093d187732 100644 --- a/cub/cub/device/dispatch/tuning/tuning_select_if.cuh +++ b/cub/cub/device/dispatch/tuning/tuning_select_if.cuh @@ -121,7 +121,7 @@ struct sm80_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template <> struct sm80_tuning<__int128_t, flagged::no, keep_rejects::no, offset_size::_4, primitive::no, input_size::_16> { @@ -174,7 +174,7 @@ struct sm80_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template <> struct sm80_tuning<__int128_t, flagged::yes, keep_rejects::no, offset_size::_4, primitive::no, input_size::_16> { @@ -227,7 +227,7 @@ struct sm80_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template <> struct sm80_tuning<__int128_t, flagged::no, keep_rejects::yes, offset_size::_4, primitive::no, input_size::_16> { @@ -280,7 +280,7 @@ struct sm80_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template <> struct sm80_tuning<__int128_t, flagged::yes, keep_rejects::yes, offset_size::_4, primitive::no, input_size::_16> { @@ -336,7 +336,7 @@ struct sm90_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template <> struct sm90_tuning<__int128_t, flagged::no, keep_rejects::no, offset_size::_4, primitive::no, input_size::_16> { @@ -389,7 +389,7 @@ struct sm90_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template <> struct sm90_tuning<__int128_t, flagged::yes, keep_rejects::no, offset_size::_4, primitive::no, input_size::_16> { @@ -442,7 +442,7 @@ struct sm90_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template <> struct sm90_tuning<__int128_t, flagged::no, keep_rejects::yes, offset_size::_4, primitive::no, input_size::_16> { @@ -495,7 +495,7 @@ struct sm90_tuning; }; -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() template <> struct sm90_tuning<__int128_t, flagged::yes, keep_rejects::yes, offset_size::_4, primitive::no, input_size::_16> { diff --git a/cub/cub/util_ptx.cuh b/cub/cub/util_ptx.cuh index 99beeed313e..e6bb45c4a31 100644 --- a/cub/cub/util_ptx.cuh +++ b/cub/cub/util_ptx.cuh @@ -99,7 +99,7 @@ BFE(UnsignedBits source, unsigned int bit_start, unsigned int num_bits, Int2Type return (source >> bit_start) & MASK; } -# if CUB_IS_INT128_ENABLED +# if _CCCL_HAS_INT128() /** * Bitfield-extract for 128-bit types. */ diff --git a/cub/cub/util_type.cuh b/cub/cub/util_type.cuh index c6be2a5209f..a89cd159309 100644 --- a/cub/cub/util_type.cuh +++ b/cub/cub/util_type.cuh @@ -76,17 +76,8 @@ _CCCL_DIAG_POP CUB_NAMESPACE_BEGIN #ifndef CUB_IS_INT128_ENABLED -# if defined(__CUDACC_RTC__) -# if defined(__CUDACC_RTC_INT128__) -# define CUB_IS_INT128_ENABLED 1 -# endif // !defined(__CUDACC_RTC_INT128__) -# else // !defined(__CUDACC_RTC__) -# if _CCCL_CUDACC_AT_LEAST(11, 5) -# if _CCCL_COMPILER(GCC) || _CCCL_COMPILER(CLANG) || _CCCL_COMPILER(ICC) || _CCCL_COMPILER(NVHPC) -# define CUB_IS_INT128_ENABLED 1 -# endif // GCC || CLANG || ICC || NVHPC -# endif // _CCCL_CUDACC_AT_LEAST(11, 5) -# endif // !defined(__CUDACC_RTC__) +// Deprecated [Since 2.8] +# define CUB_IS_INT128_ENABLED _CCCL_HAS_INT128() #endif // !defined(CUB_IS_INT128_ENABLED) /****************************************************************************** diff --git a/cub/test/catch2_test_device_for_each_in_extents.cu b/cub/test/catch2_test_device_for_each_in_extents.cu index 6f11810101c..2d87fdfb193 100644 --- a/cub/test/catch2_test_device_for_each_in_extents.cu +++ b/cub/test/catch2_test_device_for_each_in_extents.cu @@ -107,7 +107,7 @@ using index_types = uint16_t, int32_t, uint32_t -# if CUB_IS_INT128_ENABLED +# if _CCCL_HAS_INT128() , int64_t, uint64_t @@ -120,7 +120,7 @@ using index_types_dynamic = uint16_t, int32_t, uint32_t -# if CUB_IS_INT128_ENABLED +# if _CCCL_HAS_INT128() , int64_t, uint64_t diff --git a/cub/test/catch2_test_printing.cu b/cub/test/catch2_test_printing.cu index 6f93515114a..63b622f3554 100644 --- a/cub/test/catch2_test_printing.cu +++ b/cub/test/catch2_test_printing.cu @@ -11,7 +11,7 @@ std::string print(T val) return ss.str(); } -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() TEST_CASE("Test utils can print __int128", "[test][utils]") { REQUIRE(print(__int128_t{0}) == "0"); diff --git a/cub/test/internal/catch2_test_fast_div_mod.cu b/cub/test/internal/catch2_test_fast_div_mod.cu index 8a1a3e96a27..ec3b5e20d68 100644 --- a/cub/test/internal/catch2_test_fast_div_mod.cu +++ b/cub/test/internal/catch2_test_fast_div_mod.cu @@ -42,7 +42,7 @@ using index_types = uint16_t, int32_t, uint32_t -# if CUB_IS_INT128_ENABLED +# if _CCCL_HAS_INT128() , int64_t, uint64_t diff --git a/cub/test/test_util.h b/cub/test/test_util.h index c06d803ecb1..ac472cba693 100644 --- a/cub/test/test_util.h +++ b/cub/test/test_util.h @@ -716,7 +716,7 @@ std::ostream& operator<<(std::ostream& os, const CUB_NS_QUALIFIER::KeyValuePair< return os; } -#if CUB_IS_INT128_ENABLED +#if _CCCL_HAS_INT128() inline std::ostream& operator<<(std::ostream& os, __uint128_t val) { constexpr int max_digits = 40; diff --git a/libcudacxx/include/cuda/std/__cccl/extended_data_types.h b/libcudacxx/include/cuda/std/__cccl/extended_data_types.h index 034ebc51b5f..7f160656e5b 100644 --- a/libcudacxx/include/cuda/std/__cccl/extended_data_types.h +++ b/libcudacxx/include/cuda/std/__cccl/extended_data_types.h @@ -29,7 +29,7 @@ #if !defined(_CCCL_DISABLE_INT128) # if _CCCL_COMPILER(NVRTC) && defined(__CUDACC_RTC_INT128__) && _CCCL_OS(LINUX) # define _CCCL_HAS_INT128() 1 -# elif defined(__SIZEOF_INT128__) && _CCCL_OS(LINUX) +# elif defined(__SIZEOF_INT128__) && _CCCL_OS(LINUX) && _CCCL_CUDACC_AT_LEAST(11, 5) # define _CCCL_HAS_INT128() 1 # else # define _CCCL_HAS_INT128() 0