Browse Source

Calculate work utility for devices that support target diffs of greater than 1, and update scrypt code to use it.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
13e19de4d5
  1. 16
      cgminer.c
  2. 3
      driver-opencl.c
  3. 8
      miner.h

16
cgminer.c

@ -2021,15 +2021,9 @@ static void curses_print_status(void)
mvwhline(statuswin, 1, 0, '-', 80); mvwhline(statuswin, 1, 0, '-', 80);
mvwprintw(statuswin, 2, 0, " %s", statusline); mvwprintw(statuswin, 2, 0, " %s", statusline);
wclrtoeol(statuswin); 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", 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, total_staged(), total_stale, total_discarded, new_blocks,
local_work, total_go, total_ro, total_diff1 / total_secs * 60); local_work, total_go, total_ro, total_diff1 / total_secs * 60);
}
wclrtoeol(statuswin); wclrtoeol(statuswin);
if ((pool_strategy == POOL_LOADBALANCE || pool_strategy == POOL_BALANCE) && total_pools > 1) { if ((pool_strategy == POOL_LOADBALANCE || pool_strategy == POOL_BALANCE) && total_pools > 1) {
mvwprintw(statuswin, 4, 0, " Connected to multiple pools with%s LP", 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); *work_nonce = htole32(nonce);
mutex_lock(&stats_lock); mutex_lock(&stats_lock);
total_diff1++; total_diff1 += work->device_diff;
thr->cgpu->diff1++; thr->cgpu->diff1 += work->device_diff;
work->pool->diff1++; work->pool->diff1 += work->device_diff;
mutex_unlock(&stats_lock); mutex_unlock(&stats_lock);
/* Do one last check before attempting to submit the work */ /* 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); "mining thread %d", thr_id);
break; break;
} }
work->device_diff = MIN(drv->max_diff, work->work_difficulty);
do { do {
gettimeofday(&tv_start, NULL); gettimeofday(&tv_start, NULL);
@ -5757,6 +5752,7 @@ static void fill_queue(struct thr_info *mythr, struct cgpu_info *cgpu, struct de
do { do {
struct work *work = get_work(mythr, thr_id); struct work *work = get_work(mythr, thr_id);
work->device_diff = MIN(drv->max_diff, work->work_difficulty);
wr_lock(&cgpu->qlock); wr_lock(&cgpu->qlock);
HASH_ADD_INT(cgpu->queued_work, id, work); HASH_ADD_INT(cgpu->queued_work, id, work);
wr_unlock(&cgpu->qlock); wr_unlock(&cgpu->qlock);
@ -6862,6 +6858,8 @@ void fill_device_drv(struct cgpu_info *cgpu)
drv->flush_work = &noop_flush_work; drv->flush_work = &noop_flush_work;
if (!drv->queue_full) if (!drv->queue_full)
drv->queue_full = &noop_queue_full; drv->queue_full = &noop_queue_full;
if (!drv->max_diff)
drv->max_diff = 1;
} }
void enable_device(struct cgpu_info *cgpu) void enable_device(struct cgpu_info *cgpu)

3
driver-opencl.c

@ -1254,6 +1254,9 @@ static void opencl_detect()
opt_g_threads = 2; opt_g_threads = 2;
} }
if (opt_scrypt)
opencl_drv.max_diff = 65536;
for (i = 0; i < nDevs; ++i) { for (i = 0; i < nDevs; ++i) {
struct cgpu_info *cgpu; struct cgpu_info *cgpu;

8
miner.h

@ -196,6 +196,9 @@ static inline int fsync (int fd)
#endif #endif
#endif #endif
#define MIN(x, y) ((x) > (y) ? (y) : (x))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
enum drv_driver { enum drv_driver {
DRIVER_OPENCL = 0, DRIVER_OPENCL = 0,
DRIVER_ICARUS, DRIVER_ICARUS,
@ -320,6 +323,9 @@ struct device_drv {
// Does it need to be free()d? // Does it need to be free()d?
bool copy; bool copy;
/* Highest target diff the device supports */
double max_diff;
}; };
extern struct device_drv *copy_drv(struct device_drv*); extern struct device_drv *copy_drv(struct device_drv*);
@ -1099,6 +1105,8 @@ struct work {
unsigned char target[32]; unsigned char target[32];
unsigned char hash[32]; unsigned char hash[32];
double device_diff;
int rolls; int rolls;
dev_blk_ctx blk; dev_blk_ctx blk;

Loading…
Cancel
Save