Skip to content
This repository was archived by the owner on Apr 24, 2022. It is now read-only.

Hardware Monitoring for NVML, ADL and AMDGPU SysFS #319

Merged
merged 8 commits into from
Nov 27, 2017
10 changes: 3 additions & 7 deletions ethminer/MinerAux.h
Original file line number Diff line number Diff line change
@@ -818,12 +818,10 @@ class MinerCLI
});
for (unsigned i = 0; !completed; ++i)
{
auto mp = f.miningProgress();
auto mp = f.miningProgress(m_show_hwmonitors);
if (current)
{
minelog << mp << f.getSolutionStats() << f.farmLaunchedFormatted();
if (m_show_hwmonitors)
minelog << f.hwmonitors();
#if ETH_DBUS
dbusint.send(toString(mp).data());
#endif
@@ -969,14 +967,12 @@ class MinerCLI

while (client.isRunning())
{
auto mp = f.miningProgress();
auto mp = f.miningProgress(m_show_hwmonitors);
if (client.isConnected())
{
if (client.current())
{
minelog << mp << f.getSolutionStats() << f.farmLaunchedFormatted();
if (m_show_hwmonitors)
minelog << f.hwmonitors();
#if ETH_DBUS
dbusint.send(toString(mp).data());
#endif
@@ -1020,7 +1016,7 @@ class MinerCLI

while (client.isRunning())
{
auto mp = f.miningProgress();
auto mp = f.miningProgress(m_show_hwmonitors);
if (client.isConnected())
{
if (client.current())
7 changes: 3 additions & 4 deletions libapicore/ApiServer.cpp
Original file line number Diff line number Diff line change
@@ -17,8 +17,7 @@ void ApiServer::getMinerStat1(const Json::Value& request, Json::Value& response)
auto runningTime = std::chrono::duration_cast<std::chrono::minutes>(steady_clock::now() - this->m_farm.farmLaunched());

SolutionStats s = this->m_farm.getSolutionStats();
WorkingProgress p = this->m_farm.miningProgress();
HwMonitors h = this->m_farm.hwmonitors();
WorkingProgress p = this->m_farm.miningProgress(true);

ostringstream totalMhEth;
ostringstream totalMhDcr;
@@ -42,8 +41,8 @@ void ApiServer::getMinerStat1(const Json::Value& request, Json::Value& response)
}

gpuIndex = 0;
numGpus = h.minerMonitors.size();
for (auto const& i : h.minerMonitors)
numGpus = p.minerMonitors.size();
for (auto const& i : p.minerMonitors)
{
tempAndFans << i.tempC << ";" << i.fanP << (((numGpus - 1) > gpuIndex) ? "; " : ""); // Fetching Temp and Fans
gpuIndex++;
17 changes: 3 additions & 14 deletions libethcore/Farm.h
Original file line number Diff line number Diff line change
@@ -213,31 +213,21 @@ class Farm: public FarmFace
return m_isMining;
}

HwMonitors const& hwmonitors() const
{
HwMonitors hws;
for (auto const& i : m_miners) {
hws.minerMonitors.push_back(i->hwmon());
}
Guard l(x_hwmons);
m_hwmons = hws;
return m_hwmons;
}

/**
* @brief Get information on the progress of mining this work package.
* @return The progress with mining so far.
*/
WorkingProgress const& miningProgress() const
WorkingProgress const& miningProgress(bool hwmon = false) const
{
WorkingProgress p;
p.ms = 0;
p.hashes = 0;
{
Guard l2(x_minerWork);
for (auto const& i : m_miners) {
(void) i; // unused
p.minersHashes.push_back(0);
if (hwmon)
p.minerMonitors.push_back(i->hwmon());
}
}

@@ -339,7 +329,6 @@ class Farm: public FarmFace
mutable WorkingProgress m_progress;

mutable Mutex x_hwmons;
mutable HwMonitors m_hwmons;

SolutionFound m_onSolutionFound;
MinerRestart m_onMinerRestart;
23 changes: 6 additions & 17 deletions libethcore/Miner.h
Original file line number Diff line number Diff line change
@@ -72,22 +72,7 @@ struct HwMonitor

inline std::ostream& operator<<(std::ostream& os, HwMonitor _hw)
{
return os << "t=" << _hw.tempC << "C fan=" << _hw.fanP << "%";
}

struct HwMonitors
{
std::vector<HwMonitor> minerMonitors;
};

inline std::ostream& operator<<(std::ostream& _out, HwMonitors _hws)
{
for (size_t i = 0; i < _hws.minerMonitors.size(); ++i)
{
HwMonitor hw = _hws.minerMonitors[i];
_out << "gpu/" << i << " " << EthTeal << hw << EthReset << " ";
}
return _out;
return os << _hw.tempC << "C " << _hw.fanP << "%";
}

/// Describes the progress of a mining operation.
@@ -98,6 +83,7 @@ struct WorkingProgress
uint64_t rate() const { return ms == 0 ? 0 : hashes * 1000 / ms; }

std::vector<uint64_t> minersHashes;
std::vector<HwMonitor> minerMonitors;
uint64_t minerRate(const uint64_t hashCount) const { return ms == 0 ? 0 : hashCount * 1000 / ms; }
};

@@ -111,7 +97,10 @@ inline std::ostream& operator<<(std::ostream& _out, WorkingProgress _p)
for (size_t i = 0; i < _p.minersHashes.size(); ++i)
{
mh = _p.minerRate(_p.minersHashes[i]) / 1000000.0f;
_out << "gpu/" << i << " " << EthTeal << std::fixed << std::setw(5) << std::setprecision(2) << mh << EthReset << " ";
_out << "gpu/" << i << " " << EthTeal << std::fixed << std::setw(5) << std::setprecision(2) << mh << EthReset;
if (_p.minerMonitors.size() == _p.minersHashes.size())
_out << " " << EthTeal << _p.minerMonitors[i] << EthReset;
_out << " ";
}

return _out;