[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:
6
cccl_upstream/thrust/cmake/ThrustAddSubdir.cmake
Normal file
6
cccl_upstream/thrust/cmake/ThrustAddSubdir.cmake
Normal file
@@ -0,0 +1,6 @@
|
||||
cccl_add_subdir_helper(
|
||||
Thrust
|
||||
# These component lists may be set by users to explicitly request subprojects:
|
||||
REQUIRED_COMPONENTS ${THRUST_REQUIRED_SYSTEMS}
|
||||
OPTIONAL_COMPONENTS ${THRUST_OPTIONAL_SYSTEMS}
|
||||
)
|
||||
38
cccl_upstream/thrust/cmake/ThrustBuildCompilerTargets.cmake
Normal file
38
cccl_upstream/thrust/cmake/ThrustBuildCompilerTargets.cmake
Normal file
@@ -0,0 +1,38 @@
|
||||
# This file defines the `thrust_build_compiler_targets()` function, which
|
||||
# creates the following interface targets:
|
||||
#
|
||||
# thrust.compiler_interface
|
||||
# Provides compiler settings for all thrust tests, examples, etc. This should not be used
|
||||
# directly, as it is linked to by all thrust configuration targets in THRUST_TARGETS.
|
||||
|
||||
function(thrust_build_compiler_targets)
|
||||
set(cuda_compile_options)
|
||||
set(cxx_compile_options)
|
||||
set(cxx_compile_definitions)
|
||||
|
||||
if ("MSVC" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
|
||||
# Disabled loss-of-data conversion warnings.
|
||||
# TODO Re-enable.
|
||||
append_option_if_available("/wd4244" cxx_compile_options)
|
||||
|
||||
# Disable warning about applying unary operator- to unsigned type.
|
||||
# TODO Re-enable.
|
||||
append_option_if_available("/wd4146" cxx_compile_options)
|
||||
endif()
|
||||
|
||||
cccl_build_compiler_interface(
|
||||
thrust.compiler_flags
|
||||
"${cuda_compile_options}"
|
||||
"${cxx_compile_options}"
|
||||
"${cxx_compile_definitions}"
|
||||
)
|
||||
|
||||
add_library(thrust.compiler_interface INTERFACE)
|
||||
target_link_libraries(
|
||||
thrust.compiler_interface
|
||||
INTERFACE
|
||||
# order matters here, we need the project options to override the cccl options.
|
||||
cccl.compiler_interface
|
||||
thrust.compiler_flags
|
||||
)
|
||||
endfunction()
|
||||
164
cccl_upstream/thrust/cmake/ThrustBuildTargetList.cmake
Normal file
164
cccl_upstream/thrust/cmake/ThrustBuildTargetList.cmake
Normal file
@@ -0,0 +1,164 @@
|
||||
# This file provides utilities for building and working with thrust
|
||||
# configuration targets.
|
||||
#
|
||||
# THRUST_TARGETS
|
||||
# - Built by the calling the `thrust_build_target_list()` function.
|
||||
# - Each item is the name of a thrust interface target that is configured for a
|
||||
# certain combination of host/device.
|
||||
#
|
||||
# thrust_build_target_list()
|
||||
# - Creates the THRUST_TARGETS list.
|
||||
#
|
||||
# The following functions can be used to test/set metadata on a thrust target:
|
||||
#
|
||||
# thrust_get_target_property(<prop_var> <target_name> <prop>)
|
||||
# - Checks the ${prop} target property on thrust target ${target_name}
|
||||
# and sets the ${prop_var} variable in the caller's scope.
|
||||
# - <prop_var> is any valid cmake identifier.
|
||||
# - <target_name> is the name of a thrust target.
|
||||
# - <prop> is one of the following:
|
||||
# - HOST: The host system. Valid values: CPP, OMP, TBB.
|
||||
# - DEVICE: The device system. Valid values: CUDA, CPP, OMP, TBB.
|
||||
# - PREFIX: A unique "thrust.<host>.<device>" prefix that should be used to name all
|
||||
# targets/tests/examples that use this configuration
|
||||
# (e.g. ${config_label}.test.foo).
|
||||
|
||||
define_property(
|
||||
TARGET
|
||||
PROPERTY _THRUST_HOST
|
||||
BRIEF_DOCS "A target's host system: CPP, TBB, or OMP."
|
||||
FULL_DOCS "A target's host system: CPP, TBB, or OMP."
|
||||
)
|
||||
define_property(
|
||||
TARGET
|
||||
PROPERTY _THRUST_DEVICE
|
||||
BRIEF_DOCS "A target's device system: CUDA, CPP, TBB, or OMP."
|
||||
FULL_DOCS "A target's device system: CUDA, CPP, TBB, or OMP."
|
||||
)
|
||||
define_property(
|
||||
TARGET
|
||||
PROPERTY _THRUST_PREFIX
|
||||
BRIEF_DOCS
|
||||
"A prefix describing the host.device config, eg. 'thrust.cpp.cuda'."
|
||||
FULL_DOCS "A prefix describing the host.device config, eg. 'thrust.cpp.cuda'."
|
||||
)
|
||||
|
||||
function(thrust_set_target_properties target_name host device prefix)
|
||||
cccl_configure_target(${target_name})
|
||||
|
||||
set_target_properties(
|
||||
${target_name}
|
||||
PROPERTIES
|
||||
_THRUST_HOST ${host}
|
||||
_THRUST_DEVICE ${device}
|
||||
_THRUST_PREFIX ${prefix}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# Get a thrust property from a target and store it in var_name
|
||||
# thrust_get_target_property(<var_name> <target_name> [HOST|DEVICE|PREFIX]
|
||||
macro(thrust_get_target_property prop_var target_name prop)
|
||||
get_property(${prop_var} TARGET ${target_name} PROPERTY _THRUST_${prop})
|
||||
endmacro()
|
||||
|
||||
# Set ${var_name} to TRUE or FALSE in the caller's scope
|
||||
function(_thrust_is_config_valid var_name host device)
|
||||
# gersemi: off
|
||||
if (THRUST_MULTICONFIG_ENABLE_SYSTEM_${host} AND
|
||||
THRUST_MULTICONFIG_ENABLE_SYSTEM_${device} AND
|
||||
"${host}_${device}" IN_LIST
|
||||
THRUST_MULTICONFIG_WORKLOAD_${THRUST_MULTICONFIG_WORKLOAD}_CONFIGS)
|
||||
# gersemi: on
|
||||
set(${var_name} TRUE PARENT_SCOPE)
|
||||
else()
|
||||
set(${var_name} FALSE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(_thrust_init_target_list)
|
||||
set(THRUST_TARGETS "" CACHE INTERNAL "" FORCE)
|
||||
endfunction()
|
||||
|
||||
function(_thrust_add_target_to_target_list target_name host device prefix)
|
||||
thrust_set_target_properties(${target_name} ${host} ${device} ${prefix})
|
||||
target_link_libraries(${target_name} INTERFACE thrust.compiler_interface)
|
||||
set(THRUST_TARGETS ${THRUST_TARGETS} ${target_name} CACHE INTERNAL "" FORCE)
|
||||
message(STATUS "Enabling Thrust configuration: ${host}.${device}")
|
||||
endfunction()
|
||||
|
||||
function(_thrust_build_target_list_multiconfig)
|
||||
# Build THRUST_TARGETS
|
||||
foreach (host IN LISTS THRUST_HOST_SYSTEM_OPTIONS)
|
||||
foreach (device IN LISTS THRUST_DEVICE_SYSTEM_OPTIONS)
|
||||
_thrust_is_config_valid(config_valid ${host} ${device})
|
||||
if (config_valid)
|
||||
set(prefix "thrust.${host}.${device}")
|
||||
string(TOLOWER "${prefix}" prefix)
|
||||
|
||||
# Configure a thrust interface target for this host/device
|
||||
set(target_name "${prefix}.config")
|
||||
thrust_create_target(
|
||||
${target_name}
|
||||
HOST ${host}
|
||||
DEVICE ${device}
|
||||
DISPATCH ${THRUST_DISPATCH_TYPE}
|
||||
${THRUST_TARGET_FLAGS}
|
||||
)
|
||||
|
||||
# Set configuration metadata for this thrust interface target:
|
||||
_thrust_add_target_to_target_list(${target_name} ${host} ${device} ${prefix})
|
||||
endif()
|
||||
endforeach() # devices
|
||||
endforeach() # hosts
|
||||
|
||||
list(LENGTH THRUST_TARGETS count)
|
||||
message(STATUS "${count} unique Thrust host.device configurations generated")
|
||||
endfunction()
|
||||
|
||||
function(_thrust_build_target_list_singleconfig)
|
||||
set(host ${THRUST_HOST_SYSTEM})
|
||||
set(device ${THRUST_DEVICE_SYSTEM})
|
||||
set(dialect ${THRUST_CPP_DIALECT})
|
||||
set(prefix "thrust") # single config
|
||||
|
||||
# Target is created in ThrustFindThrust.cmake:
|
||||
_thrust_add_target_to_target_list(thrust.config ${host} ${device} ${dialect} ${prefix})
|
||||
endfunction()
|
||||
|
||||
# Build a ${THRUST_TARGETS} list containing target names for all
|
||||
# requested configurations
|
||||
function(thrust_build_target_list)
|
||||
# Clear the list of targets:
|
||||
_thrust_init_target_list()
|
||||
|
||||
# Generic config flags:
|
||||
set(THRUST_TARGET_FLAGS)
|
||||
macro(add_flag_option prefix flag docstring default)
|
||||
set(opt "${prefix}_${flag}")
|
||||
option(${opt} "${docstring}" "${default}")
|
||||
mark_as_advanced(${opt})
|
||||
if ("${prefix}" STREQUAL "CCCL" AND DEFINED THRUST_${flag})
|
||||
message(
|
||||
WARNING
|
||||
"The THRUST_${flag} cmake option is deprecated. Use CCCL_${flag} instead."
|
||||
)
|
||||
set(CCCL_${flag} ${THRUST_${flag}})
|
||||
endif()
|
||||
if (${${opt}})
|
||||
list(APPEND THRUST_TARGET_FLAGS ${flag})
|
||||
endif()
|
||||
endmacro()
|
||||
# FIXME these should be moved out of the Thrust build if we care about them...
|
||||
add_flag_option(CCCL IGNORE_DEPRECATED_CPP_DIALECT "Don't warn about any deprecated C++ standards and compilers." OFF)
|
||||
add_flag_option(CCCL IGNORE_DEPRECATED_CPP_11 "Don't warn about deprecated C++11." OFF)
|
||||
add_flag_option(CCCL IGNORE_DEPRECATED_CPP_14 "Don't warn about deprecated C++14." OFF)
|
||||
add_flag_option(CCCL IGNORE_DEPRECATED_COMPILER "Don't warn about deprecated compilers." OFF)
|
||||
add_flag_option(THRUST IGNORE_CUB_VERSION_CHECK "Don't warn about mismatched CUB versions." OFF)
|
||||
add_flag_option(CCCL IGNORE_DEPRECATED_API "Don't warn about deprecated Thrust or CUB APIs." OFF)
|
||||
|
||||
if (THRUST_ENABLE_MULTICONFIG)
|
||||
_thrust_build_target_list_multiconfig()
|
||||
else()
|
||||
_thrust_build_target_list_singleconfig()
|
||||
endif()
|
||||
endfunction()
|
||||
21
cccl_upstream/thrust/cmake/ThrustCudaConfig.cmake
Normal file
21
cccl_upstream/thrust/cmake/ThrustCudaConfig.cmake
Normal file
@@ -0,0 +1,21 @@
|
||||
enable_language(CUDA)
|
||||
|
||||
if (TARGET libcudacxx::libcudacxx)
|
||||
# CUDA may not have been enabled when libcudacxx was found:
|
||||
libcudacxx_update_language_compat_flags()
|
||||
endif()
|
||||
|
||||
#
|
||||
# Architecture options:
|
||||
#
|
||||
|
||||
option(
|
||||
THRUST_ENABLE_RDC_TESTS
|
||||
"Enable tests that require separable compilation."
|
||||
ON
|
||||
)
|
||||
option(
|
||||
THRUST_FORCE_RDC
|
||||
"Enable separable compilation on all targets that support it."
|
||||
OFF
|
||||
)
|
||||
42
cccl_upstream/thrust/cmake/ThrustFindThrust.cmake
Normal file
42
cccl_upstream/thrust/cmake/ThrustFindThrust.cmake
Normal file
@@ -0,0 +1,42 @@
|
||||
function(_thrust_find_thrust_multiconfig)
|
||||
# Check which systems are enabled by multiconfig:
|
||||
set(req_systems)
|
||||
if (THRUST_MULTICONFIG_ENABLE_SYSTEM_CUDA)
|
||||
list(APPEND req_systems CUDA)
|
||||
endif()
|
||||
if (THRUST_MULTICONFIG_ENABLE_SYSTEM_CPP)
|
||||
list(APPEND req_systems CPP)
|
||||
endif()
|
||||
if (THRUST_MULTICONFIG_ENABLE_SYSTEM_TBB)
|
||||
list(APPEND req_systems TBB)
|
||||
endif()
|
||||
if (THRUST_MULTICONFIG_ENABLE_SYSTEM_OMP)
|
||||
list(APPEND req_systems OMP)
|
||||
endif()
|
||||
|
||||
find_package(
|
||||
Thrust
|
||||
REQUIRED
|
||||
CONFIG
|
||||
NO_DEFAULT_PATH # Only check the explicit path in HINTS:
|
||||
HINTS "${CCCL_SOURCE_DIR}/lib/cmake/thrust/"
|
||||
COMPONENTS ${req_systems}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(_thrust_find_thrust_singleconfig)
|
||||
cccl_get_thrust()
|
||||
|
||||
# Create target now to prepare system found flags:
|
||||
thrust_create_target(thrust.config FROM_OPTIONS ${THRUST_TARGET_FLAGS})
|
||||
thrust_debug_target(thrust.config "${THRUST_VERSION}")
|
||||
endfunction()
|
||||
|
||||
# Find thrust along with all requested backends.
|
||||
function(thrust_find_thrust)
|
||||
if (THRUST_ENABLE_MULTICONFIG)
|
||||
_thrust_find_thrust_multiconfig()
|
||||
else()
|
||||
_thrust_find_thrust_singleconfig()
|
||||
endif()
|
||||
endfunction()
|
||||
170
cccl_upstream/thrust/cmake/ThrustHeaderTesting.cmake
Normal file
170
cccl_upstream/thrust/cmake/ThrustHeaderTesting.cmake
Normal file
@@ -0,0 +1,170 @@
|
||||
# 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.
|
||||
|
||||
# Add regexes matching deprecated headers here to disable warnings for them:
|
||||
set(
|
||||
deprecated_headers_regexes
|
||||
"thrust/iterator/tabulate_output_iterator\\.h"
|
||||
"thrust/iterator/strided_iterator\\.h"
|
||||
"thrust/iterator/constant_iterator\\.h"
|
||||
)
|
||||
|
||||
cccl_get_cudatoolkit()
|
||||
|
||||
function(thrust_add_header_test thrust_target label definitions)
|
||||
thrust_get_target_property(config_host ${thrust_target} HOST)
|
||||
thrust_get_target_property(config_device ${thrust_target} DEVICE)
|
||||
thrust_get_target_property(config_prefix ${thrust_target} PREFIX)
|
||||
set(config_systems ${config_host} ${config_device})
|
||||
|
||||
string(TOLOWER "${config_host}" host_lower)
|
||||
string(TOLOWER "${config_device}" device_lower)
|
||||
|
||||
if (config_device STREQUAL "CUDA")
|
||||
set(langs CUDA)
|
||||
else()
|
||||
# Compile headers with both host and cuda compilers for CPU backends.
|
||||
set(langs CXX CUDA)
|
||||
endif()
|
||||
|
||||
# GLOB ALL THE THINGS
|
||||
set(headers_globs thrust/*.h)
|
||||
set(headers_exclude_systems_globs thrust/system/*/*)
|
||||
set(
|
||||
headers_systems_globs
|
||||
thrust/system/${host_lower}/*
|
||||
thrust/system/${device_lower}/*
|
||||
)
|
||||
set(
|
||||
headers_exclude_details_globs
|
||||
thrust/detail/*
|
||||
thrust/*/detail/*
|
||||
thrust/*/*/detail/*
|
||||
)
|
||||
|
||||
# Get all .h files...
|
||||
file(
|
||||
GLOB_RECURSE headers
|
||||
RELATIVE "${Thrust_SOURCE_DIR}"
|
||||
CONFIGURE_DEPENDS
|
||||
${headers_globs}
|
||||
)
|
||||
|
||||
# ...then remove all system specific headers...
|
||||
file(
|
||||
GLOB_RECURSE headers_exclude_systems
|
||||
RELATIVE "${Thrust_SOURCE_DIR}"
|
||||
CONFIGURE_DEPENDS
|
||||
${headers_exclude_systems_globs}
|
||||
)
|
||||
list(REMOVE_ITEM headers ${headers_exclude_systems})
|
||||
|
||||
# ...then add all headers specific to the selected host and device systems back again...
|
||||
file(
|
||||
GLOB_RECURSE headers_systems
|
||||
RELATIVE "${Thrust_SOURCE_DIR}"
|
||||
CONFIGURE_DEPENDS
|
||||
${headers_systems_globs}
|
||||
)
|
||||
list(APPEND headers ${headers_systems})
|
||||
|
||||
# ...and remove all the detail headers (also removing the detail headers from the selected systems).
|
||||
file(
|
||||
GLOB_RECURSE headers_exclude_details
|
||||
RELATIVE "${Thrust_SOURCE_DIR}"
|
||||
CONFIGURE_DEPENDS
|
||||
${headers_exclude_details_globs}
|
||||
)
|
||||
list(REMOVE_ITEM headers ${headers_exclude_details})
|
||||
|
||||
foreach (lang IN LISTS langs)
|
||||
set(headertest_target ${config_prefix}.headers.${label})
|
||||
if (lang STREQUAL "CUDA" AND (NOT config_device STREQUAL "CUDA"))
|
||||
# Append .cuda to the header test target name when compiling
|
||||
# CPU backends with cuda compilers.
|
||||
set(headertest_target ${headertest_target}.cuda)
|
||||
endif()
|
||||
|
||||
cccl_generate_header_tests(
|
||||
${headertest_target}
|
||||
thrust
|
||||
LANGUAGE ${lang}
|
||||
HEADERS ${headers}
|
||||
PER_HEADER_DEFINES
|
||||
DEFINE
|
||||
CCCL_IGNORE_DEPRECATED_API
|
||||
${deprecated_headers_regexes}
|
||||
)
|
||||
target_link_libraries(${headertest_target} PUBLIC ${thrust_target})
|
||||
if (definitions)
|
||||
target_compile_definitions(${headertest_target} PRIVATE ${definitions})
|
||||
endif()
|
||||
|
||||
if (lang STREQUAL "CUDA")
|
||||
thrust_configure_cuda_target(${headertest_target} RDC ${THRUST_FORCE_RDC})
|
||||
endif()
|
||||
|
||||
if ("TBB" IN_LIST config_systems)
|
||||
# In some cases cudafe++ doesn't implement certain builtins that are used in <immintrin.h> which causes the
|
||||
# compilation to fail. In tbb_nvcc_preinclude.h, we forward declare those functions, so cudafe++ has no problems.
|
||||
if (
|
||||
"${lang}" STREQUAL "CUDA"
|
||||
AND "${CMAKE_CUDA_COMPILER_ID}" STREQUAL "NVIDIA"
|
||||
AND NOT MSVC
|
||||
)
|
||||
target_compile_options(
|
||||
${headertest_target}
|
||||
PUBLIC "-include" "${Thrust_SOURCE_DIR}/testing/tbb_nvcc_preinclude.h"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Disable macro checks on TBB; the TBB atomic implementation uses `I` and
|
||||
# our checks will issue false errors.
|
||||
target_compile_definitions(
|
||||
${headertest_target}
|
||||
PRIVATE CCCL_IGNORE_HEADER_MACRO_CHECKS
|
||||
)
|
||||
|
||||
# error #550-D: variable "alloc" was set but never used (in TBB headers)
|
||||
# Only very specific configs are emitting this:
|
||||
# gersemi: off
|
||||
if (lang STREQUAL "CUDA" AND
|
||||
"${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR}" VERSION_EQUAL "12.0" AND
|
||||
MSVC_VERSION EQUAL 1939 AND
|
||||
CMAKE_CUDA_STANDARD EQUAL 20
|
||||
)
|
||||
target_compile_options(
|
||||
${headertest_target}
|
||||
PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-diag-suppress 550>
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endforeach() # lang
|
||||
endfunction()
|
||||
|
||||
foreach (thrust_target IN LISTS THRUST_TARGETS)
|
||||
thrust_get_target_property(config_device ${thrust_target} DEVICE)
|
||||
|
||||
thrust_add_header_test(${thrust_target} base "")
|
||||
|
||||
# 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"
|
||||
)
|
||||
thrust_add_header_test(${thrust_target} wrap "${header_definitions}")
|
||||
|
||||
if ("CUDA" STREQUAL "${config_device}")
|
||||
# Check that BF16 support can be disabled
|
||||
set(header_definitions "CCCL_DISABLE_BF16_SUPPORT")
|
||||
thrust_add_header_test(${thrust_target} no_bf16 "${header_definitions}")
|
||||
|
||||
# Check that half support can be disabled
|
||||
set(header_definitions "CCCL_DISABLE_FP16_SUPPORT")
|
||||
thrust_add_header_test(${thrust_target} no_half "${header_definitions}")
|
||||
endif()
|
||||
endforeach()
|
||||
143
cccl_upstream/thrust/cmake/ThrustMultiConfig.cmake
Normal file
143
cccl_upstream/thrust/cmake/ThrustMultiConfig.cmake
Normal file
@@ -0,0 +1,143 @@
|
||||
# This file defines thrust_configure_multiconfig(), which sets up and handles
|
||||
# the MultiConfig options that allow multiple host/device configurations
|
||||
# to be generated from a single thrust build.
|
||||
|
||||
function(thrust_configure_multiconfig)
|
||||
option(
|
||||
THRUST_ENABLE_MULTICONFIG
|
||||
"Enable multiconfig options for coverage testing."
|
||||
OFF
|
||||
)
|
||||
|
||||
if (THRUST_ENABLE_MULTICONFIG)
|
||||
# Systems:
|
||||
option(
|
||||
THRUST_MULTICONFIG_ENABLE_SYSTEM_CPP
|
||||
"Generate build configurations that use CPP."
|
||||
ON
|
||||
)
|
||||
option(
|
||||
THRUST_MULTICONFIG_ENABLE_SYSTEM_CUDA
|
||||
"Generate build configurations that use CUDA."
|
||||
ON
|
||||
)
|
||||
option(
|
||||
THRUST_MULTICONFIG_ENABLE_SYSTEM_OMP
|
||||
"Generate build configurations that use OpenMP."
|
||||
OFF
|
||||
)
|
||||
option(
|
||||
THRUST_MULTICONFIG_ENABLE_SYSTEM_TBB
|
||||
"Generate build configurations that use TBB."
|
||||
OFF
|
||||
)
|
||||
|
||||
# Workload:
|
||||
# - `SMALL`: [3 configs] Minimal coverage and validation of each device system against the `CPP` host.
|
||||
# - `MEDIUM`: [6 configs] Cheap extended coverage.
|
||||
# - `LARGE`: [8 configs] Expensive extended coverage. Include all useful build configurations.
|
||||
# - `FULL`: [12 configs] The complete cross product of all possible build configurations.
|
||||
#
|
||||
# Config | Workloads | Value | Expense | Note
|
||||
# ---------|-----------|------------|-----------|-----------------------------
|
||||
# CPP/CUDA | F L M S | Essential | Expensive | Validates CUDA against CPP
|
||||
# CPP/OMP | F L M S | Essential | Cheap | Validates OMP against CPP
|
||||
# CPP/TBB | F L M S | Essential | Cheap | Validates TBB against CPP
|
||||
# CPP/CPP | F L M | Important | Cheap | Tests CPP as device
|
||||
# OMP/OMP | F L M | Important | Cheap | Tests OMP as host
|
||||
# TBB/TBB | F L M | Important | Cheap | Tests TBB as host
|
||||
# TBB/CUDA | F L | Important | Expensive | Validates TBB/CUDA interop
|
||||
# OMP/CUDA | F L | Important | Expensive | Validates OMP/CUDA interop
|
||||
# TBB/OMP | F | Not useful | Cheap | Mixes CPU-parallel systems
|
||||
# OMP/TBB | F | Not useful | Cheap | Mixes CPU-parallel systems
|
||||
# TBB/CPP | F | Not Useful | Cheap | Parallel host, serial device
|
||||
# OMP/CPP | F | Not Useful | Cheap | Parallel host, serial device
|
||||
|
||||
set(
|
||||
THRUST_MULTICONFIG_WORKLOAD
|
||||
SMALL
|
||||
CACHE STRING
|
||||
"Limit host/device configs: SMALL (up to 3 h/d combos per dialect), MEDIUM(6), LARGE(8), FULL(12)"
|
||||
)
|
||||
set_property(
|
||||
CACHE THRUST_MULTICONFIG_WORKLOAD
|
||||
PROPERTY STRINGS SMALL MEDIUM LARGE FULL
|
||||
)
|
||||
set(
|
||||
THRUST_MULTICONFIG_WORKLOAD_SMALL_CONFIGS
|
||||
CPP_OMP
|
||||
CPP_TBB
|
||||
CPP_CUDA
|
||||
CACHE INTERNAL
|
||||
"Host/device combos enabled for SMALL workloads."
|
||||
FORCE
|
||||
)
|
||||
set(
|
||||
THRUST_MULTICONFIG_WORKLOAD_MEDIUM_CONFIGS
|
||||
${THRUST_MULTICONFIG_WORKLOAD_SMALL_CONFIGS}
|
||||
CPP_CPP
|
||||
TBB_TBB
|
||||
OMP_OMP
|
||||
CACHE INTERNAL
|
||||
"Host/device combos enabled for MEDIUM workloads."
|
||||
FORCE
|
||||
)
|
||||
set(
|
||||
THRUST_MULTICONFIG_WORKLOAD_LARGE_CONFIGS
|
||||
${THRUST_MULTICONFIG_WORKLOAD_MEDIUM_CONFIGS}
|
||||
OMP_CUDA
|
||||
TBB_CUDA
|
||||
CACHE INTERNAL
|
||||
"Host/device combos enabled for LARGE workloads."
|
||||
FORCE
|
||||
)
|
||||
set(
|
||||
THRUST_MULTICONFIG_WORKLOAD_FULL_CONFIGS
|
||||
${THRUST_MULTICONFIG_WORKLOAD_LARGE_CONFIGS}
|
||||
OMP_CPP
|
||||
TBB_CPP
|
||||
OMP_TBB
|
||||
TBB_OMP
|
||||
CACHE INTERNAL
|
||||
"Host/device combos enabled for FULL workloads."
|
||||
FORCE
|
||||
)
|
||||
|
||||
# Hide the single config options if they exist from a previous run:
|
||||
if (DEFINED THRUST_HOST_SYSTEM)
|
||||
set_property(CACHE THRUST_HOST_SYSTEM PROPERTY TYPE INTERNAL)
|
||||
set_property(CACHE THRUST_DEVICE_SYSTEM PROPERTY TYPE INTERNAL)
|
||||
endif()
|
||||
else() # Single config:
|
||||
# Restore system option visibility if these cache options already exist
|
||||
# from a previous run.
|
||||
if (DEFINED THRUST_HOST_SYSTEM)
|
||||
set_property(CACHE THRUST_HOST_SYSTEM PROPERTY TYPE STRING)
|
||||
else()
|
||||
set(
|
||||
THRUST_HOST_SYSTEM
|
||||
"CPP"
|
||||
CACHE STRING
|
||||
"The targeted host system: ${THRUST_HOST_SYSTEM_OPTIONS}"
|
||||
)
|
||||
set_property(
|
||||
CACHE THRUST_HOST_SYSTEM
|
||||
PROPERTY STRINGS ${THRUST_HOST_SYSTEM_OPTIONS}
|
||||
)
|
||||
endif()
|
||||
if (DEFINED THRUST_DEVICE_SYSTEM)
|
||||
set_property(CACHE THRUST_DEVICE_SYSTEM PROPERTY TYPE STRING)
|
||||
else()
|
||||
set(
|
||||
THRUST_DEVICE_SYSTEM
|
||||
"CUDA"
|
||||
CACHE STRING
|
||||
"The targeted device system: ${THRUST_DEVICE_SYSTEM_OPTIONS}"
|
||||
)
|
||||
set_property(
|
||||
CACHE THRUST_DEVICE_SYSTEM
|
||||
PROPERTY STRINGS ${THRUST_DEVICE_SYSTEM_OPTIONS}
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
52
cccl_upstream/thrust/cmake/ThrustRunExample.cmake
Normal file
52
cccl_upstream/thrust/cmake/ThrustRunExample.cmake
Normal file
@@ -0,0 +1,52 @@
|
||||
# Inputs:
|
||||
#
|
||||
# Variable | Type | Doc
|
||||
# ---------------------|----------|--------------------------------------
|
||||
# EXAMPLE_EXECUTABLE | FilePath | Path to example executable
|
||||
# FILECHECK_ENABLED | Boolean | Run FileCheck comparison test
|
||||
# FILECHECK_EXECUTABLE | FilePath | Path to the LLVM FileCheck utility
|
||||
# REFERENCE_FILE | FilePath | Path to the FileCheck reference file
|
||||
|
||||
if (FILECHECK_ENABLED)
|
||||
if (NOT EXISTS "${REFERENCE_FILE}")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"FileCheck requested for '${EXAMPLE_EXECUTABLE}', but reference file "
|
||||
"does not exist at '${REFERENCE_FILE}`."
|
||||
)
|
||||
endif()
|
||||
|
||||
# If the reference file is empty, validate that the example doesn't
|
||||
# produce any output.
|
||||
file(SIZE "${REFERENCE_FILE}" file_size)
|
||||
message("${REFERENCE_FILE}: ${file_size} bytes")
|
||||
|
||||
if (file_size EQUAL 0)
|
||||
set(check_empty_output TRUE)
|
||||
set(filecheck_command)
|
||||
else()
|
||||
set(check_empty_output FALSE)
|
||||
set(filecheck_command COMMAND "${FILECHECK_EXECUTABLE}" "${REFERENCE_FILE}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND "${EXAMPLE_EXECUTABLE}" ${filecheck_command}
|
||||
RESULT_VARIABLE exit_code
|
||||
OUTPUT_VARIABLE stdout
|
||||
ERROR_VARIABLE stderr
|
||||
)
|
||||
|
||||
if (NOT 0 EQUAL exit_code)
|
||||
message(FATAL_ERROR "${EXAMPLE_EXECUTABLE} failed (${exit_code}):\n${stderr}")
|
||||
endif()
|
||||
|
||||
if (check_empty_output)
|
||||
string(LENGTH "${stdout}" stdout_size)
|
||||
if (NOT stdout_size EQUAL 0)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"${EXAMPLE_EXECUTABLE}: output received, but not expected:\n${stdout}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
60
cccl_upstream/thrust/cmake/ThrustUtilities.cmake
Normal file
60
cccl_upstream/thrust/cmake/ThrustUtilities.cmake
Normal file
@@ -0,0 +1,60 @@
|
||||
# Given a cu_file (e.g. foo/bar.cu) relative to CMAKE_CURRENT_SOURCE_DIR
|
||||
# and a thrust_target, create a cpp file that includes the .cu file, and set
|
||||
# ${cpp_file_var} in the parent scope to the full path of the new file. The new
|
||||
# file will be generated in:
|
||||
# ${CMAKE_CURRENT_BINARY_DIR}/<thrust_target_prefix>/${cu_file}.cpp
|
||||
function(thrust_wrap_cu_in_cpp cpp_file_var cu_file thrust_target)
|
||||
thrust_get_target_property(prefix ${thrust_target} PREFIX)
|
||||
set(wrapped_source_file "${CMAKE_CURRENT_SOURCE_DIR}/${cu_file}")
|
||||
set(cpp_file "${CMAKE_CURRENT_BINARY_DIR}/${prefix}/${cu_file}.cpp")
|
||||
configure_file(
|
||||
"${Thrust_SOURCE_DIR}/cmake/wrap_source_file.cpp.in"
|
||||
"${cpp_file}"
|
||||
)
|
||||
set(${cpp_file_var} "${cpp_file}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# thrust_configure_cuda_target(<target_name> RDC <ON|OFF>)
|
||||
#
|
||||
# Configures `target_name` with the appropriate CUDA architectures and RDC state.
|
||||
function(thrust_configure_cuda_target target_name)
|
||||
set(options)
|
||||
set(one_value_args RDC)
|
||||
set(multi_value_args)
|
||||
cmake_parse_arguments(
|
||||
thrust_cuda
|
||||
"${options}"
|
||||
"${one_value_args}"
|
||||
"${multi_value_args}"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
if (thrust_cuda_UNPARSED_ARGUMENTS)
|
||||
message(
|
||||
AUTHOR_WARNING
|
||||
"Unrecognized arguments passed to thrust_configure_cuda_target: "
|
||||
${thrust_cuda_UNPARSED_ARGUMENTS}
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED thrust_cuda_RDC)
|
||||
message(
|
||||
AUTHOR_WARNING
|
||||
"RDC option required for thrust_configure_cuda_target."
|
||||
)
|
||||
endif()
|
||||
|
||||
if (thrust_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()
|
||||
1
cccl_upstream/thrust/cmake/filecheck_smoke_test
Normal file
1
cccl_upstream/thrust/cmake/filecheck_smoke_test
Normal file
@@ -0,0 +1 @@
|
||||
SMOKE
|
||||
1
cccl_upstream/thrust/cmake/wrap_source_file.cpp.in
Normal file
1
cccl_upstream/thrust/cmake/wrap_source_file.cpp.in
Normal file
@@ -0,0 +1 @@
|
||||
#include <${wrapped_source_file}> // NOLINT(bugprone-suspicious-include)
|
||||
Reference in New Issue
Block a user