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 "device_helpers.cuh"
#ifdef XGBOOST_USE_HIP
namespace thrust {
namespace cuda = thrust::hip;
}
#endif
namespace xgboost {
struct CUDAContext {
private:

View File

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

View File

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

View File

@ -17,14 +17,6 @@
#include "quantile.cuh"
#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 cuda {
/**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,12 +25,6 @@
#include "../common/device_helpers.cuh"
#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 ProbabilityDistributionType = xgboost::common::ProbabilityDistributionType;
template <typename Distribution>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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