Remove omp_get_max_threads (#7608)
This is the one last PR for removing omp global variable. * Add context object to the `DMatrix`. This bridges `DMatrix` with https://github.com/dmlc/xgboost/issues/7308 . * Require context to be available at the construction time of booster. * Add `n_threads` support for R csc DMatrix constructor. * Remove `omp_get_max_threads` in R glue code. * Remove threading utilities that rely on omp global variable.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* Copyright (c) 2015-2022 by Contributors
|
||||
* Copyright (c) 2015-2022 by XGBoost Contributors
|
||||
* \file data.h
|
||||
* \brief The input data structure of xgboost.
|
||||
* \author Tianqi Chen
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <dmlc/data.h>
|
||||
#include <dmlc/serializer.h>
|
||||
#include <xgboost/base.h>
|
||||
#include <xgboost/generic_parameters.h>
|
||||
#include <xgboost/host_device_vector.h>
|
||||
#include <xgboost/linalg.h>
|
||||
#include <xgboost/span.h>
|
||||
@@ -467,6 +468,11 @@ class DMatrix {
|
||||
|
||||
/*! \brief Get thread local memory for returning data from DMatrix. */
|
||||
XGBAPIThreadLocalEntry& GetThreadLocal() const;
|
||||
/**
|
||||
* \brief Get the context object of this DMatrix. The context is created during construction of
|
||||
* DMatrix with user specified `nthread` parameter.
|
||||
*/
|
||||
virtual GenericParameter const* Ctx() const = 0;
|
||||
|
||||
/**
|
||||
* \brief Gets batches. Use range based for loop over BatchSet to access individual batches.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* Copyright 2014-2021 by Contributors
|
||||
* Copyright 2014-2022 by XGBoost Contributors
|
||||
* \file gbm.h
|
||||
* \brief Interface of gradient booster,
|
||||
* that learns through gradient statistics.
|
||||
@@ -39,6 +39,7 @@ class PredictionContainer;
|
||||
class GradientBooster : public Model, public Configurable {
|
||||
protected:
|
||||
GenericParameter const* ctx_;
|
||||
explicit GradientBooster(GenericParameter const* ctx) : ctx_{ctx} {}
|
||||
|
||||
public:
|
||||
/*! \brief virtual destructor */
|
||||
@@ -208,9 +209,9 @@ class GradientBooster : public Model, public Configurable {
|
||||
*/
|
||||
struct GradientBoosterReg
|
||||
: public dmlc::FunctionRegEntryBase<
|
||||
GradientBoosterReg,
|
||||
std::function<GradientBooster* (LearnerModelParam const* learner_model_param)> > {
|
||||
};
|
||||
GradientBoosterReg,
|
||||
std::function<GradientBooster*(LearnerModelParam const* learner_model_param,
|
||||
GenericParameter const* ctx)> > {};
|
||||
|
||||
/*!
|
||||
* \brief Macro to register gradient booster.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* Copyright 2015-2021 by Contributors
|
||||
* Copyright 2015-2022 by XGBoost Contributors
|
||||
* \file learner.h
|
||||
* \brief Learner interface that integrates objective, gbm and evaluation together.
|
||||
* This is the user facing XGBoost training module.
|
||||
@@ -280,8 +280,10 @@ class Learner : public Model, public Configurable, public dmlc::Serializable {
|
||||
* \return Created learner.
|
||||
*/
|
||||
static Learner* Create(const std::vector<std::shared_ptr<DMatrix> >& cache_data);
|
||||
|
||||
virtual GenericParameter const& GetGenericParameter() const = 0;
|
||||
/**
|
||||
* \brief Return the context object of this Booster.
|
||||
*/
|
||||
virtual GenericParameter const* Ctx() const = 0;
|
||||
/*!
|
||||
* \brief Get configuration arguments currently stored by the learner
|
||||
* \return Key-value pairs representing configuration arguments
|
||||
|
||||
Reference in New Issue
Block a user