Skip to content

Commit b2c6965

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into fix-int-namespace
2 parents d966cb7 + 76440b4 commit b2c6965

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2453
-462
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ target_include_directories(cuco INTERFACE
8888
target_link_libraries(cuco INTERFACE CCCL::CCCL CUDA::toolkit)
8989
target_compile_features(cuco INTERFACE cxx_std_17 cuda_std_17)
9090

91+
###################################################################################################
92+
# - Optionally download RoaringFormatSpec test data -----------------------------------------------
93+
94+
option(CUCO_DOWNLOAD_ROARING_TESTDATA "Download RoaringFormatSpec test data" ON)
95+
include(${CMAKE_CURRENT_LIST_DIR}/cmake/roaring_testdata.cmake)
96+
9197
###################################################################################################
9298
# - optionally build tests ------------------------------------------------------------------------
9399

README.md

Lines changed: 10 additions & 3 deletions
Large diffs are not rendered by default.

benchmarks/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function(ConfigureBench BENCH_NAME)
2828
target_include_directories(${BENCH_NAME} PRIVATE
2929
"${CMAKE_CURRENT_SOURCE_DIR}")
3030
target_compile_options(${BENCH_NAME} PRIVATE --compiler-options=-Wall --compiler-options=-Wextra
31-
--compiler-options=-Werror -Wno-deprecated-gpu-targets --expt-extended-lambda)
31+
--compiler-options=-Werror -Wno-deprecated-gpu-targets --expt-extended-lambda -lineinfo)
3232
# Add GCC-specific warning suppression only for GCC
3333
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
3434
target_compile_options(${BENCH_NAME} PRIVATE -Xcompiler -Wno-subobject-linkage)
@@ -104,3 +104,8 @@ ConfigureBench(HYPERLOGLOG_BENCH
104104
ConfigureBench(BLOOM_FILTER_BENCH
105105
bloom_filter/add_bench.cu
106106
bloom_filter/contains_bench.cu)
107+
108+
###################################################################################################
109+
# - roaring_bitmap benchmarks ---------------------------------------------------------------------
110+
ConfigureBench(ROARING_BITMAP_BENCH
111+
roaring_bitmap/contains_bench.cu)
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
#include <benchmark_defaults.hpp>
18+
#include <benchmark_utils.hpp>
19+
20+
#include <cuco/roaring_bitmap.cuh>
21+
#include <cuco/utility/key_generator.cuh>
22+
23+
#include <nvbench/nvbench.cuh>
24+
25+
#include <cuda/std/cstddef>
26+
#include <cuda/std/cstdint>
27+
#include <thrust/device_vector.h>
28+
#include <thrust/universal_vector.h>
29+
30+
#include <filesystem>
31+
#include <fstream>
32+
#include <string>
33+
34+
using namespace cuco::benchmark; // defaults
35+
using namespace cuco::utility; // key_generator, distribution
36+
37+
template <typename T>
38+
void roaring_bitmap_contains(nvbench::state& state, nvbench::type_list<T>)
39+
{
40+
auto const num_items = state.get_int64("NumInputs");
41+
auto const bitmap_file = state.get_string_or_default("BitmapFile", {});
42+
43+
std::ifstream file(bitmap_file, std::ios::binary);
44+
if (!file.is_open()) { state.skip("Bitmap file not found"); }
45+
46+
// Get file size
47+
auto const file_size = std::filesystem::file_size(bitmap_file);
48+
49+
thrust::universal_host_pinned_vector<cuda::std::byte> buffer(file_size);
50+
51+
file.read(reinterpret_cast<char*>(thrust::raw_pointer_cast(buffer.data())), file_size);
52+
file.close();
53+
54+
cuco::experimental::roaring_bitmap<T> roaring_bitmap(thrust::raw_pointer_cast(buffer.data()));
55+
56+
thrust::device_vector<T> items(num_items);
57+
58+
key_generator gen{};
59+
gen.generate(distribution::unique{}, items.begin(), items.end());
60+
61+
thrust::device_vector<bool> contained(items.size(), false);
62+
63+
state.add_element_count(items.size());
64+
state.add_global_memory_reads<T>(items.size(), "InputSize");
65+
66+
auto& summ = state.add_summary("BitmapSizeMB");
67+
summ.set_string("hint", "BitmapSize");
68+
summ.set_string("short_name", "BitmapSizeMB");
69+
summ.set_string("description", "Bitmap size in MB");
70+
summ.set_float64("value", static_cast<double>(file_size) / (1024 * 1024));
71+
72+
state.exec([&](nvbench::launch& launch) {
73+
roaring_bitmap.contains_async(
74+
items.begin(), items.end(), contained.begin(), {launch.get_stream()});
75+
});
76+
}
77+
78+
NVBENCH_BENCH_TYPES(roaring_bitmap_contains,
79+
NVBENCH_TYPE_AXES(nvbench::type_list<nvbench::uint32_t>))
80+
.set_name("roaring_bitmap_contains")
81+
.add_int64_power_of_two_axis("NumInputs", {32})
82+
// Default benchmark is only available if the Roaring bitmap testdata has been downloaded
83+
#ifdef CUCO_ROARING_DATA_DIR
84+
.add_string_axis("BitmapFile", {std::string(CUCO_ROARING_DATA_DIR) + "/bitmapwithruns.bin"})
85+
#endif
86+
.set_max_noise(cuco::benchmark::defaults::MAX_NOISE);
87+
88+
NVBENCH_BENCH_TYPES(roaring_bitmap_contains,
89+
NVBENCH_TYPE_AXES(nvbench::type_list<nvbench::uint64_t>))
90+
.set_name("roaring_bitmap_contains")
91+
.add_int64_power_of_two_axis("NumInputs", {31})
92+
// Default benchmark is only available if the Roaring bitmap testdata has been downloaded
93+
#ifdef CUCO_ROARING_DATA_DIR
94+
.add_string_axis("BitmapFile", {std::string(CUCO_ROARING_DATA_DIR) + "/portable_bitmap64.bin"})
95+
#endif
96+
.set_max_noise(cuco::benchmark::defaults::MAX_NOISE);

ci/build.sh

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ resolve_path() {
3737
# Ensure the script is being executed in its containing directory
3838
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
3939

40+
# Determine repo root as the parent of the `ci` directory
41+
REPO_ROOT="$(cd .. && pwd)"
42+
4043
# Script defaults
4144
BUILD_TESTS=${BUILD_TESTS:-OFF}
4245
BUILD_EXAMPLES=${BUILD_EXAMPLES:-OFF}
@@ -51,6 +54,13 @@ HOST_COMPILER=${CXX:-g++} # $CXX if set, otherwise `g++`
5154
CUDA_ARCHS=native # detect system's GPU architectures
5255
CXX_STANDARD=17
5356

57+
# Initialize CMAKE_ARGS from environment variable if available
58+
if [ -n "${CMAKE_ARGS:-}" ]; then
59+
read -ra CMAKE_ARGS <<< "$CMAKE_ARGS"
60+
else
61+
CMAKE_ARGS=()
62+
fi
63+
5464
function usage {
5565
echo "cuCollections build script"
5666
echo "Usage: $0 [OPTIONS]"
@@ -103,6 +113,16 @@ function usage {
103113
echo " Enables verbose mode for detailed output and builds with C++17 standard."
104114
echo " Build files will be written to <repo_root>/build/local and symlinked to <repo_root>/build/latest."
105115
echo
116+
echo " Using CMAKE_ARGS Environment Variable:"
117+
echo " $ CMAKE_ARGS=\"-DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_FEATURE=ON\" $0 -t"
118+
echo " $ export CMAKE_ARGS=\"-DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_FEATURE=ON\""
119+
echo " $ $0 -t"
120+
echo " Uses CMAKE_ARGS environment variable to pass additional CMake options."
121+
echo " Can be overridden by using -- followed by specific arguments."
122+
echo
123+
echo " Pass-through to CMake:"
124+
echo " -- [CMake args...] Anything after -- is forwarded to CMake (overrides CMAKE_ARGS env var)"
125+
echo
106126
exit 1
107127
}
108128

@@ -126,6 +146,7 @@ while [ "${#args[@]}" -ne 0 ]; do
126146
--arch) CUDA_ARCHS="${args[1]}"; args=("${args[@]:2}");;
127147
--std) CXX_STANDARD="${args[1]}"; args=("${args[@]:2}");;
128148
-v | -verbose | --verbose) VERBOSE=1; args=("${args[@]:1}");;
149+
--) CMAKE_ARGS=("${args[@]:1}"); break;;
129150
-h | -help | --help) usage ;;
130151
*) echo "Unrecognized option: ${args[0]}"; usage ;;
131152
esac
@@ -156,14 +177,12 @@ if [ "$BUILD_TESTS" == "OFF" ] && [ "$BUILD_EXAMPLES" == "OFF" ] && [ "$BUILD_BE
156177
BUILD_BENCHMARKS=ON
157178
fi
158179

180+
BUILD_DIR="$BUILD_PREFIX/$BUILD_INFIX"
159181
# Trigger clean (re-)build
160182
if [ "$CLEAN_BUILD" -eq 1 ]; then
161183
rm -rf BUILD_DIR
162184
fi
163-
164-
BUILD_DIR="$BUILD_PREFIX/$BUILD_INFIX"
165185
mkdir -p $BUILD_DIR
166-
export BUILD_DIR # TODO remove
167186

168187
# The most recent build will be symlinked to cuCollections/build/latest
169188
rm -f $BUILD_PREFIX/latest
@@ -186,12 +205,13 @@ CMAKE_OPTIONS="
186205
-DBUILD_TESTS=${BUILD_TESTS} \
187206
-DBUILD_EXAMPLES=${BUILD_EXAMPLES} \
188207
-DBUILD_BENCHMARKS=${BUILD_BENCHMARKS} \
208+
${CMAKE_ARGS[*]}
189209
"
190210

191-
echo "========================================"
192-
echo "-- START: $(date)"
193-
echo "-- GIT_SHA: $(git rev-parse HEAD 2>/dev/null || echo 'Not a repository')"
194-
echo "-- PWD: $(pwd)"
211+
echo "[INFO]=============================================="
212+
echo "-- TIMESTAMP: $(date -u +"%Y-%m-%d %H:%M:%S UTC")"
213+
echo "-- GIT_SHA: $(git rev-parse HEAD 2>/dev/null || echo 'N/A')"
214+
echo "-- SRC_DIR: ${REPO_ROOT}"
195215
echo "-- BUILD_DIR: ${BUILD_DIR}"
196216
echo "-- BUILD_TYPE: ${BUILD_TYPE}"
197217
echo "-- PARALLEL_LEVEL: ${PARALLEL_LEVEL}"
@@ -200,21 +220,29 @@ echo "-- BUILD_TESTS: ${BUILD_TESTS}"
200220
echo "-- BUILD_EXAMPLES: ${BUILD_EXAMPLES}"
201221
echo "-- BUILD_BENCHMARKS: ${BUILD_BENCHMARKS}"
202222

223+
if [ ${#CMAKE_ARGS[@]} -gt 0 ]; then
224+
echo "-- CMAKE_ARGS: ${CMAKE_ARGS[*]}"
225+
else
226+
echo "-- CMAKE_ARGS: (none)"
227+
fi
228+
203229
# configure
230+
echo "[CONFIGURE]========================================"
204231
cmake -S .. -B $BUILD_DIR $CMAKE_OPTIONS
205-
echo "========================================"
206232

207233
if command -v sccache >/dev/null; then
208234
source "./sccache_stats.sh" start
235+
else
236+
echo "sccache stats: N/A"
209237
fi
210238

211239
#build
240+
echo "[BUILD]============================================"
212241
cmake --build $BUILD_DIR --parallel $PARALLEL_LEVEL
213-
echo "========================================"
214242
echo "Build complete"
215243

216244
if command -v sccache >/dev/null; then
217245
source "./sccache_stats.sh" end
218246
else
219247
echo "sccache stats: N/A"
220-
fi
248+
fi

cmake/roaring_testdata.cmake

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# =============================================================================
2+
# Copyright (c) 2025, NVIDIA CORPORATION.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
# in compliance with the License. You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software distributed under the License
10+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
# or implied. See the License for the specific language governing permissions and limitations under
12+
# the License.
13+
# =============================================================================
14+
15+
# Only act if enabled
16+
if(NOT CUCO_DOWNLOAD_ROARING_TESTDATA)
17+
return()
18+
endif()
19+
20+
set(CUCO_ROARING_DATA_DIR "${CMAKE_BINARY_DIR}/data/roaring_bitmap")
21+
22+
file(MAKE_DIRECTORY "${CUCO_ROARING_DATA_DIR}")
23+
24+
set(ROARING_FORMATSPEC_BASE "https://raw.githubusercontent.com/RoaringBitmap/RoaringFormatSpec/5177ad9")
25+
26+
rapids_cmake_download_with_retry("${ROARING_FORMATSPEC_BASE}/testdata/bitmapwithoutruns.bin"
27+
"${CUCO_ROARING_DATA_DIR}/bitmapwithoutruns.bin"
28+
"d719ae2e0150a362ef7cf51c361527585891f01460b1a92bcfb6a7257282a442")
29+
30+
rapids_cmake_download_with_retry("${ROARING_FORMATSPEC_BASE}/testdata/bitmapwithruns.bin"
31+
"${CUCO_ROARING_DATA_DIR}/bitmapwithruns.bin"
32+
"1f1909bfdd354fa2f0694fe88b8076833ca5383ad9fc3f68f2709c84a2ab70e3")
33+
34+
rapids_cmake_download_with_retry("${ROARING_FORMATSPEC_BASE}/testdata64/portable_bitmap64.bin"
35+
"${CUCO_ROARING_DATA_DIR}/portable_bitmap64.bin"
36+
"b5a553a759167f5f9ccb3fa21552d943b4c73235635b753376f4faf62067d178")
37+
38+
message(STATUS "Roaring Bitmap test data downloaded to: ${CUCO_ROARING_DATA_DIR}")
39+
40+
# Define macro only when data is available
41+
add_compile_definitions(CUCO_ROARING_DATA_DIR="${CUCO_ROARING_DATA_DIR}")

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ ConfigureExample(STATIC_MULTIMAP_HOST_BULK_EXAMPLE "${CMAKE_CURRENT_SOURCE_DIR}/
5252
ConfigureExample(HYPERLOGLOG_HOST_BULK_EXAMPLE "${CMAKE_CURRENT_SOURCE_DIR}/hyperloglog/host_bulk_example.cu")
5353
ConfigureExample(HYPERLOGLOG_DEVICE_REF_EXAMPLE "${CMAKE_CURRENT_SOURCE_DIR}/hyperloglog/device_ref_example.cu")
5454
ConfigureExample(BLOOM_FILTER_HOST_BULK_EXAMPLE "${CMAKE_CURRENT_SOURCE_DIR}/bloom_filter/host_bulk_example.cu")
55+
ConfigureExample(ROARING_BITMAP_HOST_BULK_EXAMPLE "${CMAKE_CURRENT_SOURCE_DIR}/roaring_bitmap/host_bulk_example.cu")

0 commit comments

Comments
 (0)