diff --git a/src/backend/cuda/CudaBackend.cpp b/src/backend/cuda/CudaBackend.cpp index 903c096ff..2a2f8ea19 100644 --- a/src/backend/cuda/CudaBackend.cpp +++ b/src/backend/cuda/CudaBackend.cpp @@ -136,8 +136,8 @@ public: return printDisabled(RED_S " (failed to load CUDA plugin)"); } - const uint32_t runtimeVersion = CudaLib::runtimeVersion(); - const uint32_t driverVersion = CudaLib::driverVersion(); + runtimeVersion = CudaLib::runtimeVersion(); + driverVersion = CudaLib::driverVersion(); if (!runtimeVersion || !driverVersion || !CudaLib::deviceCount()) { return printDisabled(RED_S " (no devices)"); @@ -147,8 +147,8 @@ public: return; } - Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%u.%u") "/" WHITE_BOLD("%u.%u") BLACK_BOLD("/%s"), "CUDA", - runtimeVersion / 1000, runtimeVersion % 100, driverVersion / 1000, driverVersion % 100, CudaLib::pluginVersion()); + Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s") "/" WHITE_BOLD("%s") BLACK_BOLD("/%s"), "CUDA", + CudaLib::version(runtimeVersion).c_str(), CudaLib::version(driverVersion).c_str(), CudaLib::pluginVersion()); devices = CudaLib::devices(cuda.bfactor(), cuda.bsleep()); @@ -210,6 +210,8 @@ public: std::vector<CudaDevice> devices; std::vector<CudaLaunchData> threads; String profileName; + uint32_t driverVersion = 0; + uint32_t runtimeVersion = 0; Workers<CudaLaunchData> workers; }; @@ -390,6 +392,12 @@ rapidjson::Value xmrig::CudaBackend::toJSON(rapidjson::Document &doc) const out.AddMember("algo", d_ptr->algo.toJSON(), allocator); 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); + if (d_ptr->threads.empty() || !hashrate()) { return out; } diff --git a/src/backend/cuda/wrappers/CudaLib.cpp b/src/backend/cuda/wrappers/CudaLib.cpp index 10b7fab09..5f3018d36 100644 --- a/src/backend/cuda/wrappers/CudaLib.cpp +++ b/src/backend/cuda/wrappers/CudaLib.cpp @@ -204,6 +204,12 @@ nvid_ctx *xmrig::CudaLib::alloc(uint32_t id, int32_t bfactor, int32_t bsleep) no } +std::string xmrig::CudaLib::version(uint32_t version) +{ + return std::to_string(version / 1000) + "." + std::to_string((version % 1000) / 10); +} + + std::vector<xmrig::CudaDevice> xmrig::CudaLib::devices(int32_t bfactor, int32_t bsleep) noexcept { const uint32_t count = deviceCount(); diff --git a/src/backend/cuda/wrappers/CudaLib.h b/src/backend/cuda/wrappers/CudaLib.h index b1215640d..7fb1c1eba 100644 --- a/src/backend/cuda/wrappers/CudaLib.h +++ b/src/backend/cuda/wrappers/CudaLib.h @@ -35,6 +35,7 @@ using nvid_ctx = struct nvid_ctx; #include <vector> +#include <string> namespace xmrig { @@ -81,6 +82,7 @@ public: static int deviceInfo(nvid_ctx *ctx, int32_t blocks, int32_t threads, const Algorithm &algorithm) noexcept; static int32_t deviceInt(nvid_ctx *ctx, DeviceProperty property) noexcept; static nvid_ctx *alloc(uint32_t id, int32_t bfactor, int32_t bsleep) noexcept; + static std::string version(uint32_t version); static std::vector<CudaDevice> devices(int32_t bfactor, int32_t bsleep) noexcept; static uint32_t deviceCount() noexcept; static uint32_t deviceUint(nvid_ctx *ctx, DeviceProperty property) noexcept;