Browse Source

Merge branch 'master' into hashfast

nfactor-troky
Con Kolivas 11 years ago
parent
commit
669bcac36c
  1. 5
      api.c
  2. 2
      miner.php
  3. 4
      usbutils.c
  4. 133
      util.c
  5. 4
      util.h

5
api.c

@ -136,7 +136,7 @@ static const char SEPARATOR = '|'; @@ -136,7 +136,7 @@ static const char SEPARATOR = '|';
#define SEPSTR "|"
static const char GPUSEP = ',';
static const char *APIVERSION = "1.31";
static const char *APIVERSION = "1.32";
static const char *DEAD = "Dead";
#if defined(HAVE_OPENCL) || defined(HAVE_AN_FPGA) || defined(HAVE_AN_ASIC)
static const char *SICK = "Sick";
@ -2004,6 +2004,7 @@ static void gpustatus(struct io_data *io_data, int gpu, bool isjson, bool precom @@ -2004,6 +2004,7 @@ static void gpustatus(struct io_data *io_data, int gpu, bool isjson, bool precom
double rejp = cgpu->diff1 ?
(double)(cgpu->diff_rejected) / (double)(cgpu->diff1) : 0;
root = api_add_percent(root, "Device Rejected%", &rejp, false);
root = api_add_elapsed(root, "Device Elapsed", &(total_secs), true); // GPUs don't hotplug
root = print_data(root, buf, isjson, precom);
io_add(io_data, buf);
@ -2083,6 +2084,7 @@ static void ascstatus(struct io_data *io_data, int asc, bool isjson, bool precom @@ -2083,6 +2084,7 @@ static void ascstatus(struct io_data *io_data, int asc, bool isjson, bool precom
double rejp = cgpu->diff1 ?
(double)(cgpu->diff_rejected) / (double)(cgpu->diff1) : 0;
root = api_add_percent(root, "Device Rejected%", &rejp, false);
root = api_add_elapsed(root, "Device Elapsed", &(dev_runtime), false);
root = print_data(root, buf, isjson, precom);
io_add(io_data, buf);
@ -2169,6 +2171,7 @@ static void pgastatus(struct io_data *io_data, int pga, bool isjson, bool precom @@ -2169,6 +2171,7 @@ static void pgastatus(struct io_data *io_data, int pga, bool isjson, bool precom
double rejp = cgpu->diff1 ?
(double)(cgpu->diff_rejected) / (double)(cgpu->diff1) : 0;
root = api_add_percent(root, "Device Rejected%", &rejp, false);
root = api_add_elapsed(root, "Device Elapsed", &(dev_runtime), false);
root = print_data(root, buf, isjson, precom);
io_add(io_data, buf);

2
miner.php

@ -2385,7 +2385,7 @@ function ss($a, $b) @@ -2385,7 +2385,7 @@ function ss($a, $b)
$la = strlen($a);
$lb = strlen($b);
if ($la != $lb)
return $la - $lb;
return $lb - $la;
return strcmp($a, $b);
}
#

4
usbutils.c

@ -2660,7 +2660,7 @@ int _usb_read(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_t @@ -2660,7 +2660,7 @@ int _usb_read(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_t
out_unlock:
if (err && err != LIBUSB_ERROR_TIMEOUT) {
applog(LOG_WARNING, "%s %i usb read err:(%d) %s", cgpu->drv->name, cgpu->device_id,
applog(LOG_WARNING, "%s %i %s usb read err:(%d) %s", cgpu->drv->name, cgpu->device_id, usb_cmdname(cmd),
err, libusb_error_name(err));
if (cgpu->usbinfo.continuous_ioerr_count > USB_RETRY_MAX)
err = LIBUSB_ERROR_OTHER;
@ -2760,7 +2760,7 @@ int _usb_write(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_ @@ -2760,7 +2760,7 @@ int _usb_write(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_
*processed = tot;
if (err) {
applog(LOG_WARNING, "%s %i usb write err:(%d) %s", cgpu->drv->name, cgpu->device_id,
applog(LOG_WARNING, "%s %i %s usb write err:(%d) %s", cgpu->drv->name, cgpu->device_id, usb_cmdname(cmd),
err, libusb_error_name(err));
if (cgpu->usbinfo.continuous_ioerr_count > USB_RETRY_MAX)
err = LIBUSB_ERROR_OTHER;

133
util.c

@ -899,22 +899,11 @@ void timeraddspec(struct timespec *a, const struct timespec *b) @@ -899,22 +899,11 @@ void timeraddspec(struct timespec *a, const struct timespec *b)
}
}
static int timespec_to_ms(struct timespec *ts)
static int __maybe_unused timespec_to_ms(struct timespec *ts)
{
return ts->tv_sec * 1000 + ts->tv_nsec / 1000000;
}
/* Subtracts b from a and stores it in res. */
void cgtimer_sub(cgtimer_t *a, cgtimer_t *b, cgtimer_t *res)
{
res->tv_sec = a->tv_sec - b->tv_sec;
res->tv_nsec = a->tv_nsec - b->tv_nsec;
if (res->tv_nsec < 0) {
res->tv_nsec += 1000000000;
res->tv_sec--;
}
}
/* Subtract b from a */
static void __maybe_unused timersubspec(struct timespec *a, const struct timespec *b)
{
@ -926,23 +915,6 @@ static void __maybe_unused timersubspec(struct timespec *a, const struct timespe @@ -926,23 +915,6 @@ static void __maybe_unused timersubspec(struct timespec *a, const struct timespe
}
}
static void __maybe_unused cgsleep_spec(struct timespec *ts_diff, const struct timespec *ts_start)
{
struct timespec now;
timeraddspec(ts_diff, ts_start);
cgtimer_time(&now);
timersubspec(ts_diff, &now);
if (unlikely(ts_diff->tv_sec < 0))
return;
nanosleep(ts_diff, NULL);
}
int cgtimer_to_ms(cgtimer_t *cgt)
{
return timespec_to_ms(cgt);
}
/* These are cgminer specific sleep functions that use an absolute nanosecond
* resolution timer to avoid poor usleep accuracy and overruns. */
#ifdef WIN32
@ -976,19 +948,27 @@ void cgtime(struct timeval *tv) @@ -976,19 +948,27 @@ void cgtime(struct timeval *tv)
tv->tv_usec = lidiv.rem / 10;
}
void cgtimer_time(cgtimer_t *ts_start)
{
lldiv_t lidiv;;
decius_time(&lidiv);
ts_start->tv_sec = lidiv.quot;
ts_start->tv_nsec = lidiv.quot * 100;
}
#else /* WIN32 */
void cgtime(struct timeval *tv)
{
gettimeofday(tv, NULL);
}
int cgtimer_to_ms(cgtimer_t *cgt)
{
return timespec_to_ms(cgt);
}
/* Subtracts b from a and stores it in res. */
void cgtimer_sub(cgtimer_t *a, cgtimer_t *b, cgtimer_t *res)
{
res->tv_sec = a->tv_sec - b->tv_sec;
res->tv_nsec = a->tv_nsec - b->tv_nsec;
if (res->tv_nsec < 0) {
res->tv_nsec += 1000000000;
res->tv_sec--;
}
}
#endif /* WIN32 */
#ifdef CLOCK_MONOTONIC /* Essentially just linux */
@ -1051,6 +1031,84 @@ void cgtimer_time(cgtimer_t *ts_start) @@ -1051,6 +1031,84 @@ void cgtimer_time(cgtimer_t *ts_start)
ts_start->tv_nsec = tv->tv_usec * 1000;
}
#endif /* __MACH__ */
#ifdef WIN32
/* For windows we use the SystemTime stored as a LARGE_INTEGER as the cgtimer_t
* typedef, allowing us to have sub-microsecond resolution for times, do simple
* arithmetic for timer calculations, and use windows' own hTimers to get
* accurate absolute timeouts. */
int cgtimer_to_ms(cgtimer_t *cgt)
{
return (int)(cgt->QuadPart / 10000LL);
}
/* Subtracts b from a and stores it in res. */
void cgtimer_sub(cgtimer_t *a, cgtimer_t *b, cgtimer_t *res)
{
res->QuadPart = a->QuadPart - b->QuadPart;
}
/* Note that cgtimer time is NOT offset by the unix epoch since we use absolute
* timeouts with hTimers. */
void cgtimer_time(cgtimer_t *ts_start)
{
FILETIME ft;
GetSystemTimeAsFileTime(&ft);
ts_start->LowPart = ft.dwLowDateTime;
ts_start->HighPart = ft.dwHighDateTime;
}
static void liSleep(LARGE_INTEGER *li, int timeout)
{
HANDLE hTimer = CreateWaitableTimer(NULL, TRUE, NULL);
DWORD ret;
if (unlikely(!hTimer))
quit(1, "Failed to create hTimer in liSleep");
ret = SetWaitableTimer(hTimer, li, 0, NULL, NULL, 0);
if (unlikely(!ret))
quit(1, "Failed to SetWaitableTimer in liSleep");
/* We still use a timeout as a sanity check in case the system time
* is changed while we're running */
ret = WaitForSingleObject(hTimer, timeout);
if (unlikely(ret != WAIT_OBJECT_0 && ret != WAIT_TIMEOUT))
quit(1, "Failed to WaitForSingleObject in liSleep");
CloseHandle(hTimer);
}
void cgsleep_ms_r(cgtimer_t *ts_start, int ms)
{
LARGE_INTEGER li;
li.QuadPart = ts_start->QuadPart + (int64_t)ms * 10000LL;
liSleep(&li, ms);
}
void cgsleep_us_r(cgtimer_t *ts_start, int64_t us)
{
LARGE_INTEGER li;
int ms;
li.QuadPart = ts_start->QuadPart + us * 10LL;
ms = us / 1000;
if (!ms)
ms = 1;
liSleep(&li, ms);
}
#else /* WIN32 */
static void cgsleep_spec(struct timespec *ts_diff, const struct timespec *ts_start)
{
struct timespec now;
timeraddspec(ts_diff, ts_start);
cgtimer_time(&now);
timersubspec(ts_diff, &now);
if (unlikely(ts_diff->tv_sec < 0))
return;
nanosleep(ts_diff, NULL);
}
void cgsleep_ms_r(cgtimer_t *ts_start, int ms)
{
struct timespec ts_diff;
@ -1066,6 +1124,7 @@ void cgsleep_us_r(cgtimer_t *ts_start, int64_t us) @@ -1066,6 +1124,7 @@ void cgsleep_us_r(cgtimer_t *ts_start, int64_t us)
us_to_timespec(&ts_diff, us);
cgsleep_spec(&ts_diff, ts_start);
}
#endif /* WIN32 */
#endif /* CLOCK_MONOTONIC */
void cgsleep_ms(int ms)

4
util.h

@ -86,7 +86,11 @@ typedef struct cgsem cgsem_t; @@ -86,7 +86,11 @@ typedef struct cgsem cgsem_t;
#else
typedef sem_t cgsem_t;
#endif
#ifdef WIN32
typedef LARGE_INTEGER cgtimer_t;
#else
typedef struct timespec cgtimer_t;
#endif
struct thr_info;
struct pool;

Loading…
Cancel
Save