[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,45 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of CUDASTF 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) 2022-2024 NVIDIA CORPORATION & AFFILIATES.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <cuda/experimental/__places/place_partition.cuh>
|
||||
#include <cuda/experimental/__stf/internal/stf_places_partition_into_stf.cuh>
|
||||
#include <cuda/experimental/stf.cuh>
|
||||
|
||||
using namespace cuda::experimental::stf;
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _CCCL_CTK_BELOW(12, 4)
|
||||
fprintf(stderr, "Green contexts are not supported by this version of CUDA: skipping test.\n");
|
||||
return 0;
|
||||
#else // ^^^ _CCCL_CTK_BELOW(12, 4) ^^^ / vvv _CCCL_CTK_AT_LEAST(12, 4) vvv
|
||||
|
||||
context ctx;
|
||||
|
||||
auto lX = ctx.logical_data<int>(size_t(32 * 1024 * 1024));
|
||||
|
||||
ctx.parallel_for(lX.shape(), lX.write())->*[] __device__(size_t i, auto x) {
|
||||
x(i) = 3 * i - 7;
|
||||
};
|
||||
|
||||
for (auto& sub_place :
|
||||
place_partition(exec_place::current_device(), ctx.async_resources(), place_partition_scope::green_context))
|
||||
{
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
{
|
||||
ctx.parallel_for(sub_place, lX.shape(), lX.rw())->*[] __device__(size_t i, auto x) {
|
||||
x(i) += 1;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
ctx.finalize();
|
||||
#endif // ^^^ _CCCL_CKT_AT_LEAST(12, 4) ^^^
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of CUDASTF 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) 2022-2024 NVIDIA CORPORATION & AFFILIATES.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <cuda/experimental/__stf/internal/loop_dispatch.cuh>
|
||||
#include <cuda/experimental/stf.cuh>
|
||||
|
||||
using namespace cuda::experimental::stf;
|
||||
|
||||
int main()
|
||||
{
|
||||
context ctx;
|
||||
|
||||
// Loop count
|
||||
int n = 1024;
|
||||
|
||||
auto lB = ctx.logical_data<int>(size_t(1024 * 1024));
|
||||
ctx.parallel_for(lB.shape(), lB.write())->*[] __device__(size_t i, auto b) {
|
||||
b(i) = 42;
|
||||
};
|
||||
|
||||
loop_dispatch(ctx, exec_place::all_devices(), 0, n, [&](size_t) {
|
||||
auto lA = ctx.logical_data<int>(size_t(1024 * 1024));
|
||||
|
||||
ctx.parallel_for(ctx.current_exec_place(), lA.shape(), lA.write())->*[] __device__(size_t i, auto a) {
|
||||
a(i) = (int) (10.0 * cos((double) i));
|
||||
};
|
||||
|
||||
ctx.parallel_for(ctx.current_exec_place(), lA.shape(), lA.rw(), lB.read())->*[] __device__(size_t i, auto a, auto b) {
|
||||
a(i) += b(i);
|
||||
};
|
||||
});
|
||||
|
||||
ctx.finalize();
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of CUDASTF 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) 2022-2024 NVIDIA CORPORATION & AFFILIATES.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <cuda/std/cmath>
|
||||
|
||||
#include <cuda/experimental/__stf/internal/loop_dispatch.cuh>
|
||||
#include <cuda/experimental/stf.cuh>
|
||||
|
||||
using namespace cuda::experimental::stf;
|
||||
|
||||
int main()
|
||||
{
|
||||
context ctx;
|
||||
|
||||
auto lB = ctx.logical_data<int>(size_t(1024 * 1024));
|
||||
|
||||
ctx.parallel_for(lB.shape(), lB.write())->*[] __device__(size_t i, auto b) {
|
||||
b(i) = 42;
|
||||
};
|
||||
|
||||
// A fake grid which should work regardless of the underlying machine
|
||||
auto grid = exec_place::repeat(exec_place::current_device(), 8);
|
||||
|
||||
// Split the affinity into 4 parts
|
||||
loop_dispatch(ctx, grid, place_partition_scope::cuda_device, 0, 4, [&](size_t) {
|
||||
// We should have 2 places per subplace
|
||||
EXPECT(ctx.current_affinity().size() == 2);
|
||||
|
||||
// This should use ctx.current_affinity() implicitly
|
||||
loop_dispatch(ctx, 0, 4, [&](size_t) {
|
||||
auto lA = ctx.logical_data<int>(size_t(1024 * 1024));
|
||||
|
||||
ctx.parallel_for(ctx.current_exec_place(), lA.shape(), lA.write())->*[] __device__(size_t i, auto a) {
|
||||
a(i) = (int) (10.0 * cuda::std::cos((double) i));
|
||||
};
|
||||
|
||||
ctx.parallel_for(ctx.current_exec_place(), lA.shape(), lA.rw(), lB.read())
|
||||
->*[] __device__(size_t i, auto a, auto b) {
|
||||
a(i) += b(i);
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
ctx.finalize();
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of CUDASTF 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) 2022-2024 NVIDIA CORPORATION & AFFILIATES.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <cuda/experimental/__stf/internal/loop_dispatch.cuh>
|
||||
#include <cuda/experimental/stf.cuh>
|
||||
|
||||
using namespace cuda::experimental::stf;
|
||||
|
||||
int main()
|
||||
{
|
||||
stackable_ctx ctx;
|
||||
_CCCL_ASSERT(ctx.has_head_set(), "ctx construction must set head for current thread");
|
||||
|
||||
// Loop count
|
||||
int n = 1024;
|
||||
|
||||
auto lB = ctx.logical_data<int>(size_t(1024 * 1024)).set_symbol("B");
|
||||
ctx.parallel_for(lB.shape(), lB.write())->*[] __device__(size_t i, auto b) {
|
||||
b(i) = 42;
|
||||
};
|
||||
|
||||
lB.set_read_only(true);
|
||||
|
||||
for (size_t iter = 0; iter < 4; iter++)
|
||||
{
|
||||
loop_dispatch(ctx, exec_place::all_devices(), place_partition_scope::green_context, 0, n, [&](size_t iter) {
|
||||
auto lA = ctx.logical_data<int>(size_t(1024 * 1024)).set_symbol(::std::string("A") + ::std::to_string(iter));
|
||||
|
||||
ctx.parallel_for(ctx.current_exec_place(), lA.shape(), lA.write()).set_symbol("pfor1" + ::std::to_string(iter))
|
||||
->*[] __device__(size_t i, auto a) {
|
||||
a(i) = (int) (10.0 * cos((double) i));
|
||||
};
|
||||
|
||||
ctx.parallel_for(ctx.current_exec_place(), lA.shape(), lA.rw(), lB.read())
|
||||
.set_symbol("pfor2" + ::std::to_string(iter))
|
||||
->*[] __device__(size_t i, auto a, auto b) {
|
||||
a(i) += b(i);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
ctx.finalize();
|
||||
}
|
||||
Reference in New Issue
Block a user