[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,118 +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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Toy example to reproduce the asynchrony of a 1F1B pipeline
|
||||
*/
|
||||
|
||||
#include <cuda/experimental/stf.cuh>
|
||||
|
||||
using namespace cuda::experimental::stf;
|
||||
|
||||
__global__ void forward(slice<int>, long long int clock_cnt)
|
||||
{
|
||||
long long int start_clock = clock64();
|
||||
long long int clock_offset = 0;
|
||||
while (clock_offset < clock_cnt)
|
||||
{
|
||||
clock_offset = clock64() - start_clock;
|
||||
}
|
||||
}
|
||||
|
||||
__global__ void backward(slice<int>, long long int clock_cnt)
|
||||
{
|
||||
long long int start_clock = clock64();
|
||||
long long int clock_offset = 0;
|
||||
while (clock_offset < clock_cnt)
|
||||
{
|
||||
clock_offset = clock64() - start_clock;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
context ctx;
|
||||
// Use a graph context if the second argument is set and not null
|
||||
if (argc > 2 && atoi(argv[2]))
|
||||
{
|
||||
ctx = graph_ctx();
|
||||
}
|
||||
|
||||
int device;
|
||||
cudaGetDevice(&device);
|
||||
|
||||
// cudaDevAttrClockRate: Peak clock frequency in kilohertz;
|
||||
int clock_rate;
|
||||
cudaDeviceGetAttribute(&clock_rate, cudaDevAttrClockRate, device);
|
||||
|
||||
auto occ_f = reserved::compute_occupancy(forward);
|
||||
auto occ_b = reserved::compute_occupancy(backward);
|
||||
|
||||
int factor = 1;
|
||||
if (argc > 1)
|
||||
{
|
||||
factor = atoi(argv[1]);
|
||||
}
|
||||
|
||||
size_t num_batches = 8 * factor;
|
||||
int num_devs = 8;
|
||||
int real_devs;
|
||||
cuda_safe_call(cudaGetDeviceCount(&real_devs));
|
||||
|
||||
std::vector<logical_data<slice<int>>> data;
|
||||
|
||||
for (size_t b = 0; b < num_batches; b++)
|
||||
{
|
||||
auto batch_data = ctx.logical_data(shape_of<slice<int>>(1024));
|
||||
data.push_back(batch_data);
|
||||
|
||||
ctx.task(exec_place::device(0), data[b].write())->*[](cudaStream_t, auto) {
|
||||
// Init ...
|
||||
};
|
||||
}
|
||||
|
||||
cuda_safe_call(cudaStreamSynchronize(ctx.fence()));
|
||||
|
||||
size_t niter = 10;
|
||||
|
||||
for (size_t iter = 0; iter < niter; iter++)
|
||||
{
|
||||
for (size_t b = 0; b < num_batches; b++)
|
||||
{
|
||||
for (int d = 0; d < num_devs; d++)
|
||||
{
|
||||
ctx.task(exec_place::device(d % real_devs), data[b].rw())->*[=](cudaStream_t s, auto bd) {
|
||||
int ms = 10;
|
||||
long long int clock_cnt = (long long int) (ms * clock_rate / factor);
|
||||
forward<<<occ_f.min_grid_size, occ_f.block_size, 0, s>>>(bd, clock_cnt);
|
||||
};
|
||||
}
|
||||
// }
|
||||
//
|
||||
// for (size_t b = 0; b < num_batches; b++) {
|
||||
for (int d = num_devs; d-- > 0;)
|
||||
{
|
||||
ctx.task(exec_place::device(d % real_devs), data[b].rw())->*[=](cudaStream_t s, auto bd) {
|
||||
int ms = 20;
|
||||
long long int clock_cnt = (long long int) (ms * clock_rate / factor);
|
||||
backward<<<occ_b.min_grid_size, occ_b.block_size, 0, s>>>(bd, clock_cnt);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/* We introduce a fence because the actual pipeline would introduce
|
||||
* some all to all communication to update coefficients */
|
||||
cuda_safe_call(cudaStreamSynchronize(ctx.fence()));
|
||||
}
|
||||
|
||||
ctx.finalize();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user