Browse Source

Use a discrete device target for scrypt that dynamically changes to ensure we still report a work utility even if no shares are submitted such as in solo mining.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
1a7a87c2a6
  1. 23
      cgminer.c
  2. 2
      driver-opencl.c
  3. 4
      miner.h

23
cgminer.c

@ -5566,7 +5566,26 @@ static void hash_sole_work(struct thr_info *mythr) @@ -5566,7 +5566,26 @@ 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);
work->device_diff = MIN(drv->working_diff, work->work_difficulty);
#ifdef USE_SCRYPT
/* Dynamically adjust the working diff even if the target
* diff is very high to ensure we can still validate scrypt is
* returning shares. */
if (opt_scrypt) {
double wu;
wu = total_diff1 / total_secs * 60;
if (wu > 30 && drv->working_diff < drv->max_diff &&
drv->working_diff < work->work_difficulty) {
drv->working_diff++;
applog(LOG_DEBUG, "Driver %s working diff changed to %.0f",
drv->dname, drv->working_diff);
work->device_diff = MIN(drv->working_diff, work->work_difficulty);
} else if (drv->working_diff > work->work_difficulty)
drv->working_diff = work->work_difficulty;
set_target(work->device_target, work->device_diff);
}
#endif
do {
cgtime(&tv_start);
@ -6821,6 +6840,8 @@ void fill_device_drv(struct cgpu_info *cgpu) @@ -6821,6 +6840,8 @@ void fill_device_drv(struct cgpu_info *cgpu)
drv->queue_full = &noop_queue_full;
if (!drv->max_diff)
drv->max_diff = 1;
if (!drv->working_diff)
drv->working_diff = 1;
}
void enable_device(struct cgpu_info *cgpu)

2
driver-opencl.c

@ -1081,7 +1081,7 @@ static cl_int queue_scrypt_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_u @@ -1081,7 +1081,7 @@ static cl_int queue_scrypt_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_u
cl_uint le_target;
cl_int status = 0;
le_target = *(cl_uint *)(blk->work->target + 28);
le_target = *(cl_uint *)(blk->work->device_target + 28);
clState->cldata = blk->work->data;
status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 80, clState->cldata, 0, NULL,NULL);

4
miner.h

@ -336,6 +336,7 @@ struct device_drv { @@ -336,6 +336,7 @@ struct device_drv {
/* Highest target diff the device supports */
double max_diff;
double working_diff;
};
extern struct device_drv *copy_drv(struct device_drv*);
@ -1161,6 +1162,9 @@ struct work { @@ -1161,6 +1162,9 @@ struct work {
unsigned char target[32];
unsigned char hash[32];
#ifdef USE_SCRYPT
unsigned char device_target[32];
#endif
double device_diff;
uint64_t share_diff;

Loading…
Cancel
Save