Added initial NVML stub.
This commit is contained in:
parent
3bdf7111ce
commit
175a7b06b7
10 changed files with 335 additions and 17 deletions
|
@ -51,6 +51,13 @@
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_NVML
|
||||
#include "backend/cuda/wrappers/NvmlLib.h"
|
||||
|
||||
namespace xmrig { static const char *kNvmlLabel = "NVML"; }
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
|
@ -58,15 +65,16 @@ extern template class Threads<CudaThreads>;
|
|||
|
||||
|
||||
constexpr const size_t oneMiB = 1024u * 1024u;
|
||||
static const char *kLabel = "CUDA";
|
||||
static const char *tag = GREEN_BG_BOLD(WHITE_BOLD_S " nv ");
|
||||
static const String kType = "cuda";
|
||||
static std::mutex mutex;
|
||||
|
||||
|
||||
|
||||
static void printDisabled(const char *reason)
|
||||
static void printDisabled(const char *label, const char *reason)
|
||||
{
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") RED_BOLD("disabled") "%s", "CUDA", reason);
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") RED_BOLD("disabled") "%s", label, reason);
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,29 +137,44 @@ public:
|
|||
void init(const CudaConfig &cuda)
|
||||
{
|
||||
if (!cuda.isEnabled()) {
|
||||
return printDisabled("");
|
||||
return printDisabled(kLabel, "");
|
||||
}
|
||||
|
||||
if (!CudaLib::init(cuda.loader())) {
|
||||
return printDisabled(RED_S " (failed to load CUDA plugin)");
|
||||
return printDisabled(kLabel, RED_S " (failed to load CUDA plugin)");
|
||||
}
|
||||
|
||||
runtimeVersion = CudaLib::runtimeVersion();
|
||||
driverVersion = CudaLib::driverVersion();
|
||||
|
||||
if (!runtimeVersion || !driverVersion || !CudaLib::deviceCount()) {
|
||||
return printDisabled(RED_S " (no devices)");
|
||||
return printDisabled(kLabel, RED_S " (no devices)");
|
||||
}
|
||||
|
||||
if (!devices.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s") "/" WHITE_BOLD("%s") BLACK_BOLD("/%s"), "CUDA",
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s") "/" WHITE_BOLD("%s") BLACK_BOLD("/%s"), kLabel,
|
||||
CudaLib::version(runtimeVersion).c_str(), CudaLib::version(driverVersion).c_str(), CudaLib::pluginVersion());
|
||||
|
||||
devices = CudaLib::devices(cuda.bfactor(), cuda.bsleep());
|
||||
|
||||
# ifdef XMRIG_FEATURE_NVML
|
||||
if (cuda.isNvmlEnabled()) {
|
||||
if (NvmlLib::init(cuda.nvmlLoader())) {
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s") "/" GREEN_BOLD("%s"), kNvmlLabel,
|
||||
NvmlLib::version(), NvmlLib::driverVersion());
|
||||
}
|
||||
else {
|
||||
printDisabled(kLabel, RED_S " (failed to load NVML)");
|
||||
}
|
||||
}
|
||||
else {
|
||||
printDisabled(kNvmlLabel, "");
|
||||
}
|
||||
# endif
|
||||
|
||||
for (const CudaDevice &device : devices) {
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("#%zu") YELLOW(" %s") GREEN_BOLD(" %s ") WHITE_BOLD("%u/%u MHz") " smx:" WHITE_BOLD("%u") " arch:" WHITE_BOLD("%u%u") " mem:" CYAN("%zu/%zu") " MB",
|
||||
"CUDA GPU",
|
||||
|
@ -238,6 +261,10 @@ xmrig::CudaBackend::~CudaBackend()
|
|||
delete d_ptr;
|
||||
|
||||
CudaLib::close();
|
||||
|
||||
# ifdef XMRIG_FEATURE_NVML
|
||||
NvmlLib::close();
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -394,10 +421,18 @@ rapidjson::Value xmrig::CudaBackend::toJSON(rapidjson::Document &doc) const
|
|||
out.AddMember("profile", profileName().toJSON(), allocator);
|
||||
|
||||
Value versions(kObjectType);
|
||||
versions.AddMember("runtime", Value(CudaLib::version(d_ptr->runtimeVersion).c_str(), allocator), allocator);
|
||||
versions.AddMember("driver", Value(CudaLib::version(d_ptr->driverVersion).c_str(), allocator), allocator);
|
||||
versions.AddMember("plugin", String(CudaLib::pluginVersion()).toJSON(doc), allocator);
|
||||
out.AddMember("versions", versions, allocator);
|
||||
versions.AddMember("cuda-runtime", Value(CudaLib::version(d_ptr->runtimeVersion).c_str(), allocator), allocator);
|
||||
versions.AddMember("cuda-driver", Value(CudaLib::version(d_ptr->driverVersion).c_str(), allocator), allocator);
|
||||
versions.AddMember("plugin", String(CudaLib::pluginVersion()).toJSON(doc), allocator);
|
||||
|
||||
# ifdef XMRIG_FEATURE_NVML
|
||||
if (NvmlLib::isReady()) {
|
||||
versions.AddMember("nvml", StringRef(NvmlLib::version()), allocator);
|
||||
versions.AddMember("driver", StringRef(NvmlLib::driverVersion()), allocator);
|
||||
}
|
||||
# endif
|
||||
|
||||
out.AddMember("versions", versions, allocator);
|
||||
|
||||
if (d_ptr->threads.empty() || !hashrate()) {
|
||||
return out;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue