From 9b5602b2bda6572f10632713cece9c3649e784ca Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Wed, 1 Feb 2023 18:37:45 -0500 Subject: [PATCH 01/14] Initial port to new monorepo build system. --- CMakeLists.txt | 33 ++++----- cmake/CubBuildCompilerTargets.cmake | 4 +- cmake/CubBuildTargetList.cmake | 12 +--- cmake/CubCompilerHacks.cmake | 101 ++++------------------------ cmake/CubCudaConfig.cmake | 88 ++++-------------------- cmake/CubHeaderTesting.cmake | 1 + cmake/CubInstallRules.cmake | 6 -- cmake/CubUtilities.cmake | 32 ++++++--- examples/CMakeLists.txt | 13 +--- test/CMakeLists.txt | 18 +++-- 10 files changed, 76 insertions(+), 232 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08de5447e4..35aac9dbbf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,26 +1,25 @@ -# 3.15 is the minimum. -# 3.17 for NVC++. -# 3.18.3 for C++17 + CUDA. +# 3.15 is the minimum for including the project with add_subdirectory. +# 3.21 is the minimum for the developer build. cmake_minimum_required(VERSION 3.15) -# Remove this when we use the new CUDA_ARCHITECTURES properties. -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.18) - cmake_policy(SET CMP0104 OLD) -endif() - # CXX is only needed for AppendOptionIfAvailable. project(CUB NONE) # Determine whether CUB is the top-level project or included into # another project via add_subdirectory(). -if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}") - set(CUB_TOPLEVEL_PROJECT ON) +if(DEFINED CCCL_TOPLEVEL_PROJECT) + set(CUB_TOPLEVEL_PROJECT ${CCCL_TOPLEVEL_PROJECT}) else() - set(CUB_TOPLEVEL_PROJECT OFF) + if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}") + set(CUB_TOPLEVEL_PROJECT ON) + else() + set(CUB_TOPLEVEL_PROJECT OFF) + endif() endif() # This must be done before any languages are enabled: if (CUB_TOPLEVEL_PROJECT) + cmake_minimum_required(VERSION 3.21) include(cmake/CubCompilerHacks.cmake) endif() @@ -30,15 +29,9 @@ endif() # GNUInstallDirs CMake module. enable_language(CXX) -# Thrust has its own copy of CUB install rules to handle packaging usecases -# where we want to install CUB headers but aren't actually building anything. -# In these cases the add_subdirectory(dependencies/cub) line in Thrust won't get -# called so we can't rely on CUB providing its own rules. -if (NOT CUB_IN_THRUST) - option(CUB_ENABLE_INSTALL_RULES "Enable installation of CUB" ${CUB_TOPLEVEL_PROJECT}) - if (CUB_ENABLE_INSTALL_RULES) - include(cmake/CubInstallRules.cmake) - endif() +option(CUB_ENABLE_INSTALL_RULES "Enable installation of CUB" ${CUB_TOPLEVEL_PROJECT}) +if (CUB_ENABLE_INSTALL_RULES) + include(cmake/CubInstallRules.cmake) endif() # Support adding CUB to a parent project via add_subdirectory. diff --git a/cmake/CubBuildCompilerTargets.cmake b/cmake/CubBuildCompilerTargets.cmake index 094fe873ba..ceeefd9070 100644 --- a/cmake/CubBuildCompilerTargets.cmake +++ b/cmake/CubBuildCompilerTargets.cmake @@ -94,7 +94,7 @@ function(cub_build_compiler_targets) foreach (cxx_option IN LISTS cxx_compile_options) target_compile_options(cub.compiler_interface INTERFACE $<$:${cxx_option}> - $<$:${cxx_option}> + $<$:${cxx_option}> # TODO check that this works with the new nvc++ CMake recipe # Only use -Xcompiler with NVCC, not NVC++. # # CMake can't split genexs, so this can't be formatted better :( @@ -124,5 +124,7 @@ function(cub_build_compiler_targets) $<$:-Xcudafe=--promote_warnings> # Don't complain about deprecated GPU targets. $<$:-Wno-deprecated-gpu-targets> + # TODO Clean this up, it's for a spurious "error #128-D: loop is not reachable" on MSVC + nvcc 12.1. + $<$:-diag-suppress 128> ) endfunction() diff --git a/cmake/CubBuildTargetList.cmake b/cmake/CubBuildTargetList.cmake index d4cd729208..b38c372408 100644 --- a/cmake/CubBuildTargetList.cmake +++ b/cmake/CubBuildTargetList.cmake @@ -66,15 +66,7 @@ function(cub_set_target_properties target_name dialect prefix) RUNTIME_OUTPUT_DIRECTORY "${CUB_EXECUTABLE_OUTPUT_DIR}" ) - # CMake still emits errors about empty CUDA_ARCHITECTURES when CMP0104 - # is set to OLD. This suppresses the errors for good. - if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.18) - set_target_properties(${target_name} - PROPERTIES - CUDA_ARCHITECTURES OFF - ) - endif() - + # TODO is this still needed? if ("NVCXX" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") set_target_properties(${target_name} PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS OFF @@ -230,7 +222,7 @@ function(cub_build_target_list) # Some of the iterators and unittests depend on thrust. We should break the # cyclical dependency by migrating CUB's Thrust bits into Thrust. find_package(Thrust ${CUB_VERSION} EXACT CONFIG - HINTS "../../" # Check if we are in thrust/dependencies/cub + HINTS "../thrust" # Monorepo path ) if (Thrust_FOUND) diff --git a/cmake/CubCompilerHacks.cmake b/cmake/CubCompilerHacks.cmake index 45acc1c7c1..00cee98289 100644 --- a/cmake/CubCompilerHacks.cmake +++ b/cmake/CubCompilerHacks.cmake @@ -1,93 +1,16 @@ -# Set up compiler paths and apply temporary hacks to support NVC++. # This file must be included before enabling any languages. -# Temporary hacks to make NVC++ work; this requires you to define -# `CMAKE_CUDA_COMPILER_ID=NVCXX` and `CMAKE_CUDA_COMPILER_FORCED=ON`. -if ("NVCXX" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") - # If using NVC++, don't set CXX compiler - if (NOT "${CMAKE_CXX_COMPILER}" STREQUAL "") - unset(CMAKE_CXX_COMPILER CACHE) - message(FATAL_ERROR "You are using NVC++ as your CUDA C++ compiler, but have" - " specified a different ISO C++ compiler; NVC++ acts as both, so please" - " unset the CMAKE_CXX_COMPILER variable." - ) - endif() - - # We don't set CMAKE_CUDA_HOST_COMPILER for NVC++; if we do, CMake tries to - # pass `-ccbin ${CMAKE_CUDA_HOST_COMPILER}` to NVC++, which it doesn't - # understand. - if (NOT "${CMAKE_CUDA_HOST_COMPILER}" STREQUAL "") - unset(CMAKE_CUDA_HOST_COMPILER CACHE) - message(FATAL_ERROR "You are using NVC++ as your CUDA C++ compiler, but have" - " specified a different host ISO C++ compiler; NVC++ acts as both, so" - " please unset the CMAKE_CUDA_HOST_COMPILER variable." - ) - endif() - - set(CMAKE_CXX_COMPILER "${CMAKE_CUDA_COMPILER}") - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -cuda") - set(CMAKE_CUDA_HOST_LINK_LAUNCHER "${CMAKE_CUDA_COMPILER}") - set(CMAKE_CUDA_LINK_EXECUTABLE - " -o ") -endif () - -# We don't set CMAKE_CUDA_HOST_COMPILER for NVC++; if we do, CMake tries to -# pass `-ccbin ${CMAKE_CUDA_HOST_COMPILER}` to NVC++, which it doesn't -# understand. -if ((NOT "NVCXX" STREQUAL "${CMAKE_CUDA_COMPILER_ID}")) - if (NOT ("${CMAKE_CUDA_HOST_COMPILER}" STREQUAL "" OR - "${CMAKE_CUDA_HOST_COMPILER}" STREQUAL "${CMAKE_CXX_COMPILER}")) - set(tmp "${CMAKE_CUDA_HOST_COMPILER}") - unset(CMAKE_CUDA_HOST_COMPILER CACHE) - message(FATAL_ERROR - "For convenience, CUB's test harness uses CMAKE_CXX_COMPILER for the " - "CUDA host compiler. Refusing to overwrite specified " - "CMAKE_CUDA_HOST_COMPILER -- please reconfigure without setting this " - "variable. Currently:\n" - "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}\n" - "CMAKE_CUDA_HOST_COMPILER=${tmp}" - ) - endif () - set(CMAKE_CUDA_HOST_COMPILER "${CMAKE_CXX_COMPILER}") -endif () - -# Temporary hacks to make NVC++ work; this requires you to define -# `CMAKE_CUDA_COMPILER_ID=NVCXX` and `CMAKE_CUDA_COMPILER_FORCED=ON`. -if ("NVCXX" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") - # Need 3.17 for the properties used below. - cmake_minimum_required(VERSION 3.17) - - set(CMAKE_CUDA_STANDARD_DEFAULT 03) - - set(CMAKE_CUDA03_STANDARD_COMPILE_OPTION "-std=c++03") - set(CMAKE_CUDA03_EXTENSION_COMPILE_OPTION "-std=c++03") - set(CMAKE_CUDA03_STANDARD__HAS_FULL_SUPPORT TRUE) - set_property(GLOBAL PROPERTY CMAKE_CUDA03_KNOWN_FEATURES) - - set(CMAKE_CUDA11_STANDARD_COMPILE_OPTION "-std=c++11") - set(CMAKE_CUDA11_EXTENSION_COMPILE_OPTION "-std=c++11") - set(CMAKE_CUDA11_STANDARD__HAS_FULL_SUPPORT TRUE) - set_property(GLOBAL PROPERTY CMAKE_CUDA11_KNOWN_FEATURES) - - set(CMAKE_CUDA14_STANDARD_COMPILE_OPTION "-std=c++14") - set(CMAKE_CUDA14_EXTENSION_COMPILE_OPTION "-std=c++14") - set(CMAKE_CUDA14_STANDARD__HAS_FULL_SUPPORT TRUE) - set_property(GLOBAL PROPERTY CMAKE_CUDA14_KNOWN_FEATURES) - - set(CMAKE_CUDA17_STANDARD_COMPILE_OPTION "-std=c++17") - set(CMAKE_CUDA17_EXTENSION_COMPILE_OPTION "-std=c++17") - set(CMAKE_CUDA17_STANDARD__HAS_FULL_SUPPORT TRUE) - set_property(GLOBAL PROPERTY CMAKE_CUDA17_KNOWN_FEATURES) - - include(Internal/FeatureTesting) - include(Compiler/CMakeCommonCompilerMacros) - cmake_record_cuda_compile_features() - - set(CMAKE_CUDA_COMPILE_FEATURES - ${CMAKE_CUDA03_COMPILE_FEATURES} - ${CMAKE_CUDA11_COMPILE_FEATURES} - ${CMAKE_CUDA14_COMPILE_FEATURES} - ${CMAKE_CUDA17_COMPILE_FEATURES} - ${CMAKE_CUDA20_COMPILE_FEATURES} +if (NOT ("${CMAKE_CUDA_HOST_COMPILER}" STREQUAL "" OR + "${CMAKE_CUDA_HOST_COMPILER}" STREQUAL "${CMAKE_CXX_COMPILER}")) + set(tmp "${CMAKE_CUDA_HOST_COMPILER}") + unset(CMAKE_CUDA_HOST_COMPILER CACHE) + message(FATAL_ERROR + "For convenience, CUB's test harness uses CMAKE_CXX_COMPILER for the " + "CUDA host compiler. Refusing to overwrite specified " + "CMAKE_CUDA_HOST_COMPILER -- please reconfigure without setting this " + "variable. Currently:\n" + "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}\n" + "CMAKE_CUDA_HOST_COMPILER=${tmp}" ) endif () +set(CMAKE_CUDA_HOST_COMPILER "${CMAKE_CXX_COMPILER}") diff --git a/cmake/CubCudaConfig.cmake b/cmake/CubCudaConfig.cmake index c2366196c1..74cc5d5c01 100644 --- a/cmake/CubCudaConfig.cmake +++ b/cmake/CubCudaConfig.cmake @@ -1,87 +1,23 @@ enable_language(CUDA) -if (NOT CUB_IN_THRUST) - message(FATAL_ERROR - "Building CUB as a standalone project is no longer supported. " - "Use the Thrust repo instead.") -endif() - -set(CUB_CUDA_FLAGS_BASE "${THRUST_CUDA_FLAGS_BASE}") -set(CUB_CUDA_FLAGS_RDC "${THRUST_CUDA_FLAGS_RDC}") -set(CUB_CUDA_FLAGS_NO_RDC "${THRUST_CUDA_FLAGS_NO_RDC}") - -# Update the enabled architectures list from thrust -foreach (arch IN LISTS THRUST_KNOWN_COMPUTE_ARCHS) - if (THRUST_ENABLE_COMPUTE_${arch}) - set(CUB_ENABLE_COMPUTE_${arch} True) - string(APPEND arch_message " sm_${arch}") - else() - set(CUB_ENABLE_COMPUTE_${arch} False) - endif() -endforeach() - -message(STATUS ${arch_message}) - # -# RDC options: +# Architecture options: # -# RDC is off by default in NVCC and on by default in NVC++. Turning off RDC -# isn't currently supported by NVC++. So, we default to RDC off for NVCC and -# RDC on for NVC++. -set(option_init OFF) -if ("NVCXX" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") - set(option_init ON) -endif() - -option(CUB_ENABLE_TESTS_WITH_RDC - "Build all CUB tests with RDC; tests that require RDC are not affected by this option." - ${option_init} -) - -option(CUB_ENABLE_EXAMPLES_WITH_RDC - "Build all CUB examples with RDC; examples which require RDC are not affected by this option." - ${option_init} -) +# Create a new arch list that only contains arches that support CDP: +set(CUB_CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES}) +set(CUB_CUDA_ARCHITECTURES_RDC ${CUB_CUDA_ARCHITECTURES}) +list(FILTER CUB_CUDA_ARCHITECTURES_RDC EXCLUDE REGEX "53|62|72|90") -# Check for RDC/SM compatibility and error/warn if necessary -set(rdc_supported True) -foreach (arch IN LISTS no_rdc_archs) - if (CUB_ENABLE_COMPUTE_${arch}) - set(rdc_supported False) - break() - endif() -endforeach() +message(STATUS "CUB_CUDA_ARCHITECTURES: ${CUB_CUDA_ARCHITECTURES}") +message(STATUS "CUB_CUDA_ARCHITECTURES_RDC: ${CUB_CUDA_ARCHITECTURES_RDC}") -set(rdc_opts - CUB_ENABLE_TESTS_WITH_RDC - CUB_ENABLE_EXAMPLES_WITH_RDC -) -set(rdc_requested False) -foreach (rdc_opt IN LISTS rdc_opts) - if (${rdc_opt}) - set(rdc_requested True) - break() - endif() -endforeach() +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) -if (rdc_requested AND NOT rdc_supported) - string(JOIN ", " no_rdc ${no_rdc_archs}) - string(JOIN "\n" opts ${rdc_opts}) - message(FATAL_ERROR - "Architectures {${no_rdc}} do not support RDC and are incompatible with " - "these options:\n${opts}" - ) -endif() - - -# +# # Clang CUDA options # if ("Clang" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") - set(CUB_CUDA_FLAGS_BASE "${CUB_CUDA_FLAGS_BASE} -Wno-unknown-cuda-version -Xclang=-fcuda-allow-variadic-functions") -endif() - - -# By default RDC is not used: -set(CMAKE_CUDA_FLAGS "${CUB_CUDA_FLAGS_BASE} ${CUB_CUDA_FLAGS_NO_RDC}") + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-unknown-cuda-version -Xclang=-fcuda-allow-variadic-functions") +endif () diff --git a/cmake/CubHeaderTesting.cmake b/cmake/CubHeaderTesting.cmake index aaecec903e..e1db752ddb 100644 --- a/cmake/CubHeaderTesting.cmake +++ b/cmake/CubHeaderTesting.cmake @@ -29,6 +29,7 @@ function(cub_add_header_test label definitions) target_link_libraries(${headertest_target} PUBLIC ${cub_target}) target_compile_definitions(${headertest_target} PRIVATE ${definitions}) cub_clone_target_properties(${headertest_target} ${cub_target}) + cub_configure_cuda_target(${headertest_target} RDC ${CUB_FORCE_RDC}) if (CUB_IN_THRUST) thrust_fix_clang_nvcc_build_for(${headertest_target}) diff --git a/cmake/CubInstallRules.cmake b/cmake/CubInstallRules.cmake index 5474555bed..d26da438e4 100644 --- a/cmake/CubInstallRules.cmake +++ b/cmake/CubInstallRules.cmake @@ -1,9 +1,3 @@ -# Thrust manages its own copy of these rules. Update ThrustInstallRules.cmake -# if modifying this file. -if (CUB_IN_THRUST) - return() -endif() - # Bring in CMAKE_INSTALL_LIBDIR include(GNUInstallDirs) diff --git a/cmake/CubUtilities.cmake b/cmake/CubUtilities.cmake index 825010ae1b..a3f876a8ed 100644 --- a/cmake/CubUtilities.cmake +++ b/cmake/CubUtilities.cmake @@ -1,13 +1,29 @@ -# Enable RDC for a CUDA target. Encapsulates compiler hacks: -function(cub_enable_rdc_for_cuda_target target_name) - if ("NVCXX" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") +# cub_configure_cuda_target( RDC ) +# +# 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 - COMPILE_FLAGS "-gpu=rdc" - ) - elseif ("Clang" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") + CUDA_ARCHITECTURES "${CUB_CUDA_ARCHITECTURES_RDC}" + CUDA_SEPARABLE_COMPILATION ON) else() set_target_properties(${target_name} PROPERTIES - CUDA_SEPARABLE_COMPILATION ON - ) + CUDA_ARCHITECTURES "${CUB_CUDA_ARCHITECTURES}" + CUDA_SEPARABLE_COMPILATION OFF) endif() endfunction() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 7d06e7ce6f..3865b6f057 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -6,14 +6,6 @@ foreach(cub_target IN LISTS CUB_TARGETS) add_dependencies(${config_prefix}.all ${config_meta_target}) endforeach() -# Update flags to reflect RDC options. See note in CubCudaConfig.cmake -- -# these flag variables behave unintuitively: -if (CUB_ENABLE_EXAMPLES_WITH_RDC) - set(CMAKE_CUDA_FLAGS "${CUB_CUDA_FLAGS_BASE} ${CUB_CUDA_FLAGS_RDC}") -else() - set(CMAKE_CUDA_FLAGS "${CUB_CUDA_FLAGS_BASE} ${CUB_CUDA_FLAGS_NO_RDC}") -endif() - ## cub_add_example # # Add an example executable and register it with ctest. @@ -40,6 +32,7 @@ function(cub_add_example target_name_var example_name example_src cub_target) add_executable(${example_target} "${example_src}") target_link_libraries(${example_target} ${cub_target}) cub_clone_target_properties(${example_target} ${cub_target}) + cub_configure_cuda_target(${example_target} RDC ${CUB_FORCE_RDC}) target_include_directories(${example_target} PRIVATE "${CUB_SOURCE_DIR}/examples") if (CUB_IN_THRUST) @@ -55,10 +48,6 @@ function(cub_add_example target_name_var example_name example_src cub_target) endif() add_dependencies(${example_meta_target} ${example_target}) - if (CUB_ENABLE_EXAMPLES_WITH_RDC) - cub_enable_rdc_for_cuda_target(${example_target}) - endif() - add_test(NAME ${example_target} COMMAND "$" ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bba5b6c408..7b73201c44 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -303,9 +303,7 @@ foreach (test_src IN LISTS test_srcs) if (num_variants EQUAL 0) # Only one version of this test. cub_add_test(test_target ${test_name} "${test_src}" ${cub_target}) - if (CUB_ENABLE_TESTS_WITH_RDC) - cub_enable_rdc_for_cuda_target(${test_target}) - endif() + cub_configure_cuda_target(${test_target} RDC ${CUB_FORCE_RDC}) else() # has variants: # Meta target to build all parametrizations of the current test for the # current CUB_TARGET config @@ -334,10 +332,8 @@ foreach (test_src IN LISTS test_srcs) _cub_has_cdp_variant(explicit_cdp "${label}") _cub_is_cdp_enabled_variant(enable_cdp "${label}") - if (enable_cdp) - if (NOT CUB_ENABLE_TESTS_WITH_RDC) - continue() - endif() + if (enable_cdp AND NOT CUB_ENABLE_RDC_TESTS) + continue() endif() cub_add_test(test_target @@ -352,12 +348,14 @@ foreach (test_src IN LISTS test_srcs) # Enable RDC if the test either: # 1. Explicitly requests it (cdp_1 label) # 2. Does not have an explicit CDP variant (no cdp_0 or cdp_1) but - # RDC testing is globally enabled. + # RDC testing is forced # # Tests that explicitly request no cdp (cdp_0 label) should never enable # RDC. - if (enable_cdp OR ((NOT explicit_cdp) AND CUB_ENABLE_TESTS_WITH_RDC)) - cub_enable_rdc_for_cuda_target(${test_target}) + if (explicit_cdp) + cub_configure_cuda_target(${test_target} RDC ${enable_cdp}) + else() + cub_configure_cuda_target(${test_target} RDC ${CUB_FORCE_RDC}) endif() endforeach() # Variant endif() # Has variants From 5a9f2f5843f4f3b4c3395d0c63b30d964ec8562b Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Fri, 26 May 2023 11:17:13 -0400 Subject: [PATCH 02/14] Update CMake option docs. --- CONTRIBUTING.md | 44 +++++++++++--------------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8c5cdf75c5..0b6813ea78 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,6 +39,10 @@ The configuration options for CUB are: - `CMAKE_BUILD_TYPE={Release, Debug, RelWithDebInfo, MinSizeRel}` - Standard CMake build option. Default: `RelWithDebInfo` +- `CUB_ENABLE_INSTALL_RULES={ON, OFF}` + - If true, installation rules will be generated for CUB. Default is `ON` when + building CUB alone, and `OFF` when CUB is a subproject added via CMake's + `add_subdirectory`. - `CUB_ENABLE_HEADER_TESTING={ON, OFF}` - Whether to test compile public headers. Default is `ON`. - `CUB_ENABLE_TESTING={ON, OFF}` @@ -52,39 +56,13 @@ The configuration options for CUB are: - Multiple dialects may be targeted in a single build. - Possible values of `XX` are `{11, 14, 17}`. - By default, only C++14 is enabled. -- `CUB_ENABLE_COMPUTE_XX={ON, OFF}` - - Setting this has no effect when building CUB as a component of Thrust. - See Thrust's architecture options, which CUB will inherit. - - Controls the targeted CUDA architecture(s) - - Multiple options may be selected when using NVCC as the CUDA compiler. - - Valid values of `XX` are: - `{35, 37, 50, 52, 53, 60, 61, 62, 70, 72, 75, 80}` - - Default value depends on `CUB_DISABLE_ARCH_BY_DEFAULT`: -- `CUB_ENABLE_COMPUTE_FUTURE={ON, OFF}` - - Setting this has no effect when building CUB as a component of Thrust. - See Thrust's architecture options, which CUB will inherit. - - If enabled, CUDA objects will target the most recent virtual architecture - in addition to the real architectures specified by the - `CUB_ENABLE_COMPUTE_XX` options. - - Default value depends on `CUB_DISABLE_ARCH_BY_DEFAULT`: -- `CUB_DISABLE_ARCH_BY_DEFAULT={ON, OFF}` - - Setting this has no effect when building CUB as a component of Thrust. - See Thrust's architecture options, which CUB will inherit. - - When `ON`, all `CUB_ENABLE_COMPUTE_*` options are initially `OFF`. - - Default: `OFF` (meaning all architectures are enabled by default) -- `CUB_ENABLE_TESTS_WITH_RDC={ON, OFF}` - - Whether to enable Relocatable Device Code when building tests. - Default is `OFF`. -- `CUB_ENABLE_EXAMPLES_WITH_RDC={ON, OFF}` - - Whether to enable Relocatable Device Code when building examples. - Default is `OFF`. -- `CUB_ENABLE_INSTALL_RULES={ON, OFF}` - - Setting this has no effect when building CUB as a component of Thrust. - See Thrust's `THRUST_INSTALL_CUB_HEADERS` option, which controls this - behavior. - - If true, installation rules will be generated for CUB. Default is `ON` when - building CUB alone, and `OFF` when CUB is a subproject added via CMake's - `add_subdirectory`. +- `CUB_ENABLE_RDC_TESTS={ON, OFF}` + - Enable tests that require separable compilation. + - Default is `ON`. +- `CUB_FORCE_RDC={ON, OFF}` + - Enable separable compilation on all targets that are agnostic of RDC. + - Targets that explicitly require RDC to be enabled or disabled will ignore this setting. + - Default is `OFF`. # Development Model From 1c50fa17a9baf42631cf88a3a2325e8f8ed98fcc Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Thu, 1 Jun 2023 12:18:02 -0400 Subject: [PATCH 03/14] Allow TOPLEVEL_PROJECT logic to be force enabled. --- CMakeLists.txt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 35aac9dbbf..87716f1955 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,15 +7,10 @@ project(CUB NONE) # Determine whether CUB is the top-level project or included into # another project via add_subdirectory(). -if(DEFINED CCCL_TOPLEVEL_PROJECT) - set(CUB_TOPLEVEL_PROJECT ${CCCL_TOPLEVEL_PROJECT}) -else() - if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}") - set(CUB_TOPLEVEL_PROJECT ON) - else() - set(CUB_TOPLEVEL_PROJECT OFF) - endif() -endif() +if (CCCL_TOPLEVEL_PROJECT OR + "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}") + set(CUB_TOPLEVEL_PROJECT ON) +endif () # This must be done before any languages are enabled: if (CUB_TOPLEVEL_PROJECT) From ee116183135c8ecc7bfa8209fe27da03a13c3480 Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Thu, 1 Jun 2023 17:02:11 -0400 Subject: [PATCH 04/14] Version lock CUB with other CCCL libraries. --- cub/cmake/cub-config.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cub/cmake/cub-config.cmake b/cub/cmake/cub-config.cmake index ebe40efcd2..718fa29a10 100644 --- a/cub/cmake/cub-config.cmake +++ b/cub/cmake/cub-config.cmake @@ -9,7 +9,7 @@ if (TARGET CUB::CUB) endif() # Minimum supported libcudacxx version: -set(cub_libcudacxx_version 1.8.0) +set(cub_libcudacxx_version "${CUB_VERSION}") function(_cub_declare_interface_alias alias_name ugly_name) # 1) Only IMPORTED and ALIAS targets can be placed in a namespace. From e270c9628cf0908e0c754a65166fdc79ff1189e9 Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Mon, 5 Jun 2023 12:35:39 -0400 Subject: [PATCH 05/14] Remove temporary warning suppression. --- cmake/CubBuildCompilerTargets.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmake/CubBuildCompilerTargets.cmake b/cmake/CubBuildCompilerTargets.cmake index ceeefd9070..13469697b2 100644 --- a/cmake/CubBuildCompilerTargets.cmake +++ b/cmake/CubBuildCompilerTargets.cmake @@ -124,7 +124,5 @@ function(cub_build_compiler_targets) $<$:-Xcudafe=--promote_warnings> # Don't complain about deprecated GPU targets. $<$:-Wno-deprecated-gpu-targets> - # TODO Clean this up, it's for a spurious "error #128-D: loop is not reachable" on MSVC + nvcc 12.1. - $<$:-diag-suppress 128> ) endfunction() From c01ca1c15b8e49392fd4d1319df3bd9a26294c70 Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Mon, 5 Jun 2023 13:28:13 -0400 Subject: [PATCH 06/14] Add `LANGUAGES` keyword to CMake project calls. --- CMakeLists.txt | 2 +- examples/cmake/add_subdir/CMakeLists.txt | 2 +- test/cmake/test_install/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87716f1955..aa24918ae9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.15) # CXX is only needed for AppendOptionIfAvailable. -project(CUB NONE) +project(CUB LANGUAGES NONE) # Determine whether CUB is the top-level project or included into # another project via add_subdirectory(). diff --git a/examples/cmake/add_subdir/CMakeLists.txt b/examples/cmake/add_subdir/CMakeLists.txt index 41a460593d..dc4a95e312 100644 --- a/examples/cmake/add_subdir/CMakeLists.txt +++ b/examples/cmake/add_subdir/CMakeLists.txt @@ -8,7 +8,7 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.18) cmake_policy(SET CMP0104 OLD) endif() -project(CubAddSubDirExample CUDA) +project(CubAddSubDirExample LANGUAGES CUDA) # Use your project's checkout of CUB here, for most cases # `add_subdirectory(cub)` will be sufficient. diff --git a/test/cmake/test_install/CMakeLists.txt b/test/cmake/test_install/CMakeLists.txt index c43e6b38a6..5aa8f7fa07 100644 --- a/test/cmake/test_install/CMakeLists.txt +++ b/test/cmake/test_install/CMakeLists.txt @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.15) -project(CubTestInstall CXX CUDA) +project(CubTestInstall LANGUAGES CXX CUDA) # This will eventually get deleted recursively -- keep that in mind if modifying set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/install_prefix/") From 531d17a27dc6ab8d8670134a9151bad6ccdae65a Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Mon, 5 Jun 2023 13:31:15 -0400 Subject: [PATCH 07/14] Simplify some genexes and update compiler ID where needed. --- cmake/CubBuildCompilerTargets.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CubBuildCompilerTargets.cmake b/cmake/CubBuildCompilerTargets.cmake index 13469697b2..0b868f97fb 100644 --- a/cmake/CubBuildCompilerTargets.cmake +++ b/cmake/CubBuildCompilerTargets.cmake @@ -94,7 +94,7 @@ function(cub_build_compiler_targets) foreach (cxx_option IN LISTS cxx_compile_options) target_compile_options(cub.compiler_interface INTERFACE $<$:${cxx_option}> - $<$:${cxx_option}> # TODO check that this works with the new nvc++ CMake recipe + $<$:${cxx_option}> # Only use -Xcompiler with NVCC, not NVC++. # # CMake can't split genexs, so this can't be formatted better :( From fe632bab00862f3ca14d4817e4b26b8a7475209c Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Mon, 5 Jun 2023 13:33:45 -0400 Subject: [PATCH 08/14] Remove unnecessary NVC++ tweaks. --- cmake/CubBuildTargetList.cmake | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cmake/CubBuildTargetList.cmake b/cmake/CubBuildTargetList.cmake index b38c372408..426eee5e26 100644 --- a/cmake/CubBuildTargetList.cmake +++ b/cmake/CubBuildTargetList.cmake @@ -65,13 +65,6 @@ function(cub_set_target_properties target_name dialect prefix) LIBRARY_OUTPUT_DIRECTORY "${CUB_LIBRARY_OUTPUT_DIR}" RUNTIME_OUTPUT_DIRECTORY "${CUB_EXECUTABLE_OUTPUT_DIR}" ) - - # TODO is this still needed? - if ("NVCXX" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") - set_target_properties(${target_name} PROPERTIES - CUDA_RESOLVE_DEVICE_SYMBOLS OFF - ) - endif() endif() endfunction() From 0e82f72fd70fe796cd69a84296d4fe2701b6a411 Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Mon, 5 Jun 2023 14:34:04 -0400 Subject: [PATCH 09/14] Add guards against unsupported arch options. --- cmake/CubCudaConfig.cmake | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmake/CubCudaConfig.cmake b/cmake/CubCudaConfig.cmake index 74cc5d5c01..e613b8cd27 100644 --- a/cmake/CubCudaConfig.cmake +++ b/cmake/CubCudaConfig.cmake @@ -4,6 +4,17 @@ enable_language(CUDA) # Architecture options: # +# Since we have to filter the arch list based on target features, we don't +# currently support the convenience arch flags: +if ("all" IN_LIST CMAKE_CUDA_ARCHITECTURES OR + "all-major" IN_LIST CMAKE_CUDA_ARCHITECTURES OR + "native" IN_LIST CMAKE_CUDA_ARCHITECTURES) + message(FATAL_ERROR + "The CUB dev build requires an explicit list of architectures in CMAKE_CUDA_ARCHITECTURES. " + "The convenience flags of 'all', 'all-major', and 'native' are not supported.\n" + "CMAKE_CUDA_ARCHITECTURES=${CMAKE_CUDA_ARCHITECTURES}") +endif() + # Create a new arch list that only contains arches that support CDP: set(CUB_CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES}) set(CUB_CUDA_ARCHITECTURES_RDC ${CUB_CUDA_ARCHITECTURES}) From 33259c13ad18b37f859fe815de7571cbc72acf2e Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Mon, 5 Jun 2023 14:40:29 -0400 Subject: [PATCH 10/14] Enable PIC for RDC targets. --- cmake/CubUtilities.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/CubUtilities.cmake b/cmake/CubUtilities.cmake index a3f876a8ed..9607f228ce 100644 --- a/cmake/CubUtilities.cmake +++ b/cmake/CubUtilities.cmake @@ -20,6 +20,7 @@ function(cub_configure_cuda_target target_name) if (cub_cuda_RDC) set_target_properties(${target_name} PROPERTIES CUDA_ARCHITECTURES "${CUB_CUDA_ARCHITECTURES_RDC}" + POSITION_INDEPENDENT_CODE ON CUDA_SEPARABLE_COMPILATION ON) else() set_target_properties(${target_name} PROPERTIES From 2a20a0e612ac817ffc1362e2a42b030fa44d9e45 Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Tue, 6 Jun 2023 17:14:00 -0400 Subject: [PATCH 11/14] Update more CUDA compiler ID checks. --- cmake/CubBuildCompilerTargets.cmake | 2 +- test/CMakeLists.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/CubBuildCompilerTargets.cmake b/cmake/CubBuildCompilerTargets.cmake index 0b868f97fb..5725496a51 100644 --- a/cmake/CubBuildCompilerTargets.cmake +++ b/cmake/CubBuildCompilerTargets.cmake @@ -83,7 +83,7 @@ function(cub_build_compiler_targets) endif() endif() - if ("NVCXX" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") + if ("NVHPC" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") list(APPEND cxx_compile_options -Mnodaz) # TODO: Managed memory is currently not supported on windows with WSL list(APPEND cxx_compile_options -gpu=nomanaged) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7b73201c44..bf31f67b4d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,4 +1,4 @@ -if ("NVCXX" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") +if ("NVHPC" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") # NVBugs 200770766 set(CUB_SEPARATE_CATCH2 ON) else() @@ -152,7 +152,7 @@ function(cub_add_test target_name_var test_name test_src cub_target) PROPERTY POSITION_INDEPENDENT_CODE ON ) - if ("NVCXX" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") + if ("NVHPC" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") target_link_options(${config_c2h_target} PRIVATE "-cuda") target_compile_options(${config_c2h_target} PRIVATE "-fPIC") endif() @@ -195,7 +195,7 @@ function(cub_add_test target_name_var test_name test_src cub_target) target_include_directories(${config_c2run_target} PRIVATE "${CUB_SOURCE_DIR}/test" ) - if ("NVCXX" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") + if ("NVHPC" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") target_link_options(${config_c2run_target} PRIVATE "-cuda") endif() From 7ec97564122a961b76783ca70555ce20de1578f1 Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Tue, 6 Jun 2023 18:55:05 -0400 Subject: [PATCH 12/14] Move dev build toggle to the cccl project level. This allows the install rules to be generated for all projects even when the dev builds are disabled. --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa24918ae9..bc34ce4105 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,7 @@ project(CUB LANGUAGES NONE) # Determine whether CUB is the top-level project or included into # another project via add_subdirectory(). -if (CCCL_TOPLEVEL_PROJECT OR - "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}") +if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}") set(CUB_TOPLEVEL_PROJECT ON) endif () From 30790775fff637295075c0fc915b03ed6ab36c56 Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Wed, 7 Jun 2023 10:36:44 -0400 Subject: [PATCH 13/14] Remove install tests from Thrust/CUB. These are now handled at the CCCL level, using newer and more robust techniques. --- test/cmake/CMakeLists.txt | 16 ----- test/cmake/test_install/CMakeLists.txt | 93 -------------------------- 2 files changed, 109 deletions(-) delete mode 100644 test/cmake/test_install/CMakeLists.txt diff --git a/test/cmake/CMakeLists.txt b/test/cmake/CMakeLists.txt index 1f3ae43f7e..73bfd0391c 100644 --- a/test/cmake/CMakeLists.txt +++ b/test/cmake/CMakeLists.txt @@ -1,19 +1,3 @@ -if (NOT CUB_IN_THRUST) # Thrust has its own checks for this: - # Test that we can use `find_package` on an installed CUB: - add_test( - NAME cub.test.cmake.test_install - COMMAND "${CMAKE_COMMAND}" - --log-level=VERBOSE - -G "${CMAKE_GENERATOR}" - -S "${CMAKE_CURRENT_SOURCE_DIR}/test_install" - -B "${CMAKE_CURRENT_BINARY_DIR}/test_install" - -D "CUB_BINARY_DIR=${CUB_BINARY_DIR}" - -D "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" - -D "CMAKE_CUDA_COMPILER=${CMAKE_CUDA_COMPILER}" - -D "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" - ) -endif() - # Check source code for issues that can be found by pattern matching: add_test( NAME cub.test.cmake.check_source_files diff --git a/test/cmake/test_install/CMakeLists.txt b/test/cmake/test_install/CMakeLists.txt deleted file mode 100644 index 5aa8f7fa07..0000000000 --- a/test/cmake/test_install/CMakeLists.txt +++ /dev/null @@ -1,93 +0,0 @@ -# Test that an installation of the project can be located by find_package() call -# with appropriate prefix settings. -# -# Expects CUB_BINARY_DIR to be set to an existing cub build directory. - -cmake_minimum_required(VERSION 3.15) - -project(CubTestInstall LANGUAGES CXX CUDA) - -# This will eventually get deleted recursively -- keep that in mind if modifying -set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/install_prefix/") - -function(do_manual_install) - # Inspired by the VTK-m install tests, we can just glob up all of the - # cmake_install.cmake, include (ie. run) them, and they'll effectively - # install the project into the current value of CMAKE_INSTALL_PREFIX. - - # Gather all of the install files from CUB's root: - file(GLOB_RECURSE install_files - LIST_DIRECTORIES False - "${CUB_BINARY_DIR}/cmake_install.cmake" - ) - - message(STATUS "Locating install files...") - foreach (install_file IN LISTS install_files) - message(STATUS " * ${install_file}") - endforeach() - - message(STATUS "Building install tree...") - foreach(install_file IN LISTS install_files) - include("${install_file}") - endforeach() -endfunction() - -function(do_cleanup) - message(STATUS "Removing ${CMAKE_INSTALL_PREFIX}") - file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}") -endfunction() - -function(assert_boolean var_name expect) - if (expect) - if (NOT ${var_name}) - message(FATAL_ERROR "'${var_name}' is false, expected true.") - endif() - else() - if (${var_name}) - message(FATAL_ERROR "'${var_name}' is true, expected false.") - endif() - endif() -endfunction() - -function(assert_target target_name) - if (NOT TARGET "${target_name}") - message(FATAL_ERROR "Target '${target_name}' not defined.") - endif() -endfunction() - -function(find_installed_project) - set(CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}") - find_package(CUB CONFIG) - - if (NOT CUB_FOUND) - message(FATAL_ERROR - "find_package(CUB) failed. " - "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" - ) - endif() - - # Test some internal config vars to check that this is the expected install: - # TODO The cmake_path (3.19) command will provide more robust ways to do this - - # Escape regex special characters in the install prefix, see - # https://gitlab.kitware.com/cmake/cmake/-/issues/18580 - string(REGEX REPLACE "([][+.*()^])" "\\\\\\1" - prefix_regex - "${CMAKE_INSTALL_PREFIX}" - ) - if (NOT _CUB_INCLUDE_DIR MATCHES "^${prefix_regex}") - message(FATAL_ERROR - "Found CUB in unexpected location: " - " * _CUB_INCLUDE_DIR=${_CUB_INCLUDE_DIR} " - " * ExpectedPrefix=${CMAKE_INSTALL_DIR}" - ) - endif() - - assert_target(CUB::CUB) - -endfunction() - -do_cleanup() # Prepare for new installation -do_manual_install() -find_installed_project() -do_cleanup() # Clean up if successful From b729edbf8e6d43709e3ff21f9f78d6178b54fc60 Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Wed, 7 Jun 2023 13:30:03 -0400 Subject: [PATCH 14/14] Update how RDC settings are applied to Catch2 utilities. --- test/CMakeLists.txt | 19 +++++++------------ test/README.md | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bf31f67b4d..fcf3e7e6d4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,14 +18,6 @@ CPMAddPackage("gh:brunocodutra/metal@2.1.4") find_package(CUDAToolkit REQUIRED) -# Some tests always build with RDC, so make sure that the sm_XX flags are -# compatible. See note in CubCudaConfig.cmake. -# TODO once we're using CUDA_ARCHITECTURES, we can setup non-rdc fallback -# tests to build for non-rdc arches. But for now, all files in a given directory -# must build with the same `CMAKE_CUDA_FLAGS` due to CMake constraints around -# how CUDA_FLAGS works. -set(CMAKE_CUDA_FLAGS "${CUB_CUDA_FLAGS_BASE} ${CUB_CUDA_FLAGS_RDC}") - # The function below reads the filepath `src`, extracts the %PARAM% comments, # and fills `labels_var` with a list of `label1_value1.label2_value2...` # strings, and puts the corresponding `DEFINITION=value1:DEFINITION=value2` @@ -144,6 +136,11 @@ function(cub_add_test target_name_var test_name test_src cub_target) set(config_meta_target ${config_prefix}.tests) if (is_catch2_test) + set(use_rdc_for_catch2_utils OFF) + if (CUB_ENABLE_RDC_TESTS OR CUB_FORCE_RDC) + set(use_rdc_for_catch2_utils ON) + endif() + # Per config helper library: set(config_c2h_target ${config_prefix}.test.catch2_helper) if (NOT TARGET ${config_c2h_target}) @@ -162,15 +159,12 @@ function(cub_add_test target_name_var test_name test_src cub_target) ) cub_clone_target_properties(${config_c2h_target} ${cub_target}) + cub_configure_cuda_target(${config_c2h_target} RDC ${use_rdc_for_catch2_utils}) target_link_libraries(${config_c2h_target} PRIVATE CUDA::curand ${cub_target}) if (CUB_IN_THRUST) thrust_fix_clang_nvcc_build_for(${config_c2h_target}) endif() - - if (CUB_ENABLE_TESTS_WITH_RDC) - cub_enable_rdc_for_cuda_target(${config_c2h_target}) - endif() endif() # config_c2h_target if (CUB_SEPARATE_CATCH2) @@ -191,6 +185,7 @@ function(cub_add_test target_name_var test_name test_src cub_target) Catch2::Catch2 ) cub_clone_target_properties(${config_c2run_target} ${cub_target}) + cub_configure_cuda_target(${config_c2run_target} RDC ${use_rdc_for_catch2_utils}) add_dependencies(${config_meta_target} ${config_c2run_target}) target_include_directories(${config_c2run_target} PRIVATE "${CUB_SOURCE_DIR}/test" diff --git a/test/README.md b/test/README.md index 81891f495f..8836525db3 100644 --- a/test/README.md +++ b/test/README.md @@ -39,7 +39,7 @@ parameter must be `0:1`, with `0` indicating CDP disabled (RDC off) and `1` indicating CDP enabled (RDC on). Tests that do not contain a variant labeled `cdp` will only enable RDC if -the CMake variable `CUB_ENABLE_TESTS_WITH_RDC` is true. +the CMake config enables them. ## Example