Added manual (e key) health reports.

This commit is contained in:
XMRig 2019-11-01 00:09:28 +07:00
parent f110b5000b
commit 1cb4d73fe3
9 changed files with 89 additions and 26 deletions

View file

@ -53,6 +53,7 @@ public:
virtual const Hashrate *hashrate() const = 0;
virtual const String &profileName() const = 0;
virtual const String &type() const = 0;
virtual void execCommand(char command) = 0;
virtual void prepare(const Job &nextJob) = 0;
virtual void printHashrate(bool details) = 0;
virtual void setJob(const Job &job) = 0;

View file

@ -50,6 +50,8 @@ public:
~CpuBackend() override;
protected:
inline void execCommand(char) override {}
bool isEnabled() const override;
bool isEnabled(const Algorithm &algorithm) const override;
const Hashrate *hashrate() const override;

View file

@ -165,8 +165,11 @@ public:
if (NvmlLib::init(cuda.nvmlLoader())) {
NvmlLib::assign(devices);
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s") "/" GREEN_BOLD("%s"), kNvmlLabel,
NvmlLib::version(), NvmlLib::driverVersion());
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s") "/" GREEN_BOLD("%s") " press " MAGENTA_BG(WHITE_BOLD_S "e") " for health report",
kNvmlLabel,
NvmlLib::version(),
NvmlLib::driverVersion()
);
}
else {
printDisabled(kLabel, RED_S " (failed to load NVML)");
@ -230,6 +233,38 @@ public:
}
# ifdef XMRIG_FEATURE_NVML
void printHealth()
{
for (const auto &device : devices) {
const auto health = NvmlLib::health(device.nvmlDevice());
std::string clocks;
if (health.clock && health.memClock) {
clocks += " " + std::to_string(health.clock) + "/" + std::to_string(health.memClock) + " MHz";
}
std::string fans;
if (!health.fanSpeed.empty()) {
for (uint32_t i = 0; i < health.fanSpeed.size(); ++i) {
fans += " fan" + std::to_string(i) + ":" CYAN_BOLD_S + std::to_string(health.fanSpeed[i]) + "%" CLEAR;
}
}
LOG_INFO(CYAN_BOLD("#%u") YELLOW(" %s") MAGENTA_BOLD("%4uW") CSI "1;%um %2uC" CLEAR WHITE_BOLD("%s") "%s",
device.index(),
device.topology().toString().data(),
health.power,
health.temperature < 60 ? 32 : (health.temperature > 85 ? 31 : 33),
health.temperature,
clocks.c_str(),
fans.c_str()
);
}
}
# endif
Algorithm algo;
Controller *controller;
CudaLaunchStatus status;
@ -300,6 +335,16 @@ const xmrig::String &xmrig::CudaBackend::type() const
}
void xmrig::CudaBackend::execCommand(char command)
{
# ifdef XMRIG_FEATURE_NVML
if (command == 'e' || command == 'E') {
d_ptr->printHealth();
}
# endif
}
void xmrig::CudaBackend::prepare(const Job &)
{
}

View file

@ -56,6 +56,7 @@ protected:
const Hashrate *hashrate() const override;
const String &profileName() const override;
const String &type() const override;
void execCommand(char command) override;
void prepare(const Job &nextJob) override;
void printHashrate(bool details) override;
void setJob(const Job &job) override;

View file

@ -51,6 +51,8 @@ public:
~OclBackend() override;
protected:
inline void execCommand(char) override {}
bool isEnabled() const override;
bool isEnabled(const Algorithm &algorithm) const override;
const Hashrate *hashrate() const override;