Skip to content

Commit ff81c72

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into dev
2 parents 91f38eb + 3b9873a commit ff81c72

File tree

14 files changed

+256
-146
lines changed

14 files changed

+256
-146
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ include(${CMAKE_CURRENT_LIST_DIR}/cmake/roaring_testdata.cmake)
9898
# - optionally build tests ------------------------------------------------------------------------
9999

100100
if(BUILD_TESTS)
101+
include(CTest)
101102
add_subdirectory(tests)
103+
# Include header tests as part of the regular test suite
104+
include(cmake/header_testing.cmake)
102105
endif(BUILD_TESTS)
103106

104107
###################################################################################################
@@ -119,6 +122,7 @@ if(BUILD_EXAMPLES)
119122
add_subdirectory(examples)
120123
endif(BUILD_EXAMPLES)
121124

125+
122126
###################################################################################################
123127
# - Install targets -------------------------------------------------------------------------------
124128

cmake/header_testing.cmake

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#=============================================================================
2+
# Copyright (c) 2025, NVIDIA CORPORATION.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#=============================================================================
16+
17+
# For every public header, build a translation unit containing `#include <header>`
18+
# to let the compiler try to figure out warnings in that header if it is not otherwise
19+
# included in tests, and also to verify if the headers are modular enough.
20+
# .inl files are not globbed for, because they are not supposed to be used as public
21+
# entrypoints.
22+
23+
function(cuco_add_header_tests)
24+
file(GLOB_RECURSE headers
25+
RELATIVE "${CUCO_SOURCE_DIR}/include"
26+
CONFIGURE_DEPENDS
27+
"${CUCO_SOURCE_DIR}/include/cuco/*.cuh"
28+
"${CUCO_SOURCE_DIR}/include/cuco/*.hpp"
29+
)
30+
31+
list(LENGTH headers headers_count)
32+
message(STATUS "Found ${headers_count} headers for testing")
33+
34+
# List of headers that have known issues or are not meant to be included directly
35+
set(excluded_headers
36+
# Add any headers that should be excluded from testing here
37+
# Example: cuco/internal_header.cuh
38+
)
39+
40+
# Remove excluded headers
41+
if(excluded_headers)
42+
list(REMOVE_ITEM headers ${excluded_headers})
43+
endif()
44+
45+
foreach (header IN LISTS headers)
46+
# Create a safe target name by replacing path separators and dots
47+
string(REPLACE "/" "_" header_target_name "${header}")
48+
string(REPLACE "." "_" header_target_name "${header_target_name}")
49+
# Use a hash to ensure uniqueness in case of similar names
50+
string(MD5 header_hash "${header}")
51+
string(SUBSTRING "${header_hash}" 0 8 header_hash_short)
52+
set(headertest_target "cuco_header_${header_target_name}_${header_hash_short}")
53+
54+
set(header_src "${CMAKE_CURRENT_BINARY_DIR}/headers/${headertest_target}/${header}.cu")
55+
56+
# Create the directory if it doesn't exist
57+
get_filename_component(header_dir "${header_src}" DIRECTORY)
58+
file(MAKE_DIRECTORY "${header_dir}")
59+
60+
# Write simple test file that includes the header
61+
file(WRITE "${header_src}" "#include <${header}>\nint main() { return 0; }\n")
62+
63+
# Create executable test for this specific header
64+
add_executable(${headertest_target} ${header_src})
65+
target_link_libraries(${headertest_target} PRIVATE cuco::cuco CUDA::cudart)
66+
67+
target_compile_options(${headertest_target} PRIVATE
68+
$<$<COMPILE_LANGUAGE:CUDA>:--expt-extended-lambda>
69+
--compiler-options=-Wall --compiler-options=-Wextra
70+
--compiler-options=-Werror -Wno-deprecated-gpu-targets
71+
)
72+
73+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
74+
target_compile_options(${headertest_target} PRIVATE -Xcompiler -Wno-subobject-linkage)
75+
endif()
76+
77+
set_target_properties(${headertest_target} PROPERTIES
78+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests/headers"
79+
)
80+
81+
# Add as a CTest test
82+
add_test(NAME ${headertest_target} COMMAND ${headertest_target})
83+
endforeach()
84+
endfunction()
85+
86+
cuco_add_header_tests()

include/cuco/detail/bloom_filter/bloom_filter_impl.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <cuco/detail/error.hpp>
2121
#include <cuco/detail/utility/cuda.cuh>
2222
#include <cuco/detail/utility/cuda.hpp>
23+
#include <cuco/detail/utility/math.cuh>
2324
#include <cuco/detail/utils.hpp>
2425
#include <cuco/utility/cuda_thread_scope.cuh>
2526

include/cuco/detail/bloom_filter/kernels.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#pragma once
1717

1818
#include <cuco/detail/utility/cuda.cuh>
19+
#include <cuco/detail/utility/math.cuh>
1920

2021
#include <cuda/std/iterator>
2122

include/cuco/detail/hash_functions/utils.cuh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023-2024, NVIDIA CORPORATION.
2+
* Copyright (c) 2023-2025, NVIDIA CORPORATION.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717
#pragma once
1818

1919
#include <cuda/std/cstddef>
20+
#include <cuda/std/cstdint>
2021

2122
namespace cuco::detail {
2223

@@ -29,12 +30,14 @@ constexpr __host__ __device__ T load_chunk(U const* const data, Extent index) no
2930
return chunk;
3031
}
3132

32-
constexpr __host__ __device__ std::uint32_t rotl32(std::uint32_t x, std::int8_t r) noexcept
33+
constexpr __host__ __device__ cuda::std::uint32_t rotl32(cuda::std::uint32_t x,
34+
cuda::std::int8_t r) noexcept
3335
{
3436
return (x << r) | (x >> (32 - r));
3537
}
3638

37-
constexpr __host__ __device__ std::uint64_t rotl64(std::uint64_t x, std::int8_t r) noexcept
39+
constexpr __host__ __device__ cuda::std::uint64_t rotl64(cuda::std::uint64_t x,
40+
cuda::std::int8_t r) noexcept
3841
{
3942
return (x << r) | (x >> (64 - r));
4043
}

include/cuco/detail/pair/tuple_helpers.inl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, NVIDIA CORPORATION.
2+
* Copyright (c) 2023-2025, NVIDIA CORPORATION.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,8 +26,8 @@ struct tuple_size<volatile cuco::pair<T1, T2>> : tuple_size<cuco::pair<T1, T2>>
2626
template <typename T1, typename T2>
2727
struct tuple_size<const volatile cuco::pair<T1, T2>> : tuple_size<cuco::pair<T1, T2>> {};
2828

29-
template <std::size_t I, typename T1, typename T2>
30-
struct tuple_element<I, cuco::pair<T1, T2>> {
29+
template <std::size_t Index, typename T1, typename T2>
30+
struct tuple_element<Index, cuco::pair<T1, T2>> {
3131
using type = void;
3232
};
3333

@@ -61,48 +61,48 @@ template <typename T1, typename T2>
6161
struct tuple_element<1, const volatile cuco::pair<T1, T2>> : tuple_element<1, cuco::pair<T1, T2>> {
6262
};
6363

64-
template <std::size_t I, typename T1, typename T2>
64+
template <std::size_t Index, typename T1, typename T2>
6565
__host__ __device__ constexpr auto get(cuco::pair<T1, T2>& p) ->
66-
typename tuple_element<I, cuco::pair<T1, T2>>::type&
66+
typename tuple_element<Index, cuco::pair<T1, T2>>::type&
6767
{
68-
static_assert(I < 2);
69-
if constexpr (I == 0) {
68+
static_assert(Index < 2);
69+
if constexpr (Index == 0) {
7070
return p.first;
7171
} else {
7272
return p.second;
7373
}
7474
}
7575

76-
template <std::size_t I, typename T1, typename T2>
76+
template <std::size_t Index, typename T1, typename T2>
7777
__host__ __device__ constexpr auto get(cuco::pair<T1, T2>&& p) ->
78-
typename tuple_element<I, cuco::pair<T1, T2>>::type&&
78+
typename tuple_element<Index, cuco::pair<T1, T2>>::type&&
7979
{
80-
static_assert(I < 2);
81-
if constexpr (I == 0) {
80+
static_assert(Index < 2);
81+
if constexpr (Index == 0) {
8282
return cuda::std::move(p.first);
8383
} else {
8484
return cuda::std::move(p.second);
8585
}
8686
}
8787

88-
template <std::size_t I, typename T1, typename T2>
88+
template <std::size_t Index, typename T1, typename T2>
8989
__host__ __device__ constexpr auto get(cuco::pair<T1, T2> const& p) ->
90-
typename tuple_element<I, cuco::pair<T1, T2>>::type const&
90+
typename tuple_element<Index, cuco::pair<T1, T2>>::type const&
9191
{
92-
static_assert(I < 2);
93-
if constexpr (I == 0) {
92+
static_assert(Index < 2);
93+
if constexpr (Index == 0) {
9494
return p.first;
9595
} else {
9696
return p.second;
9797
}
9898
}
9999

100-
template <std::size_t I, typename T1, typename T2>
100+
template <std::size_t Index, typename T1, typename T2>
101101
__host__ __device__ constexpr auto get(cuco::pair<T1, T2> const&& p) ->
102-
typename tuple_element<I, cuco::pair<T1, T2>>::type const&&
102+
typename tuple_element<Index, cuco::pair<T1, T2>>::type const&&
103103
{
104-
static_assert(I < 2);
105-
if constexpr (I == 0) {
104+
static_assert(Index < 2);
105+
if constexpr (Index == 0) {
106106
return cuda::std::move(p.first);
107107
} else {
108108
return cuda::std::move(p.second);

include/cuco/detail/roaring_bitmap/util.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#pragma once
1818

19+
#include <cuco/detail/error.hpp>
1920
#include <cuco/utility/traits.hpp>
2021

2122
#include <cuda/std/cstddef>

include/cuco/detail/static_map/helpers.cuh

Lines changed: 0 additions & 117 deletions
This file was deleted.

include/cuco/detail/static_map/kernels.cuh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
#include <cuco/detail/bitwise_compare.cuh>
1919
#include <cuco/detail/utility/cuda.cuh>
20+
#include <cuco/operator.hpp>
21+
#include <cuco/pair.cuh>
22+
#include <cuco/types.cuh>
2023

2124
#include <cub/block/block_reduce.cuh>
2225
#include <cuda/atomic>

0 commit comments

Comments
 (0)