Fix compiler warnings. (#8022)
- Remove/fix unused parameters - Remove deprecated code in rabit. - Update dmlc-core.
This commit is contained in:
@@ -38,15 +38,16 @@ void ParallelGHistBuilderReset() {
|
||||
target_hist[i] = collection[i];
|
||||
}
|
||||
|
||||
common::BlockedSpace2d space(kNodes, [&](size_t node) { return kTasksPerNode; }, 1);
|
||||
common::BlockedSpace2d space(
|
||||
kNodes, [&](size_t /* node*/) { return kTasksPerNode; }, 1);
|
||||
hist_builder.Reset(nthreads, kNodes, space, target_hist);
|
||||
|
||||
common::ParallelFor2d(space, nthreads, [&](size_t inode, common::Range1d r) {
|
||||
common::ParallelFor2d(space, nthreads, [&](size_t inode, common::Range1d) {
|
||||
const size_t tid = omp_get_thread_num();
|
||||
|
||||
GHistRow hist = hist_builder.GetInitializedHist(tid, inode);
|
||||
// fill hist by some non-null values
|
||||
for(size_t j = 0; j < kBins; ++j) {
|
||||
for (size_t j = 0; j < kBins; ++j) {
|
||||
hist[j].Add(kValue, kValue);
|
||||
}
|
||||
});
|
||||
@@ -56,15 +57,16 @@ void ParallelGHistBuilderReset() {
|
||||
for(size_t i = 0; i < target_hist.size(); ++i) {
|
||||
target_hist[i] = collection[i];
|
||||
}
|
||||
common::BlockedSpace2d space2(kNodesExtended, [&](size_t node) { return kTasksPerNode; }, 1);
|
||||
common::BlockedSpace2d space2(
|
||||
kNodesExtended, [&](size_t /*node*/) { return kTasksPerNode; }, 1);
|
||||
hist_builder.Reset(nthreads, kNodesExtended, space2, target_hist);
|
||||
|
||||
common::ParallelFor2d(space2, nthreads, [&](size_t inode, common::Range1d r) {
|
||||
common::ParallelFor2d(space2, nthreads, [&](size_t inode, common::Range1d) {
|
||||
const size_t tid = omp_get_thread_num();
|
||||
|
||||
GHistRow hist = hist_builder.GetInitializedHist(tid, inode);
|
||||
// fill hist by some non-null values
|
||||
for(size_t j = 0; j < kBins; ++j) {
|
||||
for (size_t j = 0; j < kBins; ++j) {
|
||||
ASSERT_EQ(0.0, hist[j].GetGrad());
|
||||
ASSERT_EQ(0.0, hist[j].GetHess());
|
||||
}
|
||||
@@ -92,11 +94,12 @@ void ParallelGHistBuilderReduceHist(){
|
||||
target_hist[i] = collection[i];
|
||||
}
|
||||
|
||||
common::BlockedSpace2d space(kNodes, [&](size_t node) { return kTasksPerNode; }, 1);
|
||||
common::BlockedSpace2d space(
|
||||
kNodes, [&](size_t /*node*/) { return kTasksPerNode; }, 1);
|
||||
hist_builder.Reset(nthreads, kNodes, space, target_hist);
|
||||
|
||||
// Simple analog of BuildHist function, works in parallel for both tree-nodes and data in node
|
||||
common::ParallelFor2d(space, nthreads, [&](size_t inode, common::Range1d r) {
|
||||
common::ParallelFor2d(space, nthreads, [&](size_t inode, common::Range1d) {
|
||||
const size_t tid = omp_get_thread_num();
|
||||
|
||||
GHistRow hist = hist_builder.GetInitializedHist(tid, inode);
|
||||
@@ -260,8 +263,7 @@ TEST(HistUtil, DenseCutsExternalMemory) {
|
||||
for (auto num_rows : sizes) {
|
||||
auto x = GenerateRandom(num_rows, num_columns);
|
||||
dmlc::TemporaryDirectory tmpdir;
|
||||
auto dmat =
|
||||
GetExternalMemoryDMatrixFromData(x, num_rows, num_columns, 50, tmpdir);
|
||||
auto dmat = GetExternalMemoryDMatrixFromData(x, num_rows, num_columns, tmpdir);
|
||||
for (auto num_bins : bin_sizes) {
|
||||
HistogramCuts cuts = SketchOnDMatrix(dmat.get(), num_bins, common::OmpGetNumThreads(0));
|
||||
ValidateCuts(cuts, dmat.get(), num_bins);
|
||||
|
||||
@@ -252,8 +252,7 @@ TEST(HistUtil, DeviceSketchMultipleColumnsExternal) {
|
||||
for (auto num_rows : sizes) {
|
||||
auto x = GenerateRandom(num_rows, num_columns);
|
||||
dmlc::TemporaryDirectory temp;
|
||||
auto dmat =
|
||||
GetExternalMemoryDMatrixFromData(x, num_rows, num_columns, 100, temp);
|
||||
auto dmat = GetExternalMemoryDMatrixFromData(x, num_rows, num_columns, temp);
|
||||
for (auto num_bins : bin_sizes) {
|
||||
auto cuts = DeviceSketch(0, dmat.get(), num_bins);
|
||||
ValidateCuts(cuts, dmat.get(), num_bins);
|
||||
@@ -269,7 +268,7 @@ TEST(HistUtil, DeviceSketchExternalMemoryWithWeights) {
|
||||
dmlc::TemporaryDirectory temp;
|
||||
for (auto num_rows : sizes) {
|
||||
auto x = GenerateRandom(num_rows, num_columns);
|
||||
auto dmat = GetExternalMemoryDMatrixFromData(x, num_rows, num_columns, 100, temp);
|
||||
auto dmat = GetExternalMemoryDMatrixFromData(x, num_rows, num_columns, temp);
|
||||
dmat->Info().weights_.HostVector() = GenerateRandomWeights(num_rows);
|
||||
for (auto num_bins : bin_sizes) {
|
||||
auto cuts = DeviceSketch(0, dmat.get(), num_bins);
|
||||
@@ -284,17 +283,15 @@ auto MakeUnweightedCutsForTest(Adapter adapter, int32_t num_bins, float missing,
|
||||
HostDeviceVector<FeatureType> ft;
|
||||
SketchContainer sketch_container(ft, num_bins, adapter.NumColumns(), adapter.NumRows(), 0);
|
||||
MetaInfo info;
|
||||
AdapterDeviceSketch(adapter.Value(), num_bins, info, std::numeric_limits<float>::quiet_NaN(),
|
||||
&sketch_container);
|
||||
AdapterDeviceSketch(adapter.Value(), num_bins, info, missing, &sketch_container, batch_size);
|
||||
sketch_container.MakeCuts(&batched_cuts);
|
||||
return batched_cuts;
|
||||
}
|
||||
|
||||
template <typename Adapter>
|
||||
void ValidateBatchedCuts(Adapter adapter, int num_bins, int num_columns, int num_rows,
|
||||
DMatrix* dmat, size_t batch_size = 0) {
|
||||
void ValidateBatchedCuts(Adapter adapter, int num_bins, DMatrix* dmat, size_t batch_size = 0) {
|
||||
common::HistogramCuts batched_cuts = MakeUnweightedCutsForTest(
|
||||
adapter, num_bins, std::numeric_limits<float>::quiet_NaN());
|
||||
adapter, num_bins, std::numeric_limits<float>::quiet_NaN(), batch_size);
|
||||
ValidateCuts(batched_cuts, dmat, num_bins);
|
||||
}
|
||||
|
||||
@@ -448,8 +445,7 @@ TEST(HistUtil, AdapterDeviceSketchCategorical) {
|
||||
auto dmat = GetDMatrixFromData(x, n, 1);
|
||||
auto x_device = thrust::device_vector<float>(x);
|
||||
auto adapter = AdapterFromData(x_device, n, 1);
|
||||
ValidateBatchedCuts(adapter, num_bins, adapter.NumColumns(),
|
||||
adapter.NumRows(), dmat.get());
|
||||
ValidateBatchedCuts(adapter, num_bins, dmat.get());
|
||||
TestCategoricalSketchAdapter(n, num_categories, num_bins, true);
|
||||
TestCategoricalSketchAdapter(n, num_categories, num_bins, false);
|
||||
}
|
||||
@@ -466,7 +462,7 @@ TEST(HistUtil, AdapterDeviceSketchMultipleColumns) {
|
||||
auto x_device = thrust::device_vector<float>(x);
|
||||
for (auto num_bins : bin_sizes) {
|
||||
auto adapter = AdapterFromData(x_device, num_rows, num_columns);
|
||||
ValidateBatchedCuts(adapter, num_bins, num_columns, num_rows, dmat.get());
|
||||
ValidateBatchedCuts(adapter, num_bins, dmat.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -481,7 +477,7 @@ TEST(HistUtil, AdapterDeviceSketchBatches) {
|
||||
auto dmat = GetDMatrixFromData(x, num_rows, num_columns);
|
||||
auto x_device = thrust::device_vector<float>(x);
|
||||
auto adapter = AdapterFromData(x_device, num_rows, num_columns);
|
||||
ValidateBatchedCuts(adapter, num_bins, num_columns, num_rows, dmat.get(), batch_size);
|
||||
ValidateBatchedCuts(adapter, num_bins, dmat.get(), batch_size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,7 +500,7 @@ TEST(HistUtil, SketchingEquivalent) {
|
||||
EXPECT_EQ(dmat_cuts.Ptrs(), adapter_cuts.Ptrs());
|
||||
EXPECT_EQ(dmat_cuts.MinValues(), adapter_cuts.MinValues());
|
||||
|
||||
ValidateBatchedCuts(adapter, num_bins, num_columns, num_rows, dmat.get());
|
||||
ValidateBatchedCuts(adapter, num_bins, dmat.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ GetDMatrixFromData(const std::vector<float> &x, int num_rows, int num_columns) {
|
||||
|
||||
inline std::shared_ptr<DMatrix> GetExternalMemoryDMatrixFromData(
|
||||
const std::vector<float>& x, int num_rows, int num_columns,
|
||||
size_t page_size, const dmlc::TemporaryDirectory& tempdir) {
|
||||
const dmlc::TemporaryDirectory& tempdir) {
|
||||
// Create the svm file in a temp dir
|
||||
const std::string tmp_file = tempdir.path + "/temp.libsvm";
|
||||
std::ofstream fo(tmp_file.c_str());
|
||||
@@ -92,10 +92,9 @@ inline std::shared_ptr<DMatrix> GetExternalMemoryDMatrixFromData(
|
||||
}
|
||||
|
||||
// Test that elements are approximately equally distributed among bins
|
||||
inline void TestBinDistribution(const HistogramCuts &cuts, int column_idx,
|
||||
const std::vector<float> &sorted_column,
|
||||
const std::vector<float> &sorted_weights,
|
||||
int num_bins) {
|
||||
inline void TestBinDistribution(const HistogramCuts& cuts, int column_idx,
|
||||
const std::vector<float>& sorted_column,
|
||||
const std::vector<float>& sorted_weights) {
|
||||
std::map<int, int> bin_weights;
|
||||
for (auto i = 0ull; i < sorted_column.size(); i++) {
|
||||
auto bin_idx = cuts.SearchBin(sorted_column[i], column_idx);
|
||||
@@ -175,7 +174,7 @@ inline void ValidateColumn(const HistogramCuts& cuts, int column_idx,
|
||||
std::copy(cuts.Values().begin() + cuts.Ptrs()[column_idx],
|
||||
cuts.Values().begin() + cuts.Ptrs()[column_idx + 1],
|
||||
column_cuts.begin());
|
||||
TestBinDistribution(cuts, column_idx, sorted_column, sorted_weights, num_bins);
|
||||
TestBinDistribution(cuts, column_idx, sorted_column, sorted_weights);
|
||||
TestRank(column_cuts, sorted_column, sorted_weights);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ TEST(GPUQuantile, Unique) {
|
||||
// if with_error is true, the test tolerates floating point error
|
||||
void TestQuantileElemRank(int32_t device, Span<SketchEntry const> in,
|
||||
Span<bst_row_t const> d_columns_ptr, bool with_error = false) {
|
||||
dh::safe_cuda(cudaSetDevice(device));
|
||||
std::vector<SketchEntry> h_in(in.size());
|
||||
dh::CopyDeviceSpanToVector(&h_in, in);
|
||||
std::vector<bst_row_t> h_columns_ptr(d_columns_ptr.size());
|
||||
@@ -478,7 +479,7 @@ TEST(GPUQuantile, SameOnAllWorkers) {
|
||||
dh::CopyDeviceSpanToVector(&h_base_line, base_line);
|
||||
|
||||
size_t offset = 0;
|
||||
for (size_t i = 0; i < world; ++i) {
|
||||
for (decltype(world) i = 0; i < world; ++i) {
|
||||
auto comp = dh::ToSpan(all_workers).subspan(offset, size_as_float);
|
||||
std::vector<float> h_comp(comp.size());
|
||||
dh::CopyDeviceSpanToVector(&h_comp, comp);
|
||||
|
||||
@@ -248,7 +248,7 @@ struct TestIterCompare {
|
||||
XGBOOST_DEVICE void operator()() {
|
||||
this->operator()(0);
|
||||
}
|
||||
XGBOOST_DEVICE void operator()(int _idx) {
|
||||
XGBOOST_DEVICE void operator()(size_t) { // size_t for CUDA index
|
||||
float arr[16];
|
||||
InitializeRange(arr, arr + 16);
|
||||
Span<float> s (arr);
|
||||
|
||||
@@ -12,9 +12,8 @@ TEST(CreateBlockedSpace2d, Test) {
|
||||
constexpr size_t kDim2 = 3;
|
||||
constexpr size_t kGrainSize = 1;
|
||||
|
||||
BlockedSpace2d space(kDim1, [&](size_t i) {
|
||||
return kDim2;
|
||||
}, kGrainSize);
|
||||
BlockedSpace2d space(
|
||||
kDim1, [&](size_t) { return kDim2; }, kGrainSize);
|
||||
|
||||
ASSERT_EQ(kDim1 * kDim2, space.Size());
|
||||
|
||||
|
||||
@@ -651,7 +651,7 @@ RMMAllocatorPtr SetUpRMMResourceForCppTests(int argc, char** argv) {
|
||||
#else // defined(XGBOOST_USE_RMM) && XGBOOST_USE_RMM == 1
|
||||
class RMMAllocator {};
|
||||
|
||||
void DeleteRMMResource(RMMAllocator* r) {}
|
||||
void DeleteRMMResource(RMMAllocator*) {}
|
||||
|
||||
RMMAllocatorPtr SetUpRMMResourceForCppTests(int, char**) { return {nullptr, DeleteRMMResource}; }
|
||||
#endif // !defined(XGBOOST_USE_RMM) || XGBOOST_USE_RMM != 1
|
||||
|
||||
@@ -56,7 +56,7 @@ TEST(GPUPredictor, Basic) {
|
||||
std::vector<float>& gpu_out_predictions_h = gpu_out_predictions.predictions.HostVector();
|
||||
std::vector<float>& cpu_out_predictions_h = cpu_out_predictions.predictions.HostVector();
|
||||
float abs_tolerance = 0.001;
|
||||
for (int j = 0; j < gpu_out_predictions.predictions.Size(); j++) {
|
||||
for (size_t j = 0; j < gpu_out_predictions.predictions.Size(); j++) {
|
||||
ASSERT_NEAR(gpu_out_predictions_h[j], cpu_out_predictions_h[j], abs_tolerance);
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ TEST(GPUPredictor, ExternalMemoryTest) {
|
||||
gpu_predictor->PredictBatch(dmat.get(), &out_predictions, model, 0);
|
||||
EXPECT_EQ(out_predictions.predictions.Size(), dmat->Info().num_row_ * n_classes);
|
||||
const std::vector<float> &host_vector = out_predictions.predictions.ConstHostVector();
|
||||
for (int i = 0; i < host_vector.size() / n_classes; i++) {
|
||||
for (size_t i = 0; i < host_vector.size() / n_classes; i++) {
|
||||
ASSERT_EQ(host_vector[i * n_classes], 2.0);
|
||||
ASSERT_EQ(host_vector[i * n_classes + 1], 0.5);
|
||||
ASSERT_EQ(host_vector[i * n_classes + 2], 0.5);
|
||||
|
||||
@@ -45,7 +45,7 @@ void TestTrainingPrediction(size_t rows, size_t bins,
|
||||
size_t constexpr kIters = 3;
|
||||
|
||||
std::unique_ptr<Learner> learner;
|
||||
auto train = [&](std::string predictor, HostDeviceVector<float> *out) {
|
||||
auto train = [&](std::string predictor) {
|
||||
p_hist->Info().labels.Reshape(rows, 1);
|
||||
auto &h_label = p_hist->Info().labels.Data()->HostVector();
|
||||
|
||||
@@ -59,6 +59,7 @@ void TestTrainingPrediction(size_t rows, size_t bins,
|
||||
learner->SetParam("num_feature", std::to_string(kCols));
|
||||
learner->SetParam("num_class", std::to_string(kClasses));
|
||||
learner->SetParam("max_bin", std::to_string(bins));
|
||||
learner->SetParam("predictor", predictor);
|
||||
learner->Configure();
|
||||
|
||||
for (size_t i = 0; i < kIters; ++i) {
|
||||
@@ -77,11 +78,11 @@ void TestTrainingPrediction(size_t rows, size_t bins,
|
||||
}
|
||||
};
|
||||
|
||||
HostDeviceVector<float> predictions_0;
|
||||
train("cpu_predictor", &predictions_0);
|
||||
|
||||
HostDeviceVector<float> predictions_1;
|
||||
train("gpu_predictor", &predictions_1);
|
||||
if (tree_method == "gpu_hist") {
|
||||
train("gpu_predictor");
|
||||
} else {
|
||||
train("cpu_predictor");
|
||||
}
|
||||
}
|
||||
|
||||
void TestInplacePrediction(std::shared_ptr<DMatrix> x, std::string predictor, bst_row_t rows,
|
||||
|
||||
@@ -143,7 +143,6 @@ void TestGPUHistogramCategorical(size_t num_categories) {
|
||||
|
||||
std::vector<GradientPairPrecise> h_cat_hist(cat_hist.size());
|
||||
thrust::copy(cat_hist.begin(), cat_hist.end(), h_cat_hist.begin());
|
||||
auto cat_sum = std::accumulate(h_cat_hist.begin(), h_cat_hist.end(), GradientPairPrecise{});
|
||||
|
||||
std::vector<GradientPairPrecise> h_encode_hist(encode_hist.size());
|
||||
thrust::copy(encode_hist.begin(), encode_hist.end(), h_encode_hist.begin());
|
||||
|
||||
@@ -119,7 +119,7 @@ void TestFinalise() {
|
||||
rp.FinalisePosition(
|
||||
&ctx, task, &position,
|
||||
[=] __device__(RowPartitioner::RowIndexT ridx, int position) { return 7; },
|
||||
[] XGBOOST_DEVICE(size_t idx) { return false; });
|
||||
[] XGBOOST_DEVICE(size_t) { return false; });
|
||||
|
||||
auto position = rp.GetPositionHost();
|
||||
for (auto p : position) {
|
||||
|
||||
@@ -181,8 +181,7 @@ void TestSyncHist(bool is_distributed) {
|
||||
starting_index, sync_count);
|
||||
} else {
|
||||
histogram.SyncHistogramLocal(&tree, nodes_for_explicit_hist_build_,
|
||||
nodes_for_subtraction_trick_, starting_index,
|
||||
sync_count);
|
||||
nodes_for_subtraction_trick_);
|
||||
}
|
||||
|
||||
using GHistRowT = common::GHistRow;
|
||||
|
||||
Reference in New Issue
Block a user