Calculate work utility for devices that support target diffs of greater than 1, and update scrypt code to use it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
diff --git a/cgminer.c b/cgminer.c
index aebdf2e..c883afe 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2021,15 +2021,9 @@ static void curses_print_status(void)
mvwhline(statuswin, 1, 0, '-', 80);
mvwprintw(statuswin, 2, 0, " %s", statusline);
wclrtoeol(statuswin);
- if (opt_scrypt) {
- mvwprintw(statuswin, 3, 0, " ST: %d SS: %d DW: %d NB: %d LW: %d GF: %d RF: %d",
- total_staged(), total_stale, total_discarded, new_blocks,
- local_work, total_go, total_ro);
- } else {
- mvwprintw(statuswin, 3, 0, " ST: %d SS: %d DW: %d NB: %d LW: %d GF: %d RF: %d WU: %.1f",
- total_staged(), total_stale, total_discarded, new_blocks,
- local_work, total_go, total_ro, total_diff1 / total_secs * 60);
- }
+ mvwprintw(statuswin, 3, 0, " ST: %d SS: %d DW: %d NB: %d LW: %d GF: %d RF: %d WU: %.1f",
+ total_staged(), total_stale, total_discarded, new_blocks,
+ local_work, total_go, total_ro, total_diff1 / total_secs * 60);
wclrtoeol(statuswin);
if ((pool_strategy == POOL_LOADBALANCE || pool_strategy == POOL_BALANCE) && total_pools > 1) {
mvwprintw(statuswin, 4, 0, " Connected to multiple pools with%s LP",
@@ -5558,9 +5552,9 @@ void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
*work_nonce = htole32(nonce);
mutex_lock(&stats_lock);
- total_diff1++;
- thr->cgpu->diff1++;
- work->pool->diff1++;
+ total_diff1 += work->device_diff;
+ thr->cgpu->diff1 += work->device_diff;
+ work->pool->diff1 += work->device_diff;
mutex_unlock(&stats_lock);
/* Do one last check before attempting to submit the work */
@@ -5632,6 +5626,7 @@ static void hash_sole_work(struct thr_info *mythr)
"mining thread %d", thr_id);
break;
}
+ work->device_diff = MIN(drv->max_diff, work->work_difficulty);
do {
gettimeofday(&tv_start, NULL);
@@ -5757,6 +5752,7 @@ static void fill_queue(struct thr_info *mythr, struct cgpu_info *cgpu, struct de
do {
struct work *work = get_work(mythr, thr_id);
+ work->device_diff = MIN(drv->max_diff, work->work_difficulty);
wr_lock(&cgpu->qlock);
HASH_ADD_INT(cgpu->queued_work, id, work);
wr_unlock(&cgpu->qlock);
@@ -6862,6 +6858,8 @@ void fill_device_drv(struct cgpu_info *cgpu)
drv->flush_work = &noop_flush_work;
if (!drv->queue_full)
drv->queue_full = &noop_queue_full;
+ if (!drv->max_diff)
+ drv->max_diff = 1;
}
void enable_device(struct cgpu_info *cgpu)
diff --git a/driver-opencl.c b/driver-opencl.c
index d117e2e..af73ac8 100644
--- a/driver-opencl.c
+++ b/driver-opencl.c
@@ -1254,6 +1254,9 @@ static void opencl_detect()
opt_g_threads = 2;
}
+ if (opt_scrypt)
+ opencl_drv.max_diff = 65536;
+
for (i = 0; i < nDevs; ++i) {
struct cgpu_info *cgpu;
diff --git a/miner.h b/miner.h
index cd15b40..ee8ce52 100644
--- a/miner.h
+++ b/miner.h
@@ -196,6 +196,9 @@ static inline int fsync (int fd)
#endif
#endif
+#define MIN(x, y) ((x) > (y) ? (y) : (x))
+#define MAX(x, y) ((x) > (y) ? (x) : (y))
+
enum drv_driver {
DRIVER_OPENCL = 0,
DRIVER_ICARUS,
@@ -320,6 +323,9 @@ struct device_drv {
// Does it need to be free()d?
bool copy;
+
+ /* Highest target diff the device supports */
+ double max_diff;
};
extern struct device_drv *copy_drv(struct device_drv*);
@@ -1099,6 +1105,8 @@ struct work {
unsigned char target[32];
unsigned char hash[32];
+ double device_diff;
+
int rolls;
dev_blk_ctx blk;