Skip to content

Commit

Permalink
Ensure compilation with C++11
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber committed May 7, 2024
1 parent 374b63c commit f22eef2
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions cub/test/test_device_histogram.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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<unsigned int>::max();
return static_cast<T>((static_cast<float>(bits) / max) * max_level); // TODO(bgruber): this could use a better
// generator
return static_cast<T>(static_cast<float>(bits) / static_cast<float>(max) * max_level); // TODO(bgruber): this could
// use a better generator
}

template <int NUM_CHANNELS, int NUM_ACTIVE_CHANNELS, typename LevelT, typename SampleT, typename OffsetT>
Expand Down Expand Up @@ -470,7 +470,7 @@ void TestHistogramEven(
_CCCL_IF_CONSTEXPR (!std::is_integral<LevelT>::value)
{
fpScales[channel] =
LevelT{1.0f}
LevelT{1}
/ static_cast<LevelT>(
(upper_level[channel] - lower_level[channel]) / static_cast<LevelT>(num_levels[channel] - 1));
}
Expand Down Expand Up @@ -1143,7 +1143,10 @@ void TestChannels(LevelT max_level, int max_num_levels)
{
// TODO(bgruber): replace TestChannelsImpl with if constexpr in C++17
TestChannelsImpl<SampleT, CounterT, LevelT, OffsetT>(
max_level, max_num_levels, std::bool_constant<TestExtraChannels>{}, std::bool_constant<ActuallyRun>{});
max_level,
max_num_levels,
std::integral_constant<bool, TestExtraChannels>{},
std::integral_constant<bool, ActuallyRun>{}); // TODO(bgruber): use std::bool_constant with C++17
}

void TestLevelsAliasing()
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f22eef2

Please sign in to comment.