Skip to content

Commit

Permalink
Use rapids_cuda_set_runtime to determine cuda runtime usage by targ…
Browse files Browse the repository at this point in the history
…et (rapidsai#14833)

This PR uses rapids-cmake to handle per-target CMake linking to cudart.

Replaces rapidsai#13543 and rapidsai#11641.

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - Mark Harris (https://github.com/harrism)
  - Robert Maynard (https://github.com/robertmaynard)

URL: rapidsai#14833
  • Loading branch information
vyasr authored and PointKernel committed Jan 25, 2024
1 parent d7bcda9 commit fb4ac33
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
16 changes: 5 additions & 11 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ include(../fetch_rapids.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
include(${rapids-cmake-dir}/cuda/set_runtime.cmake)
include(rapids-export)
include(rapids-find)

Expand Down Expand Up @@ -780,17 +781,7 @@ if(TARGET conda_env)
target_link_libraries(cudf PRIVATE conda_env)
endif()

if(CUDA_STATIC_RUNTIME)
# Tell CMake what CUDA language runtime to use
set_target_properties(cudf PROPERTIES CUDA_RUNTIME_LIBRARY Static)
# Make sure to export to consumers what runtime we used
target_link_libraries(cudf PUBLIC CUDA::cudart_static)
else()
# Tell CMake what CUDA language runtime to use
set_target_properties(cudf PROPERTIES CUDA_RUNTIME_LIBRARY Shared)
# Make sure to export to consumers what runtime we used
target_link_libraries(cudf PUBLIC CUDA::cudart)
endif()
rapids_cuda_set_runtime(cudf USE_STATIC ${CUDA_STATIC_RUNTIME})

file(
WRITE "${CUDF_BINARY_DIR}/fatbin.ld"
Expand Down Expand Up @@ -838,6 +829,7 @@ if(CUDF_BUILD_TESTUTIL)
PUBLIC cudf
PRIVATE $<TARGET_NAME_IF_EXISTS:conda_env>
)
rapids_cuda_set_runtime(cudftest_default_stream USE_STATIC ${CUDA_STATIC_RUNTIME})

add_library(cudf::cudftest_default_stream ALIAS cudftest_default_stream)

Expand Down Expand Up @@ -881,6 +873,7 @@ if(CUDF_BUILD_TESTUTIL)
cudftestutil PUBLIC "$<BUILD_INTERFACE:${CUDF_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CUDF_SOURCE_DIR}/src>"
)
rapids_cuda_set_runtime(cudftestutil USE_STATIC ${CUDA_STATIC_RUNTIME})
add_library(cudf::cudftestutil ALIAS cudftestutil)

endif()
Expand Down Expand Up @@ -919,6 +912,7 @@ if(CUDF_BUILD_STREAMS_TEST_UTIL)
if(CUDF_BUILD_STACKTRACE_DEBUG)
target_link_libraries(${_tgt} PRIVATE cudf_backtrace)
endif()
rapids_cuda_set_runtime(${_tgt} USE_STATIC ${CUDA_STATIC_RUNTIME})
add_library(cudf::${_tgt} ALIAS ${_tgt})

if("${_mode}" STREQUAL "testing")
Expand Down
5 changes: 3 additions & 2 deletions cpp/cmake/Modules/JitifyPreprocessKernels.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2021-2023, NVIDIA CORPORATION.
# Copyright (c) 2021-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
Expand All @@ -16,7 +16,8 @@
add_executable(jitify_preprocess "${JITIFY_INCLUDE_DIR}/jitify2_preprocess.cpp")

target_compile_definitions(jitify_preprocess PRIVATE "_FILE_OFFSET_BITS=64")
target_link_libraries(jitify_preprocess CUDA::cudart ${CMAKE_DL_LIBS})
rapids_cuda_set_runtime(jitify_preprocess USE_STATIC ${CUDA_STATIC_RUNTIME})
target_link_libraries(jitify_preprocess PUBLIC ${CMAKE_DL_LIBS})

# Take a list of files to JIT-compile and run them through jitify_preprocess.
function(jit_preprocess_files)
Expand Down
1 change: 1 addition & 0 deletions cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function(ConfigureTest CMAKE_TEST_NAME)
${CMAKE_TEST_NAME} PRIVATE cudftestutil GTest::gmock_main GTest::gtest_main
$<TARGET_NAME_IF_EXISTS:conda_env>
)
rapids_cuda_set_runtime(${CMAKE_TEST_NAME} USE_STATIC ${CUDA_STATIC_RUNTIME})
rapids_test_add(
NAME ${CMAKE_TEST_NAME}
COMMAND ${CMAKE_TEST_NAME}
Expand Down

0 comments on commit fb4ac33

Please sign in to comment.