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
1 change: 1 addition & 0 deletions ethminer/MinerAux.h
Original file line number Diff line number Diff line change
@@ -968,6 +968,7 @@ class MinerCLI
if (client.current())
{
minelog << mp << f.getSolutionStats() << f.farmLaunchedFormatted();
minelog << f.hwmonitors();
#if ETH_DBUS
dbusint.send(toString(mp).data());
#endif
5 changes: 5 additions & 0 deletions libethash-cl/CLMiner.cpp
Original file line number Diff line number Diff line change
@@ -340,6 +340,11 @@ bool CLMiner::configureGPU(
return false;
}

HwMonitor CLMiner::hwmon()
{
HwMonitor hw;
return hw;
}

bool CLMiner::init(const h256& seed)
{
2 changes: 1 addition & 1 deletion libethash-cl/CLMiner.h
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ class CLMiner: public Miner
s_devices[i] = _devices[i];
}
}

HwMonitor hwmon() override;
protected:
void kickOff() override;
void pause() override;
9 changes: 9 additions & 0 deletions libethash-cuda/CUDAMiner.cpp
Original file line number Diff line number Diff line change
@@ -213,6 +213,15 @@ void CUDAMiner::listDevices()
return ethash_cuda_miner::listDevices();
}

HwMonitor CUDAMiner::hwmon()
{
HwMonitor hw;
if (m_miner) {
hw = m_miner->hwmon();
}
return hw;
}

bool CUDAMiner::configureGPU(
unsigned _blockSize,
unsigned _gridSize,
2 changes: 1 addition & 1 deletion libethash-cuda/CUDAMiner.h
Original file line number Diff line number Diff line change
@@ -69,10 +69,10 @@ class EthashCUDAHook;
s_devices[i] = _devices[i];
}
}
HwMonitor hwmon() override;
protected:
void kickOff() override;
void pause() override;

private:
void workLoop() override;
void report(uint64_t _nonce);
29 changes: 22 additions & 7 deletions libethash-cuda/ethash_cuda_miner.cpp
Original file line number Diff line number Diff line change
@@ -211,14 +211,16 @@ bool ethash_cuda_miner::init(ethash_light_t _light, uint8_t const* _lightData, u
return false;

// use selected device
int device_num = std::min<int>((int)_deviceId, device_count - 1);
m_device_num = std::min<int>((int)_deviceId, device_count - 1);

nvmlh = wrap_nvml_create();

cudaDeviceProp device_props;
CUDA_SAFE_CALL(cudaGetDeviceProperties(&device_props, device_num));
CUDA_SAFE_CALL(cudaGetDeviceProperties(&device_props, m_device_num));

cudalog << "Using device: " << device_props.name << " (Compute " + to_string(device_props.major) + "." + to_string(device_props.minor) + ")";

CUDA_SAFE_CALL(cudaSetDevice(device_num));
CUDA_SAFE_CALL(cudaSetDevice(m_device_num));
CUDA_SAFE_CALL(cudaDeviceReset());
CUDA_SAFE_CALL(cudaSetDeviceFlags(s_scheduleFlag));
CUDA_SAFE_CALL(cudaDeviceSetCacheConfig(cudaFuncCachePreferL1));
@@ -260,21 +262,21 @@ bool ethash_cuda_miner::init(ethash_light_t _light, uint8_t const* _lightData, u

if (!*hostDAG)
{
cudalog << "Generating DAG for GPU #" << device_num;
ethash_generate_dag(dagSize, s_gridSize, s_blockSize, m_streams[0], device_num);
cudalog << "Generating DAG for GPU #" << m_device_num;
ethash_generate_dag(dagSize, s_gridSize, s_blockSize, m_streams[0], m_device_num);

if (_cpyToHost)
{
uint8_t* memoryDAG = new uint8_t[dagSize];
cudalog << "Copying DAG from GPU #" << device_num << " to host";
cudalog << "Copying DAG from GPU #" << m_device_num << " to host";
CUDA_SAFE_CALL(cudaMemcpy(reinterpret_cast<void*>(memoryDAG), dag, dagSize, cudaMemcpyDeviceToHost));

*hostDAG = (void*)memoryDAG;
}
}
else
{
cudalog << "Copying DAG from host to GPU #" << device_num;
cudalog << "Copying DAG from host to GPU #" << m_device_num;
const void* hdag = (const void*)(*hostDAG);
CUDA_SAFE_CALL(cudaMemcpy(reinterpret_cast<void*>(dag), hdag, dagSize, cudaMemcpyHostToDevice));
}
@@ -359,3 +361,16 @@ void ethash_cuda_miner::search(uint8_t const* header, uint64_t target, search_ho
}
}

dev::eth::HwMonitor ethash_cuda_miner::hwmon()
{
dev::eth::HwMonitor hw;
if (nvmlh) {
unsigned int tempC = 0, fanpcnt = 0;
wrap_nvml_get_tempC(nvmlh, m_device_num, &tempC);
wrap_nvml_get_fanpcnt(nvmlh, m_device_num, &fanpcnt);
hw.tempC = tempC;
hw.fanP = fanpcnt;
}
return hw;
}

7 changes: 6 additions & 1 deletion libethash-cuda/ethash_cuda_miner.h
Original file line number Diff line number Diff line change
@@ -5,7 +5,9 @@
#include <time.h>
#include <functional>
#include <libethash/ethash.h>
#include <libethcore/Miner.h>
#include "ethash_cuda_miner_kernel.h"
#include "wrapnvml.h"

class ethash_cuda_miner
{
@@ -39,6 +41,7 @@ class ethash_cuda_miner

void finish();
void search(uint8_t const* header, uint64_t target, search_hook& hook, bool _ethStratum, uint64_t _startN);
dev::eth::HwMonitor hwmon();

/* -- default values -- */
/// Default value of the block size. Also known as workgroup size.
@@ -54,8 +57,8 @@ class ethash_cuda_miner
uint64_t m_current_nonce;
uint64_t m_starting_nonce;
uint64_t m_current_index;

uint32_t m_sharedBytes;
int m_device_num;

volatile uint32_t ** m_search_buf;
cudaStream_t * m_streams;
@@ -70,4 +73,6 @@ class ethash_cuda_miner
static unsigned s_scheduleFlag;

static unsigned m_parallelHash;

wrap_nvml_handle *nvmlh = NULL;
};
Loading