Fix compiler warnings. (#8022)

- Remove/fix unused parameters
- Remove deprecated code in rabit.
- Update dmlc-core.
This commit is contained in:
Jiaming Yuan
2022-06-22 21:29:10 +08:00
committed by GitHub
parent e44a082620
commit 142a208a90
61 changed files with 230 additions and 579 deletions

View File

@@ -1076,7 +1076,7 @@ XGB_DLL int XGBoosterLoadRabitCheckpoint(BoosterHandle handle,
API_BEGIN();
CHECK_HANDLE();
auto* bst = static_cast<Learner*>(handle);
*version = rabit::LoadCheckPoint(bst);
*version = rabit::LoadCheckPoint();
if (*version != 0) {
bst->Configure();
}
@@ -1086,13 +1086,9 @@ XGB_DLL int XGBoosterLoadRabitCheckpoint(BoosterHandle handle,
XGB_DLL int XGBoosterSaveRabitCheckpoint(BoosterHandle handle) {
API_BEGIN();
CHECK_HANDLE();
auto* learner = static_cast<Learner*>(handle);
auto *learner = static_cast<Learner *>(handle);
learner->Configure();
if (learner->AllowLazyCheckPoint()) {
rabit::LazyCheckPoint(learner);
} else {
rabit::CheckPoint(learner);
}
rabit::CheckPoint();
API_END();
}

View File

@@ -184,7 +184,7 @@ class CLI {
int ResetLearner(std::vector<std::shared_ptr<DMatrix>> const &matrices) {
learner_.reset(Learner::Create(matrices));
int version = rabit::LoadCheckPoint(learner_.get());
int version = rabit::LoadCheckPoint();
if (version == 0) {
if (param_.model_in != CLIParam::kNull) {
this->LoadModel(param_.model_in, learner_.get());
@@ -238,11 +238,7 @@ class CLI {
LOG(INFO) << "boosting round " << i << ", " << elapsed
<< " sec elapsed";
learner_->UpdateOneIter(i, dtrain);
if (learner_->AllowLazyCheckPoint()) {
rabit::LazyCheckPoint(learner_.get());
} else {
rabit::CheckPoint(learner_.get());
}
rabit::CheckPoint();
version += 1;
}
CHECK_EQ(version, rabit::VersionNumber());
@@ -262,11 +258,7 @@ class CLI {
this->SaveModel(os.str(), learner_.get());
}
if (learner_->AllowLazyCheckPoint()) {
rabit::LazyCheckPoint(learner_.get());
} else {
rabit::CheckPoint(learner_.get());
}
rabit::CheckPoint();
version += 1;
CHECK_EQ(version, rabit::VersionNumber());
}

View File

@@ -15,11 +15,10 @@ namespace dh {
constexpr std::size_t kUuidLength =
sizeof(std::declval<cudaDeviceProp>().uuid) / sizeof(uint64_t);
void GetCudaUUID(int world_size, int rank, int device_ord,
xgboost::common::Span<uint64_t, kUuidLength> uuid) {
void GetCudaUUID(int device_ord, xgboost::common::Span<uint64_t, kUuidLength> uuid) {
cudaDeviceProp prob;
safe_cuda(cudaGetDeviceProperties(&prob, device_ord));
std::memcpy(uuid.data(), static_cast<void*>(&(prob.uuid)), sizeof(prob.uuid));
std::memcpy(uuid.data(), static_cast<void *>(&(prob.uuid)), sizeof(prob.uuid));
}
std::string PrintUUID(xgboost::common::Span<uint64_t, kUuidLength> uuid) {
@@ -38,7 +37,7 @@ void NcclAllReducer::DoInit(int _device_ordinal) {
std::vector<uint64_t> uuids(world * kUuidLength, 0);
auto s_uuid = xgboost::common::Span<uint64_t>{uuids.data(), uuids.size()};
auto s_this_uuid = s_uuid.subspan(rank * kUuidLength, kUuidLength);
GetCudaUUID(world, rank, _device_ordinal, s_this_uuid);
GetCudaUUID(_device_ordinal, s_this_uuid);
// No allgather yet.
rabit::Allreduce<rabit::op::Sum, uint64_t>(uuids.data(), uuids.size());
@@ -67,7 +66,7 @@ void NcclAllReducer::DoInit(int _device_ordinal) {
void NcclAllReducer::DoAllGather(void const *data, size_t length_bytes,
std::vector<size_t> *segments,
dh::caching_device_vector<char> *recvbuf) {
size_t world = rabit::GetWorldSize();
int32_t world = rabit::GetWorldSize();
segments->clear();
segments->resize(world, 0);
segments->at(rabit::GetRank()) = length_bytes;

View File

@@ -246,7 +246,7 @@ std::enable_if_t<std::is_floating_point<T>::value, bool> IsInfMSVCWar(T v) {
return std::isinf(v);
}
template <typename T>
std::enable_if_t<std::is_integral<T>::value, bool> IsInfMSVCWar(T v) {
std::enable_if_t<std::is_integral<T>::value, bool> IsInfMSVCWar(T) {
return false;
}
} // namespace
@@ -850,9 +850,11 @@ Json UBJReader::Parse() {
}
case 'D': {
LOG(FATAL) << "f64 is not supported.";
break;
}
case 'H': {
LOG(FATAL) << "High precision number is not supported.";
break;
}
default:
Error("Unknown construct");
@@ -968,7 +970,7 @@ void UBJWriter::Visit(JsonInteger const* num) {
}
}
void UBJWriter::Visit(JsonNull const* null) { stream_->push_back('Z'); }
void UBJWriter::Visit(JsonNull const*) { stream_->push_back('Z'); }
void UBJWriter::Visit(JsonString const* str) {
stream_->push_back('S');

View File

@@ -55,12 +55,10 @@ __device__ SketchEntry BinarySearchQuery(EntryIter beg, EntryIter end, float ran
}
template <typename InEntry, typename ToSketchEntry>
void PruneImpl(int device,
common::Span<SketchContainer::OffsetT const> cuts_ptr,
void PruneImpl(common::Span<SketchContainer::OffsetT const> cuts_ptr,
Span<InEntry const> sorted_data,
Span<size_t const> columns_ptr_in, // could be ptr for data or cuts
Span<FeatureType const> feature_types,
Span<SketchEntry> out_cuts,
Span<FeatureType const> feature_types, Span<SketchEntry> out_cuts,
ToSketchEntry to_sketch_entry) {
dh::LaunchN(out_cuts.size(), [=] __device__(size_t idx) {
size_t column_id = dh::SegmentId(cuts_ptr, idx);
@@ -207,12 +205,8 @@ common::Span<thrust::tuple<uint64_t, uint64_t>> MergePath(
// run it in 2 passes to obtain the merge path and then customize the standard merge
// algorithm.
void MergeImpl(int32_t device, Span<SketchEntry const> const &d_x,
Span<bst_row_t const> const &x_ptr,
Span<SketchEntry const> const &d_y,
Span<bst_row_t const> const &y_ptr,
Span<FeatureType const> feature_types,
Span<SketchEntry> out,
Span<bst_row_t> out_ptr) {
Span<bst_row_t const> const &x_ptr, Span<SketchEntry const> const &d_y,
Span<bst_row_t const> const &y_ptr, Span<SketchEntry> out, Span<bst_row_t> out_ptr) {
dh::safe_cuda(cudaSetDevice(device));
CHECK_EQ(d_x.size() + d_y.size(), out.size());
CHECK_EQ(x_ptr.size(), out_ptr.size());
@@ -311,6 +305,7 @@ void MergeImpl(int32_t device, Span<SketchEntry const> const &d_x,
void SketchContainer::Push(Span<Entry const> entries, Span<size_t> columns_ptr,
common::Span<OffsetT> cuts_ptr,
size_t total_cuts, Span<float> weights) {
dh::safe_cuda(cudaSetDevice(device_));
Span<SketchEntry> out;
dh::device_vector<SketchEntry> cuts;
bool first_window = this->Current().empty();
@@ -330,8 +325,7 @@ void SketchContainer::Push(Span<Entry const> entries, Span<size_t> columns_ptr,
float rmax = sample_idx + 1;
return SketchEntry{rmin, rmax, 1, column[sample_idx].fvalue};
}; // NOLINT
PruneImpl<Entry>(device_, cuts_ptr, entries, columns_ptr, ft, out,
to_sketch_entry);
PruneImpl<Entry>(cuts_ptr, entries, columns_ptr, ft, out, to_sketch_entry);
} else {
auto to_sketch_entry = [weights, columns_ptr] __device__(
size_t sample_idx,
@@ -345,8 +339,7 @@ void SketchContainer::Push(Span<Entry const> entries, Span<size_t> columns_ptr,
wmin = wmin < 0 ? kRtEps : wmin; // GPU scan can generate floating error.
return SketchEntry{rmin, rmax, wmin, column[sample_idx].fvalue};
}; // NOLINT
PruneImpl<Entry>(device_, cuts_ptr, entries, columns_ptr, ft, out,
to_sketch_entry);
PruneImpl<Entry>(cuts_ptr, entries, columns_ptr, ft, out, to_sketch_entry);
}
auto n_uniques = this->ScanInput(out, cuts_ptr);
@@ -436,8 +429,7 @@ void SketchContainer::Prune(size_t to) {
Span<SketchEntry const> const &entries,
size_t) { return entries[sample_idx]; }; // NOLINT
auto ft = this->feature_types_.ConstDeviceSpan();
PruneImpl<SketchEntry>(device_, d_columns_ptr_out, in, d_columns_ptr_in, ft,
out, no_op);
PruneImpl<SketchEntry>(d_columns_ptr_out, in, d_columns_ptr_in, ft, out, no_op);
this->columns_ptr_.Copy(columns_ptr_b_);
this->Alternate();
@@ -466,10 +458,8 @@ void SketchContainer::Merge(Span<OffsetT const> d_that_columns_ptr,
this->Other().resize(this->Current().size() + that.size());
CHECK_EQ(d_that_columns_ptr.size(), this->columns_ptr_.Size());
auto feature_types = this->FeatureTypes().ConstDeviceSpan();
MergeImpl(device_, this->Data(), this->ColumnsPtr(), that, d_that_columns_ptr,
feature_types, dh::ToSpan(this->Other()),
columns_ptr_b_.DeviceSpan());
dh::ToSpan(this->Other()), columns_ptr_b_.DeviceSpan());
this->columns_ptr_.Copy(columns_ptr_b_);
CHECK_EQ(this->columns_ptr_.Size(), num_columns_ + 1);
this->Alternate();

View File

@@ -965,8 +965,7 @@ template DMatrix *DMatrix::Create<DataIterHandle, DMatrixHandle,
XGDMatrixCallbackNext *next, float missing, int32_t n_threads, std::string);
template <typename AdapterT>
DMatrix* DMatrix::Create(AdapterT* adapter, float missing, int nthread,
const std::string& cache_prefix) {
DMatrix* DMatrix::Create(AdapterT* adapter, float missing, int nthread, const std::string&) {
return new data::SimpleDMatrix(adapter, missing, nthread);
}

View File

@@ -190,6 +190,7 @@ class CupyAdapter : public detail::SingleBatchDataIter<CupyAdapterBatch> {
template <typename AdapterBatchT>
size_t GetRowCounts(const AdapterBatchT batch, common::Span<size_t> offset,
int device_idx, float missing) {
dh::safe_cuda(cudaSetDevice(device_idx));
IsValidFunctor is_valid(missing);
// Count elements per row
dh::LaunchN(batch.Size(), [=] __device__(size_t idx) {

View File

@@ -264,12 +264,10 @@ void WriteNullValues(EllpackPageImpl* dst, int device_idx,
}
template <typename AdapterBatch>
EllpackPageImpl::EllpackPageImpl(AdapterBatch batch, float missing, int device,
bool is_dense, int nthread,
EllpackPageImpl::EllpackPageImpl(AdapterBatch batch, float missing, int device, bool is_dense,
common::Span<size_t> row_counts_span,
common::Span<FeatureType const> feature_types,
size_t row_stride, size_t n_rows, size_t n_cols,
common::HistogramCuts const& cuts) {
common::Span<FeatureType const> feature_types, size_t row_stride,
size_t n_rows, common::HistogramCuts const& cuts) {
dh::safe_cuda(cudaSetDevice(device));
*this = EllpackPageImpl(device, cuts, is_dense, row_stride, n_rows);
@@ -277,12 +275,11 @@ EllpackPageImpl::EllpackPageImpl(AdapterBatch batch, float missing, int device,
WriteNullValues(this, device, row_counts_span);
}
#define ELLPACK_BATCH_SPECIALIZE(__BATCH_T) \
template EllpackPageImpl::EllpackPageImpl( \
__BATCH_T batch, float missing, int device, bool is_dense, int nthread, \
common::Span<size_t> row_counts_span, \
common::Span<FeatureType const> feature_types, size_t row_stride, \
size_t n_rows, size_t n_cols, common::HistogramCuts const &cuts);
#define ELLPACK_BATCH_SPECIALIZE(__BATCH_T) \
template EllpackPageImpl::EllpackPageImpl( \
__BATCH_T batch, float missing, int device, bool is_dense, \
common::Span<size_t> row_counts_span, common::Span<FeatureType const> feature_types, \
size_t row_stride, size_t n_rows, common::HistogramCuts const& cuts);
ELLPACK_BATCH_SPECIALIZE(data::CudfAdapterBatch)
ELLPACK_BATCH_SPECIALIZE(data::CupyAdapterBatch)

View File

@@ -150,12 +150,10 @@ class EllpackPageImpl {
explicit EllpackPageImpl(DMatrix* dmat, const BatchParam& parm);
template <typename AdapterBatch>
explicit EllpackPageImpl(AdapterBatch batch, float missing, int device,
bool is_dense, int nthread,
explicit EllpackPageImpl(AdapterBatch batch, float missing, int device, bool is_dense,
common::Span<size_t> row_counts_span,
common::Span<FeatureType const> feature_types,
size_t row_stride, size_t n_rows, size_t n_cols,
common::HistogramCuts const &cuts);
common::Span<FeatureType const> feature_types, size_t row_stride,
size_t n_rows, common::HistogramCuts const& cuts);
/*! \brief Copy the elements of the given ELLPACK page into this page.
*

View File

@@ -16,7 +16,7 @@
namespace xgboost {
namespace data {
void IterativeDeviceDMatrix::Initialize(DataIterHandle iter_handle, float missing, int nthread) {
void IterativeDeviceDMatrix::Initialize(DataIterHandle iter_handle, float missing) {
// A handle passed to external iterator.
DMatrixProxy* proxy = MakeProxy(proxy_);
CHECK(proxy);
@@ -132,10 +132,9 @@ void IterativeDeviceDMatrix::Initialize(DataIterHandle iter_handle, float missin
proxy->Info().feature_types.SetDevice(get_device());
auto d_feature_types = proxy->Info().feature_types.ConstDeviceSpan();
auto new_impl = Dispatch(proxy, [&](auto const &value) {
return EllpackPageImpl(value, missing, get_device(), is_dense, nthread,
row_counts_span, d_feature_types, row_stride, rows,
cols, cuts);
auto new_impl = Dispatch(proxy, [&](auto const& value) {
return EllpackPageImpl(value, missing, get_device(), is_dense, row_counts_span,
d_feature_types, row_stride, rows, cuts);
});
size_t num_elements = page_->Impl()->Copy(get_device(), &new_impl, offset);
offset += num_elements;
@@ -163,6 +162,11 @@ void IterativeDeviceDMatrix::Initialize(DataIterHandle iter_handle, float missin
BatchSet<EllpackPage> IterativeDeviceDMatrix::GetEllpackBatches(const BatchParam& param) {
CHECK(page_);
// FIXME(Jiamingy): https://github.com/dmlc/xgboost/issues/7976
if (param.max_bin != batch_param_.max_bin) {
LOG(WARNING) << "Inconsistent max_bin between Quantile DMatrix and Booster:" << param.max_bin
<< " vs. " << batch_param_.max_bin;
}
auto begin_iter = BatchIterator<EllpackPage>(new SimpleBatchIteratorImpl<EllpackPage>(page_));
return BatchSet<EllpackPage>(begin_iter);
}

View File

@@ -30,16 +30,16 @@ class IterativeDeviceDMatrix : public DMatrix {
XGDMatrixCallbackNext *next_;
public:
void Initialize(DataIterHandle iter, float missing, int nthread);
void Initialize(DataIterHandle iter, float missing);
public:
explicit IterativeDeviceDMatrix(DataIterHandle iter, DMatrixHandle proxy,
DataIterResetCallback *reset,
XGDMatrixCallbackNext *next, float missing,
int nthread, int max_bin)
DataIterResetCallback *reset, XGDMatrixCallbackNext *next,
float missing, int nthread, int max_bin)
: proxy_{proxy}, reset_{reset}, next_{next} {
batch_param_ = BatchParam{0, max_bin};
this->Initialize(iter, missing, nthread);
ctx_.UpdateAllowUnknown(Args{{"nthread", std::to_string(nthread)}});
this->Initialize(iter, missing);
}
~IterativeDeviceDMatrix() override = default;
@@ -77,7 +77,7 @@ class IterativeDeviceDMatrix : public DMatrix {
};
#if !defined(XGBOOST_USE_CUDA)
inline void IterativeDeviceDMatrix::Initialize(DataIterHandle iter, float missing, int nthread) {
inline void IterativeDeviceDMatrix::Initialize(DataIterHandle iter, float missing) {
// silent the warning about unused variables.
(void)(proxy_);
(void)(reset_);

View File

@@ -15,7 +15,7 @@ namespace data {
// Current implementation assumes a single batch. More batches can
// be supported in future. Does not currently support inferring row/column size
template <typename AdapterT>
SimpleDMatrix::SimpleDMatrix(AdapterT* adapter, float missing, int nthread) {
SimpleDMatrix::SimpleDMatrix(AdapterT* adapter, float missing, int32_t /*nthread*/) {
auto device = (adapter->DeviceIdx() < 0 || adapter->NumRows() == 0) ? dh::CurrentDevice()
: adapter->DeviceIdx();
CHECK_GE(device, 0);

View File

@@ -148,8 +148,8 @@ class GBLinear : public GradientBooster {
monitor_.Stop("DoBoost");
}
void PredictBatch(DMatrix *p_fmat, PredictionCacheEntry *predts,
bool training, unsigned layer_begin, unsigned layer_end) override {
void PredictBatch(DMatrix* p_fmat, PredictionCacheEntry* predts, bool /*training*/,
uint32_t layer_begin, uint32_t) override {
monitor_.Start("PredictBatch");
LinearCheckLayer(layer_begin);
auto* out_preds = &predts->predictions;
@@ -157,9 +157,8 @@ class GBLinear : public GradientBooster {
monitor_.Stop("PredictBatch");
}
// add base margin
void PredictInstance(const SparsePage::Inst &inst,
std::vector<bst_float> *out_preds,
unsigned layer_begin, unsigned layer_end) override {
void PredictInstance(const SparsePage::Inst& inst, std::vector<bst_float>* out_preds,
uint32_t layer_begin, uint32_t) override {
LinearCheckLayer(layer_begin);
const int ngroup = model_.learner_model_param->num_output_group;
for (int gid = 0; gid < ngroup; ++gid) {
@@ -172,9 +171,9 @@ class GBLinear : public GradientBooster {
LOG(FATAL) << "gblinear does not support prediction of leaf index";
}
void PredictContribution(DMatrix* p_fmat,
HostDeviceVector<bst_float>* out_contribs,
unsigned layer_begin, unsigned layer_end, bool, int, unsigned) override {
void PredictContribution(DMatrix* p_fmat, HostDeviceVector<bst_float>* out_contribs,
uint32_t layer_begin, uint32_t /*layer_end*/, bool, int,
unsigned) override {
model_.LazyInitModel();
LinearCheckLayer(layer_begin);
auto base_margin = p_fmat->Info().base_margin_.View(GenericParameter::kCpuId);
@@ -210,9 +209,9 @@ class GBLinear : public GradientBooster {
}
}
void PredictInteractionContributions(DMatrix* p_fmat,
HostDeviceVector<bst_float>* out_contribs,
unsigned layer_begin, unsigned layer_end, bool) override {
void PredictInteractionContributions(DMatrix* p_fmat, HostDeviceVector<bst_float>* out_contribs,
unsigned layer_begin, unsigned /*layer_end*/,
bool) override {
LinearCheckLayer(layer_begin);
std::vector<bst_float>& contribs = out_contribs->HostVector();

View File

@@ -34,7 +34,10 @@ struct DeprecatedGBLinearModelParam : public dmlc::Parameter<DeprecatedGBLinearM
std::memset(this, 0, sizeof(DeprecatedGBLinearModelParam));
}
DMLC_DECLARE_PARAMETER(DeprecatedGBLinearModelParam) {}
DMLC_DECLARE_PARAMETER(DeprecatedGBLinearModelParam) {
DMLC_DECLARE_FIELD(deprecated_num_feature);
DMLC_DECLARE_FIELD(deprecated_num_output_group);
}
};
// model for linear booster

View File

@@ -236,10 +236,6 @@ class GBTree : public GradientBooster {
void SaveModel(Json* p_out) const override;
void LoadModel(Json const& in) override;
bool AllowLazyCheckPoint() const override {
return model_.learner_model_param->num_output_group == 1;
}
// Number of trees per layer.
auto LayerTrees() const {
auto n_trees = model_.learner_model_param->num_output_group * model_.param.num_parallel_tree;

View File

@@ -61,11 +61,6 @@ enum class DataSplitMode : int {
DECLARE_FIELD_ENUM_CLASS(xgboost::DataSplitMode);
namespace xgboost {
// implementation of base learner.
bool Learner::AllowLazyCheckPoint() const {
return gbm_->AllowLazyCheckPoint();
}
Learner::~Learner() = default;
/*! \brief training parameter for regression

View File

@@ -77,8 +77,8 @@ class GPUCoordinateUpdater : public LinearUpdater { // NOLINT
auto column_end =
std::lower_bound(col.cbegin(), col.cend(),
xgboost::Entry(num_row_, 0.0f), cmp);
column_segments.emplace_back(
std::make_pair(column_begin - col.cbegin(), column_end - col.cbegin()));
column_segments.emplace_back(static_cast<bst_uint>(column_begin - col.cbegin()),
static_cast<bst_uint>(column_end - col.cbegin()));
row_ptr_.push_back(row_ptr_.back() + (column_end - column_begin));
}
data_.resize(row_ptr_.back());
@@ -109,28 +109,28 @@ class GPUCoordinateUpdater : public LinearUpdater { // NOLINT
monitor_.Stop("UpdateGpair");
monitor_.Start("UpdateBias");
this->UpdateBias(p_fmat, model);
this->UpdateBias(model);
monitor_.Stop("UpdateBias");
// prepare for updating the weights
selector_->Setup(*model, in_gpair->ConstHostVector(), p_fmat,
tparam_.reg_alpha_denorm, tparam_.reg_lambda_denorm,
coord_param_.top_k);
monitor_.Start("UpdateFeature");
for (auto group_idx = 0; group_idx < model->learner_model_param->num_output_group;
for (uint32_t group_idx = 0; group_idx < model->learner_model_param->num_output_group;
++group_idx) {
for (auto i = 0U; i < model->learner_model_param->num_feature; i++) {
auto fidx = selector_->NextFeature(
i, *model, group_idx, in_gpair->ConstHostVector(), p_fmat,
tparam_.reg_alpha_denorm, tparam_.reg_lambda_denorm);
if (fidx < 0) break;
this->UpdateFeature(fidx, group_idx, &in_gpair->HostVector(), model);
this->UpdateFeature(fidx, group_idx, model);
}
}
monitor_.Stop("UpdateFeature");
}
void UpdateBias(DMatrix *p_fmat, gbm::GBLinearModel *model) {
for (int group_idx = 0; group_idx < model->learner_model_param->num_output_group;
void UpdateBias(gbm::GBLinearModel *model) {
for (uint32_t group_idx = 0; group_idx < model->learner_model_param->num_output_group;
++group_idx) {
// Get gradient
auto grad = GradientPair(0, 0);
@@ -150,7 +150,6 @@ class GPUCoordinateUpdater : public LinearUpdater { // NOLINT
}
void UpdateFeature(int fidx, int group_idx,
std::vector<GradientPair> *in_gpair,
gbm::GBLinearModel *model) {
bst_float &w = (*model)[fidx][group_idx];
// Get gradient

View File

@@ -201,8 +201,7 @@ void Transpose(common::Span<float const> in, common::Span<float> out, size_t m,
});
}
double ScaleClasses(common::Span<double> results,
common::Span<double> local_area, common::Span<double> fp,
double ScaleClasses(common::Span<double> results, common::Span<double> local_area,
common::Span<double> tp, common::Span<double> auc,
std::shared_ptr<DeviceAUCCache> cache, size_t n_classes) {
dh::XGBDeviceAllocator<char> alloc;
@@ -333,10 +332,9 @@ double GPUMultiClassAUCOVR(MetaInfo const &info, int32_t device, common::Span<ui
dh::LaunchN(n_classes * 4,
[=] XGBOOST_DEVICE(size_t i) { d_results[i] = 0.0f; });
auto local_area = d_results.subspan(0, n_classes);
auto fp = d_results.subspan(n_classes, n_classes);
auto tp = d_results.subspan(2 * n_classes, n_classes);
auto auc = d_results.subspan(3 * n_classes, n_classes);
return ScaleClasses(d_results, local_area, fp, tp, auc, cache, n_classes);
return ScaleClasses(d_results, local_area, tp, auc, cache, n_classes);
}
/**
@@ -440,7 +438,7 @@ double GPUMultiClassAUCOVR(MetaInfo const &info, int32_t device, common::Span<ui
tp[c] = 1.0f;
}
});
return ScaleClasses(d_results, local_area, fp, tp, auc, cache, n_classes);
return ScaleClasses(d_results, local_area, tp, auc, cache, n_classes);
}
void MultiClassSortedIdx(common::Span<float const> predts,

View File

@@ -376,40 +376,40 @@ struct EvalEWiseBase : public Metric {
};
XGBOOST_REGISTER_METRIC(RMSE, "rmse")
.describe("Rooted mean square error.")
.set_body([](const char* param) { return new EvalEWiseBase<EvalRowRMSE>(); });
.describe("Rooted mean square error.")
.set_body([](const char*) { return new EvalEWiseBase<EvalRowRMSE>(); });
XGBOOST_REGISTER_METRIC(RMSLE, "rmsle")
.describe("Rooted mean square log error.")
.set_body([](const char* param) { return new EvalEWiseBase<EvalRowRMSLE>(); });
.describe("Rooted mean square log error.")
.set_body([](const char*) { return new EvalEWiseBase<EvalRowRMSLE>(); });
XGBOOST_REGISTER_METRIC(MAE, "mae")
.describe("Mean absolute error.")
.set_body([](const char* param) { return new EvalEWiseBase<EvalRowMAE>(); });
XGBOOST_REGISTER_METRIC(MAE, "mae").describe("Mean absolute error.").set_body([](const char*) {
return new EvalEWiseBase<EvalRowMAE>();
});
XGBOOST_REGISTER_METRIC(MAPE, "mape")
.describe("Mean absolute percentage error.")
.set_body([](const char* param) { return new EvalEWiseBase<EvalRowMAPE>(); });
.set_body([](const char*) { return new EvalEWiseBase<EvalRowMAPE>(); });
XGBOOST_REGISTER_METRIC(LogLoss, "logloss")
.describe("Negative loglikelihood for logistic regression.")
.set_body([](const char* param) { return new EvalEWiseBase<EvalRowLogLoss>(); });
.describe("Negative loglikelihood for logistic regression.")
.set_body([](const char*) { return new EvalEWiseBase<EvalRowLogLoss>(); });
XGBOOST_REGISTER_METRIC(PseudoErrorLoss, "mphe")
.describe("Mean Pseudo-huber error.")
.set_body([](const char* param) { return new PseudoErrorLoss{}; });
.set_body([](const char*) { return new PseudoErrorLoss{}; });
XGBOOST_REGISTER_METRIC(PossionNegLoglik, "poisson-nloglik")
.describe("Negative loglikelihood for poisson regression.")
.set_body([](const char* param) { return new EvalEWiseBase<EvalPoissonNegLogLik>(); });
.describe("Negative loglikelihood for poisson regression.")
.set_body([](const char*) { return new EvalEWiseBase<EvalPoissonNegLogLik>(); });
XGBOOST_REGISTER_METRIC(GammaDeviance, "gamma-deviance")
.describe("Residual deviance for gamma regression.")
.set_body([](const char* param) { return new EvalEWiseBase<EvalGammaDeviance>(); });
.describe("Residual deviance for gamma regression.")
.set_body([](const char*) { return new EvalEWiseBase<EvalGammaDeviance>(); });
XGBOOST_REGISTER_METRIC(GammaNLogLik, "gamma-nloglik")
.describe("Negative log-likelihood for gamma regression.")
.set_body([](const char* param) { return new EvalEWiseBase<EvalGammaNLogLik>(); });
.describe("Negative log-likelihood for gamma regression.")
.set_body([](const char*) { return new EvalEWiseBase<EvalGammaNLogLik>(); });
XGBOOST_REGISTER_METRIC(Error, "error")
.describe("Binary classification error.")

View File

@@ -230,9 +230,7 @@ struct EvalMultiLogLoss : public EvalMClassBase<EvalMultiLogLoss> {
const char* Name() const override {
return "mlogloss";
}
XGBOOST_DEVICE static bst_float EvalRow(int label,
const bst_float *pred,
size_t nclass) {
XGBOOST_DEVICE static bst_float EvalRow(int label, const bst_float* pred, size_t /*nclass*/) {
const bst_float eps = 1e-16f;
auto k = static_cast<size_t>(label);
if (pred[k] > eps) {
@@ -244,11 +242,11 @@ struct EvalMultiLogLoss : public EvalMClassBase<EvalMultiLogLoss> {
};
XGBOOST_REGISTER_METRIC(MatchError, "merror")
.describe("Multiclass classification error.")
.set_body([](const char* param) { return new EvalMatchError(); });
.describe("Multiclass classification error.")
.set_body([](const char*) { return new EvalMatchError(); });
XGBOOST_REGISTER_METRIC(MultiLogLoss, "mlogloss")
.describe("Multiclass negative loglikelihood.")
.set_body([](const char* param) { return new EvalMultiLogLoss(); });
.describe("Multiclass negative loglikelihood.")
.set_body([](const char*) { return new EvalMultiLogLoss(); });
} // namespace metric
} // namespace xgboost

View File

@@ -153,7 +153,7 @@ class ElementWiseSurvivalMetricsReduction {
};
struct EvalIntervalRegressionAccuracy {
void Configure(const Args& args) {}
void Configure(const Args&) {}
const char* Name() const {
return "interval-regression-accuracy";
@@ -277,18 +277,15 @@ struct AFTNLogLikDispatcher : public Metric {
std::unique_ptr<Metric> metric_;
};
XGBOOST_REGISTER_METRIC(AFTNLogLik, "aft-nloglik")
.describe("Negative log likelihood of Accelerated Failure Time model.")
.set_body([](const char* param) {
return new AFTNLogLikDispatcher();
});
.describe("Negative log likelihood of Accelerated Failure Time model.")
.set_body([](const char*) { return new AFTNLogLikDispatcher(); });
XGBOOST_REGISTER_METRIC(IntervalRegressionAccuracy, "interval-regression-accuracy")
.describe("")
.set_body([](const char* param) {
return new EvalEWiseSurvivalBase<EvalIntervalRegressionAccuracy>();
});
.describe("")
.set_body([](const char*) {
return new EvalEWiseSurvivalBase<EvalIntervalRegressionAccuracy>();
});
} // namespace metric
} // namespace xgboost

View File

@@ -29,7 +29,7 @@ void EncodeTreeLeafDevice(Context const* ctx, common::Span<bst_node_t const> pos
thrust::stable_sort_by_key(thrust::cuda::par(alloc), sorted_position.begin(),
sorted_position.begin() + n_samples, p_ridx->begin());
dh::XGBCachingDeviceAllocator<char> caching;
auto beg_pos =
size_t beg_pos =
thrust::find_if(thrust::cuda::par(caching), sorted_position.cbegin(), sorted_position.cend(),
[] XGBOOST_DEVICE(bst_node_t nidx) { return nidx >= 0; }) -
sorted_position.cbegin();
@@ -53,15 +53,15 @@ void EncodeTreeLeafDevice(Context const* ctx, common::Span<bst_node_t const> pos
dh::caching_device_vector<bst_node_t> unique_out(max_n_unique, 0);
auto d_unique_out = dh::ToSpan(unique_out);
size_t nbytes;
size_t nbytes{0};
auto begin_it = sorted_position.begin() + beg_pos;
cub::DeviceRunLengthEncode::Encode(nullptr, nbytes, begin_it, unique_out.data().get(),
counts_out.data().get(), d_num_runs_out.data(),
n_samples - beg_pos);
dh::safe_cuda(cub::DeviceRunLengthEncode::Encode(nullptr, nbytes, begin_it,
unique_out.data().get(), counts_out.data().get(),
d_num_runs_out.data(), n_samples - beg_pos));
dh::TemporaryArray<char> temp(nbytes);
cub::DeviceRunLengthEncode::Encode(temp.data().get(), nbytes, begin_it, unique_out.data().get(),
counts_out.data().get(), d_num_runs_out.data(),
n_samples - beg_pos);
dh::safe_cuda(cub::DeviceRunLengthEncode::Encode(temp.data().get(), nbytes, begin_it,
unique_out.data().get(), counts_out.data().get(),
d_num_runs_out.data(), n_samples - beg_pos));
dh::PinnedMemory pinned_pool;
auto pinned = pinned_pool.GetSpan<char>(sizeof(size_t) + sizeof(bst_node_t));

View File

@@ -70,9 +70,7 @@ class AFTObj : public ObjFunction {
&info.weights_);
}
void GetGradient(const HostDeviceVector<bst_float>& preds,
const MetaInfo& info,
int iter,
void GetGradient(const HostDeviceVector<bst_float>& preds, const MetaInfo& info, int /*iter*/,
HostDeviceVector<GradientPair>* out_gpair) override {
const size_t ndata = preds.Size();
CHECK_EQ(info.labels_lower_bound_.Size(), ndata);
@@ -115,7 +113,7 @@ class AFTObj : public ObjFunction {
.Eval(io_preds);
}
void EvalTransform(HostDeviceVector<bst_float> *io_preds) override {
void EvalTransform(HostDeviceVector<bst_float>* /*io_preds*/) override {
// do nothing here, since the AFT metric expects untransformed prediction score
}

View File

@@ -27,9 +27,7 @@ class HingeObj : public ObjFunction {
void Configure(Args const&) override {}
ObjInfo Task() const override { return ObjInfo::kRegression; }
void GetGradient(const HostDeviceVector<bst_float> &preds,
const MetaInfo &info,
int iter,
void GetGradient(const HostDeviceVector<bst_float> &preds, const MetaInfo &info, int /*iter*/,
HostDeviceVector<GradientPair> *out_gpair) override {
CHECK_NE(info.labels.Size(), 0U) << "label set cannot be empty";
CHECK_EQ(preds.Size(), info.labels.Size())
@@ -86,7 +84,7 @@ class HingeObj : public ObjFunction {
auto& out = *p_out;
out["name"] = String("binary:hinge");
}
void LoadConfig(Json const& in) override {}
void LoadConfig(Json const &) override {}
};
// register the objective functions

View File

@@ -218,7 +218,7 @@ class PseudoHuberRegression : public ObjFunction {
return std::max(static_cast<size_t>(1), info.labels.Shape(1));
}
void GetGradient(HostDeviceVector<bst_float> const& preds, const MetaInfo& info, int iter,
void GetGradient(HostDeviceVector<bst_float> const& preds, const MetaInfo& info, int /*iter*/,
HostDeviceVector<GradientPair>* out_gpair) override {
CheckRegInputs(info, preds);
auto slope = param_.huber_slope;
@@ -672,7 +672,7 @@ class MeanAbsoluteError : public ObjFunction {
void Configure(Args const&) override {}
ObjInfo Task() const override { return {ObjInfo::kRegression, true, true}; }
void GetGradient(HostDeviceVector<bst_float> const& preds, const MetaInfo& info, int iter,
void GetGradient(HostDeviceVector<bst_float> const& preds, const MetaInfo& info, int /*iter*/,
HostDeviceVector<GradientPair>* out_gpair) override {
CheckRegInputs(info, preds);
auto labels = info.labels.View(ctx_->gpu_id);
@@ -721,7 +721,9 @@ class MeanAbsoluteError : public ObjFunction {
out["name"] = String("reg:absoluteerror");
}
void LoadConfig(Json const& in) override {}
void LoadConfig(Json const& in) override {
CHECK_EQ(StringView{get<String const>(in["name"])}, StringView{"reg:absoluteerror"});
}
};
XGBOOST_REGISTER_OBJECTIVE(MeanAbsoluteError, "reg:absoluteerror")

View File

@@ -244,7 +244,7 @@ void FillNodeMeanValues(RegTree const* tree, std::vector<float>* mean_values) {
class CPUPredictor : public Predictor {
protected:
// init thread buffers
static void InitThreadTemp(int nthread, int num_feature, std::vector<RegTree::FVec>* out) {
static void InitThreadTemp(int nthread, std::vector<RegTree::FVec> *out) {
int prev_thread_temp_size = out->size();
if (prev_thread_temp_size < nthread) {
out->resize(nthread, RegTree::FVec());
@@ -263,8 +263,7 @@ class CPUPredictor : public Predictor {
bool blocked = density > kDensityThresh;
std::vector<RegTree::FVec> feat_vecs;
InitThreadTemp(n_threads * (blocked ? kBlockOfRowsSize : 1),
model.learner_model_param->num_feature, &feat_vecs);
InitThreadTemp(n_threads * (blocked ? kBlockOfRowsSize : 1), &feat_vecs);
for (auto const &batch : p_fmat->GetBatches<SparsePage>()) {
CHECK_EQ(out_preds->size(),
p_fmat->Info().num_row_ *
@@ -320,8 +319,7 @@ class CPUPredictor : public Predictor {
std::vector<Entry> workspace(m->NumColumns() * 8 * n_threads);
auto &predictions = out_preds->predictions.HostVector();
std::vector<RegTree::FVec> thread_temp;
InitThreadTemp(n_threads * kBlockSize, model.learner_model_param->num_feature,
&thread_temp);
InitThreadTemp(n_threads * kBlockSize, &thread_temp);
PredictBatchByBlockOfRowsKernel<AdapterView<Adapter>, kBlockSize>(
AdapterView<Adapter>(m.get(), missing, common::Span<Entry>{workspace}, n_threads),
&predictions, model, tree_begin, tree_end, &thread_temp, n_threads);
@@ -376,7 +374,7 @@ class CPUPredictor : public Predictor {
auto const n_threads = this->ctx_->Threads();
std::vector<RegTree::FVec> feat_vecs;
const int num_feature = model.learner_model_param->num_feature;
InitThreadTemp(n_threads, num_feature, &feat_vecs);
InitThreadTemp(n_threads, &feat_vecs);
const MetaInfo& info = p_fmat->Info();
// number of valid trees
if (ntree_limit == 0 || ntree_limit > model.trees.size()) {
@@ -417,7 +415,7 @@ class CPUPredictor : public Predictor {
auto const n_threads = this->ctx_->Threads();
const int num_feature = model.learner_model_param->num_feature;
std::vector<RegTree::FVec> feat_vecs;
InitThreadTemp(n_threads, num_feature, &feat_vecs);
InitThreadTemp(n_threads, &feat_vecs);
const MetaInfo& info = p_fmat->Info();
// number of valid trees
if (ntree_limit == 0 || ntree_limit > model.trees.size()) {

View File

@@ -29,7 +29,7 @@ FeatureGroups::FeatureGroups(const common::HistogramCuts& cuts, bool is_dense,
bin_segments_h.push_back(0);
const std::vector<uint32_t>& cut_ptrs = cuts.Ptrs();
int max_shmem_bins = shm_size / bin_size;
size_t max_shmem_bins = shm_size / bin_size;
max_group_bins = 0;
for (size_t i = 2; i < cut_ptrs.size(); ++i) {

View File

@@ -188,7 +188,7 @@ void BuildGradientHistogram(EllpackDeviceAccessor const& matrix,
int device = 0;
dh::safe_cuda(cudaGetDevice(&device));
// opt into maximum shared memory for the kernel if necessary
int max_shared_memory = dh::MaxSharedMemoryOptin(device);
size_t max_shared_memory = dh::MaxSharedMemoryOptin(device);
size_t smem_size = sizeof(typename HistRounding<GradientSumT>::SharedSumT) *
feature_groups.max_group_bins;

View File

@@ -79,6 +79,7 @@ void RowPartitioner::SortPosition(common::Span<bst_node_t> position,
void Reset(int device_idx, common::Span<RowPartitioner::RowIndexT> ridx,
common::Span<bst_node_t> position) {
dh::safe_cuda(cudaSetDevice(device_idx));
CHECK_EQ(ridx.size(), position.size());
dh::LaunchN(ridx.size(), [=] __device__(size_t idx) {
ridx[idx] = idx;
@@ -92,7 +93,7 @@ RowPartitioner::RowPartitioner(int device_idx, size_t num_rows)
dh::safe_cuda(cudaSetDevice(device_idx_));
ridx_ = dh::DoubleBuffer<RowIndexT>{&ridx_a_, &ridx_b_};
position_ = dh::DoubleBuffer<bst_node_t>{&position_a_, &position_b_};
ridx_segments_.emplace_back(Segment(0, num_rows));
ridx_segments_.emplace_back(static_cast<size_t>(0), num_rows);
Reset(device_idx, ridx_.CurrentSpan(), position_.CurrentSpan());
left_counts_.resize(256);

View File

@@ -140,9 +140,7 @@ class HistogramBuilder {
nodes_for_subtraction_trick,
starting_index, sync_count);
} else {
this->SyncHistogramLocal(p_tree, nodes_for_explicit_hist_build,
nodes_for_subtraction_trick, starting_index,
sync_count);
this->SyncHistogramLocal(p_tree, nodes_for_explicit_hist_build, nodes_for_subtraction_trick);
}
}
/** same as the other build hist but handles only single batch data (in-core) */
@@ -211,11 +209,9 @@ class HistogramBuilder {
nodes_for_explicit_hist_build, p_tree);
}
void SyncHistogramLocal(
RegTree *p_tree,
std::vector<ExpandEntry> const &nodes_for_explicit_hist_build,
std::vector<ExpandEntry> const &nodes_for_subtraction_trick,
int starting_index, int sync_count) {
void SyncHistogramLocal(RegTree *p_tree,
std::vector<ExpandEntry> const &nodes_for_explicit_hist_build,
std::vector<ExpandEntry> const &nodes_for_subtraction_trick) {
const size_t nbins = this->builder_.GetNumBins();
common::BlockedSpace2d space(
nodes_for_explicit_hist_build.size(), [&](size_t) { return nbins; },

View File

@@ -92,14 +92,14 @@ void ParseInteractionConstraint(
for (size_t i = 0; i < all.size(); ++i) {
auto const &set = get<Array const>(all[i]);
for (auto const &v : set) {
if (XGBOOST_EXPECT(IsA<Integer>(v), true)) {
uint32_t u = static_cast<uint32_t const>(get<Integer const>(v));
if (XGBOOST_EXPECT(IsA<Integer const>(v), true)) {
auto u = static_cast<bst_feature_t>(get<Integer const>(v));
out[i].emplace_back(u);
} else if (IsA<Number>(v)) {
double d = get<Number const>(v);
CHECK_EQ(std::floor(d), d)
<< "Found floating point number in interaction constraints";
out[i].emplace_back(static_cast<uint32_t const>(d));
out[i].emplace_back(static_cast<uint32_t>(d));
} else {
LOG(FATAL) << "Unknown value type for interaction constraint:"
<< v.GetValue().TypeStr();

View File

@@ -354,10 +354,10 @@ class TextGenerator : public TreeGenerator {
};
XGBOOST_REGISTER_TREE_IO(TextGenerator, "text")
.describe("Dump text representation of tree")
.set_body([](FeatureMap const& fmap, std::string const& attrs, bool with_stats) {
return new TextGenerator(fmap, with_stats);
});
.describe("Dump text representation of tree")
.set_body([](FeatureMap const& fmap, std::string const& /*attrs*/, bool with_stats) {
return new TextGenerator(fmap, with_stats);
});
class JsonGenerator : public TreeGenerator {
using SuperT = TreeGenerator;
@@ -510,10 +510,10 @@ class JsonGenerator : public TreeGenerator {
};
XGBOOST_REGISTER_TREE_IO(JsonGenerator, "json")
.describe("Dump json representation of tree")
.set_body([](FeatureMap const& fmap, std::string const& attrs, bool with_stats) {
return new JsonGenerator(fmap, with_stats);
});
.describe("Dump json representation of tree")
.set_body([](FeatureMap const& fmap, std::string const& /*attrs*/, bool with_stats) {
return new JsonGenerator(fmap, with_stats);
});
struct GraphvizParam : public XGBoostParameter<GraphvizParam> {
std::string yes_color;

View File

@@ -98,7 +98,7 @@ class ColMaker: public TreeUpdater {
}
void Update(HostDeviceVector<GradientPair> *gpair, DMatrix *dmat,
common::Span<HostDeviceVector<bst_node_t>> out_position,
common::Span<HostDeviceVector<bst_node_t>> /*out_position*/,
const std::vector<RegTree *> &trees) override {
if (rabit::IsDistributed()) {
LOG(FATAL) << "Updater `grow_colmaker` or `exact` tree method doesn't "

View File

@@ -42,7 +42,7 @@ class TreeRefresher : public TreeUpdater {
}
// update the tree, do pruning
void Update(HostDeviceVector<GradientPair> *gpair, DMatrix *p_fmat,
common::Span<HostDeviceVector<bst_node_t>> out_position,
common::Span<HostDeviceVector<bst_node_t>> /*out_position*/,
const std::vector<RegTree *> &trees) override {
if (trees.size() == 0) return;
const std::vector<GradientPair> &gpair_h = gpair->ConstHostVector();

View File

@@ -33,7 +33,7 @@ class TreeSyncher : public TreeUpdater {
}
void Update(HostDeviceVector<GradientPair>*, DMatrix*,
common::Span<HostDeviceVector<bst_node_t>> out_position,
common::Span<HostDeviceVector<bst_node_t>> /*out_position*/,
const std::vector<RegTree*>& trees) override {
if (rabit::GetWorldSize() == 1) return;
std::string s_model;