From ac81fd51727200400d77445d5fb0670d64fb6b3f Mon Sep 17 00:00:00 2001 From: Bernhard Manfred Gruber Date: Tue, 14 Jan 2025 15:56:40 +0100 Subject: [PATCH] Replace cub::Traits by numeric_limits and deprecate Fixes: #3381 --- c2h/generators.cu | 27 +- c2h/include/c2h/bfloat16.cuh | 26 +- c2h/include/c2h/custom_type.h | 11 +- c2h/include/c2h/generators.h | 45 +-- c2h/include/c2h/half.cuh | 30 +- c2h/include/c2h/test_util_vec.h | 298 +++++++++++------ cub/benchmarks/bench/reduce/arg_extrema.cu | 4 +- .../nvbench_helper/nvbench_helper.cuh | 22 +- cub/cub/block/radix_rank_sort_operations.cuh | 26 +- cub/cub/device/device_reduce.cuh | 14 +- cub/cub/device/device_segmented_reduce.cuh | 15 +- cub/cub/util_type.cuh | 305 +++++++++++------- cub/test/catch2_radix_sort_helper.cuh | 10 +- cub/test/catch2_test_block_radix_sort.cu | 3 +- cub/test/catch2_test_device_histogram.cu | 11 +- .../catch2_test_device_radix_sort_keys.cu | 2 +- cub/test/catch2_test_device_reduce.cuh | 34 +- cub/test/catch2_test_device_reduce_by_key.cu | 2 +- cub/test/catch2_test_device_scan.cu | 6 +- cub/test/catch2_test_device_scan_iterators.cu | 4 +- .../catch2_test_device_segmented_reduce.cu | 4 +- cub/test/test_util.h | 58 ++-- .../is_extended_floating_point.h | 20 ++ .../meta.unary.cat/is_floating_point.pass.cpp | 4 + 24 files changed, 535 insertions(+), 446 deletions(-) diff --git a/c2h/generators.cu b/c2h/generators.cu index 8044eabe6fe..771cc234c90 100644 --- a/c2h/generators.cu +++ b/c2h/generators.cu @@ -40,7 +40,7 @@ #include #include -#include +#include #include @@ -118,30 +118,7 @@ private: c2h::device_vector m_distribution; }; -// TODO(bgruber): modelled after cub::Traits. We should generalize this somewhere into libcu++. -template -struct is_floating_point : ::cuda::std::is_floating_point -{}; -#ifdef _CCCL_HAS_NVFP16 -template <> -struct is_floating_point<__half> : ::cuda::std::true_type -{}; -#endif // _CCCL_HAS_NVFP16 -#ifdef _CCCL_HAS_NVBF16 -template <> -struct is_floating_point<__nv_bfloat16> : ::cuda::std::true_type -{}; -#endif // _CCCL_HAS_NVBF16 -#ifdef __CUDA_FP8_TYPES_EXIST__ -template <> -struct is_floating_point<__nv_fp8_e4m3> : ::cuda::std::true_type -{}; -template <> -struct is_floating_point<__nv_fp8_e5m2> : ::cuda::std::true_type -{}; -#endif // __CUDA_FP8_TYPES_EXIST__ - -template ::value> +template > struct random_to_item_t { float m_min; diff --git a/c2h/include/c2h/bfloat16.cuh b/c2h/include/c2h/bfloat16.cuh index b7598562715..77701936bca 100644 --- a/c2h/include/c2h/bfloat16.cuh +++ b/c2h/include/c2h/bfloat16.cuh @@ -211,6 +211,10 @@ struct bfloat16_t } }; +#ifdef __GNUC__ +# pragma GCC diagnostic pop +#endif + /****************************************************************************** * I/O stream overloads ******************************************************************************/ @@ -229,28 +233,28 @@ inline std::ostream& operator<<(std::ostream& out, const __nv_bfloat16& x) } /****************************************************************************** - * Traits overloads + * limits ******************************************************************************/ +_LIBCUDACXX_BEGIN_NAMESPACE_STD template <> -struct CUB_NS_QUALIFIER::FpLimits +class numeric_limits { - static __host__ __device__ __forceinline__ bfloat16_t Max() +public: + static __host__ __device__ __forceinline__ bfloat16_t max() { return bfloat16_t::max(); } - static __host__ __device__ __forceinline__ bfloat16_t Lowest() + static __host__ __device__ __forceinline__ bfloat16_t lowest() { return bfloat16_t::lowest(); } }; +_LIBCUDACXX_END_NAMESPACE_STD template <> -struct CUB_NS_QUALIFIER::NumericTraits - : CUB_NS_QUALIFIER::BaseTraits -{}; - -#ifdef __GNUC__ -# pragma GCC diagnostic pop -#endif +struct CUB_NS_QUALIFIER::detail::unsigned_bits +{ + using type = unsigned short; +}; diff --git a/c2h/include/c2h/custom_type.h b/c2h/include/c2h/custom_type.h index ddbceef388a..e8759481eec 100644 --- a/c2h/include/c2h/custom_type.h +++ b/c2h/include/c2h/custom_type.h @@ -178,13 +178,12 @@ class accumulateable_t } // namespace c2h -namespace std -{ +_LIBCUDACXX_BEGIN_NAMESPACE_STD template