Skip to content

Commit

Permalink
[CMake] Explicitly link with CCCL (standalone or CTK) (#10624)
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 committed Jul 24, 2024
1 parent 7949a8d commit 411c846
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,24 @@ if(USE_CUDA)
add_subdirectory(${PROJECT_SOURCE_DIR}/gputreeshap)

find_package(CUDAToolkit REQUIRED)
find_package(CCCL CONFIG)
if(NOT CCCL_FOUND)
message(STATUS "Standalone CCCL not found. Attempting to use CCCL from CUDA Toolkit...")
find_package(CCCL CONFIG
HINTS ${CUDAToolkit_LIBRARY_DIR}/cmake)
if(NOT CCCL_FOUND)
message(STATUS "Could not locate CCCL from CUDA Toolkit. Using Thrust and CUB from CUDA Toolkit...")
find_package(libcudacxx CONFIG REQUIRED
HINTS ${CUDAToolkit_LIBRARY_DIR}/cmake)
find_package(CUB CONFIG REQUIRED
HINTS ${CUDAToolkit_LIBRARY_DIR}/cmake)
find_package(Thrust CONFIG REQUIRED
HINTS ${CUDAToolkit_LIBRARY_DIR}/cmake)
thrust_create_target(Thrust HOST CPP DEVICE CUDA)
add_library(CCCL::CCCL INTERFACE IMPORTED GLOBAL)
target_link_libraries(CCCL::CCCL INTERFACE libcudacxx::libcudacxx CUB::CUB Thrust)
endif()
endif()
endif()

if(FORCE_COLORED_OUTPUT AND (CMAKE_GENERATOR STREQUAL "Ninja") AND
Expand Down
4 changes: 2 additions & 2 deletions cmake/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ function(xgboost_set_cuda_flags target)
target_compile_definitions(${target} PRIVATE -DXGBOOST_USE_NVTX=1)
endif()

target_link_libraries(${target} PRIVATE CCCL::CCCL)
target_compile_definitions(${target} PRIVATE -DXGBOOST_USE_CUDA=1)
target_include_directories(
${target} PRIVATE
${xgboost_SOURCE_DIR}/gputreeshap
${CUDAToolkit_INCLUDE_DIRS})
${xgboost_SOURCE_DIR}/gputreeshap)

if(MSVC)
target_compile_options(${target} PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion tests/buildkite/build-cuda-with-rmm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ command_wrapper="tests/ci_build/ci_build.sh gpu_build_rockylinux8 --build-arg "`

echo "--- Build libxgboost from the source"
$command_wrapper tests/ci_build/build_via_cmake.sh \
-DCMAKE_PREFIX_PATH="/opt/grpc;/opt/rmm" \
-DCMAKE_PREFIX_PATH="/opt/grpc;/opt/rmm;/opt/rmm/lib64/rapids/cmake" \
-DUSE_CUDA=ON \
-DUSE_OPENMP=ON \
-DHIDE_CXX_SYMBOLS=ON \
Expand Down

0 comments on commit 411c846

Please sign in to comment.