Skip to content

Commit

Permalink
Tidy up patches
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 committed Jul 25, 2024
1 parent f0e8fc3 commit 0349fc6
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 178 deletions.
4 changes: 1 addition & 3 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ source:
- patches/0001-Force-endian-flag-in-cross-compilation-mode.patch # [arm64 or aarch64 or ppc64le]
- patches/0002-Enable-latest-libcxx-on-MacOS.patch # [osx]
- patches/0003-Use-mingw-w64-path.patch
- patches/0004-Undo-dmlc-xgboost-9436.patch
- patches/0005-CMake-Explicitly-link-with-CCCL-standalone-or-CTK.patch
- patches/0006-Partial-fix-for-CTK-12.5-10574.patch
- patches/0004-Backport-fixes.patch

build:
number: {{ build_number }}
Expand Down
143 changes: 143 additions & 0 deletions recipe/patches/0004-Backport-fixes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
From 7782edc8e004bd3fe10879c52753d6a6de35947d Mon Sep 17 00:00:00 2001
From: Hyunsu Cho <phcho@nvidia.com>
Date: Fri, 28 Jun 2024 17:38:34 -0700
Subject: [PATCH] Backport fixes

* Undo dmlc/xgboost#9436
* Explicitly link with CCCL (standalone or CTK) (#10624, #10633)
* Partial fix for CTK 12.5 (#10574)
---
CMakeLists.txt | 27 ++++++++++++++++++---------
cmake/Utils.cmake | 7 +++----
src/tree/updater_gpu_common.cuh | 21 ++++++++-------------
src/tree/updater_gpu_hist.cu | 1 +
4 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c4ca82937..aa078405f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -224,6 +224,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
@@ -301,15 +319,6 @@ add_subdirectory(${xgboost_SOURCE_DIR}/plugin)

if(PLUGIN_RMM)
find_package(rmm REQUIRED)
-
- # Patch the rmm targets so they reference the static cudart
- # Remove this patch once RMM stops specifying cudart requirement
- # (since RMM is a header-only library, it should not specify cudart in its CMake config)
- get_target_property(rmm_link_libs rmm::rmm INTERFACE_LINK_LIBRARIES)
- list(REMOVE_ITEM rmm_link_libs CUDA::cudart)
- list(APPEND rmm_link_libs CUDA::cudart_static)
- set_target_properties(rmm::rmm PROPERTIES INTERFACE_LINK_LIBRARIES "${rmm_link_libs}")
- get_target_property(rmm_link_libs rmm::rmm INTERFACE_LINK_LIBRARIES)
endif()

if(PLUGIN_SYCL)
diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake
index d555f5edf..c1f19fdbb 100644
--- a/cmake/Utils.cmake
+++ b/cmake/Utils.cmake
@@ -108,12 +108,12 @@ function(xgboost_set_cuda_flags target)
target_compile_definitions(${target} PRIVATE -DXGBOOST_USE_NVTX=1)
endif()

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

if(MSVC)
target_compile_options(${target} PRIVATE
@@ -240,7 +240,6 @@ macro(xgboost_target_link_libraries target)

if(USE_CUDA)
xgboost_set_cuda_flags(${target})
- target_link_libraries(${target} PUBLIC CUDA::cudart_static)
endif()

if(PLUGIN_RMM)
diff --git a/src/tree/updater_gpu_common.cuh b/src/tree/updater_gpu_common.cuh
index 1c3e6a552..5d999d6d6 100644
--- a/src/tree/updater_gpu_common.cuh
+++ b/src/tree/updater_gpu_common.cuh
@@ -1,18 +1,13 @@
-/*!
- * Copyright 2017-2019 XGBoost contributors
+/**
+ * Copyright 2017-2024, XGBoost contributors
*/
#pragma once
-#include <thrust/random.h>
-#include <cstdio>
-#include <cub/cub.cuh>
-#include <stdexcept>
-#include <string>
-#include <vector>
-#include "../common/categorical.h"
-#include "../common/device_helpers.cuh"
-#include "../common/random.h"
+#include <limits> // for numeric_limits
+#include <ostream> // for ostream
+
#include "gpu_hist/histogram.cuh"
#include "param.h"
+#include "xgboost/base.h"

namespace xgboost::tree {
struct GPUTrainingParam {
@@ -54,8 +49,8 @@ enum DefaultDirection {
};

struct DeviceSplitCandidate {
- float loss_chg {-FLT_MAX};
- DefaultDirection dir {kLeftDir};
+ float loss_chg{-std::numeric_limits<float>::max()};
+ DefaultDirection dir{kLeftDir};
int findex {-1};
float fvalue {0};
// categorical split, either it's the split category for OHE or the threshold for partition-based
diff --git a/src/tree/updater_gpu_hist.cu b/src/tree/updater_gpu_hist.cu
index 958fa0331..e126aeb31 100644
--- a/src/tree/updater_gpu_hist.cu
+++ b/src/tree/updater_gpu_hist.cu
@@ -19,6 +19,7 @@
#include "../common/cuda_context.cuh" // CUDAContext
#include "../common/device_helpers.cuh"
#include "../common/hist_util.h"
+#include "../common/random.h" // for ColumnSampler, GlobalRandom
#include "../common/timer.h"
#include "../data/ellpack_page.cuh"
#include "../data/ellpack_page.h"
--
2.45.2

45 changes: 0 additions & 45 deletions recipe/patches/0004-Undo-dmlc-xgboost-9436.patch

This file was deleted.

This file was deleted.

65 changes: 0 additions & 65 deletions recipe/patches/0006-Partial-fix-for-CTK-12.5-10574.patch

This file was deleted.

0 comments on commit 0349fc6

Please sign in to comment.