[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,140 +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__DEVICE_LOGICAL_DEVICE_CUH
|
||||
#define _CUDAX__DEVICE_LOGICAL_DEVICE_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/all_devices.h>
|
||||
#include <cuda/__device/physical_device.h>
|
||||
|
||||
#include <cuda/experimental/__green_context/green_ctx.cuh>
|
||||
|
||||
#include <cuda/std/__cccl/prologue.h>
|
||||
|
||||
namespace cuda::experimental
|
||||
{
|
||||
struct __logical_device_access;
|
||||
|
||||
//! @brief A non-owning representation of a CUDA device or a green context
|
||||
class logical_device
|
||||
{
|
||||
public:
|
||||
//! @brief Enum to indicate the kind of logical device stored
|
||||
enum class kinds
|
||||
{
|
||||
// Indicates logical device is a full device
|
||||
device,
|
||||
// Indicated logical device is a green context
|
||||
green_context
|
||||
};
|
||||
|
||||
// We might want to make this private depending on how this type ends up looking like long term,
|
||||
// not documenting it for now
|
||||
[[nodiscard]] constexpr CUcontext context() const noexcept
|
||||
{
|
||||
return __ctx;
|
||||
}
|
||||
|
||||
//! @brief Retrieve the device on which this logical device resides
|
||||
[[nodiscard]] constexpr device_ref underlying_device() const noexcept
|
||||
{
|
||||
return __dev_id;
|
||||
}
|
||||
|
||||
//! @brief Retrieve the kind of logical device stored in this object
|
||||
//! The kind indicates if this logical_device holds a device or green_context
|
||||
[[nodiscard]] constexpr kinds kind() const noexcept
|
||||
{
|
||||
return __kind;
|
||||
}
|
||||
|
||||
//! @brief Construct logical_device from a device ordinal
|
||||
//!
|
||||
//! Constructing a logical_device for a given device ordinal has a side effect of initializing that device
|
||||
explicit logical_device(int __id)
|
||||
: __dev_id(__id)
|
||||
, __kind(kinds::device)
|
||||
, __ctx(::cuda::__physical_devices()[__id].__primary_context())
|
||||
{}
|
||||
|
||||
//! @brief Construct logical_device from a device_ref
|
||||
//!
|
||||
//! Constructing a logical_device for a given device_ref has a side effect of initializing that device
|
||||
explicit logical_device(device_ref __dev)
|
||||
: logical_device(__dev.get())
|
||||
{}
|
||||
|
||||
#if _CCCL_CTK_AT_LEAST(12, 5)
|
||||
//! @brief Construct logical_device from a green_context
|
||||
logical_device(const green_context& __gctx)
|
||||
: __dev_id(__gctx.__dev_id)
|
||||
, __kind(kinds::green_context)
|
||||
, __ctx(__gctx.__transformed)
|
||||
{}
|
||||
#endif // _CCCL_CTK_AT_LEAST(12, 5)
|
||||
|
||||
//! @brief Compares two logical_devices for equality
|
||||
//!
|
||||
//! @param __lhs The first `logical_device` to compare
|
||||
//! @param __rhs The second `logical_device` to compare
|
||||
//! @return true if `lhs` and `rhs` refer to the same logical device
|
||||
[[nodiscard]] friend bool operator==(logical_device __lhs, logical_device __rhs) noexcept
|
||||
{
|
||||
return __lhs.__ctx == __rhs.__ctx;
|
||||
}
|
||||
|
||||
#if _CCCL_STD_VER <= 2017
|
||||
//! @brief Compares two logical_devices for inequality
|
||||
//!
|
||||
//! @param __lhs The first `logical_device` to compare
|
||||
//! @param __rhs The second `logical_device` to compare
|
||||
//! @return true if `lhs` and `rhs` refer to the different logical device
|
||||
[[nodiscard]] friend bool operator!=(logical_device __lhs, logical_device __rhs) noexcept
|
||||
{
|
||||
return __lhs.__ctx != __rhs.__ctx;
|
||||
}
|
||||
#endif // _CCCL_STD_VER <= 2017
|
||||
|
||||
private:
|
||||
friend __logical_device_access;
|
||||
// This might be a CUdevice as well
|
||||
int __dev_id = 0;
|
||||
kinds __kind;
|
||||
CUcontext __ctx = nullptr;
|
||||
|
||||
logical_device(int __id, CUcontext __context, kinds __k)
|
||||
: __dev_id(__id)
|
||||
, __kind(__k)
|
||||
, __ctx(__context)
|
||||
{}
|
||||
};
|
||||
|
||||
struct __logical_device_access
|
||||
{
|
||||
static logical_device make_logical_device(int __id, CUcontext __context, logical_device::kinds __k)
|
||||
{
|
||||
return logical_device(__id, __context, __k);
|
||||
}
|
||||
};
|
||||
} // namespace cuda::experimental
|
||||
|
||||
#include <cuda/std/__cccl/epilogue.h>
|
||||
|
||||
#endif // _CUDAX__DEVICE_LOGICAL_DEVICE_CUH
|
||||
Reference in New Issue
Block a user