[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,143 +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) 2026 NVIDIA CORPORATION & AFFILIATES.
//
//===----------------------------------------------------------------------===//
/**
* @file
*
* @brief AXPY over data distributed across the machine's devices with a
* structured partition specification
*
* The partition ("dimension 0, blocked over the grid of devices") is
* expressed once as a cute_partition. The same description is then used to:
*
* 1. EVALUATE the placement before committing any memory
* (evaluate_localized_placement: bytes per place, placement accuracy);
* 2. back a logical data with a composite data place, so STF tasks operate
* on memory whose pages physically live on the device that owns them;
* 3. perform a raw geometry-aware allocation (allocate_nd(data_dims, elemsize))
* outside of any STF context.
*
* Each place computes its own blocked portion (the idiomatic grid-task
* pattern), so no cross-device access is required; peer/mempool access setup
* is handled by the places machinery itself.
*/
#include <cuda/experimental/stf.cuh>
#include <cmath>
#include <cstdio>
using namespace cuda::experimental::stf;
__global__ void axpy(size_t start, size_t cnt, double a, const double* x, double* y)
{
int tid = blockIdx.x * blockDim.x + threadIdx.x;
int nthreads = gridDim.x * blockDim.x;
for (size_t i = tid; i < cnt; i += nthreads)
{
y[start + i] += a * x[start + i];
}
}
double X0(size_t i)
{
return sin((double) i);
}
double Y0(size_t i)
{
return cos((double) i);
}
int main()
{
// The places machinery enumerates the devices and sets up peer/mempool
// access between them; on a single-GPU machine this is one place.
auto all_devs = exec_place::all_devices();
const size_t nplaces = all_devs.get_dims().size();
const size_t N = 4 * 1024 * 1024;
// "Dimension 0, blocked over grid axis 0" - the per-dimension specification
auto part = make_partition(dim4(N), partition_spec{blocked<0>}, all_devs.get_dims());
// 1. Score the mapping before allocating anything
auto stats = evaluate_localized_placement(all_devs, part, sizeof(double));
printf("Placement over %zu place(s): %zu blocks in %zu allocations, accuracy %.1f%%\n",
nplaces,
stats.nblocks,
stats.nallocs,
100.0 * stats.accuracy());
for (const auto& entry : stats.bytes_per_place)
{
printf(" %s: %.2f MB\n", entry.first.c_str(), entry.second / (1024.0 * 1024.0));
}
// 2. Run STF tasks over logical data placed by the same policy
stream_ctx ctx;
::std::vector<double> X(N), Y(N);
for (size_t i = 0; i < N; i++)
{
X[i] = X0(i);
Y[i] = Y0(i);
}
auto lX = ctx.logical_data(&X[0], {N});
auto lY = ctx.logical_data(&Y[0], {N});
const double alpha = 3.14;
// The composite data place distributes instances across the grid with the
// classic blocked partitioner (the callback form of the same policy)
auto dist = data_place::composite(blocked_partition_custom<0>{}, all_devs);
// One task over the grid; each place computes its own blocked chunk
auto t = ctx.task(all_devs, lX.read(dist), lY.rw(dist));
t->*[&](auto, auto dX, auto dY) {
const size_t chunk = (N + nplaces - 1) / nplaces;
for (size_t i = 0; i < nplaces; i++)
{
const size_t start = i * chunk;
if (start >= N)
{
// With ceil-division chunks, trailing places may have no work
continue;
}
const size_t cnt = ::std::min(chunk, N - start);
auto active = t.activate_place(i);
axpy<<<128, 128, 0, t.get_stream(i)>>>(start, cnt, alpha, dX.data_handle(), dY.data_handle());
}
};
ctx.finalize();
for (size_t i = 0; i < N; i++)
{
if (fabs(Y[i] - (Y0(i) + alpha * X0(i))) > 0.0001)
{
fprintf(stderr, "Verification FAILED at %zu\n", i);
return 1;
}
}
printf("STF task over composite-placed data: verified\n");
// 3. Raw geometry-aware allocation, no STF context involved
auto dp = ::cuda::experimental::places::make_composite_data_place(all_devs, part);
void* raw = dp.allocate_nd(dim4(N), sizeof(double));
auto* d_buf = static_cast<double*>(raw);
cuda_safe_call(cudaMemset(d_buf, 0, N * sizeof(double)));
cuda_safe_call(cudaDeviceSynchronize());
dp.deallocate(raw, N * sizeof(double));
printf("Raw shaped allocation on the partitioned place: OK\n");
return 0;
}