diff --git a/src/collective/device_communicator.hip.h b/src/collective/device_communicator.hip.h new file mode 100644 index 000000000..6c4473a43 --- /dev/null +++ b/src/collective/device_communicator.hip.h @@ -0,0 +1,6 @@ +/*! + * Copyright 2022 XGBoost contributors + */ +#pragma once + +#include "device_communicator.cuh" diff --git a/src/collective/device_communicator_adapter.hip.h b/src/collective/device_communicator_adapter.hip.h new file mode 100644 index 000000000..f7cff5b4b --- /dev/null +++ b/src/collective/device_communicator_adapter.hip.h @@ -0,0 +1,6 @@ +/*! + * Copyright 2022 XGBoost contributors + */ +#pragma once + +#include "device_communicator_adapter.cuh" diff --git a/src/collective/nccl_device_communicator.hip.h b/src/collective/nccl_device_communicator.hip.h new file mode 100644 index 000000000..0b42ef9a8 --- /dev/null +++ b/src/collective/nccl_device_communicator.hip.h @@ -0,0 +1,6 @@ +/*! + * Copyright 2022 XGBoost contributors + */ +#pragma once + +#include "nccl_device_communicator.cuh" diff --git a/src/common/algorithm.hip.h b/src/common/algorithm.hip.h new file mode 100644 index 000000000..98d660c20 --- /dev/null +++ b/src/common/algorithm.hip.h @@ -0,0 +1,6 @@ +/** + * Copyright 2022-2023 by XGBoost Contributors + */ +#pragma once + +#include "algorithm.cuh" // Span,byte diff --git a/src/common/cuda_context.hip.h b/src/common/cuda_context.hip.h new file mode 100644 index 000000000..2ab5d8da0 --- /dev/null +++ b/src/common/cuda_context.hip.h @@ -0,0 +1,6 @@ +/** + * Copyright 2022 by XGBoost Contributors + */ +#pragma once + +#include "cuda_context.cuh" diff --git a/src/common/deterministic.hip.h b/src/common/deterministic.hip.h new file mode 100644 index 000000000..57d55ff12 --- /dev/null +++ b/src/common/deterministic.hip.h @@ -0,0 +1,6 @@ +/** + * Copyright 2020-2023 by XGBoost Contributors + */ +#pragma once + +#include "deterministic.cuh" // XGBOOST_DEVICE diff --git a/src/common/hist_util.hip.h b/src/common/hist_util.hip.h new file mode 100644 index 000000000..7a4f05fca --- /dev/null +++ b/src/common/hist_util.hip.h @@ -0,0 +1,9 @@ +/** + * Copyright 2020-2023 by XGBoost contributors + * + * \brief Front end and utilities for GPU based sketching. Works on sliding window + * instead of stream. + */ +#pragma once + +#include "hist_util.cuh" diff --git a/src/common/linalg_op.hip.h b/src/common/linalg_op.hip.h new file mode 100644 index 000000000..16757874c --- /dev/null +++ b/src/common/linalg_op.hip.h @@ -0,0 +1,6 @@ +/*! + * Copyright 2021-2022 by XGBoost Contributors + */ +#pragma once + +#include "linalg_op.cuh" diff --git a/src/common/quantile.hip.h b/src/common/quantile.hip.h new file mode 100644 index 000000000..59cc615a4 --- /dev/null +++ b/src/common/quantile.hip.h @@ -0,0 +1,3 @@ +#pragma once + +#include "quantile.cuh" diff --git a/src/common/ranking_utils.hip.h b/src/common/ranking_utils.hip.h new file mode 100644 index 000000000..52bd59faf --- /dev/null +++ b/src/common/ranking_utils.hip.h @@ -0,0 +1,6 @@ +/** + * Copyright 2023 by XGBoost Contributors + */ +#pragma once + +#include "ranking_utils.cuh" // for Span diff --git a/src/common/stats.hip.h b/src/common/stats.hip.h new file mode 100644 index 000000000..c5f646ebc --- /dev/null +++ b/src/common/stats.hip.h @@ -0,0 +1,6 @@ +/** + * Copyright 2022-2023 by XGBoost Contributors + */ +#pragma once + +#include "stats.cuh" // Span diff --git a/src/common/threading_utils.hip.h b/src/common/threading_utils.hip.h new file mode 100644 index 000000000..f57f1d116 --- /dev/null +++ b/src/common/threading_utils.hip.h @@ -0,0 +1,6 @@ +/** + * Copyright 2021-2023 by XGBoost Contributors + */ +#pragma once + +#include "threading_utils.cuh" // Span diff --git a/src/data/device_adapter.hip.h b/src/data/device_adapter.hip.h new file mode 100644 index 000000000..98ab457fd --- /dev/null +++ b/src/data/device_adapter.hip.h @@ -0,0 +1,7 @@ +/** + * Copyright 2019-2023 by XGBoost Contributors + * \file device_adapter.cuh + */ +#pragma once + +#include "device_adapter.cuh" diff --git a/src/data/ellpack_page.hip.h b/src/data/ellpack_page.hip.h new file mode 100644 index 000000000..a824b459a --- /dev/null +++ b/src/data/ellpack_page.hip.h @@ -0,0 +1,6 @@ +/*! + * Copyright 2019 by XGBoost Contributors + */ +#pragma once + +#include "ellpack_page.cuh" diff --git a/src/data/proxy_dmatrix.hip.h b/src/data/proxy_dmatrix.hip.h new file mode 100644 index 000000000..020129eda --- /dev/null +++ b/src/data/proxy_dmatrix.hip.h @@ -0,0 +1,6 @@ +/** + * Copyright 2021-2023 XGBoost contributors + */ +#pragma once + +#include "proxy_dmatrix.cuh" diff --git a/src/data/simple_dmatrix.hip.h b/src/data/simple_dmatrix.hip.h new file mode 100644 index 000000000..5bbc1999b --- /dev/null +++ b/src/data/simple_dmatrix.hip.h @@ -0,0 +1,7 @@ +/** + * Copyright 2019-2023 by XGBoost Contributors + * \file simple_dmatrix.cuh + */ +#pragma once + +#include "simple_dmatrix.cuh" // for HasInfInData diff --git a/src/objective/lambdarank_obj.hip.h b/src/objective/lambdarank_obj.hip.h new file mode 100644 index 000000000..4242a1f0f --- /dev/null +++ b/src/objective/lambdarank_obj.hip.h @@ -0,0 +1,6 @@ +/** + * Copyright 2023 XGBoost contributors + */ +#pragma once + +#include "lambdarank_obj.cuh" // for Span diff --git a/src/tree/constraints.hip.h b/src/tree/constraints.hip.h new file mode 100644 index 000000000..09d4b275f --- /dev/null +++ b/src/tree/constraints.hip.h @@ -0,0 +1,8 @@ +/*! + * Copyright 2019 XGBoost contributors + * + * \file Various constraints used in GPU_Hist. + */ +#pragma once + +#include "constraints.cuh" diff --git a/src/tree/gpu_hist/evaluate_splits.hip.h b/src/tree/gpu_hist/evaluate_splits.hip.h new file mode 100644 index 000000000..cf98499c2 --- /dev/null +++ b/src/tree/gpu_hist/evaluate_splits.hip.h @@ -0,0 +1,6 @@ +/*! + * Copyright 2020 by XGBoost Contributors + */ +#pragma once + +#include "evaluate_splits.cuh" diff --git a/src/tree/gpu_hist/expand_entry.hip.h b/src/tree/gpu_hist/expand_entry.hip.h new file mode 100644 index 000000000..3d2d523e2 --- /dev/null +++ b/src/tree/gpu_hist/expand_entry.hip.h @@ -0,0 +1,6 @@ +/*! + * Copyright 2020 by XGBoost Contributors + */ +#pragma once + +#include "expand_entry.cuh" diff --git a/src/tree/gpu_hist/feature_groups.hip.h b/src/tree/gpu_hist/feature_groups.hip.h new file mode 100644 index 000000000..cb90a3fa3 --- /dev/null +++ b/src/tree/gpu_hist/feature_groups.hip.h @@ -0,0 +1,7 @@ +/*! + * Copyright 2020 by XGBoost Contributors + */ + +#pragma once + +#include "feature_groups.cuh" diff --git a/src/tree/gpu_hist/gradient_based_sampler.hip.h b/src/tree/gpu_hist/gradient_based_sampler.hip.h new file mode 100644 index 000000000..2a70d886f --- /dev/null +++ b/src/tree/gpu_hist/gradient_based_sampler.hip.h @@ -0,0 +1,6 @@ +/*! + * Copyright 2019 by XGBoost Contributors + */ +#pragma once + +#include "gradient_based_sampler.cuh" diff --git a/src/tree/gpu_hist/histogram.hip.h b/src/tree/gpu_hist/histogram.hip.h new file mode 100644 index 000000000..1d00ef464 --- /dev/null +++ b/src/tree/gpu_hist/histogram.hip.h @@ -0,0 +1,6 @@ +/*! + * Copyright 2020-2021 by XGBoost Contributors + */ +#pragma once + +#include "histogram.cuh" diff --git a/src/tree/gpu_hist/row_partitioner.hip.h b/src/tree/gpu_hist/row_partitioner.hip.h new file mode 100644 index 000000000..46d3415aa --- /dev/null +++ b/src/tree/gpu_hist/row_partitioner.hip.h @@ -0,0 +1,6 @@ +/*! + * Copyright 2017-2022 XGBoost contributors + */ +#pragma once + +#include "row_partitioner.cuh" diff --git a/src/tree/updater_gpu_common.hip.h b/src/tree/updater_gpu_common.hip.h new file mode 100644 index 000000000..46d8eabd7 --- /dev/null +++ b/src/tree/updater_gpu_common.hip.h @@ -0,0 +1,6 @@ +/*! + * Copyright 2017-2019 XGBoost contributors + */ +#pragma once + +#include "updater_gpu_common.cuh" diff --git a/tests/cpp/common/test_algorithm.cu b/tests/cpp/common/test_algorithm.cu index 982f0c9ca..60a985957 100644 --- a/tests/cpp/common/test_algorithm.cu +++ b/tests/cpp/common/test_algorithm.cu @@ -9,8 +9,13 @@ #include // is_sorted #include // size_t +#if defined(XGBOOST_USE_CUDA) #include "../../../src/common/algorithm.cuh" #include "../../../src/common/device_helpers.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../src/common/algorithm.hip.h" +#include "../../../src/common/device_helpers.hip.h" +#endif #include "../helpers.h" // CreateEmptyGenericParam namespace xgboost { diff --git a/tests/cpp/common/test_hist_util.cu b/tests/cpp/common/test_hist_util.cu index 4f8bc3975..0f70775f1 100644 --- a/tests/cpp/common/test_hist_util.cu +++ b/tests/cpp/common/test_hist_util.cu @@ -10,11 +10,19 @@ #include #include "../../../include/xgboost/logging.h" +#if defined(XGBOOST_USE_CUDA) #include "../../../src/common/device_helpers.cuh" #include "../../../src/common/hist_util.cuh" #include "../../../src/common/hist_util.h" #include "../../../src/common/math.h" #include "../../../src/data/device_adapter.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../src/common/device_helpers.hip.h" +#include "../../../src/common/hist_util.hip.h" +#include "../../../src/common/hist_util.h" +#include "../../../src/common/math.h" +#include "../../../src/data/device_adapter.hip.h" +#endif #include "../../../src/data/simple_dmatrix.h" #include "../data/test_array_interface.h" #include "../filesystem.h" // dmlc::TemporaryDirectory diff --git a/tests/cpp/common/test_linalg.cu b/tests/cpp/common/test_linalg.cu index fe38f0f9b..3f6a573e2 100644 --- a/tests/cpp/common/test_linalg.cu +++ b/tests/cpp/common/test_linalg.cu @@ -3,7 +3,11 @@ */ #include +#if defined(XGBOOST_USE_CUDA) #include "../../../src/common/linalg_op.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../src/common/linalg_op.hip.h" +#endif #include "xgboost/context.h" #include "xgboost/linalg.h" diff --git a/tests/cpp/common/test_quantile.cu b/tests/cpp/common/test_quantile.cu index cdd2eb3ba..486784d9d 100644 --- a/tests/cpp/common/test_quantile.cu +++ b/tests/cpp/common/test_quantile.cu @@ -1,9 +1,15 @@ #include #include "test_quantile.h" #include "../helpers.h" +#if defined(XGBOOST_USE_CUDA) #include "../../../src/collective/device_communicator.cuh" #include "../../../src/common/hist_util.cuh" #include "../../../src/common/quantile.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../src/collective/device_communicator.hip.h" +#include "../../../src/common/hist_util.hip.h" +#include "../../../src/common/quantile.hip.h" +#endif namespace xgboost { namespace { diff --git a/tests/cpp/common/test_ranking_utils.cu b/tests/cpp/common/test_ranking_utils.cu index db0ff3b66..b2e6c2eaa 100644 --- a/tests/cpp/common/test_ranking_utils.cu +++ b/tests/cpp/common/test_ranking_utils.cu @@ -11,10 +11,17 @@ #include // for iota #include // for vector +#if defined(XGBOOST_USE_CUDA) #include "../../../src/common/algorithm.cuh" // for SegmentedSequence #include "../../../src/common/cuda_context.cuh" // for CUDAContext #include "../../../src/common/device_helpers.cuh" // for device_vector, ToSpan #include "../../../src/common/ranking_utils.cuh" // for CalcQueriesInvIDCG +#elif defined(XGBOOST_USE_HIP) +#include "../../../src/common/algorithm.hip.h" // for SegmentedSequence +#include "../../../src/common/cuda_context.hip.h" // for CUDAContext +#include "../../../src/common/device_helpers.hip.h" // for device_vector, ToSpan +#include "../../../src/common/ranking_utils.hip.h" // for CalcQueriesInvIDCG +#endif #include "../../../src/common/ranking_utils.h" // for LambdaRankParam, RankingCache #include "../helpers.h" // for EmptyDMatrix #include "test_ranking_utils.h" // for TestNDCGCache diff --git a/tests/cpp/common/test_stats.cu b/tests/cpp/common/test_stats.cu index 8643e75a7..4ed7a29a6 100644 --- a/tests/cpp/common/test_stats.cu +++ b/tests/cpp/common/test_stats.cu @@ -7,8 +7,13 @@ #include // std::pair #include // std::vector +#if defined(XGBOOST_USE_CUDA) #include "../../../src/common/linalg_op.cuh" // ElementWiseTransformDevice #include "../../../src/common/stats.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../src/common/linalg_op.hip.h" // ElementWiseTransformDevice +#include "../../../src/common/stats.hip.h" +#endif #include "xgboost/base.h" // XGBOOST_DEVICE #include "xgboost/context.h" // Context #include "xgboost/host_device_vector.h" // HostDeviceVector diff --git a/tests/cpp/common/test_threading_utils.cu b/tests/cpp/common/test_threading_utils.cu index f7160b1b5..78a902fc6 100644 --- a/tests/cpp/common/test_threading_utils.cu +++ b/tests/cpp/common/test_threading_utils.cu @@ -4,8 +4,13 @@ #include #include // thrust::copy +#if defined(XGBOOST_USE_CUDA) #include "../../../src/common/device_helpers.cuh" #include "../../../src/common/threading_utils.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../src/common/device_helpers.hip.h" +#include "../../../src/common/threading_utils.hip.h" +#endif namespace xgboost { namespace common { diff --git a/tests/cpp/data/test_device_adapter.cu b/tests/cpp/data/test_device_adapter.cu index f1c1f204b..95c35b4ed 100644 --- a/tests/cpp/data/test_device_adapter.cu +++ b/tests/cpp/data/test_device_adapter.cu @@ -7,7 +7,11 @@ #include "../helpers.h" #include +#if defined(XGBOOST_USE_CUDA) #include "../../../src/data/device_adapter.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../src/data/device_adapter.hip.h" +#endif #include "test_array_interface.h" using namespace xgboost; // NOLINT diff --git a/tests/cpp/data/test_iterative_dmatrix.cu b/tests/cpp/data/test_iterative_dmatrix.cu index 2f2f1f84f..8c98c53ff 100644 --- a/tests/cpp/data/test_iterative_dmatrix.cu +++ b/tests/cpp/data/test_iterative_dmatrix.cu @@ -3,8 +3,13 @@ */ #include +#if defined(XGBOOST_USE_CUDA) #include "../../../src/data/device_adapter.cuh" #include "../../../src/data/ellpack_page.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../src/data/device_adapter.hip.h" +#include "../../../src/data/ellpack_page.hip.h" +#endif #include "../../../src/data/iterative_dmatrix.h" #include "../../../src/tree/param.h" // TrainParam #include "../helpers.h" diff --git a/tests/cpp/data/test_proxy_dmatrix.cu b/tests/cpp/data/test_proxy_dmatrix.cu index ab38f51bb..cfbe731ec 100644 --- a/tests/cpp/data/test_proxy_dmatrix.cu +++ b/tests/cpp/data/test_proxy_dmatrix.cu @@ -7,7 +7,11 @@ #include // for any_cast #include +#if defined(XGBOOST_USE_CUDA) #include "../../../src/data/device_adapter.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../src/data/device_adapter.hip.h" +#endif #include "../../../src/data/proxy_dmatrix.h" #include "../helpers.h" diff --git a/tests/cpp/data/test_simple_dmatrix.cu b/tests/cpp/data/test_simple_dmatrix.cu index 931daa9e7..32083c715 100644 --- a/tests/cpp/data/test_simple_dmatrix.cu +++ b/tests/cpp/data/test_simple_dmatrix.cu @@ -4,7 +4,11 @@ #include +#if defined(XGBOOST_USE_CUDA) #include "../../../src/data/device_adapter.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../src/data/device_adapter.hip.h" +#endif #include "../helpers.h" #include "test_array_interface.h" #include "../../../src/data/array_interface.h" diff --git a/tests/cpp/helpers.cu b/tests/cpp/helpers.cu index f72281cb4..560de5d51 100644 --- a/tests/cpp/helpers.cu +++ b/tests/cpp/helpers.cu @@ -1,7 +1,11 @@ #include #include "helpers.h" +#if defined(XGBOOST_USE_CUDA) #include "../../src/data/device_adapter.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../src/data/device_adapter.hip.h" +#endif #include "../../src/data/iterative_dmatrix.h" namespace xgboost { diff --git a/tests/cpp/objective/test_lambdarank_obj.cu b/tests/cpp/objective/test_lambdarank_obj.cu index d0f448993..3e6f0465b 100644 --- a/tests/cpp/objective/test_lambdarank_obj.cu +++ b/tests/cpp/objective/test_lambdarank_obj.cu @@ -7,8 +7,13 @@ #include // for uint32_t #include // for vector +#if defined(XGBOOST_USE_CUDA) #include "../../../src/common/cuda_context.cuh" // for CUDAContext #include "../../../src/objective/lambdarank_obj.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../src/common/cuda_context.hip.h" // for CUDAContext +#include "../../../src/objective/lambdarank_obj.hip.h" +#endif #include "test_lambdarank_obj.h" namespace xgboost::obj { diff --git a/tests/cpp/predictor/test_gpu_predictor.cu b/tests/cpp/predictor/test_gpu_predictor.cu index ff215d254..04b41e39c 100644 --- a/tests/cpp/predictor/test_gpu_predictor.cu +++ b/tests/cpp/predictor/test_gpu_predictor.cu @@ -9,7 +9,11 @@ #include +#if defined(XGBOOST_USE_CUDA) #include "../../../src/data/device_adapter.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../src/data/device_adapter.hip.h" +#endif #include "../../../src/data/proxy_dmatrix.h" #include "../../../src/gbm/gbtree_model.h" #include "../helpers.h" diff --git a/tests/cpp/tree/gpu_hist/test_driver.cu b/tests/cpp/tree/gpu_hist/test_driver.cu index 106004c63..2c5109c1a 100644 --- a/tests/cpp/tree/gpu_hist/test_driver.cu +++ b/tests/cpp/tree/gpu_hist/test_driver.cu @@ -1,6 +1,10 @@ #include #include "../../../../src/tree/driver.h" +#if defined(XGBOOST_USE_CUDA) #include "../../../../src/tree/gpu_hist/expand_entry.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../../src/tree/gpu_hist/expand_entry.hip.h" +#endif namespace xgboost { namespace tree { diff --git a/tests/cpp/tree/gpu_hist/test_evaluate_splits.cu b/tests/cpp/tree/gpu_hist/test_evaluate_splits.cu index f1317fc02..ce0a61f65 100644 --- a/tests/cpp/tree/gpu_hist/test_evaluate_splits.cu +++ b/tests/cpp/tree/gpu_hist/test_evaluate_splits.cu @@ -3,7 +3,11 @@ */ #include +#if defined(XGBOOST_USE_CUDA) #include "../../../../src/tree/gpu_hist/evaluate_splits.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../../src/tree/gpu_hist/evaluate_splits.hip.h" +#endif #include "../../helpers.h" #include "../../histogram_helpers.h" #include "../test_evaluate_splits.h" // TestPartitionBasedSplit diff --git a/tests/cpp/tree/gpu_hist/test_histogram.cu b/tests/cpp/tree/gpu_hist/test_histogram.cu index 1f93ddff2..7acb5723e 100644 --- a/tests/cpp/tree/gpu_hist/test_histogram.cu +++ b/tests/cpp/tree/gpu_hist/test_histogram.cu @@ -6,8 +6,13 @@ #include #include "../../../../src/common/categorical.h" +#if defined(XGBOOST_USE_CUDA) #include "../../../../src/tree/gpu_hist/histogram.cuh" #include "../../../../src/tree/gpu_hist/row_partitioner.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../../src/tree/gpu_hist/histogram.hip.h" +#include "../../../../src/tree/gpu_hist/row_partitioner.hip.h" +#endif #include "../../../../src/tree/param.h" // TrainParam #include "../../categorical_helpers.h" #include "../../helpers.h" diff --git a/tests/cpp/tree/gpu_hist/test_row_partitioner.cu b/tests/cpp/tree/gpu_hist/test_row_partitioner.cu index 30fcb12df..730e28a14 100644 --- a/tests/cpp/tree/gpu_hist/test_row_partitioner.cu +++ b/tests/cpp/tree/gpu_hist/test_row_partitioner.cu @@ -9,7 +9,11 @@ #include #include +#if defined(XGBOOST_USE_CUDA) #include "../../../../src/tree/gpu_hist/row_partitioner.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../../../../src/tree/gpu_hist/row_partitioner.hip.h" +#endif #include "../../helpers.h" #include "xgboost/base.h" #include "xgboost/context.h" diff --git a/tests/cpp/tree/test_gpu_hist.cu b/tests/cpp/tree/test_gpu_hist.cu index 1a32a1ee9..18ce2dc0f 100644 --- a/tests/cpp/tree/test_gpu_hist.cu +++ b/tests/cpp/tree/test_gpu_hist.cu @@ -12,10 +12,17 @@ #include "../../../src/common/common.h" #include "../../../src/data/sparse_page_source.h" +#if defined(XGBOOST_USE_CUDA) #include "../../../src/tree/constraints.cuh" #include "../../../src/tree/param.h" // for TrainParam #include "../../../src/tree/updater_gpu_common.cuh" #include "../../../src/tree/updater_gpu_hist.cu" +#elif defined(XGBOOST_USE_HIP) +#include "../../../src/tree/constraints.hip.h" +#include "../../../src/tree/param.h" // for TrainParam +#include "../../../src/tree/updater_gpu_common.hip.h" +#include "../../../src/tree/updater_gpu_hist.hip" +#endif #include "../filesystem.h" // dmlc::TemporaryDirectory #include "../helpers.h" #include "../histogram_helpers.h"