[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:
muh-bot
2026-08-03 12:39:26 +00:00
parent a2a5dd8f00
commit 24ef6a91b5
5439 changed files with 0 additions and 719516 deletions

View File

@@ -1,58 +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 <cuda/std/cstddef>
#include <cuda/experimental/__cuco/capacity.cuh>
#include <cuda/experimental/__cuco/hash_functions.cuh>
#include <cuda/experimental/__cuco/probing_scheme.cuh>
#include <testing.cuh>
namespace cudax = cuda::experimental;
C2H_TEST("cuco make_valid_capacity rounding and validation", "[capacity]")
{
using probing = cudax::cuco::double_hashing<1, cudax::cuco::hash<int>>;
[[maybe_unused]] constexpr int bucket = 1;
static_assert(cudax::cuco::is_double_hashing_v<probing>, "scheme is double hashing");
// make_valid_capacity rounds up and is idempotent; is_valid_capacity is derived from it
constexpr auto valid = cudax::cuco::make_valid_capacity<probing, bucket>(::cuda::std::size_t{1000});
static_assert(valid >= 1000, "rounds up");
static_assert(cudax::cuco::is_valid_capacity<probing, bucket>(valid), "result is valid");
static_assert(cudax::cuco::make_valid_capacity<probing, bucket>(valid) == valid, "idempotent");
// 1000 is not a valid double-hashing capacity; it rounds up to a prime-cycle capacity
static_assert(!cudax::cuco::is_valid_capacity<probing, bucket>(::cuda::std::size_t{1000}), "1000 is not valid");
// equal-rounding requests produce the same valid capacity
static_assert(cudax::cuco::make_valid_capacity<probing, bucket>(::cuda::std::size_t{1000})
== cudax::cuco::make_valid_capacity<probing, bucket>(::cuda::std::size_t{1008}),
"requests that round to the same capacity agree");
// cuCollections extent_test parity: double hashing, cg_size 2, bucket_size 4.
// 1234 rounds up to next_prime(ceil(1234 / 8) = 155) = 157, times the stride 8 -> 1256.
using dh4 = cudax::cuco::double_hashing<2, cudax::cuco::hash<int>>;
[[maybe_unused]] constexpr int bucket4 = 4;
static_assert(cudax::cuco::make_valid_capacity<dh4, bucket4>(::cuda::std::size_t{1234}) == ::cuda::std::size_t{1256},
"compile-time valid capacity matches the cuCollections extent test");
REQUIRE(cudax::cuco::make_valid_capacity<dh4, bucket4>(::cuda::std::size_t{1234}) == ::cuda::std::size_t{1256});
// a desired load factor outside (0, 1] is rejected
using lp4 = cudax::cuco::linear_probing<2, cudax::cuco::hash<int>>;
auto bad_lf = [](double __lf) {
[[maybe_unused]] auto __r = cudax::cuco::make_valid_capacity<lp4, bucket4>(::cuda::std::size_t{1000}, __lf);
};
REQUIRE_THROWS(bad_lf(0.0));
REQUIRE_THROWS(bad_lf(-0.5));
REQUIRE_THROWS(bad_lf(1.5));
}

View File

@@ -1,243 +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) 2025 NVIDIA CORPORATION & AFFILIATES.
//
//===----------------------------------------------------------------------===//
#include <thrust/detail/raw_pointer_cast.h>
#include <cuda/std/array>
#include <cuda/std/cstddef>
#include <cuda/std/functional>
#include <cuda/std/limits>
#include <cuda/std/span>
#include <cuda/experimental/__cuco/hash_functions.cuh>
#include <testing.cuh>
#include <catch2/catch_template_test_macros.hpp>
#include <catch2/catch_test_macros.hpp>
template <int32_t Words>
struct large_key
{
constexpr _CCCL_HOST_DEVICE large_key(int32_t value) noexcept
{
for (int32_t i = 0; i < Words; ++i)
{
data_[i] = value;
}
}
private:
int32_t data_[Words];
};
template <cudax::cuco::hash_algorithm Algorithm>
struct hash_test
{
template <typename Key, typename ResultT, typename... HashConstructorArgs>
_CCCL_HOST_DEVICE void
operator()(Key const& key, ResultT expected, HashConstructorArgs&&... hash_constructor_args) noexcept
{
cudax::cuco::hash<Key, Algorithm> hasher(::cuda::std::forward<HashConstructorArgs>(hash_constructor_args)...);
cuda::std::array<Key, 1> arr_keys = {key};
REQUIRE(hasher(key) == expected);
REQUIRE(hasher(cuda::std::span<Key>(thrust::raw_pointer_cast(arr_keys.data()), arr_keys.size())) == expected);
}
};
struct test_xxhash32
{
hash_test<cudax::cuco::hash_algorithm::xxhash_32> xxhash32_test;
_CCCL_HOST_DEVICE void operator()()
{
xxhash32_test(static_cast<char>(0), 3479547966u, 0);
xxhash32_test(static_cast<char>(42), 3774771295u, 0);
xxhash32_test(static_cast<char>(0), 2099223482u, 42);
xxhash32_test(static_cast<int32_t>(0), 148298089u, 0);
xxhash32_test(static_cast<int32_t>(0), 2132181312u, 42);
xxhash32_test(static_cast<int32_t>(42), 1161967057u, 0);
xxhash32_test(static_cast<int32_t>(123456789), 2987034094u, 0);
xxhash32_test(static_cast<int64_t>(0), 3736311059u, 0);
xxhash32_test(static_cast<int64_t>(0), 1076387279u, 42);
xxhash32_test(static_cast<int64_t>(42), 2332451213u, 0);
xxhash32_test(static_cast<int64_t>(123456789), 1561711919u, 0);
#if _CCCL_HAS_INT128()
xxhash32_test(static_cast<__int128_t>(123456789), 1846633701u, 0);
#endif
xxhash32_test(large_key<32>(123456789), 3715432378u, 0);
}
};
struct test_xxhash64
{
hash_test<cudax::cuco::hash_algorithm::xxhash_64> xxhash64_test;
_CCCL_HOST_DEVICE void operator()()
{
xxhash64_test(static_cast<char>(0), 16804241149081757544ull, 0);
xxhash64_test(static_cast<char>(42), 765293966243412708ull, 0);
xxhash64_test(static_cast<char>(0), 9486749600008296231ull, 42);
xxhash64_test(static_cast<int32_t>(0), 4246796580750024372ull, 0);
xxhash64_test(static_cast<int32_t>(0), 3614696996920510707ull, 42);
xxhash64_test(static_cast<int32_t>(42), 15516826743637085169ull, 0);
xxhash64_test(static_cast<int32_t>(123456789), 9462334144942111946ull, 0);
xxhash64_test(static_cast<int64_t>(0), 3803688792395291579ull, 0);
xxhash64_test(static_cast<int64_t>(0), 13194218611613725804ull, 42);
xxhash64_test(static_cast<int64_t>(42), 13066772586158965587ull, 0);
xxhash64_test(static_cast<int64_t>(123456789), 14662639848940634189ull, 0);
#if _CCCL_HAS_INT128()
xxhash64_test(static_cast<__int128_t>(123456789), 7986913354431084250ull, 0);
#endif
xxhash64_test(large_key<32>(123456789), 2031761887105658523ull, 0);
}
};
struct test_murmurhash3_32
{
hash_test<cudax::cuco::hash_algorithm::murmurhash3_32> murmurhash3_32_test;
_CCCL_HOST_DEVICE void operator()()
{
murmurhash3_32_test(static_cast<char>(0), 1364076727u, 0);
murmurhash3_32_test(static_cast<char>(42), 338914844u, 0);
murmurhash3_32_test(static_cast<char>(0), 3712240066u, 42);
murmurhash3_32_test(static_cast<int32_t>(0), 593689054u, 0);
murmurhash3_32_test(static_cast<int32_t>(0), 933211791u, 42);
murmurhash3_32_test(static_cast<int32_t>(42), 3160117731u, 0);
murmurhash3_32_test(static_cast<int32_t>(123456789), 3206620847u, 0);
murmurhash3_32_test(static_cast<int64_t>(0), 1669671676u, 0);
murmurhash3_32_test(static_cast<int64_t>(0), 2624043101u, 42);
murmurhash3_32_test(static_cast<int64_t>(42), 1871679806u, 0);
murmurhash3_32_test(static_cast<int64_t>(123456789), 690028081u, 0);
#if _CCCL_HAS_INT128()
murmurhash3_32_test(static_cast<__int128_t>(123456789), 2191144977u, 0);
#endif
murmurhash3_32_test(large_key<32>(123456789), 2555553099u, 0);
}
};
#if _CCCL_HAS_INT128()
struct test_murmurhash3_x86_128
{
hash_test<cudax::cuco::hash_algorithm::murmurhash3_x86_128> murmurhash3_x86_128_test;
_CCCL_HOST_DEVICE __uint128_t conv(cuda::std::array<uint32_t, 4> const& arr) const
{
return cuda::std::bit_cast<__uint128_t>(arr);
}
_CCCL_HOST_DEVICE void operator()()
{
murmurhash3_x86_128_test(int32_t(0), conv({3422973727u, 2656139328u, 2656139328u, 2656139328u}), 0);
murmurhash3_x86_128_test(int32_t(9), conv({2808089785u, 314604614u, 314604614u, 314604614u}), 0);
murmurhash3_x86_128_test(int32_t(42), conv({3611919118u, 1962256489u, 1962256489u, 1962256489u}), 0);
murmurhash3_x86_128_test(int32_t(42), conv({3399017053u, 732469929u, 732469929u, 732469929u}), 42);
murmurhash3_x86_128_test(
cuda::std::array<int32_t, 2>{2, 2}, conv({1234494082u, 1431451587u, 431049201u, 431049201u}), 0);
murmurhash3_x86_128_test(
cuda::std::array<int32_t, 3>{1, 4, 9}, conv({2516796247u, 2757675829u, 778406919u, 2453259553u}), 42);
murmurhash3_x86_128_test(
cuda::std::array<int32_t, 4>{42, 64, 108, 1024}, conv({2686265656u, 591236665u, 3797082165u, 2731908938u}), 63);
murmurhash3_x86_128_test(cuda::std::array<int32_t, 16>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
conv({3918256832u, 4205523739u, 1707810111u, 1625952473u}),
1024);
murmurhash3_x86_128_test(
cuda::std::array<int64_t, 2>{2, 2}, conv({3811075945u, 727160712u, 3510740342u, 235225510u}), 0);
murmurhash3_x86_128_test(
cuda::std::array<int64_t, 3>{1, 4, 9}, conv({2817194959u, 206796677u, 3391242768u, 248681098u}), 42);
murmurhash3_x86_128_test(
cuda::std::array<int64_t, 4>{42, 64, 108, 1024}, conv({2335912146u, 1566515912u, 760710030u, 452077451u}), 63);
murmurhash3_x86_128_test(cuda::std::array<int64_t, 16>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
conv({1101169764u, 1758958147u, 2406511780u, 2903571412u}),
1024);
}
};
struct test_murmurhash3_x64_128
{
hash_test<cudax::cuco::hash_algorithm::murmurhash3_x64_128> murmurhash3_x64_128_test;
_CCCL_HOST_DEVICE __uint128_t conv(cuda::std::array<uint64_t, 2> const& arr) const
{
return cuda::std::bit_cast<__uint128_t>(arr);
}
_CCCL_HOST_DEVICE void operator()()
{
murmurhash3_x64_128_test(int32_t(0), conv({14961230494313510588ull, 6383328099726337777ull}), 0);
murmurhash3_x64_128_test(int32_t(9), conv({1779292183511753683ull, 16298496441448380334ull}), 0);
murmurhash3_x64_128_test(int32_t(42), conv({2913627637088662735ull, 16344193523890567190ull}), 0);
murmurhash3_x64_128_test(int32_t(42), conv({2248879576374326886ull, 18006515275339376488ull}), 42);
murmurhash3_x64_128_test(
cuda::std::array<int32_t, 2>{2, 2}, conv({12221386834995143465ull, 6690950894782946573ull}), 0);
murmurhash3_x64_128_test(
cuda::std::array<int32_t, 3>{1, 4, 9}, conv({299140022350411792ull, 9891903873182035274ull}), 42);
murmurhash3_x64_128_test(
cuda::std::array<int32_t, 4>{42, 64, 108, 1024}, conv({4333511168876981289ull, 4659486988434316416ull}), 63);
murmurhash3_x64_128_test(cuda::std::array<int32_t, 16>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
conv({3302412811061286680ull, 7070355726356610672ull}),
1024);
murmurhash3_x64_128_test(
cuda::std::array<int64_t, 2>{2, 2}, conv({8554944597931919519ull, 14938998000509429729ull}), 0);
murmurhash3_x64_128_test(
cuda::std::array<int64_t, 3>{1, 4, 9}, conv({13442629947720186435ull, 7061727494178573325ull}), 42);
murmurhash3_x64_128_test(
cuda::std::array<int64_t, 4>{42, 64, 108, 1024}, conv({8786399719555989948ull, 14954183901757012458ull}), 63);
murmurhash3_x64_128_test(cuda::std::array<int64_t, 16>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
conv({15409921801541329777ull, 10546487400963404004ull}),
1024);
}
};
#endif // _CCCL_HAS_INT128()
template <typename TestFn>
__global__ void test_hasher_kernel(TestFn test_fn)
{
test_fn();
}
template <typename TestFn>
void test_hasher_on_device(TestFn test_fn)
{
test_hasher_kernel<<<1, 1>>>(test_fn);
REQUIRE_CUDART(cudaDeviceSynchronize());
}
TEST_CASE("Test Hasher's on host and device", "")
{
SECTION("host-generated hash values match the reference implementation.")
{
test_xxhash32{}();
test_xxhash64{}();
test_murmurhash3_32{}();
#if _CCCL_HAS_INT128()
test_murmurhash3_x86_128{}();
test_murmurhash3_x64_128{}();
#endif // _CCCL_HAS_INT128()
}
SECTION("device-generated hash values match the reference implementation.")
{
test_hasher_on_device(test_xxhash32{});
test_hasher_on_device(test_xxhash64{});
test_hasher_on_device(test_murmurhash3_32{});
#if _CCCL_HAS_INT128()
test_hasher_on_device(test_murmurhash3_x86_128{});
test_hasher_on_device(test_murmurhash3_x64_128{});
#endif // _CCCL_HAS_INT128()
}
}