Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build CUB and Thrust tests with assertions #2987

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add an _CCCL_IF_CONSTEXPR(_CCCL_TRAIT(is_signed, T))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't entrust ICC with the competency to not issue the warning if we put a runtime if around the assert before C++17. Plus, ICC is going away soon anyway. I would like to keep the code as is.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its less about whether ICC is able to suppress the warning, but whether we want pay the price of the check in debug mode for unsigned integers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry. I thought your comment was related to my warning suppression. Follow-up: #2997

_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
Loading