#pragma once
#include <cstddef>
#include <limits>
#include "xgboost/parameter.h"
#include "xgboost/tree_model.h"
#include "xgboost/context.h"
namespace xgboost::tree {
struct HistMakerTrainParam : public XGBoostParameter<HistMakerTrainParam> {
private:
constexpr static std::size_t NotSet() { return std::numeric_limits<std::size_t>::max(); }
std::size_t max_cached_hist_node{NotSet()};
public:
constexpr static std::size_t CpuDefaultNodes() { return static_cast<std::size_t>(1) << 16; }
constexpr static std::size_t CudaDefaultNodes() { return static_cast<std::size_t>(1) << 12; }
bool debug_synchronize{false};
bool extmem_single_page{false};
void CheckTreesSynchronized(Context const* ctx, RegTree const* local_tree) const;
std::size_t MaxCachedHistNodes(DeviceOrd device) const {
if (max_cached_hist_node != NotSet()) {
return max_cached_hist_node;
}
return device.IsCPU() ? CpuDefaultNodes() : CudaDefaultNodes();
}
DMLC_DECLARE_PARAMETER(HistMakerTrainParam) {
DMLC_DECLARE_FIELD(debug_synchronize)
.set_default(false)
.describe("Check if all distributed tree are identical after tree construction.");
DMLC_DECLARE_FIELD(max_cached_hist_node)
.set_default(NotSet())
.set_lower_bound(1)
.describe("Maximum number of nodes in histogram cache.");
DMLC_DECLARE_FIELD(extmem_single_page).set_default(false);
}
};
}