Fixes compilation errors on MSVC x86 targets (#8823)

This commit is contained in:
Mauro Leggieri 2023-02-25 22:20:28 +03:00 committed by GitHub
parent a65ad0bd9c
commit 90c0633a28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 7 deletions

View File

@ -151,7 +151,7 @@ inline LINALG_HD int Popc(uint64_t v) {
return __popcll(v); return __popcll(v);
#elif defined(__GNUC__) || defined(__clang__) #elif defined(__GNUC__) || defined(__clang__)
return __builtin_popcountll(v); return __builtin_popcountll(v);
#elif defined(_MSC_VER) #elif defined(_MSC_VER) && _defined(_M_X64)
return __popcnt64(v); return __popcnt64(v);
#else #else
return NativePopc(v); return NativePopc(v);

View File

@ -455,7 +455,8 @@ XGB_DLL int XGDMatrixCreateFromCSC(char const *indptr, char const *indices, char
xgboost_CHECK_C_ARG_PTR(indptr); xgboost_CHECK_C_ARG_PTR(indptr);
xgboost_CHECK_C_ARG_PTR(indices); xgboost_CHECK_C_ARG_PTR(indices);
xgboost_CHECK_C_ARG_PTR(data); xgboost_CHECK_C_ARG_PTR(data);
data::CSCArrayAdapter adapter{StringView{indptr}, StringView{indices}, StringView{data}, nrow}; data::CSCArrayAdapter adapter{StringView{indptr}, StringView{indices}, StringView{data},
static_cast<std::size_t>(nrow)};
xgboost_CHECK_C_ARG_PTR(c_json_config); xgboost_CHECK_C_ARG_PTR(c_json_config);
auto config = Json::Load(StringView{c_json_config}); auto config = Json::Load(StringView{c_json_config});
float missing = GetMissing(config); float missing = GetMissing(config);

View File

@ -80,8 +80,11 @@ class QuantileRegression : public ObjFunction {
linalg::ElementWiseKernel( linalg::ElementWiseKernel(
ctx_, gpair, [=] XGBOOST_DEVICE(std::size_t i, GradientPair const&) mutable { ctx_, gpair, [=] XGBOOST_DEVICE(std::size_t i, GradientPair const&) mutable {
auto idx = linalg::UnravelIndex( auto idx = linalg::UnravelIndex(static_cast<std::size_t>(i),
i, {n_samples, static_cast<SizeT>(alpha.size()), n_targets / alpha.size()}); {static_cast<std::size_t>(n_samples),
static_cast<std::size_t>(alpha.size()),
static_cast<std::size_t>(n_targets / alpha.size())});
// std::tie is not available for cuda kernel. // std::tie is not available for cuda kernel.
std::size_t sample_id = std::get<0>(idx); std::size_t sample_id = std::get<0>(idx);
std::size_t quantile_id = std::get<1>(idx); std::size_t quantile_id = std::get<1>(idx);

View File

@ -164,7 +164,7 @@ struct GHistIndexMatrixView {
SparsePage::Inst operator[](size_t r) { SparsePage::Inst operator[](size_t r) {
auto t = omp_get_thread_num(); auto t = omp_get_thread_num();
auto const beg = (n_features_ * kUnroll * t) + (current_unroll_[t] * n_features_); auto const beg = (n_features_ * kUnroll * t) + (current_unroll_[t] * n_features_);
size_t non_missing{beg}; size_t non_missing{static_cast<std::size_t>(beg)};
for (bst_feature_t c = 0; c < n_features_; ++c) { for (bst_feature_t c = 0; c < n_features_; ++c) {
float f = page_.GetFvalue(r, c, common::IsCat(ft_, c)); float f = page_.GetFvalue(r, c, common::IsCat(ft_, c));
@ -477,7 +477,8 @@ class ColumnSplitHelper {
// auto block_id has the same type as `n_blocks`. // auto block_id has the same type as `n_blocks`.
common::ParallelFor(n_blocks, n_threads_, [&](auto block_id) { common::ParallelFor(n_blocks, n_threads_, [&](auto block_id) {
auto const batch_offset = block_id * block_of_rows_size; auto const batch_offset = block_id * block_of_rows_size;
auto const block_size = std::min(nsize - batch_offset, block_of_rows_size); auto const block_size = std::min(static_cast<std::size_t>(nsize - batch_offset),
static_cast<std::size_t>(block_of_rows_size));
auto const fvec_offset = omp_get_thread_num() * block_of_rows_size; auto const fvec_offset = omp_get_thread_num() * block_of_rows_size;
FVecFill(block_size, batch_offset, num_feature, &batch, fvec_offset, &feat_vecs_); FVecFill(block_size, batch_offset, num_feature, &batch, fvec_offset, &feat_vecs_);
@ -490,7 +491,8 @@ class ColumnSplitHelper {
// auto block_id has the same type as `n_blocks`. // auto block_id has the same type as `n_blocks`.
common::ParallelFor(n_blocks, n_threads_, [&](auto block_id) { common::ParallelFor(n_blocks, n_threads_, [&](auto block_id) {
auto const batch_offset = block_id * block_of_rows_size; auto const batch_offset = block_id * block_of_rows_size;
auto const block_size = std::min(nsize - batch_offset, block_of_rows_size); auto const block_size = std::min(static_cast<std::size_t>(nsize - batch_offset),
static_cast<std::size_t>(block_of_rows_size));
PredictAllTrees(out_preds, batch_offset, batch_offset + batch.base_rowid, num_group, PredictAllTrees(out_preds, batch_offset, batch_offset + batch.base_rowid, num_group,
block_size); block_size);
}); });