Skip to content

Commit

Permalink
Build CUB and Thrust tests with assertions (NVIDIA#2987)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber authored and davebayer committed Dec 2, 2024
1 parent 47163ab commit edf83cb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cub/cub/detail/fast_modulo_division.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ multiply_extract_higher_bits(T value, R multiplier)
{
static_assert(supported_integral<T>::value, "unsupported type");
static_assert(supported_integral<R>::value, "unsupported type");
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_ICC(186) // pointless comparison of unsigned integer with zero
_CCCL_ASSERT(value >= 0, "value must be non-negative");
_CCCL_ASSERT(multiplier >= 0, "multiplier must be non-negative");
_CCCL_DIAG_POP
static constexpr int NumBits = sizeof(DivisorType) * CHAR_BIT;
using unsigned_t = unsigned_implicit_prom_t<DivisorType>;
using larger_t = larger_unsigned_type_t<DivisorType>;
Expand Down
3 changes: 3 additions & 0 deletions cub/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ function(cub_add_test target_name_var test_name test_src cub_target launcher_id)
add_test(NAME ${test_target} COMMAND "$<TARGET_FILE:${test_target}>")
endif()
endif() # Not catch2 test

# Ensure that we test with assertions enabled
target_compile_definitions(${test_target} PRIVATE CCCL_ENABLE_ASSERTIONS)
endfunction()

# Sets out_var to launch id if the label contains launch variants
Expand Down
10 changes: 10 additions & 0 deletions thrust/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ function(thrust_add_test target_name_var test_name test_src thrust_target)
target_compile_definitions(${test_target} PRIVATE THRUST_TEST_DEVICE_SIDE)
endif()

# nvcc < 11.5 generates "error #186-D: pointless comparison of unsigned integer with zero"
# when including <cuda_pipeline_primitives.h> in CUB's dispatch_transform.h,
# despite explicitly suppressing the warning there
if ("NVIDIA" STREQUAL "${CMAKE_CUDA_COMPILER_ID}" AND CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 11.5.0)
target_compile_options(${test_target} PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-Xcudafe=--diag_suppress=186>)
endif ()

# Ensure that we test with assertions enabled
target_compile_definitions(${test_target} PRIVATE CCCL_ENABLE_ASSERTIONS)

thrust_fix_clang_nvcc_build_for(${test_target})

# Add to the active configuration's meta target
Expand Down

0 comments on commit edf83cb

Please sign in to comment.