xgboost
|
Runtime context for XGBoost. Contains information like threads and device. More...
#include <context.h>
Public Member Functions | |
Context () | |
void | Init (Args const &kwargs) |
template<typename Container > | |
Args | UpdateAllowUnknown (Container const &kwargs) |
void | ConfigureGpuId (bool require_gpu) |
Configure the parameter ‘device’. Deprecated, will remove once gpu_id is removed. More... | |
std::int32_t | Threads () const |
Returns the automatically chosen number of threads based on the nthread parameter and the system settting. More... | |
bool | IsCPU () const |
Is XGBoost running on CPU? More... | |
bool | IsCUDA () const |
Is XGBoost running on a CUDA device? More... | |
bool | IsSyclDefault () const |
Is XGBoost running on the default SYCL device? More... | |
bool | IsSyclCPU () const |
Is XGBoost running on a SYCL CPU? More... | |
bool | IsSyclGPU () const |
Is XGBoost running on a SYCL GPU? More... | |
bool | IsSycl () const |
Is XGBoost running on any SYCL device? More... | |
DeviceOrd | Device () const |
Get the current device and ordinal. More... | |
bst_d_ordinal_t | Ordinal () const |
Get the CUDA device ordinal. -1 if XGBoost is running on CPU. More... | |
std::string | DeviceName () const |
Name of the current device. More... | |
CUDAContext const * | CUDACtx () const |
Get a CUDA device context for allocator and stream. More... | |
Context | MakeCUDA (bst_d_ordinal_t ordinal=0) const |
Make a CUDA context based on the current context. More... | |
Context | MakeCPU () const |
Make a CPU context based on the current context. More... | |
template<typename CPUFn , typename CUDAFn > | |
decltype(auto) | DispatchDevice (CPUFn &&cpu_fn, CUDAFn &&cuda_fn) const |
Call function based on the current device. More... | |
template<typename CPUFn , typename CUDAFn , typename SYCLFn > | |
decltype(auto) | DispatchDevice (CPUFn &&cpu_fn, CUDAFn &&cuda_fn, SYCLFn &&sycl_fn) const |
Call function for sycl devices. More... | |
DMLC_DECLARE_PARAMETER (Context) | |
Public Member Functions inherited from xgboost::XGBoostParameter< Context > | |
Args | UpdateAllowUnknown (Container const &kwargs) |
bool | GetInitialised () const |
Public Attributes | |
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 constexpr std::int64_t | kDefaultSeed = 0 |
Additional Inherited Members | |
Protected Attributes inherited from xgboost::XGBoostParameter< Context > | |
bool | initialised_ |
Runtime context for XGBoost. Contains information like threads and device.
xgboost::Context::Context | ( | ) |
void xgboost::Context::ConfigureGpuId | ( | bool | require_gpu | ) |
Configure the parameter ‘device’. Deprecated, will remove once gpu_id
is removed.
require_gpu | Whether GPU is explicitly required by the user through other configurations. |
CUDAContext const* xgboost::Context::CUDACtx | ( | ) | const |
Get a CUDA device context for allocator and stream.
|
inline |
Get the current device and ordinal.
|
inline |
Name of the current device.
|
inline |
Call function based on the current device.
|
inline |
Call function for sycl devices.
|
inline |
void xgboost::Context::Init | ( | Args const & | kwargs | ) |
|
inline |
Is XGBoost running on CPU?
|
inline |
Is XGBoost running on a CUDA device?
|
inline |
Is XGBoost running on any SYCL device?
|
inline |
Is XGBoost running on a SYCL CPU?
|
inline |
Is XGBoost running on the default SYCL device?
|
inline |
Is XGBoost running on a SYCL GPU?
|
inline |
Make a CPU context based on the current context.
|
inline |
Make a CUDA context based on the current context.
ordinal | The CUDA device ordinal. |
|
inline |
Get the CUDA device ordinal. -1 if XGBoost is running on CPU.
std::int32_t xgboost::Context::Threads | ( | ) | const |
Returns the automatically chosen number of threads based on the nthread
parameter and the system settting.
|
inline |
bool xgboost::Context::fail_on_invalid_gpu_id {false} |
|
staticconstexpr |
std::int32_t xgboost::Context::nthread {0} |
std::int64_t xgboost::Context::seed {kDefaultSeed} |
bool xgboost::Context::seed_per_iteration {false} |
bool xgboost::Context::validate_parameters {false} |