[CCCL] 瘦身 + 补全: 移除 cudax/python/libcudacxx-tests 冗余文件, 新增 c2h 测试助手 + cmake 构建系统 + 8 个 CUDA thrust examples
变更摘要:
- 删除: cudax/ (783 files, 7.2M) — 实验性组件,竞赛不需要
- 删除: python/ (226 files, 2.0M) — Python 绑定,竞赛不需要
- 删除: libcudacxx/{test,benchmarks,codegen,cmake,share} (4432 files, 31M)
保留: libcudacxx/include/ (1463 headers, cuda::std 编译依赖)
- 新增: c2h/ (27 files) — CUB Catch2 测试辅助头文件,编译 243 个测试必需
- 新增: cmake/ (29 files) — CCCL 原生 CMake 构建系统
- 新增: thrust/examples/cuda/ (7 files) + cpp_integration/ (1 file)
async_reduce, custom_temporary_allocation, explicit_cuda_stream,
global_device_vector, range_view, unwrap_pointer, wrap_pointer, device
结果: cccl_upstream 从 74M→35M (瘦身 53%), 核心内容 100% 保留:
27/27 tuning headers, 78 benchmarks, 243 tests,
60 thrust examples, 18 CUB examples, 全部编译头文件
This commit is contained in:
@@ -1,133 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of CUDA Experimental in CUDA C++ Core Libraries,
|
||||
// under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <thrust/execution_policy.h>
|
||||
#include <thrust/sequence.h>
|
||||
|
||||
#include <cuda/buffer>
|
||||
#include <cuda/memory_resource>
|
||||
#include <cuda/std/cmath>
|
||||
#include <cuda/std/cstddef>
|
||||
#include <cuda/stream>
|
||||
|
||||
#include <cuda/experimental/__cuco/hyperloglog.cuh>
|
||||
|
||||
#include "common/defaults.cuh"
|
||||
#include <nvbench/nvbench.cuh>
|
||||
|
||||
namespace cudax = cuda::experimental;
|
||||
namespace bench = cudax::cuco::benchmark;
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename Key>
|
||||
void add_relative_error_summary(
|
||||
nvbench::state& state,
|
||||
cudax::cuco::hyperloglog<Key>& estimator,
|
||||
cuda::stream_ref stream,
|
||||
Key* first,
|
||||
cuda::std::size_t num_items)
|
||||
{
|
||||
estimator.add(stream, first, first + num_items);
|
||||
const auto estimated_cardinality = estimator.estimate(stream);
|
||||
const auto relative_error =
|
||||
cuda::std::abs(static_cast<double>(estimated_cardinality) / static_cast<double>(num_items) - 1.0);
|
||||
estimator.clear(stream);
|
||||
|
||||
auto& summary = state.add_summary("RelativeError");
|
||||
summary.set_string("hint", "RelErr");
|
||||
summary.set_string("short_name", "RelativeError");
|
||||
summary.set_string("description", "Relative approximation error.");
|
||||
summary.set_float64("value", relative_error);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
/**
|
||||
* @brief A benchmark evaluating `cudax::cuco::hyperloglog` end-to-end performance.
|
||||
*/
|
||||
template <typename Key>
|
||||
void hyperloglog_e2e(nvbench::state& state, nvbench::type_list<Key>)
|
||||
{
|
||||
using estimator_type = cudax::cuco::hyperloglog<Key>;
|
||||
using sketch_size_kb_type = typename estimator_type::sketch_size_kb;
|
||||
|
||||
const auto num_items = static_cast<cuda::std::size_t>(state.get_int64("NumInputs"));
|
||||
const auto sketch_size_kb = sketch_size_kb_type{static_cast<double>(state.get_int64("SketchSizeKB"))};
|
||||
|
||||
const auto device = cuda::device_ref{0};
|
||||
cuda::stream stream{device};
|
||||
const cuda::device_memory_pool_ref mr = cuda::device_default_memory_pool(device);
|
||||
|
||||
auto items = cuda::make_device_buffer<Key>(stream, device, num_items, cuda::no_init);
|
||||
thrust::sequence(thrust::cuda::par_nosync.on(stream.get()), items.begin(), items.end(), Key{0});
|
||||
|
||||
estimator_type estimator{stream, mr, sketch_size_kb};
|
||||
stream.sync();
|
||||
|
||||
state.add_element_count(num_items);
|
||||
state.add_global_memory_reads<Key>(num_items, "InputSize");
|
||||
|
||||
add_relative_error_summary(state, estimator, stream, items.data(), num_items);
|
||||
|
||||
state.exec(nvbench::exec_tag::sync | nvbench::exec_tag::timer, [&](nvbench::launch& launch, auto& timer) {
|
||||
timer.start();
|
||||
estimator.add_async({launch.get_stream()}, items.begin(), items.end());
|
||||
[[maybe_unused]] const auto estimated_cardinality = estimator.estimate({launch.get_stream()});
|
||||
timer.stop();
|
||||
|
||||
estimator.clear_async({launch.get_stream()});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A benchmark evaluating `cudax::cuco::hyperloglog::add_async` performance.
|
||||
*/
|
||||
template <typename Key>
|
||||
void hyperloglog_add(nvbench::state& state, nvbench::type_list<Key>)
|
||||
{
|
||||
using estimator_type = cudax::cuco::hyperloglog<Key>;
|
||||
using sketch_size_kb_type = typename estimator_type::sketch_size_kb;
|
||||
|
||||
const auto num_items = static_cast<cuda::std::size_t>(state.get_int64("NumInputs"));
|
||||
const auto sketch_size_kb = sketch_size_kb_type{static_cast<double>(state.get_int64("SketchSizeKB"))};
|
||||
|
||||
const auto device = cuda::device_ref{0};
|
||||
cuda::stream stream{device};
|
||||
const cuda::device_memory_pool_ref mr = cuda::device_default_memory_pool(device);
|
||||
|
||||
auto items = cuda::make_device_buffer<Key>(stream, device, num_items, cuda::no_init);
|
||||
thrust::sequence(thrust::cuda::par_nosync.on(stream.get()), items.begin(), items.end(), Key{0});
|
||||
|
||||
estimator_type estimator{stream, mr, sketch_size_kb};
|
||||
stream.sync();
|
||||
|
||||
state.add_element_count(num_items);
|
||||
state.add_global_memory_reads<Key>(num_items, "InputSize");
|
||||
|
||||
state.exec(nvbench::exec_tag::timer, [&](nvbench::launch& launch, auto& timer) {
|
||||
timer.start();
|
||||
estimator.add_async({launch.get_stream()}, items.begin(), items.end());
|
||||
timer.stop();
|
||||
|
||||
estimator.clear_async({launch.get_stream()});
|
||||
});
|
||||
}
|
||||
|
||||
NVBENCH_BENCH_TYPES(hyperloglog_e2e, NVBENCH_TYPE_AXES(bench::defaults::key_type_range))
|
||||
.set_name("hyperloglog_e2e")
|
||||
.set_type_axes_names({"Key"})
|
||||
.add_int64_power_of_two_axis("NumInputs", {30})
|
||||
.add_int64_axis("SketchSizeKB", {8, 16, 32, 64, 128, 256});
|
||||
|
||||
NVBENCH_BENCH_TYPES(hyperloglog_add, NVBENCH_TYPE_AXES(bench::defaults::key_type_range))
|
||||
.set_name("hyperloglog_add")
|
||||
.set_type_axes_names({"Key"})
|
||||
.add_int64_power_of_two_axis("NumInputs", {30})
|
||||
.add_int64_axis("SketchSizeKB", {8, 16, 32, 64, 128, 256});
|
||||
Reference in New Issue
Block a user