From f22eef2e14a7b065f37cd8668280697d307fe03b Mon Sep 17 00:00:00 2001 From: Bernhard Manfred Gruber Date: Mon, 6 May 2024 10:03:27 +0200 Subject: [PATCH] Ensure compilation with C++11 --- cub/test/test_device_histogram.cu | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/cub/test/test_device_histogram.cu b/cub/test/test_device_histogram.cu index 350f5e00d0f..b3912632190 100644 --- a/cub/test/test_device_histogram.cu +++ b/cub/test/test_device_histogram.cu @@ -82,7 +82,7 @@ auto castIfArrayOfHalfPointers(T** p) -> T** } #if TEST_HALF_T -auto castIfHalfPointer(half_t* p) +auto castIfHalfPointer(half_t* p) -> __half* { return reinterpret_cast<__half*>(p); } @@ -290,8 +290,8 @@ auto GenerateSample(LevelT max_level, int entropy_reduction) -> T unsigned int bits; RandomBits(bits, entropy_reduction); const auto max = std::numeric_limits::max(); - return static_cast((static_cast(bits) / max) * max_level); // TODO(bgruber): this could use a better - // generator + return static_cast(static_cast(bits) / static_cast(max) * max_level); // TODO(bgruber): this could + // use a better generator } template @@ -470,7 +470,7 @@ void TestHistogramEven( _CCCL_IF_CONSTEXPR (!std::is_integral::value) { fpScales[channel] = - LevelT{1.0f} + LevelT{1} / static_cast( (upper_level[channel] - lower_level[channel]) / static_cast(num_levels[channel] - 1)); } @@ -1143,7 +1143,10 @@ void TestChannels(LevelT max_level, int max_num_levels) { // TODO(bgruber): replace TestChannelsImpl with if constexpr in C++17 TestChannelsImpl( - max_level, max_num_levels, std::bool_constant{}, std::bool_constant{}); + max_level, + max_num_levels, + std::integral_constant{}, + std::integral_constant{}); // TODO(bgruber): use std::bool_constant with C++17 } void TestLevelsAliasing() @@ -1161,7 +1164,8 @@ void TestLevelsAliasing() 11, 11, 11, 11, 11, 11 // bin 5 }; - constexpr int num_samples = std::size(h_samples); + constexpr int num_samples = sizeof(h_samples) / sizeof(h_samples[0]); // TODO(bgruber) use std::size(h_samples) in + // C++17 int* d_histogram = nullptr; int* d_samples = nullptr; @@ -1206,7 +1210,8 @@ void TestIntegerBinCalcs() constexpr int lower_level = 0; constexpr int upper_level = 12; - constexpr int num_samples = std::size(h_samples); + constexpr int num_samples = sizeof(h_samples) / sizeof(h_samples[0]); // TODO(bgruber) use std::size(h_samples) in + // C++17 int* d_histogram = nullptr; int* d_samples = nullptr;