[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,131 +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.
//
//===----------------------------------------------------------------------===//
#ifndef _CUDAX___KERNEL_ATTRIBUTES_CUH
#define _CUDAX___KERNEL_ATTRIBUTES_CUH
#include <cuda/__cccl_config>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
# pragma GCC system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
# pragma clang system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
# pragma system_header
#endif // no system header
#include <cuda/__device/device_ref.h>
#include <cuda/__driver/driver_api.h>
#include <cuda/__fwd/devices.h>
#include <cuda/std/cstddef>
#include <cuda/experimental/__kernel/kernel_ref.cuh>
#include <cuda/std/__cccl/prologue.h>
namespace cuda::experimental
{
namespace __detail
{
template <::CUfunction_attribute _Attr, typename _Type>
struct __kernel_attr_impl
{
using type = _Type;
[[nodiscard]] constexpr operator ::CUfunction_attribute() const noexcept
{
return _Attr;
}
template <class _Signature>
[[nodiscard]] type operator()(kernel_ref<_Signature> __kernel, device_ref __dev) const
{
return static_cast<type>(
::cuda::__driver::__kernelGetAttribute(_Attr, __kernel.get(), ::cuda::__driver::__deviceGet(__dev.get())));
}
};
template <::CUfunction_attribute _Attr>
struct __kernel_attr : __kernel_attr_impl<_Attr, int>
{};
template <>
struct __kernel_attr<::CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES> //
: __kernel_attr_impl<::CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES, ::cuda::std::size_t>
{};
template <>
struct __kernel_attr<::CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES> //
: __kernel_attr_impl<::CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES, ::cuda::std::size_t>
{};
template <>
struct __kernel_attr<::CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES> //
: __kernel_attr_impl<::CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES, ::cuda::std::size_t>
{};
template <>
struct __kernel_attr<::CU_FUNC_ATTRIBUTE_PTX_VERSION> //
: __kernel_attr_impl<::CU_FUNC_ATTRIBUTE_PTX_VERSION, ::cuda::arch_id>
{};
template <>
struct __kernel_attr<::CU_FUNC_ATTRIBUTE_BINARY_VERSION> //
: __kernel_attr_impl<::CU_FUNC_ATTRIBUTE_BINARY_VERSION, ::cuda::arch_id>
{};
template <>
struct __kernel_attr<::CU_FUNC_ATTRIBUTE_CACHE_MODE_CA> //
: __kernel_attr_impl<::CU_FUNC_ATTRIBUTE_CACHE_MODE_CA, bool>
{};
template <>
struct __kernel_attr<::CU_FUNC_ATTRIBUTE_CLUSTER_SIZE_MUST_BE_SET> //
: __kernel_attr_impl<::CU_FUNC_ATTRIBUTE_CLUSTER_SIZE_MUST_BE_SET, bool>
{};
} // namespace __detail
namespace kernel_attributes
{
// Maximum number of threads per block
using max_threads_per_block_t = __detail::__kernel_attr<::CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK>;
static constexpr max_threads_per_block_t max_threads_per_block{};
// The size in bytes of statically-allocated shared memory required by this kernel
using shared_size_bytes_t = __detail::__kernel_attr<::CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES>;
static constexpr shared_size_bytes_t shared_memory_size{};
// The size in bytes of user-allocated constant memory required by this kernel
using const_size_bytes_t = __detail::__kernel_attr<::CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES>;
static constexpr const_size_bytes_t const_memory_size{};
// The size in bytes of local memory used by each thread of this kernel
using local_size_bytes_t = __detail::__kernel_attr<::CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES>;
static constexpr local_size_bytes_t local_memory_size{};
// The number of registers used by each thread of this kernel
using num_regs_t = __detail::__kernel_attr<::CU_FUNC_ATTRIBUTE_NUM_REGS>;
static constexpr num_regs_t num_regs{};
// The virtual architecture for which the kernel was compiled
using virtual_arch_t = __detail::__kernel_attr<::CU_FUNC_ATTRIBUTE_PTX_VERSION>;
static constexpr virtual_arch_t virtual_arch{};
// The binary (real) architecture for which the kernel was compiled
using binary_arch_t = __detail::__kernel_attr<::CU_FUNC_ATTRIBUTE_BINARY_VERSION>;
static constexpr binary_arch_t binary_arch{};
// The attribute to indicate whether the function has been compiled with user specified option "-Xptxas --dlcm=ca" set
using cache_mode_ca_t = __detail::__kernel_attr<::CU_FUNC_ATTRIBUTE_CACHE_MODE_CA>;
static constexpr cache_mode_ca_t cache_mode_ca{};
// Is the kernel required to be launched with a cluster size?
using requires_cluster_dims_t = __detail::__kernel_attr<::CU_FUNC_ATTRIBUTE_CLUSTER_SIZE_MUST_BE_SET>;
static constexpr requires_cluster_dims_t requires_cluster_dims{};
} // namespace kernel_attributes
} // namespace cuda::experimental
#include <cuda/std/__cccl/epilogue.h>
#endif // _CUDAX___KERNEL_ATTRIBUTES_CUH

View File

@@ -1,169 +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.
//
//===----------------------------------------------------------------------===//
#ifndef _CUDAX___KERNEL_KERNEL_REF
#define _CUDAX___KERNEL_KERNEL_REF
#include <cuda/__cccl_config>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
# pragma GCC system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
# pragma clang system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
# pragma system_header
#endif // no system header
#include <cuda/__device/device_ref.h>
#include <cuda/__driver/driver_api.h>
#include <cuda/__memory/address_space.h>
#include <cuda/__runtime/api_wrapper.h>
#include <cuda/__type_traits/is_trivially_copyable.h>
#include <cuda/std/__type_traits/always_false.h>
#include <cuda/std/__utility/forward.h>
#include <cuda/std/string_view>
#include <string>
#include <cuda.h>
namespace cuda::experimental
{
//! @brief A non-owning representation of a CUDA kernel
//!
//! @tparam _Signature The signature of the kernel
//!
//! @note The return type of the kernel must be `void`
template <class _Signature>
class kernel_ref
{
static_assert(::cuda::std::__always_false_v<_Signature>,
"kernel_ref must have a signature of the form `void(Args...)`");
};
template <class... _Args>
class kernel_ref<void(_Args...)>
{
static_assert((true && ... && ::cuda::is_trivially_copyable_v<_Args>),
"All kernel_ref argument types must be trivially copyable.");
public:
#if _CCCL_CTK_BELOW(12, 1)
using value_type = ::CUkernel;
#else // ^^^ _CCCL_CTK_BELOW(12, 1) ^^^ / vvv _CCCL_CTK_AT_LEAST(12, 1) vvv
using value_type = ::cudaKernel_t;
#endif // ^^^ _CCCL_CTK_AT_LEAST(12, 1) ^^^
kernel_ref(::cuda::std::nullptr_t) = delete;
//! @brief Constructs a `kernel_ref` from a kernel object
//!
//! @param __kernel The kernel object
explicit constexpr kernel_ref(value_type __kernel) noexcept
: __kernel_((::CUkernel) __kernel)
{}
#if _CCCL_CTK_AT_LEAST(12, 1)
//! @brief Constructs a `kernel_ref` from an entry function address
//!
//! @param __entry_func_address The entry function address
//!
//! @throws cuda_error if the kernel cannot be obtained from the entry function address
kernel_ref(void (*__entry_func_address)(_Args...))
{
_CCCL_TRY_CUDA_API(::cudaGetKernel,
"Failed to get kernel from entry function address",
(cudaKernel_t*) &__kernel_,
(const void*) __entry_func_address);
}
#endif // _CCCL_CTK_AT_LEAST(12, 1)
kernel_ref(const kernel_ref&) = default;
#if _CCCL_CTK_AT_LEAST(12, 3)
//! @brief Get the mangled name of the kernel
//!
//! @return The mangled name of the kernel
//!
//! @throws cuda_error if the kernel name cannot be obtained
[[nodiscard]] ::cuda::std::string_view name() const
{
return ::cuda::__driver::__kernelGetName(__kernel_);
}
#endif // _CCCL_CTK_AT_LEAST(12, 3)
//! @brief Retrieve the specified attribute for the kernel on the specified device
//!
//! @param __attr The attribute to query. See `kernel::attributes` for the available
//! attributes.
//! @param __dev The device for which to query the attribute
//!
//! @throws cuda_error if the attribute query fails
//!
//! @sa kernel::attributes
template <typename _Attr>
[[nodiscard]] auto attribute(_Attr __attr, device_ref __dev) const
{
return __attr(*this, __dev);
}
//! @brief Retrieve the native kernel handle
//!
//! @return The native kernel handle
[[nodiscard]] constexpr value_type get() const noexcept
{
return (value_type) __kernel_;
}
//! @brief Compares two `kernel_ref` for equality
//!
//! @param __lhs The first `kernel_ref` to compare
//! @param __rhs The second `kernel_ref` to compare
//! @return true if `lhs` and `rhs` refer to the same kernel
[[nodiscard]] friend constexpr bool operator==(kernel_ref __lhs, kernel_ref __rhs) noexcept
{
return __lhs.__kernel_ == __rhs.__kernel_;
}
//! @brief Compares two `kernel_ref` for inequality
//!
//! @param __lhs The first `kernel_ref` to compare
//! @param __rhs The second `kernel_ref` to compare
//! @return true if `lhs` and `rhs` refer to a different kernels
[[nodiscard]] friend constexpr bool operator!=(kernel_ref __lhs, kernel_ref __rhs) noexcept
{
return !(__lhs == __rhs);
}
private:
::CUkernel __kernel_;
};
#if _CCCL_CTK_AT_LEAST(12, 1)
template <class... _Args>
kernel_ref(void (*)(_Args...)) -> kernel_ref<void(_Args...)>;
#endif // _CCCL_CTK_AT_LEAST(12, 1)
namespace __detail
{
template <class _Tp>
inline constexpr bool __is_kernel_ref_v = false;
template <class _Tp>
inline constexpr bool __is_kernel_ref_v<const _Tp> = __is_kernel_ref_v<_Tp>;
template <class _Tp>
inline constexpr bool __is_kernel_ref_v<volatile _Tp> = __is_kernel_ref_v<_Tp>;
template <class _Tp>
inline constexpr bool __is_kernel_ref_v<const volatile _Tp> = __is_kernel_ref_v<_Tp>;
template <class... _Signature>
inline constexpr bool __is_kernel_ref_v<kernel_ref<_Signature...>> = true;
} // namespace __detail
} // namespace cuda::experimental
#endif // _CUDAX___KERNEL_KERNEL_REF