diff --git a/api.cpp b/api.cpp index a3d72ca..73d9f31 100644 --- a/api.cpp +++ b/api.cpp @@ -125,6 +125,7 @@ static void gpustatus(int thr_id) #ifdef USE_WRAPNVML cgpu->has_monitoring = true; + cgpu->gpu_bus = gpu_busid(cgpu); cgpu->gpu_temp = gpu_temp(cgpu); cgpu->gpu_fan = gpu_fanpercent(cgpu); cgpu->gpu_pstate = gpu_pstate(cgpu); @@ -154,9 +155,9 @@ static void gpustatus(int thr_id) card = device_name[gpuid]; - snprintf(buf, sizeof(buf), "THR=%d;GPU=%d;CARD=%s;TEMP=%.1f;FAN=%d;" + snprintf(buf, sizeof(buf), "GPU=%d;BUS=%d;CARD=%s;TEMP=%.1f;FAN=%d;" "FREQ=%d;PST=%s;KHS=%.2f;HWF=%d;I=%d|", - thr_id, gpuid, card, cgpu->gpu_temp, cgpu->gpu_fan, + gpuid, cgpu->gpu_bus, card, cgpu->gpu_temp, cgpu->gpu_fan, cgpu->gpu_clock, pstate, cgpu->khashes, cgpu->hw_errors, cgpu->intensity); @@ -207,16 +208,16 @@ static char *getthreads(char *params) */ static char *gethistory(char *params) { - struct stats_data data[20]; + struct stats_data data[50]; int thrid = params ? atoi(params) : -1; char *p = buffer; *buffer = '\0'; int records = stats_get_history(thrid, data, ARRAY_SIZE(data)); for (int i = 0; i < records; i++) { time_t ts = data[i].tm_stat; - p += sprintf(p, "THR=%d|GPU=%d;KHS=%.2f;DIFF=%.6f;" + p += sprintf(p, "GPU=%d;H=%u;KHS=%.2f;DIFF=%.6f;" "COUNT=%u;FOUND=%u;TS=%u|", - data[i].thr_id, data[i].gpu_id, data[i].hashrate, data[i].difficulty, + data[i].gpu_id, data[i].height, data[i].hashrate, data[i].difficulty, data[i].hashcount, data[i].hashfound, (uint32_t)ts); } return buffer; diff --git a/api/index.php b/api/index.php index da1d76c..c344dcd 100644 --- a/api/index.php +++ b/api/index.php @@ -27,7 +27,7 @@ function getdataFromPears() function ignoreField($key) { $ignored = array( - 'API','VER','THR','GPU', + 'API','VER','GPU','BUS', 'CARD','GPUS','CPU','TS', ); return in_array($key, $ignored); @@ -50,6 +50,7 @@ function translateField($key) $intl['UPTIME'] = 'Miner up time'; $intl['TS'] = 'Last update'; + $intl['H'] = 'Bloc height'; $intl['I'] = 'Intensity'; $intl['TEMP'] = 'T°c'; diff --git a/ccminer.cpp b/ccminer.cpp index bad42de..0a7f003 100644 --- a/ccminer.cpp +++ b/ccminer.cpp @@ -1346,7 +1346,7 @@ continue_scan: if (rc > 1) thr_hashrates[thr_id] = (rc * hashes_done) / (diff.tv_sec + 1e-6 * diff.tv_usec); thr_hashrates[thr_id] *= rate_factor; - stats_remember_speed(thr_id, hashes_done, thr_hashrates[thr_id], (uint8_t) rc); + stats_remember_speed(thr_id, hashes_done, thr_hashrates[thr_id], (uint8_t) rc, work.height); } pthread_mutex_unlock(&stats_lock); } diff --git a/miner.h b/miner.h index b7eeeb5..afc8e6f 100644 --- a/miner.h +++ b/miner.h @@ -376,6 +376,7 @@ struct cgpu_info { double khashes; uint8_t intensity; uint8_t has_monitoring; + int gpu_bus; float gpu_temp; int gpu_fan; int gpu_clock; @@ -534,6 +535,7 @@ struct work { struct stats_data { uint32_t tm_stat; uint32_t hashcount; + uint32_t height; double difficulty; double hashrate; uint8_t thr_id; @@ -562,7 +564,7 @@ void hashlog_purge_all(void); void hashlog_dump_job(char* jobid); void hashlog_getmeminfo(uint64_t *mem, uint32_t *records); -void stats_remember_speed(int thr_id, uint32_t hashcount, double hashrate, uint8_t found); +void stats_remember_speed(int thr_id, uint32_t hashcount, double hashrate, uint8_t found, uint32_t height); double stats_get_speed(int thr_id, double def_speed); int stats_get_history(int thr_id, struct stats_data *data, int max_records); void stats_purge_old(void); diff --git a/nvml.cpp b/nvml.cpp index e182bee..c69e1e6 100644 --- a/nvml.cpp +++ b/nvml.cpp @@ -330,6 +330,16 @@ int wrap_nvml_get_pstate(wrap_nvml_handle *nvmlh, int cudaindex, int *pstate) return 0; } +int wrap_nvml_get_busid(wrap_nvml_handle *nvmlh, int cudaindex, int *busid) +{ + int gpuindex = nvmlh->cuda_nvml_device_id[cudaindex]; + if (gpuindex < 0 || gpuindex >= nvmlh->nvml_gpucount) + return -1; + + (*busid) = nvmlh->nvml_pci_bus_id[gpuindex]; + return 0; +} + int wrap_nvml_destroy(wrap_nvml_handle *nvmlh) { nvmlh->nvmlShutdown(); @@ -445,6 +455,15 @@ int nvapi_getpstate(unsigned int devNum, unsigned int *power) return 0; } +int nvapi_getbusid(unsigned int devNum, int *busid) +{ + if (devNum >= 0 && devNum <= 8) { + (*busid) = device_bus_ids[devNum]; + return 0; + } + return -1; +} + int wrap_nvapi_init() { NvAPI_Status ret = NvAPI_Initialize(); @@ -578,6 +597,22 @@ int gpu_pstate(struct cgpu_info *gpu) return pstate; } +int gpu_busid(struct cgpu_info *gpu) +{ + int busid = -1; + int support = -1; + if (hnvml) { + support = wrap_nvml_get_busid(hnvml, device_map[gpu->thr_id], &busid); + } +#ifdef WIN32 + if (support == -1) { + nvapi_getbusid(nvapi_dev_map[gpu->gpu_id], &busid); + } +#endif + return busid; +} + + unsigned int gpu_power(struct cgpu_info *gpu) { unsigned int mw = 0; diff --git a/nvml.h b/nvml.h index 2479e30..186dfa1 100644 --- a/nvml.h +++ b/nvml.h @@ -145,6 +145,7 @@ float gpu_temp(struct cgpu_info *gpu); int gpu_clock(struct cgpu_info *gpu); unsigned int gpu_power(struct cgpu_info *gpu); int gpu_pstate(struct cgpu_info *gpu); +int gpu_busid(struct cgpu_info *gpu); #if defined(__cplusplus) } diff --git a/stats.cpp b/stats.cpp index ad60831..fef5c30 100644 --- a/stats.cpp +++ b/stats.cpp @@ -25,7 +25,7 @@ extern int device_map[8]; /** * Store speed per thread (todo: compute vardiff ?) */ -void stats_remember_speed(int thr_id, uint32_t hashcount, double hashrate, uint8_t found) +void stats_remember_speed(int thr_id, uint32_t hashcount, double hashrate, uint8_t found, uint32_t height) { uint64_t gpu = device_map[thr_id]; uint64_t key = (gpu << 56) + (uid++ % UINT32_MAX); @@ -42,6 +42,7 @@ void stats_remember_speed(int thr_id, uint32_t hashcount, double hashrate, uint8 data.gpu_id = (uint8_t)gpu; data.thr_id = (uint8_t)thr_id; data.tm_stat = (uint32_t) time(NULL); + data.height = height; data.hashcount = hashcount; data.hashfound = found; data.hashrate = hashrate;