Expose build info (#7399)
This commit is contained in:
@@ -42,6 +42,68 @@ XGB_DLL void XGBoostVersion(int* major, int* minor, int* patch) {
|
||||
}
|
||||
}
|
||||
|
||||
using GlobalConfigAPIThreadLocalStore = dmlc::ThreadLocalStore<XGBAPIThreadLocalEntry>;
|
||||
|
||||
#if !defined(XGBOOST_USE_CUDA)
|
||||
namespace xgboost {
|
||||
void XGBBuildInfoDevice(Json *p_info) {
|
||||
auto &info = *p_info;
|
||||
info["USE_CUDA"] = Boolean{false};
|
||||
info["USE_NCCL"] = Boolean{false};
|
||||
info["USE_RMM"] = Boolean{false};
|
||||
}
|
||||
} // namespace xgboost
|
||||
#endif
|
||||
|
||||
XGB_DLL int XGBBuildInfo(char const **out) {
|
||||
API_BEGIN();
|
||||
CHECK(out) << "Invalid input pointer";
|
||||
Json info{Object{}};
|
||||
|
||||
#if defined(XGBOOST_BUILTIN_PREFETCH_PRESENT)
|
||||
info["BUILTIN_PREFETCH_PRESENT"] = Boolean{true};
|
||||
#else
|
||||
info["BUILTIN_PREFETCH_PRESENT"] = Boolean{false};
|
||||
#endif
|
||||
|
||||
#if defined(XGBOOST_MM_PREFETCH_PRESENT)
|
||||
info["MM_PREFETCH_PRESENT"] = Boolean{true};
|
||||
#else
|
||||
info["MM_PREFETCH_PRESENT"] = Boolean{false};
|
||||
#endif
|
||||
|
||||
#if defined(_OPENMP)
|
||||
info["USE_OPENMP"] = Boolean{true};
|
||||
#else
|
||||
info["USE_OPENMP"] = Boolean{false};
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
info["GCC_VERSION"] = std::vector<Json>{Json{Integer{__GNUC__}}, Json{Integer{__GNUC_MINOR__}},
|
||||
Json{Integer{__GNUC_PATCHLEVEL__}}};
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
info["CLANG_VERSION"] =
|
||||
std::vector<Json>{Json{Integer{__clang_major__}}, Json{Integer{__clang_minor__}},
|
||||
Json{Integer{__clang_patchlevel__}}};
|
||||
#endif
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
info["DEBUG"] = Boolean{true};
|
||||
#else
|
||||
info["DEBUG"] = Boolean{false};
|
||||
#endif
|
||||
|
||||
XGBBuildInfoDevice(&info);
|
||||
|
||||
auto &out_str = GlobalConfigAPIThreadLocalStore::Get()->ret_str;
|
||||
Json::Dump(info, &out_str);
|
||||
*out = out_str.c_str();
|
||||
|
||||
API_END();
|
||||
}
|
||||
|
||||
XGB_DLL int XGBRegisterLogCallback(void (*callback)(const char*)) {
|
||||
API_BEGIN_UNGUARD();
|
||||
LogCallbackRegistry* registry = LogCallbackRegistryStore::Get();
|
||||
@@ -95,8 +157,6 @@ XGB_DLL int XGBSetGlobalConfig(const char* json_str) {
|
||||
API_END();
|
||||
}
|
||||
|
||||
using GlobalConfigAPIThreadLocalStore = dmlc::ThreadLocalStore<XGBAPIThreadLocalEntry>;
|
||||
|
||||
XGB_DLL int XGBGetGlobalConfig(const char** json_str) {
|
||||
API_BEGIN();
|
||||
auto const& global_config = *GlobalConfigThreadLocalStore::Get();
|
||||
|
||||
@@ -7,6 +7,37 @@
|
||||
#include "../data/device_adapter.cuh"
|
||||
|
||||
namespace xgboost {
|
||||
|
||||
void XGBBuildInfoDevice(Json *p_info) {
|
||||
auto &info = *p_info;
|
||||
|
||||
info["USE_CUDA"] = true;
|
||||
|
||||
std::vector<Json> v{Json{Integer{THRUST_MAJOR_VERSION}}, Json{Integer{THRUST_MINOR_VERSION}},
|
||||
Json{Integer{THRUST_SUBMINOR_VERSION}}};
|
||||
info["THRUST_VERSION"] = v;
|
||||
|
||||
v = {Json{Integer{dh::CUDAVersion().first}}, Json{Integer{dh::CUDAVersion().second}}};
|
||||
info["CUDA_VERSION"] = v;
|
||||
|
||||
#if defined(XGBOOST_USE_NCCL)
|
||||
info["USE_NCCL"] = Boolean{true};
|
||||
v = {Json{Integer{NCCL_MAJOR}}, Json{Integer{NCCL_MINOR}}, Json{Integer{NCCL_PATCH}}};
|
||||
info["NCCL_VERSION"] = v;
|
||||
#else
|
||||
info["USE_NCCL"] = Boolean{false};
|
||||
#endif
|
||||
|
||||
#if defined(XGBOOST_USE_RMM)
|
||||
info["USE_RMM"] = Boolean{true};
|
||||
v = {Json{Integer{RMM_VERSION_MAJOR}}, Json{Integer{RMM_VERSION_MINOR}},
|
||||
Json{Integer{RMM_VERSION_PATCH}}};
|
||||
info["RMM_VERSION"] = v;
|
||||
#else
|
||||
info["USE_RMM"] = Boolean{false};
|
||||
#endif
|
||||
}
|
||||
|
||||
void XGBoostAPIGuard::SetGPUAttribute() {
|
||||
try {
|
||||
device_id_ = dh::CurrentDevice();
|
||||
|
||||
@@ -239,5 +239,7 @@ inline void GenerateFeatureMap(Learner const *learner,
|
||||
}
|
||||
CHECK_EQ(feature_map.Size(), n_features);
|
||||
}
|
||||
|
||||
void XGBBuildInfoDevice(Json* p_info);
|
||||
} // namespace xgboost
|
||||
#endif // XGBOOST_C_API_C_API_UTILS_H_
|
||||
|
||||
Reference in New Issue
Block a user