[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:
1
cccl_upstream/cub/cmake/CubAddSubdir.cmake
Normal file
1
cccl_upstream/cub/cmake/CubAddSubdir.cmake
Normal file
@@ -0,0 +1 @@
|
||||
cccl_add_subdir_helper(CUB)
|
||||
56
cccl_upstream/cub/cmake/CubBuildCompilerTargets.cmake
Normal file
56
cccl_upstream/cub/cmake/CubBuildCompilerTargets.cmake
Normal file
@@ -0,0 +1,56 @@
|
||||
# This file provides the following function which defines the following targets:
|
||||
#
|
||||
# cub.compiler_interface
|
||||
# - Interface target that includes all compiler settings for cub tests, etc.
|
||||
|
||||
function(cub_build_compiler_targets)
|
||||
cccl_get_cub()
|
||||
cccl_get_libcudacxx()
|
||||
cccl_get_thrust()
|
||||
|
||||
thrust_create_target(cub.thrust HOST CPP DEVICE CUDA)
|
||||
|
||||
set(ptxas_compile_options)
|
||||
if (CCCL_ENABLE_PTXAS_WARNINGS)
|
||||
list(
|
||||
APPEND ptxas_compile_options
|
||||
"--warn-on-spills"
|
||||
"--warn-on-local-memory-usage"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(cuda_compile_options)
|
||||
set(cxx_compile_options)
|
||||
set(cxx_compile_definitions)
|
||||
|
||||
# append ptxas compile options to cuda_compile_options with compiler specific prefix
|
||||
foreach (ptxas_compile_option ${ptxas_compile_options})
|
||||
if (
|
||||
"${CMAKE_CUDA_COMPILER_ID}" STREQUAL "NVIDIA"
|
||||
OR "${CMAKE_CUDA_COMPILER_ID}" STREQUAL "NVHPC"
|
||||
)
|
||||
list(APPEND cuda_compile_options "-Xptxas=${ptxas_compile_option}")
|
||||
elseif ("${CMAKE_CUDA_COMPILER_ID}" STREQUAL "CLANG")
|
||||
list(APPEND cuda_compile_options "-Xcuda-ptxas ${ptxas_compile_option}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
cccl_build_compiler_interface(
|
||||
cub.compiler_flags
|
||||
"${cuda_compile_options}"
|
||||
"${cxx_compile_options}"
|
||||
"${cxx_compile_definitions}"
|
||||
)
|
||||
|
||||
add_library(cub.compiler_interface INTERFACE)
|
||||
target_link_libraries(
|
||||
cub.compiler_interface
|
||||
INTERFACE
|
||||
# order matters here, we need the project options to override the cccl options.
|
||||
cccl.compiler_interface
|
||||
cub.compiler_flags
|
||||
libcudacxx::libcudacxx
|
||||
CUB::CUB
|
||||
cub.thrust
|
||||
)
|
||||
endfunction()
|
||||
62
cccl_upstream/cub/cmake/CubCudaConfig.cmake
Normal file
62
cccl_upstream/cub/cmake/CubCudaConfig.cmake
Normal file
@@ -0,0 +1,62 @@
|
||||
#
|
||||
# Architecture options:
|
||||
#
|
||||
|
||||
option(
|
||||
CUB_ENABLE_RDC_TESTS
|
||||
"Enable tests that require separable compilation."
|
||||
ON
|
||||
)
|
||||
option(
|
||||
CUB_FORCE_RDC
|
||||
"Enable separable compilation on all targets that support it."
|
||||
OFF
|
||||
)
|
||||
|
||||
option(
|
||||
CUB_ENABLE_LAUNCH_NO_LAUNCHER
|
||||
"Enable tests/examples without explicit launch variants."
|
||||
ON
|
||||
)
|
||||
option(
|
||||
CUB_ENABLE_LAUNCH_HOST_LAUNCHER
|
||||
"Enable host launch variants (lid_0)."
|
||||
ON
|
||||
)
|
||||
option(
|
||||
CUB_ENABLE_LAUNCH_DEVICE_LAUNCHER
|
||||
"Enable device launch variants (lid_1)."
|
||||
ON
|
||||
)
|
||||
option(
|
||||
CUB_ENABLE_LAUNCH_GRAPH_LAUNCHER
|
||||
"Enable graph launch variants (lid_2)."
|
||||
ON
|
||||
)
|
||||
|
||||
option(
|
||||
CUB_ENABLE_LAUNCH_VARIANTS
|
||||
"Deprecated: use CUB_ENABLE_LAUNCH_DEVICE_LAUNCHER/GRAPH_LAUNCHER to control lid_1/lid_2."
|
||||
ON
|
||||
)
|
||||
|
||||
if (NOT CUB_ENABLE_LAUNCH_VARIANTS)
|
||||
message(
|
||||
WARNING
|
||||
"CUB_ENABLE_LAUNCH_VARIANTS is deprecated; disabling lid_1/lid_2 launch variants."
|
||||
)
|
||||
set(
|
||||
CUB_ENABLE_LAUNCH_DEVICE_LAUNCHER
|
||||
OFF
|
||||
CACHE BOOL
|
||||
"Enable device launch variants (lid_1)."
|
||||
FORCE
|
||||
)
|
||||
set(
|
||||
CUB_ENABLE_LAUNCH_GRAPH_LAUNCHER
|
||||
OFF
|
||||
CACHE BOOL
|
||||
"Enable graph launch variants (lid_2)."
|
||||
FORCE
|
||||
)
|
||||
endif()
|
||||
54
cccl_upstream/cub/cmake/CubHeaderTesting.cmake
Normal file
54
cccl_upstream/cub/cmake/CubHeaderTesting.cmake
Normal file
@@ -0,0 +1,54 @@
|
||||
# For every public header, build a translation unit containing `#include <header>`
|
||||
# to let the compiler try to figure out warnings in that header if it is not otherwise
|
||||
# included in tests, and also to verify if the headers are modular enough.
|
||||
# .inl files are not globbed for, because they are not supposed to be used as public
|
||||
# entrypoints.
|
||||
|
||||
if (NOT CUB_ENABLE_LAUNCH_NO_LAUNCHER)
|
||||
# Header tests are treated as core-only artifacts.
|
||||
return()
|
||||
endif()
|
||||
|
||||
function(cub_add_header_test label definitions)
|
||||
set(headertest_target cub.headers.${label})
|
||||
|
||||
cccl_generate_header_tests(${headertest_target} cub GLOBS "cub/*.cuh")
|
||||
cub_configure_cuda_target(${headertest_target} RDC ${CUB_FORCE_RDC})
|
||||
target_link_libraries(${headertest_target} PUBLIC cub.compiler_interface)
|
||||
target_compile_definitions(${headertest_target} PRIVATE ${definitions})
|
||||
endfunction()
|
||||
|
||||
# Wrap Thrust/CUB in a custom namespace to check proper use of ns macros:
|
||||
set(
|
||||
header_definitions
|
||||
"THRUST_WRAPPED_NAMESPACE=wrapped_thrust"
|
||||
"CUB_WRAPPED_NAMESPACE=wrapped_cub"
|
||||
)
|
||||
cub_add_header_test(base "${header_definitions}")
|
||||
|
||||
# Check that BF16 support can be disabled
|
||||
set(
|
||||
header_definitions
|
||||
"THRUST_WRAPPED_NAMESPACE=wrapped_thrust"
|
||||
"CUB_WRAPPED_NAMESPACE=wrapped_cub"
|
||||
"CCCL_DISABLE_BF16_SUPPORT"
|
||||
)
|
||||
cub_add_header_test(no_bf16 "${header_definitions}")
|
||||
|
||||
# Check that half support can be disabled
|
||||
set(
|
||||
header_definitions
|
||||
"THRUST_WRAPPED_NAMESPACE=wrapped_thrust"
|
||||
"CUB_WRAPPED_NAMESPACE=wrapped_cub"
|
||||
"CCCL_DISABLE_FP16_SUPPORT"
|
||||
)
|
||||
cub_add_header_test(no_half "${header_definitions}")
|
||||
|
||||
# Check that half support can be disabled
|
||||
set(
|
||||
header_definitions
|
||||
"THRUST_WRAPPED_NAMESPACE=wrapped_thrust"
|
||||
"CUB_WRAPPED_NAMESPACE=wrapped_cub"
|
||||
"CCCL_DISABLE_FP8_SUPPORT"
|
||||
)
|
||||
cub_add_header_test(no_fp8 "${header_definitions}")
|
||||
41
cccl_upstream/cub/cmake/CubUtilities.cmake
Normal file
41
cccl_upstream/cub/cmake/CubUtilities.cmake
Normal file
@@ -0,0 +1,41 @@
|
||||
# cub_configure_cuda_target(<target_name> RDC <ON|OFF>)
|
||||
#
|
||||
# Configures `target_name` with the appropriate CUDA architectures and RDC state.
|
||||
function(cub_configure_cuda_target target_name)
|
||||
set(options)
|
||||
set(one_value_args RDC)
|
||||
set(multi_value_args)
|
||||
cmake_parse_arguments(
|
||||
cub_cuda
|
||||
"${options}"
|
||||
"${one_value_args}"
|
||||
"${multi_value_args}"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
if (cub_cuda_UNPARSED_ARGUMENTS)
|
||||
message(
|
||||
AUTHOR_WARNING
|
||||
"Unrecognized arguments passed to cub_configure_cuda_target: "
|
||||
${cub_cuda_UNPARSED_ARGUMENTS}
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED cub_cuda_RDC)
|
||||
message(AUTHOR_WARNING "RDC option required for cub_configure_cuda_target.")
|
||||
endif()
|
||||
|
||||
if (cub_cuda_RDC)
|
||||
set_target_properties(
|
||||
${target_name}
|
||||
PROPERTIES #
|
||||
CUDA_SEPARABLE_COMPILATION ON
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
)
|
||||
else()
|
||||
set_target_properties(
|
||||
${target_name}
|
||||
PROPERTIES CUDA_SEPARABLE_COMPILATION OFF
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
Reference in New Issue
Block a user