Fix compiler warnings. (#8703)
Fix warnings about signed/unsigned comparisons.
This commit is contained in:
parent
e49e0998c0
commit
34eee56256
@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* Copyright by XGBoost Contributors 2017-2022
|
||||
/**
|
||||
* Copyright 2017-2023 by XGBoost Contributors
|
||||
*/
|
||||
#include <dmlc/any.h>
|
||||
#include <dmlc/omp.h>
|
||||
@ -326,13 +326,13 @@ class ColumnSplitHelper {
|
||||
auto const n_trees = tree_end_ - tree_begin_;
|
||||
tree_sizes_.resize(n_trees);
|
||||
tree_offsets_.resize(n_trees);
|
||||
for (auto i = 0; i < n_trees; i++) {
|
||||
for (decltype(tree_begin) i = 0; i < n_trees; i++) {
|
||||
auto const &tree = *model_.trees[tree_begin_ + i];
|
||||
tree_sizes_[i] = tree.GetNodes().size();
|
||||
}
|
||||
// std::exclusive_scan (only available in c++17) equivalent to get tree offsets.
|
||||
tree_offsets_[0] = 0;
|
||||
for (auto i = 1; i < n_trees; i++) {
|
||||
for (decltype(tree_begin) i = 1; i < n_trees; i++) {
|
||||
tree_offsets_[i] = tree_offsets_[i - 1] + tree_sizes_[i - 1];
|
||||
}
|
||||
bits_per_row_ = tree_offsets_.back() + tree_sizes_.back();
|
||||
@ -390,8 +390,9 @@ class ColumnSplitHelper {
|
||||
auto const &tree = *model_.trees[tree_id];
|
||||
auto const &cats = tree.GetCategoriesMatrix();
|
||||
auto const has_categorical = tree.HasCategoricalSplit();
|
||||
bst_node_t n_nodes = tree.GetNodes().size();
|
||||
|
||||
for (auto nid = 0; nid < tree.GetNodes().size(); nid++) {
|
||||
for (bst_node_t nid = 0; nid < n_nodes; nid++) {
|
||||
auto const &node = tree[nid];
|
||||
if (node.IsDeleted() || node.IsLeaf()) {
|
||||
continue;
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*!
|
||||
* Copyright 2017-2022 XGBoost contributors
|
||||
/**
|
||||
* Copyright 2017-2023 by XGBoost contributors
|
||||
*/
|
||||
#include <gtest/gtest.h>
|
||||
#include <xgboost/predictor.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <thread>
|
||||
|
||||
#include "../../../src/collective/communicator-inl.h"
|
||||
@ -95,7 +96,7 @@ TEST(CpuPredictor, ColumnSplit) {
|
||||
auto dmat = RandomDataGenerator(kRows, kCols, 0).GenerateDMatrix();
|
||||
|
||||
std::vector<std::thread> threads;
|
||||
size_t constexpr kWorldSize = 2;
|
||||
std::int32_t constexpr kWorldSize = 2;
|
||||
size_t constexpr kSliceSize = (kCols + 1) / kWorldSize;
|
||||
for (auto rank = 0; rank < kWorldSize; rank++) {
|
||||
threads.emplace_back([=, &dmat]() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user