Fix compiler warnings. (#7974)
- Remove unused parameters. There are still many warnings that are not yet addressed. Currently, the warnings in dmlc-core dominate the error log. - Remove `distributed` parameter from metric. - Fixes some warnings about signed comparison.
This commit is contained in:
@@ -67,7 +67,7 @@ TEST(SegmentedUnique, Basic) {
|
||||
CHECK_EQ(n_uniques, 5);
|
||||
|
||||
std::vector<float> values_sol{0.1f, 0.2f, 0.3f, 0.62448811531066895f, 0.4f};
|
||||
for (auto i = 0 ; i < values_sol.size(); i ++) {
|
||||
for (size_t i = 0 ; i < values_sol.size(); i ++) {
|
||||
ASSERT_EQ(d_vals_out[i], values_sol[i]);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ TEST(SegmentedUnique, Basic) {
|
||||
d_segs_out.data().get(), d_vals_out.data().get(),
|
||||
thrust::equal_to<float>{});
|
||||
ASSERT_EQ(n_uniques, values.size());
|
||||
for (auto i = 0 ; i < values.size(); i ++) {
|
||||
for (size_t i = 0 ; i < values.size(); i ++) {
|
||||
ASSERT_EQ(d_vals_out[i], values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,10 +315,10 @@ TEST(Linalg, Popc) {
|
||||
TEST(Linalg, Stack) {
|
||||
Tensor<float, 3> l{{2, 3, 4}, kCpuId};
|
||||
ElementWiseTransformHost(l.View(kCpuId), omp_get_max_threads(),
|
||||
[=](size_t i, float v) { return i; });
|
||||
[=](size_t i, float) { return i; });
|
||||
Tensor<float, 3> r_0{{2, 3, 4}, kCpuId};
|
||||
ElementWiseTransformHost(r_0.View(kCpuId), omp_get_max_threads(),
|
||||
[=](size_t i, float v) { return i; });
|
||||
[=](size_t i, float) { return i; });
|
||||
|
||||
Stack(&l, r_0);
|
||||
|
||||
|
||||
@@ -50,8 +50,8 @@ TEST(PartitionBuilder, BasicTest) {
|
||||
right[i] = left_total + value_right++;
|
||||
}
|
||||
|
||||
builder.SetNLeftElems(nid, begin, end, n_left);
|
||||
builder.SetNRightElems(nid, begin, end, n_right);
|
||||
builder.SetNLeftElems(nid, begin, n_left);
|
||||
builder.SetNRightElems(nid, begin, n_right);
|
||||
}
|
||||
}
|
||||
builder.CalculateRowOffsets();
|
||||
|
||||
@@ -77,7 +77,7 @@ void TestDistributedQuantile(size_t rows, size_t cols) {
|
||||
std::vector<float> hessian(rows, 1.0);
|
||||
auto hess = Span<float const>{hessian};
|
||||
|
||||
ContainerType<use_column> sketch_distributed(n_bins, m->Info(), column_size, false, hess,
|
||||
ContainerType<use_column> sketch_distributed(n_bins, m->Info(), column_size, false,
|
||||
OmpGetNumThreads(0));
|
||||
|
||||
if (use_column) {
|
||||
@@ -98,7 +98,7 @@ void TestDistributedQuantile(size_t rows, size_t cols) {
|
||||
CHECK_EQ(rabit::GetWorldSize(), 1);
|
||||
std::for_each(column_size.begin(), column_size.end(), [=](auto& size) { size *= world; });
|
||||
m->Info().num_row_ = world * rows;
|
||||
ContainerType<use_column> sketch_on_single_node(n_bins, m->Info(), column_size, false, hess,
|
||||
ContainerType<use_column> sketch_on_single_node(n_bins, m->Info(), column_size, false,
|
||||
OmpGetNumThreads(0));
|
||||
m->Info().num_row_ = rows;
|
||||
|
||||
@@ -190,7 +190,7 @@ TEST(Quantile, SameOnAllWorkers) {
|
||||
|
||||
constexpr size_t kRows = 1000, kCols = 100;
|
||||
RunWithSeedsAndBins(
|
||||
kRows, [=](int32_t seed, size_t n_bins, MetaInfo const &info) {
|
||||
kRows, [=](int32_t seed, size_t n_bins, MetaInfo const&) {
|
||||
auto rank = rabit::GetRank();
|
||||
HostDeviceVector<float> storage;
|
||||
std::vector<FeatureType> ft(kCols);
|
||||
|
||||
@@ -36,7 +36,7 @@ struct TestTestStatus {
|
||||
XGBOOST_DEVICE void operator()() {
|
||||
this->operator()(0);
|
||||
}
|
||||
XGBOOST_DEVICE void operator()(int _idx) {
|
||||
XGBOOST_DEVICE void operator()(size_t) { // size_t for CUDA index
|
||||
SPAN_ASSERT_TRUE(false, status_);
|
||||
}
|
||||
};
|
||||
@@ -49,7 +49,7 @@ struct TestAssignment {
|
||||
XGBOOST_DEVICE void operator()() {
|
||||
this->operator()(0);
|
||||
}
|
||||
XGBOOST_DEVICE void operator()(int _idx) {
|
||||
XGBOOST_DEVICE void operator()(size_t) { // size_t for CUDA index
|
||||
Span<float> s1;
|
||||
|
||||
float arr[] = {3, 4, 5};
|
||||
@@ -71,7 +71,7 @@ struct TestBeginEnd {
|
||||
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);
|
||||
|
||||
@@ -93,7 +93,7 @@ struct TestRBeginREnd {
|
||||
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);
|
||||
|
||||
@@ -121,7 +121,7 @@ struct TestObservers {
|
||||
XGBOOST_DEVICE void operator()() {
|
||||
this->operator()(0);
|
||||
}
|
||||
XGBOOST_DEVICE void operator()(int _idx) {
|
||||
XGBOOST_DEVICE void operator()(size_t) { // size_t for CUDA index
|
||||
// empty
|
||||
{
|
||||
float *arr = nullptr;
|
||||
@@ -148,7 +148,7 @@ struct TestCompare {
|
||||
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 lhs_arr[16], rhs_arr[16];
|
||||
InitializeRange(lhs_arr, lhs_arr + 16);
|
||||
InitializeRange(rhs_arr, rhs_arr + 16);
|
||||
@@ -178,7 +178,7 @@ struct TestIterConstruct {
|
||||
XGBOOST_DEVICE void operator()() {
|
||||
this->operator()(0);
|
||||
}
|
||||
XGBOOST_DEVICE void operator()(int _idx) {
|
||||
XGBOOST_DEVICE void operator()(size_t) { // size_t for CUDA index.
|
||||
Span<float>::iterator it1;
|
||||
Span<float>::iterator it2;
|
||||
SPAN_ASSERT_TRUE(it1 == it2, status_);
|
||||
@@ -197,7 +197,7 @@ struct TestIterRef {
|
||||
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);
|
||||
|
||||
@@ -215,7 +215,7 @@ struct TestIterCalculate {
|
||||
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);
|
||||
|
||||
@@ -278,7 +278,7 @@ struct TestAsBytes {
|
||||
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);
|
||||
|
||||
@@ -313,7 +313,7 @@ struct TestAsWritableBytes {
|
||||
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);
|
||||
|
||||
|
||||
@@ -34,9 +34,8 @@ TEST(ParallelFor2d, Test) {
|
||||
|
||||
// working space is matrix of size (kDim1 x kDim2)
|
||||
std::vector<int> matrix(kDim1 * kDim2, 0);
|
||||
BlockedSpace2d space(kDim1, [&](size_t i) {
|
||||
return kDim2;
|
||||
}, kGrainSize);
|
||||
BlockedSpace2d space(
|
||||
kDim1, [&](size_t) { return kDim2; }, kGrainSize);
|
||||
|
||||
auto old = omp_get_max_threads();
|
||||
omp_set_num_threads(4);
|
||||
|
||||
@@ -167,7 +167,7 @@ double GetMultiMetricEval(xgboost::Metric* metric,
|
||||
info.weights_.HostVector() = weights;
|
||||
info.group_ptr_ = groups;
|
||||
|
||||
return metric->Eval(preds, info, false);
|
||||
return metric->Eval(preds, info);
|
||||
}
|
||||
|
||||
namespace xgboost {
|
||||
@@ -653,8 +653,6 @@ class RMMAllocator {};
|
||||
|
||||
void DeleteRMMResource(RMMAllocator* r) {}
|
||||
|
||||
RMMAllocatorPtr SetUpRMMResourceForCppTests(int argc, char** argv) {
|
||||
return {nullptr, DeleteRMMResource};
|
||||
}
|
||||
RMMAllocatorPtr SetUpRMMResourceForCppTests(int, char**) { return {nullptr, DeleteRMMResource}; }
|
||||
#endif // !defined(XGBOOST_USE_RMM) || XGBOOST_USE_RMM != 1
|
||||
} // namespace xgboost
|
||||
|
||||
@@ -29,9 +29,7 @@ int CudaArrayIterForTest::Next() {
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<DMatrix> RandomDataGenerator::GenerateDeviceDMatrix(bool with_label,
|
||||
bool float_label,
|
||||
size_t classes) {
|
||||
std::shared_ptr<DMatrix> RandomDataGenerator::GenerateDeviceDMatrix() {
|
||||
CudaArrayIterForTest iter{this->sparsity_, this->rows_, this->cols_, 1};
|
||||
auto m = std::make_shared<data::IterativeDeviceDMatrix>(
|
||||
&iter, iter.Proxy(), Reset, Next, std::numeric_limits<float>::quiet_NaN(),
|
||||
|
||||
@@ -296,9 +296,7 @@ class RandomDataGenerator {
|
||||
bool float_label = true,
|
||||
size_t classes = 1) const;
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
std::shared_ptr<DMatrix> GenerateDeviceDMatrix(bool with_label = false,
|
||||
bool float_label = true,
|
||||
size_t classes = 1);
|
||||
std::shared_ptr<DMatrix> GenerateDeviceDMatrix();
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ TEST(Metric, DeclareUnifiedTest(BinaryAUC)) {
|
||||
// Invalid dataset
|
||||
MetaInfo info;
|
||||
info.labels = linalg::Tensor<float, 2>{{0.0f, 0.0f}, {2}, -1};
|
||||
float auc = metric->Eval({1, 1}, info, false);
|
||||
float auc = metric->Eval({1, 1}, info);
|
||||
ASSERT_TRUE(std::isnan(auc));
|
||||
*info.labels.Data() = HostDeviceVector<float>{};
|
||||
auc = metric->Eval(HostDeviceVector<float>{}, info, false);
|
||||
auc = metric->Eval(HostDeviceVector<float>{}, info);
|
||||
ASSERT_TRUE(std::isnan(auc));
|
||||
|
||||
EXPECT_NEAR(GetMetricEval(metric, {0, 1, 0, 1}, {0, 1, 0, 1}), 1.0f, 1e-10);
|
||||
|
||||
@@ -36,9 +36,9 @@ inline void CheckDeterministicMetricElementWise(StringView name, int32_t device)
|
||||
h_labels[i] = dist(&lcg);
|
||||
}
|
||||
|
||||
auto result = metric->Eval(predts, info, false);
|
||||
auto result = metric->Eval(predts, info);
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
ASSERT_EQ(metric->Eval(predts, info, false), result);
|
||||
ASSERT_EQ(metric->Eval(predts, info), result);
|
||||
}
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
@@ -35,9 +35,9 @@ inline void CheckDeterministicMetricMultiClass(StringView name, int32_t device)
|
||||
}
|
||||
}
|
||||
|
||||
auto result = metric->Eval(predts, info, false);
|
||||
auto result = metric->Eval(predts, info);
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
ASSERT_EQ(metric->Eval(predts, info, false), result);
|
||||
ASSERT_EQ(metric->Eval(predts, info), result);
|
||||
}
|
||||
}
|
||||
} // namespace xgboost
|
||||
|
||||
@@ -40,9 +40,9 @@ inline void CheckDeterministicMetricElementWise(StringView name, int32_t device)
|
||||
h_upper[i] = 10;
|
||||
}
|
||||
|
||||
auto result = metric->Eval(predts, info, false);
|
||||
auto result = metric->Eval(predts, info);
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
ASSERT_EQ(metric->Eval(predts, info, false), result);
|
||||
ASSERT_EQ(metric->Eval(predts, info), result);
|
||||
}
|
||||
}
|
||||
} // anonymous namespace
|
||||
@@ -72,7 +72,7 @@ TEST(Metric, DeclareUnifiedTest(AFTNegLogLik)) {
|
||||
std::unique_ptr<Metric> metric(Metric::Create("aft-nloglik", &lparam));
|
||||
metric->Configure({ {"aft_loss_distribution", test_case.dist_type},
|
||||
{"aft_loss_distribution_scale", "1.0"} });
|
||||
EXPECT_NEAR(metric->Eval(preds, info, false), test_case.reference_value, 1e-4);
|
||||
EXPECT_NEAR(metric->Eval(preds, info), test_case.reference_value, 1e-4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,15 +87,15 @@ TEST(Metric, DeclareUnifiedTest(IntervalRegressionAccuracy)) {
|
||||
HostDeviceVector<bst_float> preds(4, std::log(60.0f));
|
||||
|
||||
std::unique_ptr<Metric> metric(Metric::Create("interval-regression-accuracy", &lparam));
|
||||
EXPECT_FLOAT_EQ(metric->Eval(preds, info, false), 0.75f);
|
||||
EXPECT_FLOAT_EQ(metric->Eval(preds, info), 0.75f);
|
||||
info.labels_lower_bound_.HostVector()[2] = 70.0f;
|
||||
EXPECT_FLOAT_EQ(metric->Eval(preds, info, false), 0.50f);
|
||||
EXPECT_FLOAT_EQ(metric->Eval(preds, info), 0.50f);
|
||||
info.labels_upper_bound_.HostVector()[2] = std::numeric_limits<bst_float>::infinity();
|
||||
EXPECT_FLOAT_EQ(metric->Eval(preds, info, false), 0.50f);
|
||||
EXPECT_FLOAT_EQ(metric->Eval(preds, info), 0.50f);
|
||||
info.labels_upper_bound_.HostVector()[3] = std::numeric_limits<bst_float>::infinity();
|
||||
EXPECT_FLOAT_EQ(metric->Eval(preds, info, false), 0.50f);
|
||||
EXPECT_FLOAT_EQ(metric->Eval(preds, info), 0.50f);
|
||||
info.labels_lower_bound_.HostVector()[0] = 70.0f;
|
||||
EXPECT_FLOAT_EQ(metric->Eval(preds, info, false), 0.25f);
|
||||
EXPECT_FLOAT_EQ(metric->Eval(preds, info), 0.25f);
|
||||
|
||||
CheckDeterministicMetricElementWise(StringView{"interval-regression-accuracy"}, GPUIDX);
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ TEST(Objective, NDCGLambdaWeightComputerTest) {
|
||||
EXPECT_EQ(hgroup_dcgs.size(), segment_label_sorter->GetNumGroups());
|
||||
std::vector<float> hsorted_labels(segment_label_sorter->GetNumItems());
|
||||
dh::CopyDeviceSpanToVector(&hsorted_labels, segment_label_sorter->GetItemsSpan());
|
||||
for (auto i = 0; i < hgroup_dcgs.size(); ++i) {
|
||||
for (size_t i = 0; i < hgroup_dcgs.size(); ++i) {
|
||||
// Compute group DCG value on CPU and compare
|
||||
auto gbegin = hgroups[i];
|
||||
auto gend = hgroups[i + 1];
|
||||
@@ -244,7 +244,7 @@ TEST(Objective, ComputeAndCompareMAPStatsTest) {
|
||||
std::vector<uint32_t> hgroups(segment_label_sorter->GetNumGroups() + 1);
|
||||
dh::CopyDeviceSpanToVector(&hgroups, segment_label_sorter->GetGroupsSpan());
|
||||
|
||||
for (auto i = 0; i < hgroups.size() - 1; ++i) {
|
||||
for (size_t i = 0; i < hgroups.size() - 1; ++i) {
|
||||
auto gbegin = hgroups[i];
|
||||
auto gend = hgroups[i + 1];
|
||||
std::vector<xgboost::obj::ListEntry> lst_entry;
|
||||
|
||||
@@ -66,10 +66,7 @@ TEST(GPUPredictor, EllpackBasic) {
|
||||
size_t constexpr kCols {8};
|
||||
for (size_t bins = 2; bins < 258; bins += 16) {
|
||||
size_t rows = bins * 16;
|
||||
auto p_m = RandomDataGenerator{rows, kCols, 0.0}
|
||||
.Bins(bins)
|
||||
.Device(0)
|
||||
.GenerateDeviceDMatrix(true);
|
||||
auto p_m = RandomDataGenerator{rows, kCols, 0.0}.Bins(bins).Device(0).GenerateDeviceDMatrix();
|
||||
ASSERT_FALSE(p_m->PageExists<SparsePage>());
|
||||
TestPredictionFromGradientIndex<EllpackPage>("gpu_predictor", rows, kCols, p_m);
|
||||
TestPredictionFromGradientIndex<EllpackPage>("gpu_predictor", bins, kCols, p_m);
|
||||
@@ -78,10 +75,8 @@ TEST(GPUPredictor, EllpackBasic) {
|
||||
|
||||
TEST(GPUPredictor, EllpackTraining) {
|
||||
size_t constexpr kRows { 128 }, kCols { 16 }, kBins { 64 };
|
||||
auto p_ellpack = RandomDataGenerator{kRows, kCols, 0.0}
|
||||
.Bins(kBins)
|
||||
.Device(0)
|
||||
.GenerateDeviceDMatrix(true);
|
||||
auto p_ellpack =
|
||||
RandomDataGenerator{kRows, kCols, 0.0}.Bins(kBins).Device(0).GenerateDeviceDMatrix();
|
||||
HostDeviceVector<float> storage(kRows * kCols);
|
||||
auto columnar = RandomDataGenerator{kRows, kCols, 0.0}
|
||||
.Device(0)
|
||||
|
||||
@@ -94,8 +94,8 @@ TEST(GPUFeatureInteractionConstraint, Init) {
|
||||
tree::TrainParam param = GetParameter();
|
||||
param.interaction_constraints = R"([[0, 1, 3], [3, 5, 6]])";
|
||||
FConstraintWrapper constraints(param, kFeatures);
|
||||
std::vector<int32_t> h_sets {0, 0, 0, 1, 1, 1};
|
||||
std::vector<int32_t> h_sets_ptr {0, 1, 2, 2, 4, 4, 5, 6};
|
||||
std::vector<bst_feature_t> h_sets {0, 0, 0, 1, 1, 1};
|
||||
std::vector<size_t> h_sets_ptr {0, 1, 2, 2, 4, 4, 5, 6};
|
||||
auto d_sets = constraints.GetDSets();
|
||||
ASSERT_EQ(h_sets.size(), d_sets.size());
|
||||
auto d_sets_ptr = constraints.GetDSetsPtr();
|
||||
|
||||
@@ -242,7 +242,7 @@ void TestHistogramIndexImpl() {
|
||||
int constexpr kNRows = 1000, kNCols = 10;
|
||||
|
||||
// Build 2 matrices and build a histogram maker with that
|
||||
|
||||
|
||||
GenericParameter generic_param(CreateEmptyGenericParam(0));
|
||||
tree::GPUHistMaker hist_maker{&generic_param,ObjInfo{ObjInfo::kRegression}},
|
||||
hist_maker_ext{&generic_param,ObjInfo{ObjInfo::kRegression}};
|
||||
@@ -346,7 +346,7 @@ TEST(GpuHist, UniformSampling) {
|
||||
// Make sure the predictions are the same.
|
||||
auto preds_h = preds.ConstHostVector();
|
||||
auto preds_sampling_h = preds_sampling.ConstHostVector();
|
||||
for (int i = 0; i < kRows; i++) {
|
||||
for (size_t i = 0; i < kRows; i++) {
|
||||
EXPECT_NEAR(preds_h[i], preds_sampling_h[i], 1e-8);
|
||||
}
|
||||
}
|
||||
@@ -376,7 +376,7 @@ TEST(GpuHist, GradientBasedSampling) {
|
||||
// Make sure the predictions are the same.
|
||||
auto preds_h = preds.ConstHostVector();
|
||||
auto preds_sampling_h = preds_sampling.ConstHostVector();
|
||||
for (int i = 0; i < kRows; i++) {
|
||||
for (size_t i = 0; i < kRows; i++) {
|
||||
EXPECT_NEAR(preds_h[i], preds_sampling_h[i], 1e-3);
|
||||
}
|
||||
}
|
||||
@@ -409,7 +409,7 @@ TEST(GpuHist, ExternalMemory) {
|
||||
// Make sure the predictions are the same.
|
||||
auto preds_h = preds.ConstHostVector();
|
||||
auto preds_ext_h = preds_ext.ConstHostVector();
|
||||
for (int i = 0; i < kRows; i++) {
|
||||
for (size_t i = 0; i < kRows; i++) {
|
||||
EXPECT_NEAR(preds_h[i], preds_ext_h[i], 1e-6);
|
||||
}
|
||||
}
|
||||
@@ -451,7 +451,7 @@ TEST(GpuHist, ExternalMemoryWithSampling) {
|
||||
// Make sure the predictions are the same.
|
||||
auto preds_h = preds.ConstHostVector();
|
||||
auto preds_ext_h = preds_ext.ConstHostVector();
|
||||
for (int i = 0; i < kRows; i++) {
|
||||
for (size_t i = 0; i < kRows; i++) {
|
||||
ASSERT_NEAR(preds_h[i], preds_ext_h[i], 1e-3);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user