From 1c3a95213dddc26b5b1a4ac50f068ae65b1537ab Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Tue, 17 May 2016 21:38:22 +0200 Subject: [PATCH] nvml: do average on milliwatts reading and ignore nvapi percents in pool stats also allow decimals in intensity --- api.cpp | 2 +- nvml.cpp | 5 ++++- util.cpp | 8 +++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/api.cpp b/api.cpp index b8a00c0..d8ad3f1 100644 --- a/api.cpp +++ b/api.cpp @@ -122,7 +122,7 @@ static void gpustatus(int thr_id) cgpu->gpu_temp = gpu_temp(cgpu); cgpu->gpu_fan = (uint16_t) gpu_fanpercent(cgpu); cgpu->gpu_fan_rpm = (uint16_t) gpu_fanrpm(cgpu); - cgpu->gpu_power = gpu_power(cgpu); + cgpu->gpu_power = gpu_power(cgpu); // mWatts #endif cuda_gpu_clocks(cgpu); diff --git a/nvml.cpp b/nvml.cpp index 2d9249e..74f2994 100644 --- a/nvml.cpp +++ b/nvml.cpp @@ -1050,7 +1050,6 @@ int gpu_busid(struct cgpu_info *gpu) return busid; } -/* not used in api (too much variable) */ unsigned int gpu_power(struct cgpu_info *gpu) { unsigned int mw = 0; @@ -1065,6 +1064,10 @@ unsigned int gpu_power(struct cgpu_info *gpu) mw = pct; // to fix } #endif + if (gpu->gpu_power > 0) { + // average + mw = (gpu->gpu_power + mw) / 2; + } return mw; } diff --git a/util.cpp b/util.cpp index 555111a..371cc9b 100644 --- a/util.cpp +++ b/util.cpp @@ -1619,6 +1619,7 @@ static bool stratum_benchdata(json_t *result, json_t *params, int thr_id) char vid[32], arch[8], driver[32]; char *card; char os[8]; + uint32_t watts = 0; int dev_id = device_map[thr_id]; int cuda_ver = cuda_version(); struct cgpu_info *cgpu = &thr_info[thr_id].gpu; @@ -1634,7 +1635,8 @@ static bool stratum_benchdata(json_t *result, json_t *params, int thr_id) #ifdef USE_WRAPNVML cgpu->has_monitoring = true; - cgpu->gpu_power = gpu_power(cgpu); // Watts + cgpu->gpu_power = gpu_power(cgpu); // mWatts + watts = (cgpu->gpu_power >= 1000) ? cgpu->gpu_power / 1000 : 0; // ignore nvapi % gpu_info(cgpu); #endif cuda_gpu_clocks(cgpu); @@ -1656,9 +1658,9 @@ static bool stratum_benchdata(json_t *result, json_t *params, int thr_id) json_object_set_new(val, "arch", json_string(arch)); json_object_set_new(val, "freq", json_integer(cgpu->gpu_clock/1000)); json_object_set_new(val, "memf", json_integer(cgpu->gpu_memclock/1000)); - json_object_set_new(val, "power", json_integer(cgpu->gpu_power/1000)); + json_object_set_new(val, "power", json_integer(watts)); json_object_set_new(val, "khashes", json_real(cgpu->khashes)); - json_object_set_new(val, "intensity", json_integer(cgpu->intensity)); + json_object_set_new(val, "intensity", json_real(cgpu->intensity)); json_object_set_new(val, "throughput", json_integer(cgpu->throughput)); json_object_set_new(val, "client", json_string(PACKAGE_NAME "/" PACKAGE_VERSION)); json_object_set_new(val, "os", json_string(os));