[CI] Test building for 32-bit arch (#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 c652bc6a037361bcceaf56fb01863210b462793d. * 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>
This commit is contained in:
parent
234674a0a6
commit
4dfbe2a893
39
.github/workflows/i386.yml
vendored
Normal file
39
.github/workflows/i386.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
name: XGBoost-i386-test
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read # to fetch code (actions/checkout)
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-32bit:
|
||||||
|
name: Build 32-bit
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
registry:
|
||||||
|
image: registry:2
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2.5.0
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
driver-opts: network=host
|
||||||
|
- name: Build and push container
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: tests/ci_build/Dockerfile.i386
|
||||||
|
push: true
|
||||||
|
tags: localhost:5000/xgboost/build-32bit:latest
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
- name: Build XGBoost
|
||||||
|
run: |
|
||||||
|
docker run --rm -v $PWD:/workspace -w /workspace \
|
||||||
|
-e CXXFLAGS='-Wno-error=overloaded-virtual -Wno-error=maybe-uninitialized -Wno-error=redundant-move' \
|
||||||
|
localhost:5000/xgboost/build-32bit:latest \
|
||||||
|
tests/ci_build/build_via_cmake.sh
|
||||||
@ -39,9 +39,6 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|||||||
message(FATAL_ERROR "Need Clang 9.0 or newer to build XGBoost")
|
message(FATAL_ERROR "Need Clang 9.0 or newer to build XGBoost")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(CMAKE_SIZE_OF_VOID_P EQUAL 4)
|
|
||||||
message(FATAL_ERROR "XGBoost does not support 32-bit archs. Please use 64-bit arch instead.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(${xgboost_SOURCE_DIR}/cmake/PrefetchIntrinsics.cmake)
|
include(${xgboost_SOURCE_DIR}/cmake/PrefetchIntrinsics.cmake)
|
||||||
find_prefetch_intrinsics()
|
find_prefetch_intrinsics()
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2014-2023 by XGBoost Contributors
|
* Copyright 2014-2024 by XGBoost Contributors
|
||||||
*/
|
*/
|
||||||
#include "xgboost/c_api.h"
|
#include "xgboost/c_api.h"
|
||||||
|
|
||||||
@ -991,8 +991,8 @@ XGB_DLL int XGBoosterBoostOneIter(BoosterHandle handle, DMatrixHandle dtrain, bs
|
|||||||
auto *learner = static_cast<Learner *>(handle);
|
auto *learner = static_cast<Learner *>(handle);
|
||||||
auto ctx = learner->Ctx()->MakeCPU();
|
auto ctx = learner->Ctx()->MakeCPU();
|
||||||
|
|
||||||
auto t_grad = linalg::MakeTensorView(&ctx, common::Span{grad, len}, len);
|
auto t_grad = linalg::MakeTensorView(&ctx, common::Span{grad, static_cast<size_t>(len)}, len);
|
||||||
auto t_hess = linalg::MakeTensorView(&ctx, common::Span{hess, len}, len);
|
auto t_hess = linalg::MakeTensorView(&ctx, common::Span{hess, static_cast<size_t>(len)}, len);
|
||||||
|
|
||||||
auto s_grad = linalg::ArrayInterfaceStr(t_grad);
|
auto s_grad = linalg::ArrayInterfaceStr(t_grad);
|
||||||
auto s_hess = linalg::ArrayInterfaceStr(t_hess);
|
auto s_hess = linalg::ArrayInterfaceStr(t_hess);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2017-2023, XGBoost Contributors
|
* Copyright 2017-2024, XGBoost Contributors
|
||||||
* \file column_matrix.h
|
* \file column_matrix.h
|
||||||
* \brief Utility for fast column-wise access
|
* \brief Utility for fast column-wise access
|
||||||
* \author Philip Cho
|
* \author Philip Cho
|
||||||
@ -176,7 +176,7 @@ class ColumnMatrix {
|
|||||||
void SetValid(typename LBitField32::index_type i) { missing.Clear(i); }
|
void SetValid(typename LBitField32::index_type i) { missing.Clear(i); }
|
||||||
/** @brief assign the storage to the view. */
|
/** @brief assign the storage to the view. */
|
||||||
void InitView() {
|
void InitView() {
|
||||||
missing = LBitField32{Span{storage.data(), storage.size()}};
|
missing = LBitField32{Span{storage.data(), static_cast<size_t>(storage.size())}};
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrowTo(std::size_t n_elements, bool init) {
|
void GrowTo(std::size_t n_elements, bool init) {
|
||||||
@ -318,8 +318,8 @@ class ColumnMatrix {
|
|||||||
common::Span<const BinIdxType> bin_index = {
|
common::Span<const BinIdxType> bin_index = {
|
||||||
reinterpret_cast<const BinIdxType*>(&index_[feature_offset * bins_type_size_]),
|
reinterpret_cast<const BinIdxType*>(&index_[feature_offset * bins_type_size_]),
|
||||||
column_size};
|
column_size};
|
||||||
return std::move(DenseColumnIter<BinIdxType, any_missing>{
|
return DenseColumnIter<BinIdxType, any_missing>{
|
||||||
bin_index, static_cast<bst_bin_t>(index_base_[fidx]), missing_.missing, feature_offset});
|
bin_index, static_cast<bst_bin_t>(index_base_[fidx]), missing_.missing, feature_offset};
|
||||||
}
|
}
|
||||||
|
|
||||||
// all columns are dense column and has no missing value
|
// all columns are dense column and has no missing value
|
||||||
@ -332,7 +332,7 @@ class ColumnMatrix {
|
|||||||
DispatchBinType(bins_type_size_, [&](auto t) {
|
DispatchBinType(bins_type_size_, [&](auto t) {
|
||||||
using ColumnBinT = decltype(t);
|
using ColumnBinT = decltype(t);
|
||||||
auto column_index = Span<ColumnBinT>{reinterpret_cast<ColumnBinT*>(index_.data()),
|
auto column_index = Span<ColumnBinT>{reinterpret_cast<ColumnBinT*>(index_.data()),
|
||||||
index_.size() / sizeof(ColumnBinT)};
|
static_cast<size_t>(index_.size() / sizeof(ColumnBinT))};
|
||||||
ParallelFor(n_samples, n_threads, [&](auto rid) {
|
ParallelFor(n_samples, n_threads, [&](auto rid) {
|
||||||
rid += base_rowid;
|
rid += base_rowid;
|
||||||
const size_t ibegin = rid * n_features;
|
const size_t ibegin = rid * n_features;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2017-2023 by XGBoost Contributors
|
* Copyright 2017-2024 by XGBoost Contributors
|
||||||
* \file hist_util.h
|
* \file hist_util.h
|
||||||
* \brief Utility for fast histogram aggregation
|
* \brief Utility for fast histogram aggregation
|
||||||
* \author Philip Cho, Tianqi Chen
|
* \author Philip Cho, Tianqi Chen
|
||||||
@ -113,8 +113,8 @@ class HistogramCuts {
|
|||||||
auto end = ptrs[column_id + 1];
|
auto end = ptrs[column_id + 1];
|
||||||
auto beg = ptrs[column_id];
|
auto beg = ptrs[column_id];
|
||||||
auto it = std::upper_bound(values.cbegin() + beg, values.cbegin() + end, value);
|
auto it = std::upper_bound(values.cbegin() + beg, values.cbegin() + end, value);
|
||||||
auto idx = it - values.cbegin();
|
auto idx = static_cast<bst_bin_t>(it - values.cbegin());
|
||||||
idx -= !!(idx == end);
|
idx -= !!(idx == static_cast<bst_bin_t>(end));
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,8 +136,8 @@ class HistogramCuts {
|
|||||||
auto beg = ptrs[fidx] + vals.cbegin();
|
auto beg = ptrs[fidx] + vals.cbegin();
|
||||||
// Truncates the value in case it's not perfectly rounded.
|
// Truncates the value in case it's not perfectly rounded.
|
||||||
auto v = static_cast<float>(common::AsCat(value));
|
auto v = static_cast<float>(common::AsCat(value));
|
||||||
auto bin_idx = std::lower_bound(beg, end, v) - vals.cbegin();
|
auto bin_idx = static_cast<bst_bin_t>(std::lower_bound(beg, end, v) - vals.cbegin());
|
||||||
if (bin_idx == ptrs.at(fidx + 1)) {
|
if (bin_idx == static_cast<bst_bin_t>(ptrs.at(fidx + 1))) {
|
||||||
bin_idx -= 1;
|
bin_idx -= 1;
|
||||||
}
|
}
|
||||||
return bin_idx;
|
return bin_idx;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2023, XGBoost Contributors
|
* Copyright 2023-2024, XGBoost Contributors
|
||||||
*/
|
*/
|
||||||
#ifndef XGBOOST_COMMON_REF_RESOURCE_VIEW_H_
|
#ifndef XGBOOST_COMMON_REF_RESOURCE_VIEW_H_
|
||||||
#define XGBOOST_COMMON_REF_RESOURCE_VIEW_H_
|
#define XGBOOST_COMMON_REF_RESOURCE_VIEW_H_
|
||||||
@ -76,7 +76,7 @@ class RefResourceView {
|
|||||||
|
|
||||||
[[nodiscard]] size_type size() const { return size_; } // NOLINT
|
[[nodiscard]] size_type size() const { return size_; } // NOLINT
|
||||||
[[nodiscard]] size_type size_bytes() const { // NOLINT
|
[[nodiscard]] size_type size_bytes() const { // NOLINT
|
||||||
return Span<const value_type>{data(), size()}.size_bytes();
|
return Span<const value_type>{data(), static_cast<size_t>(size())}.size_bytes();
|
||||||
}
|
}
|
||||||
[[nodiscard]] value_type* data() { return ptr_; }; // NOLINT
|
[[nodiscard]] value_type* data() { return ptr_; }; // NOLINT
|
||||||
[[nodiscard]] value_type const* data() const { return ptr_; }; // NOLINT
|
[[nodiscard]] value_type const* data() const { return ptr_; }; // NOLINT
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2017-2023, XGBoost Contributors
|
* Copyright 2017-2024, XGBoost Contributors
|
||||||
* \brief Data type for fast histogram aggregation.
|
* \brief Data type for fast histogram aggregation.
|
||||||
*/
|
*/
|
||||||
#include "gradient_index.h"
|
#include "gradient_index.h"
|
||||||
@ -148,7 +148,8 @@ void GHistIndexMatrix::ResizeIndex(const size_t n_index, const bool isDense) {
|
|||||||
new_vec = {new_ptr, n_bytes / sizeof(std::uint8_t), malloc_resource};
|
new_vec = {new_ptr, n_bytes / sizeof(std::uint8_t), malloc_resource};
|
||||||
}
|
}
|
||||||
this->data = std::move(new_vec);
|
this->data = std::move(new_vec);
|
||||||
this->index = common::Index{common::Span{data.data(), data.size()}, t_size};
|
this->index = common::Index{common::Span{data.data(), static_cast<size_t>(data.size())},
|
||||||
|
t_size};
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((MaxNumBinPerFeat() - 1 <= static_cast<int>(std::numeric_limits<uint8_t>::max())) &&
|
if ((MaxNumBinPerFeat() - 1 <= static_cast<int>(std::numeric_limits<uint8_t>::max())) &&
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2021-2023 XGBoost contributors
|
* Copyright 2021-2024 XGBoost contributors
|
||||||
*/
|
*/
|
||||||
#include <cstddef> // for size_t
|
#include <cstddef> // for size_t
|
||||||
#include <cstdint> // for uint8_t
|
#include <cstdint> // for uint8_t
|
||||||
@ -40,7 +40,9 @@ class GHistIndexRawFormat : public SparsePageFormat<GHistIndexMatrix> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// - index
|
// - index
|
||||||
page->index = common::Index{common::Span{page->data.data(), page->data.size()}, size_type};
|
page->index =
|
||||||
|
common::Index{common::Span{page->data.data(), static_cast<size_t>(page->data.size())},
|
||||||
|
size_type};
|
||||||
|
|
||||||
// hit count
|
// hit count
|
||||||
if (!common::ReadVec(fi, &page->hit_count)) {
|
if (!common::ReadVec(fi, &page->hit_count)) {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2017-2023 by Contributors
|
* Copyright 2017-2024 by Contributors
|
||||||
*/
|
*/
|
||||||
#include "xgboost/predictor.h"
|
#include "xgboost/predictor.h"
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ void ValidateBaseMarginShape(linalg::Tensor<float, D> const& margin, bst_row_t n
|
|||||||
void Predictor::InitOutPredictions(const MetaInfo& info, HostDeviceVector<bst_float>* out_preds,
|
void Predictor::InitOutPredictions(const MetaInfo& info, HostDeviceVector<bst_float>* out_preds,
|
||||||
const gbm::GBTreeModel& model) const {
|
const gbm::GBTreeModel& model) const {
|
||||||
CHECK_NE(model.learner_model_param->num_output_group, 0);
|
CHECK_NE(model.learner_model_param->num_output_group, 0);
|
||||||
std::size_t n{model.learner_model_param->OutputLength() * info.num_row_};
|
auto n = static_cast<size_t>(model.learner_model_param->OutputLength() * info.num_row_);
|
||||||
|
|
||||||
const HostDeviceVector<bst_float>* base_margin = info.base_margin_.Data();
|
const HostDeviceVector<bst_float>* base_margin = info.base_margin_.Data();
|
||||||
if (ctx_->Device().IsCUDA()) {
|
if (ctx_->Device().IsCUDA()) {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2023 by XGBoost Contributors
|
* Copyright 2023-2024 by XGBoost Contributors
|
||||||
*/
|
*/
|
||||||
#ifndef XGBOOST_TREE_HIST_HIST_CACHE_H_
|
#ifndef XGBOOST_TREE_HIST_HIST_CACHE_H_
|
||||||
#define XGBOOST_TREE_HIST_HIST_CACHE_H_
|
#define XGBOOST_TREE_HIST_HIST_CACHE_H_
|
||||||
@ -48,11 +48,13 @@ class BoundedHistCollection {
|
|||||||
BoundedHistCollection() = default;
|
BoundedHistCollection() = default;
|
||||||
common::GHistRow operator[](std::size_t idx) {
|
common::GHistRow operator[](std::size_t idx) {
|
||||||
auto offset = node_map_.at(idx);
|
auto offset = node_map_.at(idx);
|
||||||
return common::Span{data_->data(), data_->size()}.subspan(offset, n_total_bins_);
|
return common::Span{data_->data(), static_cast<size_t>(data_->size())}.subspan(
|
||||||
|
offset, n_total_bins_);
|
||||||
}
|
}
|
||||||
common::ConstGHistRow operator[](std::size_t idx) const {
|
common::ConstGHistRow operator[](std::size_t idx) const {
|
||||||
auto offset = node_map_.at(idx);
|
auto offset = node_map_.at(idx);
|
||||||
return common::Span{data_->data(), data_->size()}.subspan(offset, n_total_bins_);
|
return common::Span{data_->data(), static_cast<size_t>(data_->size())}.subspan(
|
||||||
|
offset, n_total_bins_);
|
||||||
}
|
}
|
||||||
void Reset(bst_bin_t n_total_bins, std::size_t n_cached_nodes) {
|
void Reset(bst_bin_t n_total_bins, std::size_t n_cached_nodes) {
|
||||||
n_total_bins_ = n_total_bins;
|
n_total_bins_ = n_total_bins;
|
||||||
|
|||||||
8
tests/ci_build/Dockerfile.i386
Normal file
8
tests/ci_build/Dockerfile.i386
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
FROM i386/debian:sid
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
SHELL ["/bin/bash", "-c"] # Use Bash as shell
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y tar unzip wget git build-essential ninja-build cmake
|
||||||
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2019-2023 XGBoost contributors
|
* Copyright 2019-2024 XGBoost contributors
|
||||||
*/
|
*/
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <xgboost/c_api.h>
|
#include <xgboost/c_api.h>
|
||||||
@ -212,8 +212,8 @@ TEST(CAPI, JsonModelIO) {
|
|||||||
bst_ulong saved_len{0};
|
bst_ulong saved_len{0};
|
||||||
XGBoosterSaveModelToBuffer(handle, R"({"format": "ubj"})", &saved_len, &saved);
|
XGBoosterSaveModelToBuffer(handle, R"({"format": "ubj"})", &saved_len, &saved);
|
||||||
ASSERT_EQ(len, saved_len);
|
ASSERT_EQ(len, saved_len);
|
||||||
auto l = StringView{data, len};
|
auto l = StringView{data, static_cast<size_t>(len)};
|
||||||
auto r = StringView{saved, saved_len};
|
auto r = StringView{saved, static_cast<size_t>(saved_len)};
|
||||||
ASSERT_EQ(l.size(), r.size());
|
ASSERT_EQ(l.size(), r.size());
|
||||||
ASSERT_EQ(l, r);
|
ASSERT_EQ(l, r);
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2016-2023 by XGBoost contributors
|
* Copyright 2016-2024 by XGBoost contributors
|
||||||
*/
|
*/
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ SimpleLCG::StateType SimpleLCG::Max() const { return max(); }
|
|||||||
static_assert(SimpleLCG::max() - SimpleLCG::min());
|
static_assert(SimpleLCG::max() - SimpleLCG::min());
|
||||||
|
|
||||||
void RandomDataGenerator::GenerateLabels(std::shared_ptr<DMatrix> p_fmat) const {
|
void RandomDataGenerator::GenerateLabels(std::shared_ptr<DMatrix> p_fmat) const {
|
||||||
RandomDataGenerator{p_fmat->Info().num_row_, this->n_targets_, 0.0f}.GenerateDense(
|
RandomDataGenerator{static_cast<bst_row_t>(p_fmat->Info().num_row_), this->n_targets_, 0.0f}.GenerateDense(
|
||||||
p_fmat->Info().labels.Data());
|
p_fmat->Info().labels.Data());
|
||||||
CHECK_EQ(p_fmat->Info().labels.Size(), this->rows_ * this->n_targets_);
|
CHECK_EQ(p_fmat->Info().labels.Size(), this->rows_ * this->n_targets_);
|
||||||
p_fmat->Info().labels.Reshape(this->rows_, this->n_targets_);
|
p_fmat->Info().labels.Reshape(this->rows_, this->n_targets_);
|
||||||
@ -458,7 +458,7 @@ void RandomDataGenerator::GenerateCSR(
|
|||||||
EXPECT_EQ(row_count, dmat->Info().num_row_);
|
EXPECT_EQ(row_count, dmat->Info().num_row_);
|
||||||
|
|
||||||
if (with_label) {
|
if (with_label) {
|
||||||
RandomDataGenerator{dmat->Info().num_row_, this->n_targets_, 0.0f}.GenerateDense(
|
RandomDataGenerator{static_cast<bst_row_t>(dmat->Info().num_row_), this->n_targets_, 0.0f}.GenerateDense(
|
||||||
dmat->Info().labels.Data());
|
dmat->Info().labels.Data());
|
||||||
CHECK_EQ(dmat->Info().labels.Size(), this->rows_ * this->n_targets_);
|
CHECK_EQ(dmat->Info().labels.Size(), this->rows_ * this->n_targets_);
|
||||||
dmat->Info().labels.Reshape(this->rows_, this->n_targets_);
|
dmat->Info().labels.Reshape(this->rows_, this->n_targets_);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2016-2023 by XGBoost contributors
|
* Copyright 2016-2024 by XGBoost contributors
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ class RandomDataGenerator {
|
|||||||
|
|
||||||
bst_bin_t bins_{0};
|
bst_bin_t bins_{0};
|
||||||
std::vector<FeatureType> ft_;
|
std::vector<FeatureType> ft_;
|
||||||
bst_cat_t max_cat_;
|
bst_cat_t max_cat_{32};
|
||||||
|
|
||||||
Json ArrayInterfaceImpl(HostDeviceVector<float>* storage, size_t rows, size_t cols) const;
|
Json ArrayInterfaceImpl(HostDeviceVector<float>* storage, size_t rows, size_t cols) const;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user