namespace to reduce code

This commit is contained in:
Hui Liu 2023-10-27 10:51:32 -07:00
parent 4302200a33
commit 6762230d9a
26 changed files with 14 additions and 136 deletions

View File

@ -6,12 +6,6 @@
#include <thrust/execution_policy.h> #include <thrust/execution_policy.h>
#include "device_helpers.cuh" #include "device_helpers.cuh"
#ifdef XGBOOST_USE_HIP
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost { namespace xgboost {
struct CUDAContext { struct CUDAContext {
private: private:

View File

@ -54,4 +54,18 @@
#define cudaDevAttrMultiProcessorCount hipDeviceAttributeMultiprocessorCount #define cudaDevAttrMultiProcessorCount hipDeviceAttributeMultiprocessorCount
#define cudaOccupancyMaxActiveBlocksPerMultiprocessor hipOccupancyMaxActiveBlocksPerMultiprocessor #define cudaOccupancyMaxActiveBlocksPerMultiprocessor hipOccupancyMaxActiveBlocksPerMultiprocessor
namespace thrust {
namespace hip {
}
}
namespace thrust {
namespace cuda = thrust::hip;
}
namespace hipcub {
}
namespace cub = hipcub;
#endif #endif

View File

@ -26,12 +26,6 @@
#include "quantile.h" #include "quantile.h"
#include "xgboost/host_device_vector.h" #include "xgboost/host_device_vector.h"
#ifdef XGBOOST_USE_HIP
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost::common { namespace xgboost::common {
constexpr float SketchContainer::kFactor; constexpr float SketchContainer::kFactor;

View File

@ -17,14 +17,6 @@
#include "quantile.cuh" #include "quantile.cuh"
#include "xgboost/span.h" // for IterSpan #include "xgboost/span.h" // for IterSpan
#if defined(XGBOOST_USE_HIP)
namespace cub = hipcub;
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost::common { namespace xgboost::common {
namespace cuda { namespace cuda {
/** /**

View File

@ -8,12 +8,6 @@
#include "xgboost/context.h" // Context #include "xgboost/context.h" // Context
#include "xgboost/host_device_vector.h" // HostDeviceVector #include "xgboost/host_device_vector.h" // HostDeviceVector
#ifdef XGBOOST_USE_HIP
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost::common::cuda_impl { namespace xgboost::common::cuda_impl {
double Reduce(Context const* ctx, HostDeviceVector<float> const& values) { double Reduce(Context const* ctx, HostDeviceVector<float> const& values) {
values.SetDevice(ctx->Device()); values.SetDevice(ctx->Device());

View File

@ -22,12 +22,6 @@
#include "transform_iterator.h" // MakeIndexTransformIter #include "transform_iterator.h" // MakeIndexTransformIter
#include "xgboost/span.h" #include "xgboost/span.h"
#ifdef XGBOOST_USE_HIP
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost { namespace xgboost {
namespace common { namespace common {

View File

@ -10,12 +10,6 @@
#include "timer.h" #include "timer.h"
#include "categorical.h" #include "categorical.h"
#if defined(XGBOOST_USE_HIP)
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost { namespace xgboost {
namespace common { namespace common {

View File

@ -25,8 +25,6 @@
#if defined(XGBOOST_USE_HIP) #if defined(XGBOOST_USE_HIP)
#include <hipcub/hipcub.hpp> #include <hipcub/hipcub.hpp>
namespace cub = hipcub;
#endif #endif
namespace xgboost::ltr { namespace xgboost::ltr {

View File

@ -15,10 +15,6 @@
#include "xgboost/host_device_vector.h" // HostDeviceVector #include "xgboost/host_device_vector.h" // HostDeviceVector
#include "xgboost/linalg.h" // linalg::TensorView, UnravelIndex, Apply #include "xgboost/linalg.h" // linalg::TensorView, UnravelIndex, Apply
#if defined(XGBOOST_USE_HIP)
namespace cub = hipcub;
#endif
namespace xgboost::common::cuda_impl { namespace xgboost::common::cuda_impl {
void Median(Context const* ctx, linalg::TensorView<float const, 2> t, void Median(Context const* ctx, linalg::TensorView<float const, 2> t,
common::OptionalWeights weights, linalg::Tensor<float, 1>* out) { common::OptionalWeights weights, linalg::Tensor<float, 1>* out) {

View File

@ -23,12 +23,6 @@
#include "xgboost/context.h" // Context #include "xgboost/context.h" // Context
#include "xgboost/span.h" // Span #include "xgboost/span.h" // Span
#ifdef XGBOOST_USE_HIP
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost { namespace xgboost {
namespace common { namespace common {
namespace detail { namespace detail {

View File

@ -15,13 +15,6 @@
#include "xgboost/json.h" #include "xgboost/json.h"
#include "xgboost/logging.h" #include "xgboost/logging.h"
#if defined(XGBOOST_USE_HIP)
namespace cub = hipcub;
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost { namespace xgboost {
namespace { namespace {
auto SetDeviceToPtr(void const* ptr) { auto SetDeviceToPtr(void const* ptr) {

View File

@ -17,12 +17,6 @@
#include "adapter.h" #include "adapter.h"
#include "array_interface.h" #include "array_interface.h"
#if defined(XGBOOST_USE_HIP)
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost { namespace xgboost {
namespace data { namespace data {

View File

@ -16,12 +16,6 @@
#include "simple_batch_iterator.h" #include "simple_batch_iterator.h"
#include "sparse_page_source.h" #include "sparse_page_source.h"
#if defined(XGBOOST_USE_HIP)
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost::data { namespace xgboost::data {
void IterativeDMatrix::InitFromCUDA(Context const* ctx, BatchParam const& p, void IterativeDMatrix::InitFromCUDA(Context const* ctx, BatchParam const& p,
DataIterHandle iter_handle, float missing, DataIterHandle iter_handle, float missing,

View File

@ -13,12 +13,6 @@
#include "../common/error_msg.h" // for InfInData #include "../common/error_msg.h" // for InfInData
#include "device_adapter.cuh" // for HasInfInData #include "device_adapter.cuh" // for HasInfInData
#if defined(XGBOOST_USE_HIP)
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost::data { namespace xgboost::data {
#if defined(XGBOOST_USE_CUDA) #if defined(XGBOOST_USE_CUDA)

View File

@ -25,12 +25,6 @@
#include "xgboost/data.h" #include "xgboost/data.h"
#include "xgboost/span.h" #include "xgboost/span.h"
#if defined(XGBOOST_USE_HIP)
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost { namespace xgboost {
namespace metric { namespace metric {
// tag the this file, used by force static link later. // tag the this file, used by force static link later.

View File

@ -30,12 +30,6 @@
#include "../common/device_helpers.cuh" #include "../common/device_helpers.cuh"
#endif // defined(XGBOOST_USE_CUDA) || defined(XGBOOST_USE_HIP) #endif // defined(XGBOOST_USE_CUDA) || defined(XGBOOST_USE_HIP)
#if defined(XGBOOST_USE_HIP)
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost { namespace xgboost {
namespace metric { namespace metric {
// tag the this file, used by force static link later. // tag the this file, used by force static link later.

View File

@ -24,12 +24,6 @@
#include "../common/device_helpers.cuh" #include "../common/device_helpers.cuh"
#endif // XGBOOST_USE_CUDA || XGBOOST_USE_HIP #endif // XGBOOST_USE_CUDA || XGBOOST_USE_HIP
#if defined(XGBOOST_USE_HIP)
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost { namespace xgboost {
namespace metric { namespace metric {
// tag the this file, used by force static link later. // tag the this file, used by force static link later.

View File

@ -26,8 +26,6 @@
#if defined(XGBOOST_USE_HIP) #if defined(XGBOOST_USE_HIP)
#include <hipcub/hipcub.hpp> #include <hipcub/hipcub.hpp>
namespace cub = hipcub;
#endif #endif
namespace xgboost::metric { namespace xgboost::metric {

View File

@ -25,12 +25,6 @@
#include "../common/device_helpers.cuh" #include "../common/device_helpers.cuh"
#endif // XGBOOST_USE_CUDA || XGBOOST_USE_HIP #endif // XGBOOST_USE_CUDA || XGBOOST_USE_HIP
#if defined(XGBOOST_USE_HIP)
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
using AFTParam = xgboost::common::AFTParam; using AFTParam = xgboost::common::AFTParam;
using ProbabilityDistributionType = xgboost::common::ProbabilityDistributionType; using ProbabilityDistributionType = xgboost::common::ProbabilityDistributionType;
template <typename Distribution> template <typename Distribution>

View File

@ -19,11 +19,6 @@
#include "xgboost/context.h" #include "xgboost/context.h"
namespace xgboost { namespace xgboost {
#if defined(XGBOOST_USE_HIP)
namespace cub = hipcub;
#endif
namespace obj { namespace obj {
namespace detail { namespace detail {
void EncodeTreeLeafDevice(Context const* ctx, common::Span<bst_node_t const> position, void EncodeTreeLeafDevice(Context const* ctx, common::Span<bst_node_t const> position,

View File

@ -35,8 +35,6 @@
#if defined(XGBOOST_USE_HIP) #if defined(XGBOOST_USE_HIP)
#include <hipcub/hipcub.hpp> #include <hipcub/hipcub.hpp>
namespace cub = hipcub;
#endif #endif
namespace xgboost::obj { namespace xgboost::obj {

View File

@ -29,12 +29,6 @@
#include "xgboost/tree_model.h" #include "xgboost/tree_model.h"
#include "xgboost/tree_updater.h" #include "xgboost/tree_updater.h"
#if defined(XGBOOST_USE_HIP)
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost::predictor { namespace xgboost::predictor {
DMLC_REGISTRY_FILE_TAG(gpu_predictor); DMLC_REGISTRY_FILE_TAG(gpu_predictor);

View File

@ -21,12 +21,6 @@
#include "xgboost/logging.h" // CHECK_EQ #include "xgboost/logging.h" // CHECK_EQ
#include "xgboost/span.h" // span #include "xgboost/span.h" // span
#if defined(XGBOOST_USE_HIP)
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost::tree::cuda_impl { namespace xgboost::tree::cuda_impl {
void FitStump(Context const* ctx, MetaInfo const& info, void FitStump(Context const* ctx, MetaInfo const& info,
linalg::TensorView<GradientPair const, 2> gpair, linalg::VectorView<float> out) { linalg::TensorView<GradientPair const, 2> gpair, linalg::VectorView<float> out) {

View File

@ -24,10 +24,6 @@
#define WARP_SIZE WAVEFRONT_SIZE #define WARP_SIZE WAVEFRONT_SIZE
#endif #endif
#if defined(XGBOOST_USE_HIP)
namespace cub = hipcub;
#endif
namespace xgboost::tree { namespace xgboost::tree {
// With constraints // With constraints
XGBOOST_DEVICE float LossChangeMissing(const GradientPairInt64 &scan, XGBOOST_DEVICE float LossChangeMissing(const GradientPairInt64 &scan,

View File

@ -12,12 +12,6 @@
#include "evaluate_splits.cuh" #include "evaluate_splits.cuh"
#include "xgboost/data.h" #include "xgboost/data.h"
#if defined(XGBOOST_USE_HIP)
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost::tree { namespace xgboost::tree {
void GPUHistEvaluator::Reset(common::HistogramCuts const &cuts, common::Span<FeatureType const> ft, void GPUHistEvaluator::Reset(common::HistogramCuts const &cuts, common::Span<FeatureType const> ft,
bst_feature_t n_features, TrainParam const &param, bst_feature_t n_features, TrainParam const &param,

View File

@ -16,12 +16,6 @@
#include "row_partitioner.cuh" #include "row_partitioner.cuh"
#include "xgboost/base.h" #include "xgboost/base.h"
#if defined(XGBOOST_USE_HIP)
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost { namespace xgboost {
namespace tree { namespace tree {
namespace { namespace {