From afdebe8d8f29849f75669bbc004590f3c627f154 Mon Sep 17 00:00:00 2001 From: Tianqi Chen Date: Sat, 25 Apr 2015 20:40:43 -0700 Subject: [PATCH] fix platform dependent thing --- src/gbm/gbtree-inl.hpp | 2 +- src/learner/learner-inl.hpp | 4 ++-- src/utils/omp.h | 1 + src/utils/utils.h | 8 ++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gbm/gbtree-inl.hpp b/src/gbm/gbtree-inl.hpp index 8e2627f86..0a1ee4f98 100644 --- a/src/gbm/gbtree-inl.hpp +++ b/src/gbm/gbtree-inl.hpp @@ -372,7 +372,7 @@ class GBTree : public IGradBooster { #pragma omp parallel for schedule(static) for (bst_omp_uint i = 0; i < nsize; ++i) { const int tid = omp_get_thread_num(); - int64_t ridx = static_cast(batch.base_rowid + i); + size_t ridx = static_cast(batch.base_rowid + i); tree::RegTree::FVec &feats = thread_temp[tid]; feats.Fill(batch[i]); for (unsigned j = 0; j < ntree_limit; ++j) { diff --git a/src/learner/learner-inl.hpp b/src/learner/learner-inl.hpp index 216e063b3..e972b2257 100644 --- a/src/learner/learner-inl.hpp +++ b/src/learner/learner-inl.hpp @@ -166,12 +166,12 @@ class BoostLearner : public rabit::Serializable { { // backward compatibility code for compatible with old model type // for new model, Read(&name_obj_) is suffice - size_t len; + uint64_t len; utils::Check(fi.Read(&len, sizeof(len)) != 0, "BoostLearner: wrong model format"); if (len >= std::numeric_limits::max()) { int gap; utils::Check(fi.Read(&gap, sizeof(gap)) != 0, "BoostLearner: wrong model format"); - len = len >> 32UL; + len = len >> static_cast(32UL); } if (len != 0) { name_obj_.resize(len); diff --git a/src/utils/omp.h b/src/utils/omp.h index 5eb5612e0..87cad380e 100644 --- a/src/utils/omp.h +++ b/src/utils/omp.h @@ -15,6 +15,7 @@ inline int omp_get_thread_num() { return 0; } inline int omp_get_num_threads() { return 1; } inline void omp_set_num_threads(int nthread) {} +inline int omp_get_num_procs() { return 1; } #endif // loop variable used in openmp diff --git a/src/utils/utils.h b/src/utils/utils.h index 7aee5a29a..e6026c3a6 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -42,10 +42,10 @@ extern "C" { #ifdef _MSC_VER typedef unsigned char uint8_t; -typedef unsigned short int uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long uint64_t; -typedef long int64_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +typedef __int64 int64_t; #else #include #endif