Skip to content

Commit 4dfbe2a

Browse files
hcho3trivialfis
andauthored
[CI] Test building for 32-bit arch (dmlc#10021)
* [CI] Test building for 32-bit arch * Update CMakeLists.txt * Fix yaml * Use Debian container * Remove -Werror for 32-bit * Revert "Remove -Werror for 32-bit" This reverts commit c652bc6. * Don't error for overloaded-virtual warning * Ignore some warnings from dmlc-core * Fix compiler warnings * Fix formatting * Apply suggestions from code review Co-authored-by: Jiaming Yuan <jm.yuan@outlook.com> * Add more cast --------- Co-authored-by: Jiaming Yuan <jm.yuan@outlook.com>
1 parent 234674a commit 4dfbe2a

File tree

14 files changed

+84
-35
lines changed

14 files changed

+84
-35
lines changed

.github/workflows/i386.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: XGBoost-i386-test
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read # to fetch code (actions/checkout)
7+
8+
jobs:
9+
build-32bit:
10+
name: Build 32-bit
11+
runs-on: ubuntu-latest
12+
services:
13+
registry:
14+
image: registry:2
15+
ports:
16+
- 5000:5000
17+
steps:
18+
- uses: actions/checkout@v2.5.0
19+
with:
20+
submodules: 'true'
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
with:
24+
driver-opts: network=host
25+
- name: Build and push container
26+
uses: docker/build-push-action@v5
27+
with:
28+
context: .
29+
file: tests/ci_build/Dockerfile.i386
30+
push: true
31+
tags: localhost:5000/xgboost/build-32bit:latest
32+
cache-from: type=gha
33+
cache-to: type=gha,mode=max
34+
- name: Build XGBoost
35+
run: |
36+
docker run --rm -v $PWD:/workspace -w /workspace \
37+
-e CXXFLAGS='-Wno-error=overloaded-virtual -Wno-error=maybe-uninitialized -Wno-error=redundant-move' \
38+
localhost:5000/xgboost/build-32bit:latest \
39+
tests/ci_build/build_via_cmake.sh

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
3939
message(FATAL_ERROR "Need Clang 9.0 or newer to build XGBoost")
4040
endif()
4141
endif()
42-
if(CMAKE_SIZE_OF_VOID_P EQUAL 4)
43-
message(FATAL_ERROR "XGBoost does not support 32-bit archs. Please use 64-bit arch instead.")
44-
endif()
4542

4643
include(${xgboost_SOURCE_DIR}/cmake/PrefetchIntrinsics.cmake)
4744
find_prefetch_intrinsics()

src/c_api/c_api.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2014-2023 by XGBoost Contributors
2+
* Copyright 2014-2024 by XGBoost Contributors
33
*/
44
#include "xgboost/c_api.h"
55

@@ -991,8 +991,8 @@ XGB_DLL int XGBoosterBoostOneIter(BoosterHandle handle, DMatrixHandle dtrain, bs
991991
auto *learner = static_cast<Learner *>(handle);
992992
auto ctx = learner->Ctx()->MakeCPU();
993993

994-
auto t_grad = linalg::MakeTensorView(&ctx, common::Span{grad, len}, len);
995-
auto t_hess = linalg::MakeTensorView(&ctx, common::Span{hess, len}, len);
994+
auto t_grad = linalg::MakeTensorView(&ctx, common::Span{grad, static_cast<size_t>(len)}, len);
995+
auto t_hess = linalg::MakeTensorView(&ctx, common::Span{hess, static_cast<size_t>(len)}, len);
996996

997997
auto s_grad = linalg::ArrayInterfaceStr(t_grad);
998998
auto s_hess = linalg::ArrayInterfaceStr(t_hess);

src/common/column_matrix.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2017-2023, XGBoost Contributors
2+
* Copyright 2017-2024, XGBoost Contributors
33
* \file column_matrix.h
44
* \brief Utility for fast column-wise access
55
* \author Philip Cho
@@ -176,7 +176,7 @@ class ColumnMatrix {
176176
void SetValid(typename LBitField32::index_type i) { missing.Clear(i); }
177177
/** @brief assign the storage to the view. */
178178
void InitView() {
179-
missing = LBitField32{Span{storage.data(), storage.size()}};
179+
missing = LBitField32{Span{storage.data(), static_cast<size_t>(storage.size())}};
180180
}
181181

182182
void GrowTo(std::size_t n_elements, bool init) {
@@ -318,8 +318,8 @@ class ColumnMatrix {
318318
common::Span<const BinIdxType> bin_index = {
319319
reinterpret_cast<const BinIdxType*>(&index_[feature_offset * bins_type_size_]),
320320
column_size};
321-
return std::move(DenseColumnIter<BinIdxType, any_missing>{
322-
bin_index, static_cast<bst_bin_t>(index_base_[fidx]), missing_.missing, feature_offset});
321+
return DenseColumnIter<BinIdxType, any_missing>{
322+
bin_index, static_cast<bst_bin_t>(index_base_[fidx]), missing_.missing, feature_offset};
323323
}
324324

325325
// all columns are dense column and has no missing value
@@ -332,7 +332,7 @@ class ColumnMatrix {
332332
DispatchBinType(bins_type_size_, [&](auto t) {
333333
using ColumnBinT = decltype(t);
334334
auto column_index = Span<ColumnBinT>{reinterpret_cast<ColumnBinT*>(index_.data()),
335-
index_.size() / sizeof(ColumnBinT)};
335+
static_cast<size_t>(index_.size() / sizeof(ColumnBinT))};
336336
ParallelFor(n_samples, n_threads, [&](auto rid) {
337337
rid += base_rowid;
338338
const size_t ibegin = rid * n_features;

src/common/hist_util.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2017-2023 by XGBoost Contributors
2+
* Copyright 2017-2024 by XGBoost Contributors
33
* \file hist_util.h
44
* \brief Utility for fast histogram aggregation
55
* \author Philip Cho, Tianqi Chen
@@ -113,8 +113,8 @@ class HistogramCuts {
113113
auto end = ptrs[column_id + 1];
114114
auto beg = ptrs[column_id];
115115
auto it = std::upper_bound(values.cbegin() + beg, values.cbegin() + end, value);
116-
auto idx = it - values.cbegin();
117-
idx -= !!(idx == end);
116+
auto idx = static_cast<bst_bin_t>(it - values.cbegin());
117+
idx -= !!(idx == static_cast<bst_bin_t>(end));
118118
return idx;
119119
}
120120

@@ -136,8 +136,8 @@ class HistogramCuts {
136136
auto beg = ptrs[fidx] + vals.cbegin();
137137
// Truncates the value in case it's not perfectly rounded.
138138
auto v = static_cast<float>(common::AsCat(value));
139-
auto bin_idx = std::lower_bound(beg, end, v) - vals.cbegin();
140-
if (bin_idx == ptrs.at(fidx + 1)) {
139+
auto bin_idx = static_cast<bst_bin_t>(std::lower_bound(beg, end, v) - vals.cbegin());
140+
if (bin_idx == static_cast<bst_bin_t>(ptrs.at(fidx + 1))) {
141141
bin_idx -= 1;
142142
}
143143
return bin_idx;

src/common/ref_resource_view.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2023, XGBoost Contributors
2+
* Copyright 2023-2024, XGBoost Contributors
33
*/
44
#ifndef XGBOOST_COMMON_REF_RESOURCE_VIEW_H_
55
#define XGBOOST_COMMON_REF_RESOURCE_VIEW_H_
@@ -76,7 +76,7 @@ class RefResourceView {
7676

7777
[[nodiscard]] size_type size() const { return size_; } // NOLINT
7878
[[nodiscard]] size_type size_bytes() const { // NOLINT
79-
return Span<const value_type>{data(), size()}.size_bytes();
79+
return Span<const value_type>{data(), static_cast<size_t>(size())}.size_bytes();
8080
}
8181
[[nodiscard]] value_type* data() { return ptr_; }; // NOLINT
8282
[[nodiscard]] value_type const* data() const { return ptr_; }; // NOLINT

src/data/gradient_index.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2017-2023, XGBoost Contributors
2+
* Copyright 2017-2024, XGBoost Contributors
33
* \brief Data type for fast histogram aggregation.
44
*/
55
#include "gradient_index.h"
@@ -148,7 +148,8 @@ void GHistIndexMatrix::ResizeIndex(const size_t n_index, const bool isDense) {
148148
new_vec = {new_ptr, n_bytes / sizeof(std::uint8_t), malloc_resource};
149149
}
150150
this->data = std::move(new_vec);
151-
this->index = common::Index{common::Span{data.data(), data.size()}, t_size};
151+
this->index = common::Index{common::Span{data.data(), static_cast<size_t>(data.size())},
152+
t_size};
152153
};
153154

154155
if ((MaxNumBinPerFeat() - 1 <= static_cast<int>(std::numeric_limits<uint8_t>::max())) &&

src/data/gradient_index_format.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2021-2023 XGBoost contributors
2+
* Copyright 2021-2024 XGBoost contributors
33
*/
44
#include <cstddef> // for size_t
55
#include <cstdint> // for uint8_t
@@ -40,7 +40,9 @@ class GHistIndexRawFormat : public SparsePageFormat<GHistIndexMatrix> {
4040
return false;
4141
}
4242
// - index
43-
page->index = common::Index{common::Span{page->data.data(), page->data.size()}, size_type};
43+
page->index =
44+
common::Index{common::Span{page->data.data(), static_cast<size_t>(page->data.size())},
45+
size_type};
4446

4547
// hit count
4648
if (!common::ReadVec(fi, &page->hit_count)) {

src/predictor/predictor.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2017-2023 by Contributors
2+
* Copyright 2017-2024 by Contributors
33
*/
44
#include "xgboost/predictor.h"
55

@@ -46,7 +46,7 @@ void ValidateBaseMarginShape(linalg::Tensor<float, D> const& margin, bst_row_t n
4646
void Predictor::InitOutPredictions(const MetaInfo& info, HostDeviceVector<bst_float>* out_preds,
4747
const gbm::GBTreeModel& model) const {
4848
CHECK_NE(model.learner_model_param->num_output_group, 0);
49-
std::size_t n{model.learner_model_param->OutputLength() * info.num_row_};
49+
auto n = static_cast<size_t>(model.learner_model_param->OutputLength() * info.num_row_);
5050

5151
const HostDeviceVector<bst_float>* base_margin = info.base_margin_.Data();
5252
if (ctx_->Device().IsCUDA()) {

src/tree/hist/hist_cache.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2023 by XGBoost Contributors
2+
* Copyright 2023-2024 by XGBoost Contributors
33
*/
44
#ifndef XGBOOST_TREE_HIST_HIST_CACHE_H_
55
#define XGBOOST_TREE_HIST_HIST_CACHE_H_
@@ -48,11 +48,13 @@ class BoundedHistCollection {
4848
BoundedHistCollection() = default;
4949
common::GHistRow operator[](std::size_t idx) {
5050
auto offset = node_map_.at(idx);
51-
return common::Span{data_->data(), data_->size()}.subspan(offset, n_total_bins_);
51+
return common::Span{data_->data(), static_cast<size_t>(data_->size())}.subspan(
52+
offset, n_total_bins_);
5253
}
5354
common::ConstGHistRow operator[](std::size_t idx) const {
5455
auto offset = node_map_.at(idx);
55-
return common::Span{data_->data(), data_->size()}.subspan(offset, n_total_bins_);
56+
return common::Span{data_->data(), static_cast<size_t>(data_->size())}.subspan(
57+
offset, n_total_bins_);
5658
}
5759
void Reset(bst_bin_t n_total_bins, std::size_t n_cached_nodes) {
5860
n_total_bins_ = n_total_bins;

0 commit comments

Comments
 (0)