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

Commit 7878635

Browse files
committedFeb 17, 2018
Power usage parameterized: -HWMON 0 works as before and -HWMON 1 shows power percentage for NVIDIA cards
1 parent 07f5d71 commit 7878635

File tree

4 files changed

+35
-9
lines changed

4 files changed

+35
-9
lines changed
 

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,6 @@ project.pbxproj
7171
doc/html
7272
*.autosave
7373
node_modules/
74+
75+
# vscode
76+
.vscode/

‎ethminer/MinerAux.h

+10-6
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ class MinerCLI
9292

9393
MinerCLI(OperationMode _mode = OperationMode::None): mode(_mode) {}
9494

95-
static void signalHandler(int sig)
96-
{
97-
g_running = false;
95+
static void signalHandler(int sig)
96+
{
97+
g_running = false;
9898
}
9999

100100
bool interpretOption(int& i, int argc, char** argv)
@@ -252,6 +252,7 @@ class MinerCLI
252252
else if ((arg == "-HWMON") && i + 1 < argc)
253253
{
254254
m_show_hwmonitors = true;
255+
m_show_power = (bool)atoi(argv[++i]);
255256
}
256257

257258
#if API_CORE
@@ -596,7 +597,7 @@ class MinerCLI
596597
}
597598

598599
g_running = true;
599-
signal(SIGINT, MinerCLI::signalHandler);
600+
signal(SIGINT, MinerCLI::signalHandler);
600601
signal(SIGTERM, MinerCLI::signalHandler);
601602

602603
if (mode == OperationMode::Benchmark)
@@ -625,7 +626,9 @@ class MinerCLI
625626
<< " 1: eth-proxy compatible: dwarfpool, f2pool, nanopool (required for hashrate reporting to work with nanopool)" << endl
626627
<< " 2: EthereumStratum/1.0.0: nicehash" << endl
627628
<< " -RH, --report-hashrate Report current hashrate to pool (please only enable on pools supporting this)" << endl
628-
<< " -HWMON Displays gpu temp and fan percent." << endl
629+
<< " -HWMON Displays gpu temp, fan percent and power usage." << endl
630+
<< " 0: Displays only temp and fan percent" << endl
631+
<< " 1: Also displays power usage (only NVIDIA)" << endl
629632
<< " -SE, --stratum-email <s> Email address used in eth-proxy (optional)" << endl
630633
<< " --farm-recheck <n> Leave n ms between checks for changed work (default: 500). When using stratum, use a high value (i.e. 2000) to get more stable hashrate output" << endl
631634
<< endl
@@ -881,7 +884,7 @@ class MinerCLI
881884
// Run CLI in loop
882885
while (g_running) {
883886
if (mgr.isConnected()) {
884-
auto mp = f.miningProgress(m_show_hwmonitors);
887+
auto mp = f.miningProgress(m_show_hwmonitors, m_show_power);
885888
minelog << mp << f.getSolutionStats() << f.farmLaunchedFormatted();
886889

887890
#if ETH_DBUS
@@ -944,6 +947,7 @@ class MinerCLI
944947
bool m_farmRecheckSet = false;
945948
int m_worktimeout = 180;
946949
bool m_show_hwmonitors = false;
950+
bool m_show_power = false;
947951
#if API_CORE
948952
int m_api_port = 0;
949953
#endif

‎libethcore/Farm.h

+14-2
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class Farm: public FarmFace
247247
* @brief Get information on the progress of mining this work package.
248248
* @return The progress with mining so far.
249249
*/
250-
WorkingProgress const& miningProgress(bool hwmon = false) const
250+
WorkingProgress const& miningProgress(bool hwmon = false, bool power = false) const
251251
{
252252
std::lock_guard<std::mutex> lock(x_minerWork);
253253
WorkingProgress p;
@@ -259,26 +259,38 @@ class Farm: public FarmFace
259259
if (hwmon) {
260260
HwMonitorInfo hwInfo = i->hwmonInfo();
261261
HwMonitor hw;
262-
unsigned int tempC = 0, fanpcnt = 0;
262+
unsigned int tempC = 0, fanpcnt = 0, powerW = 0;
263263
if (hwInfo.deviceIndex >= 0) {
264264
if (hwInfo.deviceType == HwMonitorInfoType::NVIDIA && nvmlh) {
265265
wrap_nvml_get_tempC(nvmlh, hwInfo.deviceIndex, &tempC);
266266
wrap_nvml_get_fanpcnt(nvmlh, hwInfo.deviceIndex, &fanpcnt);
267+
if(power) {
268+
wrap_nvml_get_power_usage(nvmlh, hwInfo.deviceIndex, &powerW);
269+
}
267270
}
268271
else if (hwInfo.deviceType == HwMonitorInfoType::AMD && adlh) {
269272
wrap_adl_get_tempC(adlh, hwInfo.deviceIndex, &tempC);
270273
wrap_adl_get_fanpcnt(adlh, hwInfo.deviceIndex, &fanpcnt);
274+
//TODO
275+
//if(power) {
276+
//wrap_adl_get_power_usage(adlh, hwInfo.deviceIndex, &powerW);
277+
//}
271278
}
272279
#if defined(__linux)
273280
// Overwrite with sysfs data if present
274281
if (hwInfo.deviceType == HwMonitorInfoType::AMD && sysfsh) {
275282
wrap_amdsysfs_get_tempC(sysfsh, hwInfo.deviceIndex, &tempC);
276283
wrap_amdsysfs_get_fanpcnt(sysfsh, hwInfo.deviceIndex, &fanpcnt);
284+
//TODO
285+
//if(power) {
286+
//wrap_amdsysfs_get_power_usage(sysfsh, hwInfo.deviceIndex, &powerW);
287+
//}
277288
}
278289
#endif
279290
}
280291
hw.tempC = tempC;
281292
hw.fanP = fanpcnt;
293+
hw.powrW = powerW/((double)1000.0);
282294
p.minerMonitors.push_back(hw);
283295
}
284296
}

‎libethcore/Miner.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,18 @@ struct HwMonitor
8080
{
8181
int tempC = 0;
8282
int fanP = 0;
83+
double powrW = 0;
8384
};
8485

8586
inline std::ostream& operator<<(std::ostream& os, HwMonitor _hw)
8687
{
87-
return os << _hw.tempC << "C " << _hw.fanP << "%";
88+
string power = "";
89+
if(_hw.powrW != 0){
90+
ostringstream stream;
91+
stream << fixed << setprecision(2) << _hw.powrW << "W";
92+
power = stream.str();
93+
}
94+
return os << _hw.tempC << "C " << _hw.fanP << "% " << power;
8895
}
8996

9097
/// Describes the progress of a mining operation.

0 commit comments

Comments
 (0)
This repository has been archived.