From 669d268aa6251e47948070e81273b652f1713497 Mon Sep 17 00:00:00 2001 From: Georgy Evtushenko Date: Fri, 21 Jul 2023 16:17:03 +0400 Subject: [PATCH] Fix CUB tests / MSVC 2022 --- cub/cmake/CubBuildCompilerTargets.cmake | 4 ++- .../catch2_test_device_partition_flagged.cu | 25 ++++++++++++------- cub/test/catch2_test_device_select_flagged.cu | 25 +++++++++++-------- cub/test/catch2_test_device_select_unique.cu | 2 +- ...catch2_test_device_select_unique_by_key.cu | 2 +- cub/test/test_device_radix_sort.cu | 2 +- 6 files changed, 37 insertions(+), 23 deletions(-) diff --git a/cub/cmake/CubBuildCompilerTargets.cmake b/cub/cmake/CubBuildCompilerTargets.cmake index e9b0bf0ce3..6a77bc608a 100644 --- a/cub/cmake/CubBuildCompilerTargets.cmake +++ b/cub/cmake/CubBuildCompilerTargets.cmake @@ -4,7 +4,7 @@ # # 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) @@ -12,6 +12,8 @@ function(cub_build_compiler_targets) 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) diff --git a/cub/test/catch2_test_device_partition_flagged.cu b/cub/test/catch2_test_device_partition_flagged.cu index e07faff4a1..61504afa03 100644 --- a/cub/test/catch2_test_device_partition_flagged.cu +++ b/cub/test/catch2_test_device_partition_flagged.cu @@ -115,7 +115,7 @@ CUB_TEST("DevicePartition::Flagged handles all matched", "[device][partition_fla thrust::device_vector out(num_items); c2h::gen(CUB_SEED(2), in); - thrust::device_vector flags(num_items, 1); + thrust::device_vector flags(num_items, static_cast(1)); // Needs to be device accessible thrust::device_vector num_selected_out(1, 0); @@ -140,7 +140,7 @@ CUB_TEST("DevicePartition::Flagged handles no matched", "[device][partition_flag thrust::device_vector out(num_items); c2h::gen(CUB_SEED(2), in); - thrust::device_vector flags(num_items, 0); + thrust::device_vector flags(num_items, static_cast(0)); // Needs to be device accessible thrust::device_vector num_selected_out(1, 0); @@ -170,7 +170,8 @@ CUB_TEST("DevicePartition::Flagged does not change input", "[device][partition_f thrust::device_vector 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(thrust::count(flags.begin(), flags.end(), 1)); // Needs to be device accessible thrust::device_vector num_selected_out(1, 0); @@ -200,7 +201,8 @@ CUB_TEST("DevicePartition::Flagged is stable", "[device][partition_flagged]") thrust::device_vector 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(thrust::count(flags.begin(), flags.end(), 1)); const thrust::host_vector reference = get_reference(in, flags); // Needs to be device accessible @@ -228,7 +230,8 @@ CUB_TEST("DevicePartition::Flagged works with iterators", "[device][partition_fl thrust::device_vector 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(thrust::count(flags.begin(), flags.end(), 1)); const thrust::host_vector reference = get_reference(in, flags); // Needs to be device accessible @@ -256,7 +259,8 @@ CUB_TEST("DevicePartition::Flagged works with pointers", "[device][partition_fla thrust::device_vector 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(thrust::count(flags.begin(), flags.end(), 1)); const thrust::host_vector reference = get_reference(in, flags); // Needs to be device accessible @@ -295,8 +299,9 @@ CUB_TEST("DevicePartition::Flagged works with flags that are convertible to bool thrust::device_vector iflags(num_items); c2h::gen(CUB_SEED(1), iflags, 0, 1); + thrust::device_vector flags = iflags; - const int num_selected = thrust::count(flags.begin(), flags.end(), 1); + const int num_selected = static_cast(thrust::count(flags.begin(), flags.end(), 1)); const thrust::host_vector reference = get_reference(in, flags); // Needs to be device accessible @@ -322,7 +327,8 @@ CUB_TEST("DevicePartition::Flagged works with flags that alias input", "[device] thrust::device_vector 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(thrust::count(flags.begin(), flags.end(), 1)); const thrust::host_vector reference = get_reference(flags, flags); // Needs to be device accessible @@ -363,7 +369,8 @@ CUB_TEST("DevicePartition::Flagged works with different output type", "[device][ thrust::device_vector 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(thrust::count(flags.begin(), flags.end(), 1)); const thrust::host_vector reference = get_reference(in, flags); // Needs to be device accessible diff --git a/cub/test/catch2_test_device_select_flagged.cu b/cub/test/catch2_test_device_select_flagged.cu index 914ba037ae..12a91ed272 100644 --- a/cub/test/catch2_test_device_select_flagged.cu +++ b/cub/test/catch2_test_device_select_flagged.cu @@ -165,7 +165,7 @@ CUB_TEST("DeviceSelect::Flagged does not change input", "[device][select_flagged thrust::device_vector 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(thrust::count(flags.begin(), flags.end(), 1)); // Needs to be device accessible thrust::device_vector num_selected_out(1, 0); @@ -196,7 +196,7 @@ CUB_TEST("DeviceSelect::Flagged is stable", "[device][select_flagged]", thrust::device_vector 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(thrust::count(flags.begin(), flags.end(), 1)); const thrust::host_vector reference = get_reference(in, flags); // Needs to be device accessible @@ -225,7 +225,7 @@ CUB_TEST("DeviceSelect::Flagged works with iterators", "[device][select_flagged] thrust::device_vector 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(thrust::count(flags.begin(), flags.end(), 1)); const thrust::host_vector reference = get_reference(in, flags); // Needs to be device accessible @@ -254,7 +254,8 @@ CUB_TEST("DeviceSelect::Flagged works with pointers", "[device][select_flagged]" thrust::device_vector 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(thrust::count(flags.begin(), flags.end(), 1)); const thrust::host_vector reference = get_reference(in, flags); // Needs to be device accessible @@ -294,8 +295,9 @@ CUB_TEST("DeviceSelect::Flagged works with flags that are convertible to bool", thrust::device_vector iflags(num_items); c2h::gen(CUB_SEED(1), iflags, 0, 1); + thrust::device_vector flags = iflags; - const int num_selected = thrust::count(flags.begin(), flags.end(), 1); + const int num_selected = static_cast(thrust::count(flags.begin(), flags.end(), 1)); const thrust::host_vector reference = get_reference(in, flags); // Needs to be device accessible @@ -322,7 +324,7 @@ CUB_TEST("DeviceSelect::Flagged works with flags that alias input", "[device][se thrust::device_vector 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(thrust::count(flags.begin(), flags.end(), 1)); const thrust::host_vector reference = get_reference(flags, flags); // Needs to be device accessible @@ -350,7 +352,7 @@ CUB_TEST("DeviceSelect::Flagged works in place", "[device][select_if]", types) thrust::device_vector 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 reference = get_reference(in, flags); // Needs to be device accessible @@ -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 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(thrust::count(flags.begin(), flags.end(), 1)); const thrust::host_vector reference = get_reference(flags, flags); // Needs to be device accessible @@ -414,7 +418,8 @@ CUB_TEST("DeviceSelect::Flagged works with a different output type", "[device][s thrust::device_vector 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(thrust::count(flags.begin(), flags.end(), 1)); const thrust::host_vector reference = get_reference(in, flags); // Needs to be device accessible diff --git a/cub/test/catch2_test_device_select_unique.cu b/cub/test/catch2_test_device_select_unique.cu index 062a536238..898919f644 100644 --- a/cub/test/catch2_test_device_select_unique.cu +++ b/cub/test/catch2_test_device_select_unique.cu @@ -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 in(num_items, 1); + thrust::device_vector in(num_items, static_cast(1)); thrust::device_vector out(1); // Needs to be device accessible diff --git a/cub/test/catch2_test_device_select_unique_by_key.cu b/cub/test/catch2_test_device_select_unique_by_key.cu index 7de02baa36..0b14176e36 100644 --- a/cub/test/catch2_test_device_select_unique_by_key.cu +++ b/cub/test/catch2_test_device_select_unique_by_key.cu @@ -145,7 +145,7 @@ CUB_TEST("DeviceSelect::UniqueByKey handles all equal", "[device][select_unique_ using val_type = c2h::custom_type_t; const int num_items = GENERATE_COPY(take(2, random(1, 1000000))); - thrust::device_vector keys_in(num_items, 1); + thrust::device_vector keys_in(num_items, static_cast(1)); thrust::device_vector vals_in(num_items); thrust::device_vector keys_out(1); thrust::device_vector vals_out(1); diff --git a/cub/test/test_device_radix_sort.cu b/cub/test/test_device_radix_sort.cu index 0f13032d4e..b62801ccda 100644 --- a/cub/test/test_device_radix_sort.cu +++ b/cub/test/test_device_radix_sort.cu @@ -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);