Skip to content

Commit

Permalink
Fix CPU build.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Dec 5, 2019
1 parent 1b6f983 commit 895e88c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/xgboost/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ using bst_float = float; // NOLINT

/*! \brief Type for data column (feature) index. */
using bst_feature_t = uint32_t; // NOLINT
/*! \breif Type for data row index.
/*! \brief Type for data row index.
*
* Be careful `std::size_t' is implementation-defined. Meaning that the binary
* representation of DMatrix might not be portable across platform. Booster model should
Expand Down
1 change: 0 additions & 1 deletion include/xgboost/tree_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,6 @@ class RegTree : public Model {
/*!
* \brief get the leaf index
* \param feat dense feature vector, if the feature is missing the field is set to NaN
* \param root_id starting root index of the instance
* \return the leaf index of the given feature
*/
int GetLeafIndex(const FVec& feat) const;
Expand Down
2 changes: 1 addition & 1 deletion src/gbm/gbtree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void GBTree::LoadConfig(Json const& in) {
fromJson(in["gbtree_train_param"], &tparam_);
int32_t const n_gpus = xgboost::common::AllVisibleGPUs();
if (n_gpus == 0) {
tparam_.UpdateAllowUnknown(Args{{"predictor", "cpu_predictor"}});
tparam_.UpdateAllowUnknown(Args{{"predictor", "auto"}});
}
if (n_gpus == 0 && tparam_.tree_method == TreeMethod::kGPUHist) {
tparam_.tree_method = TreeMethod::kHist;
Expand Down
19 changes: 15 additions & 4 deletions src/gbm/gbtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,13 @@ class GBTree : public GradientBooster {
CHECK(configured_);
if (tparam_.predictor != PredictorType::kAuto) {
if (tparam_.predictor == PredictorType::kGPUPredictor) {
this->AssertGPUSupport();
#if defined(XGBOOST_USE_CUDA)
CHECK(gpu_predictor_);
return gpu_predictor_;
#else
this->AssertGPUSupport();
return cpu_predictor_;
#endif // defined(XGBOOST_USE_CUDA)
}
CHECK(cpu_predictor_);
return cpu_predictor_;
Expand All @@ -276,11 +280,13 @@ class GBTree : public GradientBooster {

// Use GPU Predictor if data is already on device.
if (on_device) {
#if !defined(XGBOOST_USE_CUDA)
LOG(FATAL) << "Data is on CUDA device, but XGBoost is not compiled with CUDA support.";
#endif // defined(XGBOOST_USE_CUDA)
#if defined(XGBOOST_USE_CUDA)
CHECK(gpu_predictor_);
return gpu_predictor_;
#else
LOG(FATAL) << "Data is on CUDA device, but XGBoost is not compiled with CUDA support.";
return cpu_predictor_;
#endif // defined(XGBOOST_USE_CUDA)
}

// GPU_Hist by default has prediction cache calculated from quantile values, so GPU
Expand All @@ -298,8 +304,13 @@ class GBTree : public GradientBooster {
}

if (tparam_.tree_method == TreeMethod::kGPUHist) {
#if defined(XGBOOST_USE_CUDA)
CHECK(gpu_predictor_);
return gpu_predictor_;
#else
this->AssertGPUSupport();
return cpu_predictor_;
#endif // defined(XGBOOST_USE_CUDA)
}

CHECK(cpu_predictor_);
Expand Down

0 comments on commit 895e88c

Please sign in to comment.