6 #ifndef XGBOOST_BASE_H_ 7 #define XGBOOST_BASE_H_ 17 #ifndef XGBOOST_STRICT_R_MODE 18 #define XGBOOST_STRICT_R_MODE 0 19 #endif // XGBOOST_STRICT_R_MODE 27 #ifndef XGBOOST_LOG_WITH_TIME 28 #define XGBOOST_LOG_WITH_TIME 1 29 #endif // XGBOOST_LOG_WITH_TIME 34 #ifndef XGBOOST_CUSTOMIZE_LOGGER 35 #define XGBOOST_CUSTOMIZE_LOGGER XGBOOST_STRICT_R_MODE 36 #endif // XGBOOST_CUSTOMIZE_LOGGER 41 #ifndef XGBOOST_CUSTOMIZE_GLOBAL_PRNG 42 #define XGBOOST_CUSTOMIZE_GLOBAL_PRNG XGBOOST_STRICT_R_MODE 43 #endif // XGBOOST_CUSTOMIZE_GLOBAL_PRNG 48 #if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || __GNUC__ > 4) 49 #define XGBOOST_ALIGNAS(X) alignas(X) 51 #define XGBOOST_ALIGNAS(X) 52 #endif // defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || __GNUC__ > 4) 54 #if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || __GNUC__ > 4) && \ 56 #include <parallel/algorithm> 57 #define XGBOOST_PARALLEL_SORT(X, Y, Z) __gnu_parallel::sort((X), (Y), (Z)) 58 #define XGBOOST_PARALLEL_STABLE_SORT(X, Y, Z) \ 59 __gnu_parallel::stable_sort((X), (Y), (Z)) 60 #elif defined(_MSC_VER) && (!__INTEL_COMPILER) 62 #define XGBOOST_PARALLEL_SORT(X, Y, Z) concurrency::parallel_sort((X), (Y), (Z)) 63 #define XGBOOST_PARALLEL_STABLE_SORT(X, Y, Z) std::stable_sort((X), (Y), (Z)) 65 #define XGBOOST_PARALLEL_SORT(X, Y, Z) std::sort((X), (Y), (Z)) 66 #define XGBOOST_PARALLEL_STABLE_SORT(X, Y, Z) std::stable_sort((X), (Y), (Z)) 67 #endif // GLIBC VERSION 72 #if defined (__CUDA__) || defined(__NVCC__) 73 #define XGBOOST_DEVICE __host__ __device__ 75 #define XGBOOST_DEVICE 76 #endif // defined (__CUDA__) || defined(__NVCC__) 117 : grad_(g.grad_), hess_(g.hess_) {}
121 template <
typename T2>
140 g.grad_ = grad_ + rhs.grad_;
141 g.hess_ = hess_ + rhs.hess_;
155 g.grad_ = grad_ - rhs.grad_;
156 g.hess_ = hess_ - rhs.hess_;
162 static_cast<float>(value));
174 return grad_ * 1e-4f;
178 return hess_ * 1e-4f;
182 grad_ =
static_cast<int64_t
>(std::round(g * 1e4));
186 hess_ =
static_cast<int64_t
>(std::round(h * 1e4));
214 #if DMLC_USE_CXX11 && defined(__GNUC__) && !defined(__clang_version__) 215 #if __GNUC__ == 4 && __GNUC_MINOR__ < 8 218 #endif // __GNUC__ == 4 && __GNUC_MINOR__ < 8 219 #endif // DMLC_USE_CXX11 && defined(__GNUC__) && !defined(__clang_version__) 225 #endif // XGBOOST_BASE_H_ XGBOOST_DEVICE GradientPairInternal(const GradientPairInternal< T2 > &g)
Definition: base.h:122
float bst_float
float type, used for storing statistics
Definition: base.h:89
XGBOOST_DEVICE GradientPairInternal< T > & operator-=(const GradientPairInternal< T > &rhs)
Definition: base.h:145
int32_t bst_int
Definition: base.h:85
XGBOOST_DEVICE GradientPairInternal(int value)
Definition: base.h:160
dmlc::omp_ulong omp_ulong
define unsigned long for openmp loop
Definition: base.h:206
dmlc::omp_uint bst_omp_uint
define unsigned int for openmp loop
Definition: base.h:208
XGBOOST_DEVICE GradientPairInternal()
Definition: base.h:108
XGBOOST_DEVICE float GetGrad() const
Definition: base.h:127
Implementation of gradient statistics pair. Template specialisation may be used to overload different...
Definition: base.h:96
XGBOOST_DEVICE GradientPairInternal(float grad, float hess)
Definition: base.h:110
const bst_float kRtEps
small eps gap for minimum split decision.
Definition: base.h:203
uint64_t bst_ulong
long integers
Definition: base.h:87
XGBOOST_DEVICE GradientPairInternal< T > & operator+=(const GradientPairInternal< T > &rhs)
Definition: base.h:130
#define XGBOOST_DEVICE
Tag function as usable by device.
Definition: base.h:75
namespace of xgboost
Definition: base.h:79
XGBOOST_DEVICE GradientPairInternal(const GradientPairInternal< T > &g)
Definition: base.h:116
friend std::ostream & operator<<(std::ostream &os, const GradientPairInternal< T > &g)
Definition: base.h:165
XGBOOST_DEVICE GradientPairInternal< T > operator-(const GradientPairInternal< T > &rhs) const
Definition: base.h:152
XGBOOST_DEVICE GradientPairInternal< T > operator+(const GradientPairInternal< T > &rhs) const
Definition: base.h:137
uint32_t bst_uint
unsigned integer type used in boost, used for feature index and row index.
Definition: base.h:84
XGBOOST_DEVICE float GetHess() const
Definition: base.h:128
T ValueT
Definition: base.h:106