[R] make all customizations to meet strict standard of cran
This commit is contained in:
@@ -7,8 +7,8 @@
|
||||
|
||||
namespace xgboost {
|
||||
namespace common {
|
||||
RandomEngine& GlobalRandom() {
|
||||
static RandomEngine inst;
|
||||
GlobalRandomEngine& GlobalRandom() {
|
||||
static GlobalRandomEngine inst;
|
||||
return inst;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ inline bool CheckNAN(T v) {
|
||||
#ifdef _MSC_VER
|
||||
return (_isnan(v) != 0);
|
||||
#else
|
||||
return isnan(v);
|
||||
return std::isnan(v);
|
||||
#endif
|
||||
}
|
||||
template<typename T>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define XGBOOST_COMMON_RANDOM_H_
|
||||
|
||||
#include <random>
|
||||
#include <limits>
|
||||
|
||||
namespace xgboost {
|
||||
namespace common {
|
||||
@@ -15,11 +16,54 @@ namespace common {
|
||||
* \brief Define mt19937 as default type Random Engine.
|
||||
*/
|
||||
typedef std::mt19937 RandomEngine;
|
||||
|
||||
#if XGBOOST_CUSTOMIZE_GLOBAL_PRNG
|
||||
/*!
|
||||
* \brief An customized random engine, used to be plugged in PRNG from other systems.
|
||||
* The implementation of this library is not provided by xgboost core library.
|
||||
* Instead the other library can implement this class, which will be used as GlobalRandomEngine
|
||||
* If XGBOOST_RANDOM_CUSTOMIZE = 1, by default this is switched off.
|
||||
*/
|
||||
class CustomGlobalRandomEngine {
|
||||
public:
|
||||
/*! \brief The result type */
|
||||
typedef size_t result_type;
|
||||
/*! \brief The minimum of random numbers generated */
|
||||
inline static constexpr result_type min() {
|
||||
return 0;
|
||||
}
|
||||
/*! \brief The maximum random numbers generated */
|
||||
inline static constexpr result_type max() {
|
||||
return std::numeric_limits<size_t>::max();
|
||||
}
|
||||
/*!
|
||||
* \brief seed function, to be implemented
|
||||
* \param val The value of the seed.
|
||||
*/
|
||||
void seed(result_type val);
|
||||
/*!
|
||||
* \return next random number.
|
||||
*/
|
||||
result_type operator()();
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief global random engine
|
||||
*/
|
||||
typedef CustomGlobalRandomEngine GlobalRandomEngine;
|
||||
|
||||
#else
|
||||
/*!
|
||||
* \brief global random engine
|
||||
*/
|
||||
typedef RandomEngine GlobalRandomEngine;
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief global singleton of a random engine.
|
||||
* Only use this engine when necessary, not thread-safe.
|
||||
*/
|
||||
RandomEngine& GlobalRandom(); // NOLINT(*)
|
||||
GlobalRandomEngine& GlobalRandom(); // NOLINT(*)
|
||||
|
||||
} // namespace common
|
||||
} // namespace xgboost
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <dmlc/timer.h>
|
||||
#include <xgboost/logging.h>
|
||||
#include <memory>
|
||||
|
||||
#if DMLC_ENABLE_STD_THREAD
|
||||
#include "./sparse_page_dmatrix.h"
|
||||
#include "../common/random.h"
|
||||
#include "../common/group_data.h"
|
||||
@@ -278,3 +280,4 @@ void SparsePageDMatrix::InitColAccess(const std::vector<bool>& enabled,
|
||||
|
||||
} // namespace data
|
||||
} // namespace xgboost
|
||||
#endif
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <dmlc/timer.h>
|
||||
#include <xgboost/logging.h>
|
||||
#include <memory>
|
||||
|
||||
#if DMLC_ENABLE_STD_THREAD
|
||||
#include "./sparse_page_source.h"
|
||||
|
||||
namespace xgboost {
|
||||
@@ -175,3 +177,4 @@ void SparsePageSource::Create(DMatrix* src,
|
||||
|
||||
} // namespace data
|
||||
} // namespace xgboost
|
||||
#endif
|
||||
|
||||
@@ -334,7 +334,8 @@ class LearnerImpl : public Learner {
|
||||
// in distributed mode, use safe choice otherwise
|
||||
size_t max_row_perbatch = tparam.max_row_perbatch;
|
||||
if (tparam.test_flag == "block" || tparam.dsplit == 2) {
|
||||
max_row_perbatch = std::min(32UL << 10UL, max_row_perbatch);
|
||||
max_row_perbatch = std::min(
|
||||
static_cast<size_t>(32UL << 10UL), max_row_perbatch);
|
||||
}
|
||||
// initialize column access
|
||||
p_train->InitColAccess(enabled,
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "./common/sync.h"
|
||||
|
||||
namespace xgboost {
|
||||
|
||||
#if XGBOOST_CUSTOMIZE_LOGGER == 0
|
||||
ConsoleLogger::~ConsoleLogger() {
|
||||
std::cout << log_stream_.str() << std::endl;
|
||||
}
|
||||
@@ -17,4 +19,5 @@ TrackerLogger::~TrackerLogger() {
|
||||
log_stream_ << '\n';
|
||||
rabit::TrackerPrint(log_stream_.str());
|
||||
}
|
||||
#endif
|
||||
} // namespace xgboost
|
||||
|
||||
@@ -374,8 +374,10 @@ class BaseMaker: public TreeUpdater {
|
||||
}
|
||||
} else {
|
||||
if (rmax >= next_goal) {
|
||||
rabit::TrackerPrintf("INFO: rmax=%g, sum_total=%g, next_goal=%g, size=%lu\n",
|
||||
rmax, sum_total, next_goal, sketch->temp.size);
|
||||
LOG(TRACKER) << "INFO: rmax=" << rmax
|
||||
<< ", sum_total=" << sum_total
|
||||
<< ", naxt_goal=" << next_goal
|
||||
<< ", size=" << sketch->temp.size;
|
||||
}
|
||||
}
|
||||
rmin = rmax;
|
||||
|
||||
Reference in New Issue
Block a user