[INFRA] Import NVIDIA/CCCL upstream as optimization reference library

CCCL (CUDA C++ Core Libraries) provides:
- CUB: device/block/warp-level GPU primitives (reduce, scan, sort, topk)
- Thrust: high-level parallel algorithms (transform_reduce, sort, scan)
- libcudacxx: CUDA C++ standard library (atomics, barriers, memory)
- cudax: experimental features (memory resources, allocators)
- Tuning policies: per-SM hardware-specific algorithm parameters

Competition optimization vectors mapped to CCCL:
- Output TPS (83% weight): warp_reduce, block_reduce, device_topk
- Input TPS (14% weight): device_scan, block_load, prefetch
- Cache TPS (3% weight): prefix caching strategy patterns
- Memory (0.9 util): pooled/cached/buddy allocators

Source: https://github.com/NVIDIA/cccl (shallow clone, HEAD only)
License: Apache-2.0
This commit is contained in:
EngineX CI
2026-07-30 09:35:51 +00:00
parent b4d01f481e
commit 56fd68e7dd
8871 changed files with 1454674 additions and 0 deletions

View File

@@ -0,0 +1,127 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, 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 NVIDIA CORPORATION & AFFILIATES.
//
//===----------------------------------------------------------------------===//
#ifndef _CUDA_STD___EXPECTED_BAD_EXPECTED_ACCESS_H
#define _CUDA_STD___EXPECTED_BAD_EXPECTED_ACCESS_H
#include <cuda/std/detail/__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/std/__exception/terminate.h>
#include <cuda/std/__utility/forward.h>
#include <cuda/std/__utility/move.h>
#include <nv/target>
#if _CCCL_HAS_EXCEPTIONS()
# if __cpp_lib_expected >= 202202L
# include <expected>
# else // ^^^ __cpp_lib_expected >= 202202L ^^^ / vvv __cpp_lib_expected < 202202L vvv
# include <exception>
# endif // ^^^ __cpp_lib_expected < 202202L ^^^
#endif // !_CCCL_HAS_EXCEPTIONS()
#include <cuda/std/__cccl/prologue.h>
_CCCL_BEGIN_NAMESPACE_CUDA_STD
#if _CCCL_HAS_EXCEPTIONS()
# if __cpp_lib_expected >= 202202L
using ::std::bad_expected_access;
# else // ^^^ __cpp_lib_expected >= 202202L ^^^ / vvv __cpp_lib_expected < 202202L vvv
template <class _Err>
class bad_expected_access;
template <>
class bad_expected_access<void> : public ::std::exception
{
public:
// The way this has been designed (by using a class template below) means that we'll already
// have a profusion of these vtables in TUs, and the dynamic linker will already have a bunch
// of work to do. So it is not worth hiding the <void> specialization in the dylib, given that
// it adds deployment target restrictions.
const char* what() const noexcept override
{
return "bad access to cuda::std::expected";
}
};
template <class _Err>
class bad_expected_access : public bad_expected_access<void>
{
public:
# if _CCCL_CUDA_COMPILER(CLANG) // Clang needs this or it breaks with device only types
_CCCL_HOST_DEVICE
# endif // _CCCL_CUDA_COMPILER(CLANG)
_CCCL_HIDE_FROM_ABI explicit bad_expected_access(_Err __e)
: __unex_(::cuda::std::move(__e))
{}
# if _CCCL_CUDA_COMPILER(CLANG) // Clang needs this or it breaks with device only types
_CCCL_HOST_DEVICE
# endif // _CCCL_CUDA_COMPILER(CLANG)
_CCCL_HIDE_FROM_ABI ~bad_expected_access() noexcept override
{
__unex_.~_Err();
}
_CCCL_API inline _Err& error() & noexcept
{
return __unex_;
}
_CCCL_API inline const _Err& error() const& noexcept
{
return __unex_;
}
_CCCL_API inline _Err&& error() && noexcept
{
return ::cuda::std::move(__unex_);
}
_CCCL_API inline const _Err&& error() const&& noexcept
{
return ::cuda::std::move(__unex_);
}
private:
_Err __unex_;
};
# endif // ^^^ __cpp_lib_expected < 202202L ^^^
#endif // _CCCL_HAS_EXCEPTIONS()
template <class _Err, class _Arg>
[[noreturn]] _CCCL_API inline void __throw_bad_expected_access([[maybe_unused]] _Arg&& __arg)
{
#if _CCCL_HAS_EXCEPTIONS()
NV_IF_ELSE_TARGET(NV_IS_HOST,
(throw ::cuda::std::bad_expected_access<_Err>(::cuda::std::forward<_Arg>(__arg));),
((void) __arg; ::cuda::std::terminate();))
#else // ^^^ _CCCL_HAS_EXCEPTIONS() ^^^ / vvv !_CCCL_HAS_EXCEPTIONS() vvv
::cuda::std::terminate();
#endif // !_CCCL_HAS_EXCEPTIONS()
}
_CCCL_END_NAMESPACE_CUDA_STD
#include <cuda/std/__cccl/epilogue.h>
#endif // _CUDA_STD___EXPECTED_BAD_EXPECTED_ACCESS_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,37 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, 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 NVIDIA CORPORATION & AFFILIATES.
//
//===----------------------------------------------------------------------===//
#ifndef _CUDA_STD___EXPECTED_UNEXPECT_H
#define _CUDA_STD___EXPECTED_UNEXPECT_H
#include <cuda/std/detail/__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/std/__cccl/prologue.h>
_CCCL_BEGIN_NAMESPACE_CUDA_STD
struct unexpect_t
{
_CCCL_HIDE_FROM_ABI explicit unexpect_t() = default;
};
_CCCL_GLOBAL_CONSTANT unexpect_t unexpect{};
_CCCL_END_NAMESPACE_CUDA_STD
#include <cuda/std/__cccl/epilogue.h>
#endif // _CUDA_STD___EXPECTED_UNEXPECT_H

View File

@@ -0,0 +1,166 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, 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 NVIDIA CORPORATION & AFFILIATES.
//
//===----------------------------------------------------------------------===//
#ifndef _CUDA_STD___EXPECTED_UNEXPECTED_H
#define _CUDA_STD___EXPECTED_UNEXPECTED_H
#include <cuda/std/detail/__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/std/__concepts/concept_macros.h>
#include <cuda/std/__fwd/unexpected.h>
#include <cuda/std/__type_traits/integral_constant.h>
#include <cuda/std/__type_traits/is_array.h>
#include <cuda/std/__type_traits/is_const.h>
#include <cuda/std/__type_traits/is_constructible.h>
#include <cuda/std/__type_traits/is_nothrow_constructible.h>
#include <cuda/std/__type_traits/is_object.h>
#include <cuda/std/__type_traits/is_same.h>
#include <cuda/std/__type_traits/is_swappable.h>
#include <cuda/std/__type_traits/is_volatile.h>
#include <cuda/std/__type_traits/remove_cvref.h>
#include <cuda/std/__utility/forward.h>
#include <cuda/std/__utility/in_place.h>
#include <cuda/std/__utility/move.h>
#include <cuda/std/initializer_list>
#include <cuda/std/__cccl/prologue.h>
_CCCL_BEGIN_NAMESPACE_CUDA_STD
namespace __unexpected
{
template <class _Tp>
inline constexpr bool __valid_unexpected =
is_object_v<_Tp> && !is_array_v<_Tp> && !__is_cuda_std_unexpected<_Tp> && !is_const_v<_Tp> && !is_volatile_v<_Tp>;
} // namespace __unexpected
// [expected.un.general]
template <class _Err>
class unexpected
{
static_assert(__unexpected::__valid_unexpected<_Err>,
"[expected.un.general] states a program that instantiates std::unexpected for a non-object type, an "
"array type, a specialization of unexpected, or a cv-qualified type is ill-formed.");
template <class, class>
friend class expected;
public:
// [expected.un.ctor]
_CCCL_HIDE_FROM_ABI unexpected(const unexpected&) = default;
_CCCL_HIDE_FROM_ABI unexpected(unexpected&&) = default;
// NOLINTBEGIN(bugprone-forwarding-reference-overload)
_CCCL_EXEC_CHECK_DISABLE
_CCCL_TEMPLATE(class _Error = _Err)
_CCCL_REQUIRES((!is_same_v<remove_cvref_t<_Error>, unexpected> && !is_same_v<remove_cvref_t<_Error>, in_place_t>
&& is_constructible_v<_Err, _Error>) )
_CCCL_API constexpr explicit unexpected(_Error&& __error) noexcept(is_nothrow_constructible_v<_Err, _Error>)
: __unex_(::cuda::std::forward<_Error>(__error))
{}
// NOLINTEND(bugprone-forwarding-reference-overload)
_CCCL_EXEC_CHECK_DISABLE
_CCCL_TEMPLATE(class... _Args)
_CCCL_REQUIRES(is_constructible_v<_Err, _Args...>)
_CCCL_API constexpr explicit unexpected(in_place_t,
_Args&&... __args) noexcept(is_nothrow_constructible_v<_Err, _Args...>)
: __unex_(::cuda::std::forward<_Args>(__args)...)
{}
_CCCL_EXEC_CHECK_DISABLE
_CCCL_TEMPLATE(class _Up, class... _Args)
_CCCL_REQUIRES(is_constructible_v<_Err, initializer_list<_Up>&, _Args...>)
_CCCL_API constexpr explicit unexpected(in_place_t, initializer_list<_Up> __il, _Args&&... __args) noexcept(
is_nothrow_constructible_v<_Err, initializer_list<_Up>&, _Args...>)
: __unex_(__il, ::cuda::std::forward<_Args>(__args)...)
{}
_CCCL_HIDE_FROM_ABI constexpr unexpected& operator=(const unexpected&) = default;
_CCCL_HIDE_FROM_ABI constexpr unexpected& operator=(unexpected&&) = default;
// [expected.un.obs]
[[nodiscard]] _CCCL_API constexpr const _Err& error() const& noexcept
{
return __unex_;
}
[[nodiscard]] _CCCL_API constexpr _Err& error() & noexcept
{
return __unex_;
}
[[nodiscard]] _CCCL_API constexpr const _Err&& error() const&& noexcept
{
return ::cuda::std::move(__unex_);
}
[[nodiscard]] _CCCL_API constexpr _Err&& error() && noexcept
{
return ::cuda::std::move(__unex_);
}
// [expected.un.swap]
_CCCL_EXEC_CHECK_DISABLE
_CCCL_API constexpr void swap(unexpected& __other) noexcept(is_nothrow_swappable_v<_Err>)
{
static_assert(is_swappable_v<_Err>, "E must be swappable");
using ::cuda::std::swap;
swap(__unex_, __other.__unex_);
}
_CCCL_EXEC_CHECK_DISABLE
_CCCL_TEMPLATE(class _Err2 = _Err)
_CCCL_REQUIRES(is_swappable_v<_Err2>)
_CCCL_API friend constexpr void swap(unexpected& __lhs, unexpected& __rhs) noexcept(is_nothrow_swappable_v<_Err2>)
{
__lhs.swap(__rhs);
return;
}
// [expected.un.eq]
_CCCL_EXEC_CHECK_DISABLE
template <class _UErr>
[[nodiscard]] _CCCL_API friend constexpr bool
operator==(const unexpected& __lhs,
const unexpected<_UErr>& __rhs) noexcept(noexcept(static_cast<bool>(__lhs.error() == __rhs.error())))
{
return __lhs.error() == __rhs.error();
}
#if _CCCL_STD_VER < 2020
_CCCL_EXEC_CHECK_DISABLE
template <class _UErr>
[[nodiscard]] _CCCL_API friend constexpr bool
operator!=(const unexpected& __lhs,
const unexpected<_UErr>& __rhs) noexcept(noexcept(static_cast<bool>(__lhs.error() != __rhs.error())))
{
return __lhs.error() != __rhs.error();
}
#endif // _CCCL_STD_VER < 2020
private:
_Err __unex_;
};
template <class _Err>
unexpected(_Err) -> unexpected<_Err>;
_CCCL_END_NAMESPACE_CUDA_STD
#include <cuda/std/__cccl/epilogue.h>
#endif // _CUDA_STD___EXPECTED_UNEXPECTED_H