[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,5 @@
add_custom_target(libcudacxx.test.nvtarget)
add_subdirectory(arch_specific)
add_subdirectory(dialect)
add_subdirectory(family_specific)

View File

@@ -0,0 +1,20 @@
if (NOT "${CMAKE_CUDA_COMPILER_ID}" STREQUAL "NVIDIA")
return()
endif()
# arch-specific features are supported since 12.9
if ("${CMAKE_CUDA_COMPILER_VERSION}" VERSION_LESS "12.9")
return()
endif()
set_directory_properties(
PROPERTIES INCLUDE_DIRECTORIES "${libcudacxx_SOURCE_DIR}/include"
)
set(target_name "libcudacxx.test.nvtarget.arch_specific")
add_library(${target_name} OBJECT arch_specific.cu)
set_target_properties(
${target_name}
PROPERTIES CUDA_ARCHITECTURES "103a-virtual"
)
add_dependencies(libcudacxx.test.nvtarget ${target_name})

View File

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// Part of libcu++, the C++ Standard Library for your entire system,
// 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.
//
//===----------------------------------------------------------------------===//
// This test checks if arch-specific NV target macros work properly.
#include <nv/target>
// Currently, nvcc is the only compiler that supports arch-specific architectures.
#if !defined(__NVCC__)
# error "This test works with nvcc only."
#endif // !__NVCC__
#if defined(__CUDA_ARCH__)
# if __CUDA_ARCH_SPECIFIC__ != 1030
# error "This test must be compiled for sm_103a target."
# endif // __CUDA_ARCH_SPECIFIC__ != 1030
#endif // __CUDA_ARCH__
#define CHECK_TRUE(_PRED) \
do \
{ \
NV_IF_ELSE_TARGET(_PRED, static_assert(true);, static_assert(false);) \
} while (0)
#define CHECK_FALSE(_PRED) \
do \
{ \
NV_IF_ELSE_TARGET(_PRED, static_assert(false);, static_assert(true);) \
} while (0)
#ifdef __CUDACC_TILE__
__tile__
#endif // __CUDACC_TILE__
__host__ __device__ void
fn()
{
#if defined(__CUDA_ARCH__)
CHECK_TRUE(NV_IS_EXACTLY_SM_103);
CHECK_TRUE(NV_HAS_FEATURE_SM_103a);
CHECK_TRUE(NV_HAS_FEATURE_SM_100f);
CHECK_TRUE(NV_HAS_FEATURE_SM_103f);
#else // ^^^ __CUDA_ARCH__ ^^^ / vvv !__CUDA_ARCH__ vvv
CHECK_TRUE(NV_IS_HOST);
CHECK_FALSE(NV_HAS_FEATURE_SM_103a);
CHECK_FALSE(NV_HAS_FEATURE_SM_100f);
CHECK_FALSE(NV_HAS_FEATURE_SM_103f);
#endif // ^^^ !__CUDA_ARCH__ ^^^
CHECK_FALSE(NV_HAS_FEATURE_SM_100a);
CHECK_FALSE(NV_HAS_FEATURE_SM_110a);
CHECK_FALSE(NV_HAS_FEATURE_SM_110f);
}

View File

@@ -0,0 +1,47 @@
# This unit just checks that nv/target can be used with the specified dialects.
set(nvtarget_dialects 11 14 17 20)
# cudafe++ 12.9 has problem compiling some parts of <type_traits> when using libstdc++ 14, so let's just filter out
# dialect version 11.
if (
"${CMAKE_CUDA_COMPILER_ID}" STREQUAL "NVIDIA"
AND "${CMAKE_CUDA_COMPILER_VERSION}" VERSION_GREATER_EQUAL "12.9"
AND "${CMAKE_CUDA_COMPILER_VERSION}" VERSION_LESS "13.0"
AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"
AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_GREATER_EQUAL "14.0"
AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "15.0"
)
list(FILTER nvtarget_dialects EXCLUDE REGEX "^11$")
endif()
set_directory_properties(
PROPERTIES INCLUDE_DIRECTORIES "${libcudacxx_SOURCE_DIR}/include"
)
foreach (dialect ${nvtarget_dialects})
if ("cxx_std_${dialect}" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
set(target_name "libcudacxx.test.nvtarget.dialect.cpp${dialect}")
add_library(${target_name} OBJECT nvtargettest.cpp)
# This is required to override CMAKE_CXX_STANDARD - target_compile_features is insufficient.
set_target_properties(
${target_name}
PROPERTIES CXX_STANDARD "${dialect}" CXX_STANDARD_REQUIRED ON
)
add_dependencies(libcudacxx.test.nvtarget ${target_name})
endif()
if (
"cuda_std_${dialect}" IN_LIST CMAKE_CUDA_COMPILE_FEATURES
AND "cxx_std_${dialect}" IN_LIST CMAKE_CXX_COMPILE_FEATURES
)
set(target_name "libcudacxx.test.nvtarget.dialect.cuda${dialect}")
add_library(${target_name} OBJECT nvtargettest.cu)
# This is required to override CMAKE_CXX_STANDARD - target_compile_features is insufficient.
set_target_properties(
${target_name}
PROPERTIES CUDA_STANDARD "${dialect}" CUDA_STANDARD_REQUIRED ON
)
add_dependencies(libcudacxx.test.nvtarget ${target_name})
endif()
endforeach()

View File

@@ -0,0 +1,13 @@
//===----------------------------------------------------------------------===//
//
// Part of libcu++, the C++ Standard Library for your entire system,
// 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.
//
//===----------------------------------------------------------------------===//
#include <nv/target>
void fn() {}

View File

@@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// Part of libcu++, the C++ Standard Library for your entire system,
// 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.
//
//===----------------------------------------------------------------------===//
#include <nv/target>
#ifdef __CUDACC_TILE__
__tile__
#endif // __CUDACC_TILE__
__host__ __device__ void
fn()
{}

View File

@@ -0,0 +1,20 @@
if (NOT "${CMAKE_CUDA_COMPILER_ID}" STREQUAL "NVIDIA")
return()
endif()
# family-specific features are supported since 12.9
if ("${CMAKE_CUDA_COMPILER_VERSION}" VERSION_LESS "12.9")
return()
endif()
set_directory_properties(
PROPERTIES INCLUDE_DIRECTORIES "${libcudacxx_SOURCE_DIR}/include"
)
set(target_name "libcudacxx.test.nvtarget.family_specific")
add_library(${target_name} OBJECT family_specific.cu)
set_target_properties(
${target_name}
PROPERTIES CUDA_ARCHITECTURES "103f-virtual"
)
add_dependencies(libcudacxx.test.nvtarget ${target_name})

View File

@@ -0,0 +1,60 @@
//===----------------------------------------------------------------------===//
//
// Part of libcu++, the C++ Standard Library for your entire system,
// 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.
//
//===----------------------------------------------------------------------===//
// This test checks if family-specific NV target macros work properly.
#include <nv/target>
// Currently, nvcc is the only compiler that supports arch-specific architectures.
#if !defined(__NVCC__)
# error "This test works with nvcc only."
#endif // !__NVCC__
#if defined(__CUDA_ARCH__)
# if __CUDA_ARCH_FAMILY_SPECIFIC__ != 1030
# error "This test must be compiled for sm_103f target."
# endif // __CUDA_ARCH_FAMILY_SPECIFIC__ != 1030
#endif // __CUDA_ARCH__
#define CHECK_TRUE(_PRED) \
do \
{ \
NV_IF_ELSE_TARGET(_PRED, static_assert(true);, static_assert(false);) \
} while (0)
#define CHECK_FALSE(_PRED) \
do \
{ \
NV_IF_ELSE_TARGET(_PRED, static_assert(false);, static_assert(true);) \
} while (0)
#ifdef __CUDACC_TILE__
__tile__
#endif // __CUDACC_TILE__
__host__ __device__ void
fn()
{
#if defined(__CUDA_ARCH__)
CHECK_TRUE(NV_IS_EXACTLY_SM_103);
CHECK_TRUE(NV_HAS_FEATURE_SM_100f);
CHECK_TRUE(NV_HAS_FEATURE_SM_103f);
#else // ^^^ __CUDA_ARCH__ ^^^ / vvv !__CUDA_ARCH__ vvv
CHECK_TRUE(NV_IS_HOST);
CHECK_FALSE(NV_HAS_FEATURE_SM_100f);
CHECK_FALSE(NV_HAS_FEATURE_SM_103f);
#endif // ^^^ !__CUDA_ARCH__ ^^^
CHECK_FALSE(NV_HAS_FEATURE_SM_110f);
CHECK_FALSE(NV_HAS_FEATURE_SM_100a);
CHECK_FALSE(NV_HAS_FEATURE_SM_103a);
CHECK_FALSE(NV_HAS_FEATURE_SM_110a);
}