[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,125 +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) 2024 NVIDIA CORPORATION & AFFILIATES.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <cuda/experimental/execution.cuh>
|
||||
|
||||
#include "testing.cuh"
|
||||
|
||||
namespace ex = cudax::execution;
|
||||
|
||||
__host__ __device__ bool _on_device() noexcept
|
||||
{
|
||||
NV_IF_ELSE_TARGET(NV_IS_HOST, //
|
||||
({ return false; }),
|
||||
({ return true; }));
|
||||
}
|
||||
|
||||
auto const main_thread_id = ::std::this_thread::get_id();
|
||||
|
||||
void simple_start_on_thread_test()
|
||||
{
|
||||
ex::thread_context ctx;
|
||||
auto sch = ctx.get_scheduler();
|
||||
auto sndr = ex::on(sch, ex::just() | ex::then([] {
|
||||
CHECK(::std::this_thread::get_id() != main_thread_id);
|
||||
}))
|
||||
| ex::then([]() -> int {
|
||||
CHECK(::std::this_thread::get_id() == main_thread_id);
|
||||
return 42;
|
||||
});
|
||||
auto [result] = ex::sync_wait(std::move(sndr)).value();
|
||||
CHECK(result == 42);
|
||||
}
|
||||
|
||||
void simple_continue_on_thread_test()
|
||||
{
|
||||
ex::thread_context ctx;
|
||||
auto sch = ctx.get_scheduler();
|
||||
auto sndr = ex::just() | ex::on(sch, ex::then([] {
|
||||
CHECK(::std::this_thread::get_id() != main_thread_id);
|
||||
}))
|
||||
| ex::then([]() -> int {
|
||||
CHECK(::std::this_thread::get_id() == main_thread_id);
|
||||
return 42;
|
||||
});
|
||||
auto [result] = ex::sync_wait(std::move(sndr)).value();
|
||||
CHECK(result == 42);
|
||||
}
|
||||
|
||||
void simple_start_on_stream_test()
|
||||
{
|
||||
cudax::stream str{cuda::device_ref(0)};
|
||||
auto sch = cudax::stream_ref{str};
|
||||
auto sndr = ex::on(sch, ex::just(42) | ex::then([] __host__ __device__(int i) noexcept -> int {
|
||||
return _on_device() ? i : -i;
|
||||
}))
|
||||
| ex::then([] __host__ __device__(int i) noexcept -> int {
|
||||
return _on_device() ? -1 : i;
|
||||
});
|
||||
auto [result] = ex::sync_wait(std::move(sndr)).value();
|
||||
CHECK(result == 42);
|
||||
}
|
||||
|
||||
void simple_continue_on_stream_test()
|
||||
{
|
||||
cudax::stream str{cuda::device_ref(0)};
|
||||
auto sch = cudax::stream_ref{str};
|
||||
auto sndr = ex::just(42) | ex::on(sch, ex::then([] __host__ __device__(int i) noexcept -> int {
|
||||
return _on_device() ? i : -i;
|
||||
}))
|
||||
| ex::then([] __host__ __device__(int i) noexcept -> int {
|
||||
return _on_device() ? -1 : i;
|
||||
});
|
||||
auto [result] = ex::sync_wait(std::move(sndr)).value();
|
||||
CHECK(result == 42);
|
||||
}
|
||||
|
||||
void test_continues_on_updates_env()
|
||||
{
|
||||
ex::thread_context ctx;
|
||||
auto sch = ctx.get_scheduler();
|
||||
auto sndr = ex::just() | ex::on(sch, ex::let_value([] {
|
||||
return ex::read_env(ex::get_scheduler);
|
||||
}))
|
||||
| ex::then([](auto sch2) -> int {
|
||||
STATIC_REQUIRE(cuda::std::same_as<decltype(sch2), decltype(sch)>);
|
||||
return 42;
|
||||
});
|
||||
auto [result] = ex::sync_wait(std::move(sndr)).value();
|
||||
CHECK(result == 42);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
C2H_TEST("simple on(sch, sndr) thread test", "[on]")
|
||||
{
|
||||
simple_start_on_thread_test();
|
||||
}
|
||||
|
||||
C2H_TEST("simple on(sndr, sch, closure) thread test", "[on]")
|
||||
{
|
||||
simple_continue_on_thread_test();
|
||||
}
|
||||
|
||||
C2H_TEST("simple on(sch, sndr) stream test", "[on][stream]")
|
||||
{
|
||||
simple_start_on_stream_test();
|
||||
}
|
||||
|
||||
C2H_TEST("simple on(sndr, sch, closure) stream test", "[on][stream]")
|
||||
{
|
||||
simple_continue_on_stream_test();
|
||||
}
|
||||
|
||||
C2H_TEST("test that on(sndr, sch, closure) updates the env for closure", "[on][stream]")
|
||||
{
|
||||
test_continues_on_updates_env();
|
||||
}
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user