Browse Source

Use mining start time for device MH/U calculations

nfactor-troky
Kano 12 years ago
parent
commit
84ffcbc51b
  1. 32
      api.c
  2. 45
      cgminer.c
  3. 2
      driver-modminer.c
  4. 2
      miner.h
  5. 21
      usbutils.c
  6. 1
      usbutils.h

32
api.c

@ -1581,8 +1581,20 @@ static void ascstatus(struct io_data *io_data, int asc, bool isjson, bool precom @@ -1581,8 +1581,20 @@ static void ascstatus(struct io_data *io_data, int asc, bool isjson, bool precom
struct cgpu_info *cgpu = get_devices(dev);
float temp = cgpu->temp;
struct timeval now;
double dev_runtime;
cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
if (cgpu->dev_start_tv.tv_sec == 0)
dev_runtime = total_secs;
else {
cgtime(&now);
dev_runtime = tdiff(&now, &(cgpu->dev_start_tv));
}
if (dev_runtime < 1.0)
dev_runtime = 1.0;
cgpu->utility = cgpu->accepted / dev_runtime * 60;
if (cgpu->deven != DEV_DISABLED)
enabled = (char *)YES;
@ -1597,7 +1609,7 @@ static void ascstatus(struct io_data *io_data, int asc, bool isjson, bool precom @@ -1597,7 +1609,7 @@ static void ascstatus(struct io_data *io_data, int asc, bool isjson, bool precom
root = api_add_string(root, "Enabled", enabled, false);
root = api_add_string(root, "Status", status, false);
root = api_add_temp(root, "Temperature", &temp, false);
double mhs = cgpu->total_mhashes / total_secs;
double mhs = cgpu->total_mhashes / dev_runtime;
root = api_add_mhs(root, "MHS av", &mhs, false);
char mhsname[27];
sprintf(mhsname, "MHS %ds", opt_log_interval);
@ -1643,6 +1655,18 @@ static void pgastatus(struct io_data *io_data, int pga, bool isjson, bool precom @@ -1643,6 +1655,18 @@ static void pgastatus(struct io_data *io_data, int pga, bool isjson, bool precom
struct cgpu_info *cgpu = get_devices(dev);
double frequency = 0;
float temp = cgpu->temp;
struct timeval now;
double dev_runtime;
if (cgpu->dev_start_tv.tv_sec == 0)
dev_runtime = total_secs;
else {
cgtime(&now);
dev_runtime = tdiff(&now, &(cgpu->dev_start_tv));
}
if (dev_runtime < 1.0)
dev_runtime = 1.0;
#ifdef USE_ZTEX
if (cgpu->drv->drv_id == DRIVER_ZTEX && cgpu->device_ztex)
@ -1653,7 +1677,7 @@ static void pgastatus(struct io_data *io_data, int pga, bool isjson, bool precom @@ -1653,7 +1677,7 @@ static void pgastatus(struct io_data *io_data, int pga, bool isjson, bool precom
frequency = cgpu->clock;
#endif
cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
cgpu->utility = cgpu->accepted / dev_runtime * 60;
if (cgpu->deven != DEV_DISABLED)
enabled = (char *)YES;
@ -1668,7 +1692,7 @@ static void pgastatus(struct io_data *io_data, int pga, bool isjson, bool precom @@ -1668,7 +1692,7 @@ static void pgastatus(struct io_data *io_data, int pga, bool isjson, bool precom
root = api_add_string(root, "Enabled", enabled, false);
root = api_add_string(root, "Status", status, false);
root = api_add_temp(root, "Temperature", &temp, false);
double mhs = cgpu->total_mhashes / total_secs;
double mhs = cgpu->total_mhashes / dev_runtime;
root = api_add_mhs(root, "MHS av", &mhs, false);
char mhsname[27];
sprintf(mhsname, "MHS %ds", opt_log_interval);

45
cgminer.c

@ -1989,8 +1989,20 @@ static void get_statline(char *buf, struct cgpu_info *cgpu) @@ -1989,8 +1989,20 @@ static void get_statline(char *buf, struct cgpu_info *cgpu)
{
char displayed_hashes[16], displayed_rolling[16];
uint64_t dh64, dr64;
struct timeval now;
double dev_runtime;
if (cgpu->dev_start_tv.tv_sec == 0)
dev_runtime = total_secs;
else {
cgtime(&now);
dev_runtime = tdiff(&now, &(cgpu->dev_start_tv));
}
dh64 = (double)cgpu->total_mhashes / total_secs * 1000000ull;
if (dev_runtime < 1.0)
dev_runtime = 1.0;
dh64 = (double)cgpu->total_mhashes / dev_runtime * 1000000ull;
dr64 = (double)cgpu->rolling * 1000000ull;
suffix_string(dh64, displayed_hashes, 4);
suffix_string(dr64, displayed_rolling, 4);
@ -2070,6 +2082,8 @@ static void curses_print_devstatus(struct cgpu_info *cgpu, int count) @@ -2070,6 +2082,8 @@ static void curses_print_devstatus(struct cgpu_info *cgpu, int count)
char logline[256];
char displayed_hashes[16], displayed_rolling[16];
uint64_t dh64, dr64;
struct timeval now;
double dev_runtime;
if (opt_compact)
return;
@ -2077,7 +2091,17 @@ static void curses_print_devstatus(struct cgpu_info *cgpu, int count) @@ -2077,7 +2091,17 @@ static void curses_print_devstatus(struct cgpu_info *cgpu, int count)
if (devcursor + count > LINES - 2)
return;
cgpu->utility = cgpu->accepted / total_secs * 60;
if (cgpu->dev_start_tv.tv_sec == 0)
dev_runtime = total_secs;
else {
cgtime(&now);
dev_runtime = tdiff(&now, &(cgpu->dev_start_tv));
}
if (dev_runtime < 1.0)
dev_runtime = 1.0;
cgpu->utility = cgpu->accepted / dev_runtime * 60;
wmove(statuswin,devcursor + count, 0);
wprintw(statuswin, " %s %*d: ", cgpu->drv->name, dev_width, cgpu->device_id);
@ -2085,7 +2109,7 @@ static void curses_print_devstatus(struct cgpu_info *cgpu, int count) @@ -2085,7 +2109,7 @@ static void curses_print_devstatus(struct cgpu_info *cgpu, int count)
cgpu->drv->get_statline_before(logline, cgpu);
wprintw(statuswin, "%s", logline);
dh64 = (double)cgpu->total_mhashes / total_secs * 1000000ull;
dh64 = (double)cgpu->total_mhashes / dev_runtime * 1000000ull;
dr64 = (double)cgpu->rolling * 1000000ull;
suffix_string(dh64, displayed_hashes, 4);
suffix_string(dr64, displayed_rolling, 4);
@ -2432,6 +2456,8 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit) @@ -2432,6 +2456,8 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
struct timeval tv_submit, tv_submit_reply;
char hashshow[64 + 4] = "";
char worktime[200] = "";
struct timeval now;
double dev_runtime;
cgpu = get_thr_cgpu(thr_id);
@ -2570,7 +2596,17 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit) @@ -2570,7 +2596,17 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
share_result(val, res, err, work, hashshow, resubmit, worktime);
cgpu->utility = cgpu->accepted / total_secs * 60;
if (cgpu->dev_start_tv.tv_sec == 0)
dev_runtime = total_secs;
else {
cgtime(&now);
dev_runtime = tdiff(&now, &(cgpu->dev_start_tv));
}
if (dev_runtime < 1.0)
dev_runtime = 1.0;
cgpu->utility = cgpu->accepted / dev_runtime * 60;
if (!opt_realquiet)
print_status(thr_id);
@ -7170,6 +7206,7 @@ static void hotplug_process() @@ -7170,6 +7206,7 @@ static void hotplug_process()
cgpu->thr = malloc(sizeof(*cgpu->thr) * (cgpu->threads+1));
cgpu->thr[cgpu->threads] = NULL;
cgpu->status = LIFE_INIT;
cgtime(&(cgpu->dev_start_tv));
for (j = 0; j < cgpu->threads; ++j) {
thr = get_thread(mining_threads);

2
driver-modminer.c

@ -552,6 +552,8 @@ static bool modminer_fpga_upload_bitstream(struct cgpu_info *modminer) @@ -552,6 +552,8 @@ static bool modminer_fpga_upload_bitstream(struct cgpu_info *modminer)
// Give it a 2/3s delay after programming
nmsleep(666);
usb_set_dev_start(modminer);
return true;
undame:
;

2
miner.h

@ -555,6 +555,8 @@ struct cgpu_info { @@ -555,6 +555,8 @@ struct cgpu_info {
unsigned int queued_count;
bool shutdown;
struct timeval dev_start_tv;
};
extern bool add_cgpu(struct cgpu_info*);

21
usbutils.c

@ -2690,6 +2690,27 @@ uint32_t usb_buffer_size(struct cgpu_info *cgpu) @@ -2690,6 +2690,27 @@ uint32_t usb_buffer_size(struct cgpu_info *cgpu)
return cgusb->bufamt;
}
// Need to set all devices with matching usbdev
void usb_set_dev_start(struct cgpu_info *cgpu)
{
struct cg_usb_device *cgusb = cgpu->usbdev;
struct cgpu_info *cgpu2;
struct timeval now;
// If the device wasn't dropped
if (cgusb != NULL) {
int i;
cgtime(&now);
for (i = 0; i < total_devices; i++) {
cgpu2 = get_devices(i);
if (cgpu2->usbdev == cgusb)
copy_time(&(cgpu2->dev_start_tv), &now);
}
}
}
void usb_cleanup()
{
struct cgpu_info *cgpu;

1
usbutils.h

@ -290,6 +290,7 @@ void usb_buffer_enable(struct cgpu_info *cgpu); @@ -290,6 +290,7 @@ void usb_buffer_enable(struct cgpu_info *cgpu);
void usb_buffer_disable(struct cgpu_info *cgpu);
void usb_buffer_clear(struct cgpu_info *cgpu);
uint32_t usb_buffer_size(struct cgpu_info *cgpu);
void usb_set_dev_start(struct cgpu_info *cgpu);
void usb_cleanup();
void usb_initialise();
void *usb_resource_thread(void *userdata);

Loading…
Cancel
Save