Browse Source

api: fix histo gpu/thr id mismatch

master
Tanguy Pruvot 10 years ago
parent
commit
582c971f2b
  1. 20
      api.cpp
  2. 4
      api/index.php
  3. 2
      ccminer.cpp
  4. 14
      miner.h

20
api.cpp

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
* Software Foundation; either version 2 of the License, or (at your option)
* any later version. See COPYING for more details.
*/
#define APIVERSION "1.1"
#define APIVERSION "1.2"
#ifdef WIN32
# define _WINSOCK_DEPRECATED_NO_WARNINGS
@ -120,12 +120,11 @@ static void gpustatus(int thr_id) @@ -120,12 +120,11 @@ static void gpustatus(int thr_id)
{
if (thr_id >= 0 && thr_id < gpu_threads) {
struct cgpu_info *cgpu = &thr_info[thr_id].gpu;
int gpuid = cgpu->gpu_id;
char buf[512]; *buf = '\0';
char pstate[8];
char* card;
cgpu->thr_id = thr_id;
#ifdef USE_WRAPNVML
cgpu->has_monitoring = true;
cgpu->gpu_temp = gpu_temp(cgpu);
@ -149,13 +148,13 @@ static void gpustatus(int thr_id) @@ -149,13 +148,13 @@ static void gpustatus(int thr_id)
cgpu->accepted = accepted_count;
cgpu->rejected = rejected_count;
cgpu->khashes = stats_get_speed(thr_id, 0.0) / 1000.0;
cgpu->khashes = stats_get_speed(cgpu->gpu_id, 0.0) / 1000.0;
snprintf(pstate, sizeof(pstate), "P%u", cgpu->gpu_pstate);
if (cgpu->gpu_pstate == -1)
*pstate= '\0';
card = device_name[device_map[thr_id]];
card = device_name[gpuid];
snprintf(buf, sizeof(buf), "GPU=%d;CARD=%s;TEMP=%.1f;FAN=%d;"
"FREQ=%d;PST=%s;KHS=%.2f;HWF=%d;I=%d|",
@ -211,15 +210,16 @@ static char *getthreads(char *params) @@ -211,15 +210,16 @@ static char *getthreads(char *params)
static char *gethistory(char *params)
{
struct stats_data data[20];
int thr = params ? atoi(params) : -1;
int thrid = params ? atoi(params) : -1;
int gpuid = params ? device_map[(thrid & 0x7)] : -1;
char *p = buffer;
*buffer = '\0';
int records = stats_get_history(thr, data, ARRAY_SIZE(data));
int records = stats_get_history(gpuid, data, ARRAY_SIZE(data));
for (int i = 0; i < records; i++) {
time_t ts = data[i].tm_stat;
p += sprintf(p, "GPU=%d;KHS=%.2f;DIFF=%.6f;"
p += sprintf(p, "THR=%d|GPU=%d;KHS=%.2f;DIFF=%.6f;"
"COUNT=%u;FOUND=%u;TS=%u|",
data[i].gpu_id, data[i].hashrate, data[i].difficulty,
data[i].thr_id, data[i].gpu_id, data[i].hashrate, data[i].difficulty,
data[i].hashcount, data[i].hashfound, (uint32_t)ts);
}
return buffer;
@ -238,7 +238,7 @@ static char *getmeminfo(char *params) @@ -238,7 +238,7 @@ static char *getmeminfo(char *params)
totmem = smem + hmem;
*buffer = '\0';
sprintf(buffer, "STATS=%u;HASHLOG=%u;MEM=%llu|",
sprintf(buffer, "STATS=%u;HASHLOG=%u;MEM=%lu|",
srec, hrec, totmem);
return buffer;

4
api/index.php

@ -26,7 +26,7 @@ function getdataFromPears() @@ -26,7 +26,7 @@ function getdataFromPears()
function ignoreField($key)
{
$ignored = array('API','VER','GPU','CARD','GPUS','CPU');
$ignored = array('API','VER','GPU','CARD','GPUS','CPU','TS');
return in_array($key, $ignored);
}
@ -47,6 +47,8 @@ function translateField($key) @@ -47,6 +47,8 @@ function translateField($key)
$intl['UPTIME'] = 'Miner up time';
$intl['TS'] = 'Last update';
$intl['I'] = 'Intensity';
$intl['TEMP'] = 'T°c';
$intl['FAN'] = 'Fan %';
$intl['FREQ'] = 'Freq.';

2
ccminer.cpp

@ -2186,6 +2186,8 @@ int main(int argc, char *argv[]) @@ -2186,6 +2186,8 @@ int main(int argc, char *argv[])
thr = &thr_info[i];
thr->id = i;
thr->gpu.gpu_id = device_map[i];
thr->gpu.thr_id = i;
thr->q = tq_new();
if (!thr->q)
return 1;

14
miner.h

@ -112,6 +112,11 @@ typedef unsigned char uchar; @@ -112,6 +112,11 @@ typedef unsigned char uchar;
# define min(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef UINT32_MAX
/* for gcc 4.4 */
#define UINT32_MAX UINT_MAX
#endif
#if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
#define WANT_BUILTIN_BSWAP
#else
@ -363,21 +368,20 @@ extern int scanhash_x17(int thr_id, uint32_t *pdata, @@ -363,21 +368,20 @@ extern int scanhash_x17(int thr_id, uint32_t *pdata,
void *api_thread(void *userdata);
struct cgpu_info {
int thr_id;
uint8_t gpu_id;
uint8_t thr_id;
int accepted;
int rejected;
int hw_errors;
double khashes;
int intensity;
#ifdef USE_WRAPNVML
bool has_monitoring;
uint8_t intensity;
uint8_t has_monitoring;
float gpu_temp;
int gpu_fan;
int gpu_clock;
int gpu_memclock;
int gpu_pstate;
double gpu_vddc;
#endif
};
struct thr_api {

Loading…
Cancel
Save