mirror of
https://github.com/GOSTSec/ccminer
synced 2025-01-10 14:57:53 +00:00
api: add gpu pci bus id, unified id + bloc height
This commit is contained in:
parent
17cf3767e9
commit
b24b65a9c9
11
api.cpp
11
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;
|
||||
|
@ -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';
|
||||
|
@ -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);
|
||||
}
|
||||
|
4
miner.h
4
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);
|
||||
|
35
nvml.cpp
35
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;
|
||||
|
1
nvml.h
1
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)
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user