Browse Source

api: also fix nvapi mapping and double swap on histo

2upstream
Tanguy Pruvot 10 years ago
parent
commit
17cf3767e9
  1. 15
      api.cpp
  2. 5
      api/index.php
  3. 20
      nvml.cpp

15
api.cpp

@ -112,13 +112,11 @@ extern uint32_t rejected_count; @@ -112,13 +112,11 @@ extern uint32_t rejected_count;
extern int device_map[8];
extern char *device_name[8];
#define gpu_threads opt_n_threads
/***************************************************************/
static void gpustatus(int thr_id)
{
if (thr_id >= 0 && thr_id < gpu_threads) {
if (thr_id >= 0 && thr_id < opt_n_threads) {
struct cgpu_info *cgpu = &thr_info[thr_id].gpu;
int gpuid = cgpu->gpu_id;
char buf[512]; *buf = '\0';
@ -156,9 +154,9 @@ static void gpustatus(int thr_id) @@ -156,9 +154,9 @@ static void gpustatus(int thr_id)
card = device_name[gpuid];
snprintf(buf, sizeof(buf), "GPU=%d;CARD=%s;TEMP=%.1f;FAN=%d;"
snprintf(buf, sizeof(buf), "THR=%d;GPU=%d;CARD=%s;TEMP=%.1f;FAN=%d;"
"FREQ=%d;PST=%s;KHS=%.2f;HWF=%d;I=%d|",
thr_id, card, cgpu->gpu_temp, cgpu->gpu_fan,
thr_id, gpuid, card, cgpu->gpu_temp, cgpu->gpu_fan,
cgpu->gpu_clock, pstate, cgpu->khashes,
cgpu->hw_errors, cgpu->intensity);
@ -186,7 +184,7 @@ static char *getsummary(char *params) @@ -186,7 +184,7 @@ static char *getsummary(char *params)
"ALGO=%s;GPUS=%d;KHS=%.2f;ACC=%d;REJ=%d;"
"ACCMN=%.3f;DIFF=%.6f;UPTIME=%.0f;TS=%u|",
PACKAGE_NAME, PACKAGE_VERSION, APIVERSION,
algo, gpu_threads, (double)global_hashrate / 1000.0,
algo, opt_n_threads, (double)global_hashrate / 1000.0,
accepted_count, rejected_count,
accps, global_diff, uptime, (uint32_t) ts);
return buffer;
@ -198,7 +196,7 @@ static char *getsummary(char *params) @@ -198,7 +196,7 @@ static char *getsummary(char *params)
static char *getthreads(char *params)
{
*buffer = '\0';
for (int i = 0; i < gpu_threads; i++)
for (int i = 0; i < opt_n_threads; i++)
gpustatus(i);
return buffer;
}
@ -211,10 +209,9 @@ static char *gethistory(char *params) @@ -211,10 +209,9 @@ static char *gethistory(char *params)
{
struct stats_data data[20];
int thrid = params ? atoi(params) : -1;
int gpuid = params ? device_map[(thrid & 0x7)] : -1;
char *p = buffer;
*buffer = '\0';
int records = stats_get_history(gpuid, data, ARRAY_SIZE(data));
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;"

5
api/index.php

@ -26,7 +26,10 @@ function getdataFromPears() @@ -26,7 +26,10 @@ function getdataFromPears()
function ignoreField($key)
{
$ignored = array('API','VER','GPU','CARD','GPUS','CPU','TS');
$ignored = array(
'API','VER','THR','GPU',
'CARD','GPUS','CPU','TS',
);
return in_array($key, $ignored);
}

20
nvml.cpp

@ -346,7 +346,7 @@ int wrap_nvml_destroy(wrap_nvml_handle *nvmlh) @@ -346,7 +346,7 @@ int wrap_nvml_destroy(wrap_nvml_handle *nvmlh)
#ifdef WIN32
#include "nvapi/nvapi_ccminer.h"
static int nvapi_dev_map[NVAPI_MAX_PHYSICAL_GPUS] = { 0 };
static int nvapi_dev_map[8] = { 0 };
static NvDisplayHandle hDisplay_a[NVAPI_MAX_PHYSICAL_GPUS * 2] = { 0 };
static NvPhysicalGpuHandle phys[NVAPI_MAX_PHYSICAL_GPUS] = { 0 };
static NvU32 nvapi_dev_cnt = 0;
@ -469,24 +469,24 @@ int wrap_nvapi_init() @@ -469,24 +469,24 @@ int wrap_nvapi_init()
cudaDeviceProp props;
if (cudaGetDeviceProperties(&props, g) == cudaSuccess)
device_bus_ids[g] = props.pciBusID;
nvapi_dev_map[g] = g;// default mapping
}
for (NvU8 i = 0; i < nvapi_dev_cnt; i++) {
NvAPI_ShortString name;
nvapi_dev_map[i] = i; // default mapping
ret = NvAPI_GPU_GetFullName(phys[i], name);
if (ret == NVAPI_OK) {
for (int g = 0; g < num_processors; g++) {
NvU32 busId;
ret = NvAPI_GPU_GetBusId(phys[i], &busId);
if (ret == NVAPI_OK && busId == device_bus_ids[g]) {
nvapi_dev_map[i] = g;
nvapi_dev_map[g] = i;
if (opt_debug)
applog(LOG_DEBUG, "CUDA GPU[%d] matches NVAPI GPU[%d]",
g, i);
break;
}
}
if (opt_debug)
applog(LOG_DEBUG, "CUDA GPU[%d] matches NVAPI GPU[%d]",
nvapi_dev_map[i], i);
} else {
NvAPI_ShortString string;
NvAPI_GetErrorMessage(ret, string);
@ -518,7 +518,7 @@ int gpu_fanpercent(struct cgpu_info *gpu) @@ -518,7 +518,7 @@ int gpu_fanpercent(struct cgpu_info *gpu)
#ifdef WIN32
else {
unsigned int rpm = 0;
nvapi_fanspeed(nvapi_dev_map[gpu->thr_id], &rpm);
nvapi_fanspeed(nvapi_dev_map[gpu->gpu_id], &rpm);
pct = (rpm * 100) / fan_speed_max;
if (pct > 100) {
pct = 100;
@ -539,7 +539,7 @@ float gpu_temp(struct cgpu_info *gpu) @@ -539,7 +539,7 @@ float gpu_temp(struct cgpu_info *gpu)
}
#ifdef WIN32
else {
nvapi_temperature(nvapi_dev_map[gpu->thr_id], &tmp);
nvapi_temperature(nvapi_dev_map[gpu->gpu_id], &tmp);
tc = (float)tmp;
}
#endif
@ -555,7 +555,7 @@ int gpu_clock(struct cgpu_info *gpu) @@ -555,7 +555,7 @@ int gpu_clock(struct cgpu_info *gpu)
}
#ifdef WIN32
if (support == -1) {
nvapi_getclock(nvapi_dev_map[gpu->thr_id], &freq);
nvapi_getclock(nvapi_dev_map[gpu->gpu_id], &freq);
}
#endif
return (int) freq;
@ -571,7 +571,7 @@ int gpu_pstate(struct cgpu_info *gpu) @@ -571,7 +571,7 @@ int gpu_pstate(struct cgpu_info *gpu)
#ifdef WIN32
if (support == -1) {
unsigned int pst = 0;
nvapi_getpstate(nvapi_dev_map[gpu->thr_id], &pst);
nvapi_getpstate(nvapi_dev_map[gpu->gpu_id], &pst);
pstate = (int) pst;
}
#endif

Loading…
Cancel
Save