Medial Code Documentation
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes
xgboost::Context Struct Reference

Runtime context for XGBoost. More...

#include <context.h>

Inheritance diagram for xgboost::Context:
xgboost::XGBoostParameter< Context >

Public Member Functions

template<typename Container >
Args UpdateAllowUnknown (Container const &kwargs)
 
void ConfigureGpuId (bool require_gpu)
 Configure the parameter ‘gpu_id’.
 
std::int32_t Threads () const
 Returns the automatically chosen number of threads based on the nthread parameter and the system settting.
 
bool IsCPU () const
 Is XGBoost running on CPU?
 
bool IsCUDA () const
 Is XGBoost running on a CUDA device?
 
DeviceOrd Device () const
 Get the current device and ordinal.
 
bst_d_ordinal_t Ordinal () const
 Get the CUDA device ordinal.
 
std::string DeviceName () const
 Name of the current device.
 
CUDAContext const * CUDACtx () const
 Get a CUDA device context for allocator and stream.
 
Context MakeCUDA (bst_d_ordinal_t ordinal=0) const
 Make a CUDA context based on the current context.
 
Context MakeCPU () const
 Make a CPU context based on the current context.
 
template<typename CPUFn , typename CUDAFn >
decltype(auto) DispatchDevice (CPUFn &&cpu_fn, CUDAFn &&cuda_fn) const
 Call function based on the current device.
 
 DMLC_DECLARE_PARAMETER (Context)
 
- Public Member Functions inherited from xgboost::XGBoostParameter< Context >
Args UpdateAllowUnknown (Container const &kwargs)
 
bool GetInitialised () const
 

Static Public Member Functions

static bst_d_ordinal_t constexpr InvalidOrdinal ()
 

Data Fields

std::int32_t gpu_id {kCpuId}
 
std::int32_t nthread {0}
 
std::int64_t seed {kDefaultSeed}
 
bool seed_per_iteration {false}
 
bool fail_on_invalid_gpu_id {false}
 
bool validate_parameters {false}
 

Static Public Attributes

static bst_d_ordinal_t constexpr kCpuId = -1
 
static std::int64_t constexpr kDefaultSeed = 0
 

Additional Inherited Members

- Protected Attributes inherited from xgboost::XGBoostParameter< Context >
bool initialised_
 

Detailed Description

Runtime context for XGBoost.

Contains information like threads and device.

Member Function Documentation

◆ ConfigureGpuId()

void xgboost::Context::ConfigureGpuId ( bool  require_gpu)

Configure the parameter ‘gpu_id’.

Parameters
require_gpuWhether GPU is explicitly required by the user through other configurations.

◆ MakeCUDA()

Context xgboost::Context::MakeCUDA ( bst_d_ordinal_t  ordinal = 0) const
inline

Make a CUDA context based on the current context.

Parameters
ordinalThe CUDA device ordinal.

◆ Ordinal()

bst_d_ordinal_t xgboost::Context::Ordinal ( ) const
inline

Get the CUDA device ordinal.

-1 if XGBoost is running on CPU.


The documentation for this struct was generated from the following files: