Skip to content

Commit

Permalink
Merge pull request #255 from senior-zero/fix-main/github/msvc
Browse files Browse the repository at this point in the history
Fix CUB tests / MSVC 2022
  • Loading branch information
gevtushenko committed Jul 21, 2023
2 parents 96af536 + 669d268 commit 06fd8af
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 23 deletions.
4 changes: 3 additions & 1 deletion cub/cmake/CubBuildCompilerTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
#
# cub.compiler_interface
# - Interface target providing compiler-specific options needed to build
# Thrust's tests, examples, etc.
# CUB's tests, examples, etc.

function(cub_build_compiler_targets)
set(cxx_compile_definitions)
set(cxx_compile_options)
set(cuda_compile_options)

if ("MSVC" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
list(APPEND cxx_compile_definitions _ENABLE_EXTENDED_ALIGNED_STORAGE)

append_option_if_available("/W4" cxx_compile_options)

append_option_if_available("/WX" cxx_compile_options)
Expand Down
25 changes: 16 additions & 9 deletions cub/test/catch2_test_device_partition_flagged.cu
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ CUB_TEST("DevicePartition::Flagged handles all matched", "[device][partition_fla
thrust::device_vector<type> out(num_items);
c2h::gen(CUB_SEED(2), in);

thrust::device_vector<char> flags(num_items, 1);
thrust::device_vector<char> flags(num_items, static_cast<char>(1));

// Needs to be device accessible
thrust::device_vector<int> num_selected_out(1, 0);
Expand All @@ -140,7 +140,7 @@ CUB_TEST("DevicePartition::Flagged handles no matched", "[device][partition_flag
thrust::device_vector<type> out(num_items);
c2h::gen(CUB_SEED(2), in);

thrust::device_vector<char> flags(num_items, 0);
thrust::device_vector<char> flags(num_items, static_cast<char>(0));

// Needs to be device accessible
thrust::device_vector<int> num_selected_out(1, 0);
Expand Down Expand Up @@ -170,7 +170,8 @@ CUB_TEST("DevicePartition::Flagged does not change input", "[device][partition_f

thrust::device_vector<int> flags(num_items);
c2h::gen(CUB_SEED(1), flags, 0, 1);
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);

const int num_selected = static_cast<int>(thrust::count(flags.begin(), flags.end(), 1));

// Needs to be device accessible
thrust::device_vector<int> num_selected_out(1, 0);
Expand Down Expand Up @@ -200,7 +201,8 @@ CUB_TEST("DevicePartition::Flagged is stable", "[device][partition_flagged]")

thrust::device_vector<int> flags(num_items);
c2h::gen(CUB_SEED(1), flags, 0, 1);
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);

const int num_selected = static_cast<int>(thrust::count(flags.begin(), flags.end(), 1));
const thrust::host_vector<type> reference = get_reference(in, flags);

// Needs to be device accessible
Expand Down Expand Up @@ -228,7 +230,8 @@ CUB_TEST("DevicePartition::Flagged works with iterators", "[device][partition_fl

thrust::device_vector<int> flags(num_items);
c2h::gen(CUB_SEED(1), flags, 0, 1);
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);

const int num_selected = static_cast<int>(thrust::count(flags.begin(), flags.end(), 1));
const thrust::host_vector<type> reference = get_reference(in, flags);

// Needs to be device accessible
Expand Down Expand Up @@ -256,7 +259,8 @@ CUB_TEST("DevicePartition::Flagged works with pointers", "[device][partition_fla

thrust::device_vector<int> flags(num_items);
c2h::gen(CUB_SEED(1), flags, 0, 1);
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);

const int num_selected = static_cast<int>(thrust::count(flags.begin(), flags.end(), 1));
const thrust::host_vector<type> reference = get_reference(in, flags);

// Needs to be device accessible
Expand Down Expand Up @@ -295,8 +299,9 @@ CUB_TEST("DevicePartition::Flagged works with flags that are convertible to bool

thrust::device_vector<int> iflags(num_items);
c2h::gen(CUB_SEED(1), iflags, 0, 1);

thrust::device_vector<convertible_to_bool> flags = iflags;
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);
const int num_selected = static_cast<int>(thrust::count(flags.begin(), flags.end(), 1));
const thrust::host_vector<type> reference = get_reference(in, flags);

// Needs to be device accessible
Expand All @@ -322,7 +327,8 @@ CUB_TEST("DevicePartition::Flagged works with flags that alias input", "[device]

thrust::device_vector<int> flags(num_items);
c2h::gen(CUB_SEED(1), flags, 0, 1);
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);

const int num_selected = static_cast<int>(thrust::count(flags.begin(), flags.end(), 1));
const thrust::host_vector<type> reference = get_reference(flags, flags);

// Needs to be device accessible
Expand Down Expand Up @@ -363,7 +369,8 @@ CUB_TEST("DevicePartition::Flagged works with different output type", "[device][

thrust::device_vector<int> flags(num_items);
c2h::gen(CUB_SEED(1), flags, 0, 1);
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);

const int num_selected = static_cast<int>(thrust::count(flags.begin(), flags.end(), 1));
const thrust::host_vector<type> reference = get_reference(in, flags);

// Needs to be device accessible
Expand Down
25 changes: 15 additions & 10 deletions cub/test/catch2_test_device_select_flagged.cu
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ CUB_TEST("DeviceSelect::Flagged does not change input", "[device][select_flagged

thrust::device_vector<int> flags(num_items);
c2h::gen(CUB_SEED(1), flags, 0, 1);
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);
const int num_selected = static_cast<int>(thrust::count(flags.begin(), flags.end(), 1));

// Needs to be device accessible
thrust::device_vector<int> num_selected_out(1, 0);
Expand Down Expand Up @@ -196,7 +196,7 @@ CUB_TEST("DeviceSelect::Flagged is stable", "[device][select_flagged]",

thrust::device_vector<int> flags(num_items);
c2h::gen(CUB_SEED(1), flags, 0, 1);
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);
const int num_selected = static_cast<int>(thrust::count(flags.begin(), flags.end(), 1));
const thrust::host_vector<type> reference = get_reference(in, flags);

// Needs to be device accessible
Expand Down Expand Up @@ -225,7 +225,7 @@ CUB_TEST("DeviceSelect::Flagged works with iterators", "[device][select_flagged]

thrust::device_vector<int> flags(num_items);
c2h::gen(CUB_SEED(1), flags, 0, 1);
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);
const int num_selected = static_cast<int>(thrust::count(flags.begin(), flags.end(), 1));
const thrust::host_vector<type> reference = get_reference(in, flags);

// Needs to be device accessible
Expand Down Expand Up @@ -254,7 +254,8 @@ CUB_TEST("DeviceSelect::Flagged works with pointers", "[device][select_flagged]"

thrust::device_vector<int> flags(num_items);
c2h::gen(CUB_SEED(1), flags, 0, 1);
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);

const int num_selected = static_cast<int>(thrust::count(flags.begin(), flags.end(), 1));
const thrust::host_vector<type> reference = get_reference(in, flags);

// Needs to be device accessible
Expand Down Expand Up @@ -294,8 +295,9 @@ CUB_TEST("DeviceSelect::Flagged works with flags that are convertible to bool",

thrust::device_vector<int> iflags(num_items);
c2h::gen(CUB_SEED(1), iflags, 0, 1);

thrust::device_vector<convertible_to_bool> flags = iflags;
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);
const int num_selected = static_cast<int>(thrust::count(flags.begin(), flags.end(), 1));
const thrust::host_vector<type> reference = get_reference(in, flags);

// Needs to be device accessible
Expand All @@ -322,7 +324,7 @@ CUB_TEST("DeviceSelect::Flagged works with flags that alias input", "[device][se

thrust::device_vector<int> flags(num_items);
c2h::gen(CUB_SEED(1), flags, 0, 1);
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);
const int num_selected = static_cast<int>(thrust::count(flags.begin(), flags.end(), 1));
const thrust::host_vector<type> reference = get_reference(flags, flags);

// Needs to be device accessible
Expand Down Expand Up @@ -350,7 +352,7 @@ CUB_TEST("DeviceSelect::Flagged works in place", "[device][select_if]", types)

thrust::device_vector<int> flags(num_items);
c2h::gen(CUB_SEED(1), flags, 0, 1);
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);

const thrust::host_vector<type> reference = get_reference(in, flags);

// Needs to be device accessible
Expand All @@ -370,10 +372,12 @@ CUB_TEST("DeviceSelect::Flagged works in place with flags that alias input", "[d
{
using type = int;

const int num_items = GENERATE_COPY(take(2, random(1, 1000000)));
const int num_items = GENERATE_COPY(take(2, random(1, 1000000)));
thrust::device_vector<int> flags(num_items);

c2h::gen(CUB_SEED(1), flags, 0, 1);
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);

const int num_selected = static_cast<int>(thrust::count(flags.begin(), flags.end(), 1));
const thrust::host_vector<type> reference = get_reference(flags, flags);

// Needs to be device accessible
Expand Down Expand Up @@ -414,7 +418,8 @@ CUB_TEST("DeviceSelect::Flagged works with a different output type", "[device][s

thrust::device_vector<int> flags(num_items);
c2h::gen(CUB_SEED(1), flags, 0, 1);
const int num_selected = thrust::count(flags.begin(), flags.end(), 1);

const int num_selected = static_cast<int>(thrust::count(flags.begin(), flags.end(), 1));
const thrust::host_vector<type> reference = get_reference(in, flags);

// Needs to be device accessible
Expand Down
2 changes: 1 addition & 1 deletion cub/test/catch2_test_device_select_unique.cu
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ CUB_TEST("DeviceSelect::Unique handles all equal", "[device][select_unique]", ty
using type = typename c2h::get<0, TestType>;

const int num_items = GENERATE_COPY(take(2, random(1, 1000000)));
thrust::device_vector<type> in(num_items, 1);
thrust::device_vector<type> in(num_items, static_cast<type>(1));
thrust::device_vector<type> out(1);

// Needs to be device accessible
Expand Down
2 changes: 1 addition & 1 deletion cub/test/catch2_test_device_select_unique_by_key.cu
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ CUB_TEST("DeviceSelect::UniqueByKey handles all equal", "[device][select_unique_
using val_type = c2h::custom_type_t<c2h::equal_comparable_t>;

const int num_items = GENERATE_COPY(take(2, random(1, 1000000)));
thrust::device_vector<type> keys_in(num_items, 1);
thrust::device_vector<type> keys_in(num_items, static_cast<type>(1));
thrust::device_vector<val_type> vals_in(num_items);
thrust::device_vector<type> keys_out(1);
thrust::device_vector<val_type> vals_out(1);
Expand Down
2 changes: 1 addition & 1 deletion cub/test/test_device_radix_sort.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,7 @@ void TestGen(
TestSizes(h_keys.get(), large_num_items, max_segments, true);
fflush(stdout);
}
catch (std::bad_alloc &e)
catch (std::bad_alloc &)
{
printf("\nNot enough host memory, skipping large num items test\n");
fflush(stdout);
Expand Down

0 comments on commit 06fd8af

Please sign in to comment.