Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Update how RDC settings are applied to Catch2 utilities.
Browse files Browse the repository at this point in the history
  • Loading branch information
alliepiper committed Jun 7, 2023
1 parent 1fdce39 commit ab1c756
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
19 changes: 7 additions & 12 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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})
Expand All @@ -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)
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ab1c756

Please sign in to comment.