Use the max_hashes variable to determine when to abandon work.
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
diff --git a/cgminer.c b/cgminer.c
index 2c457ca..75ef41f 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -3292,6 +3292,7 @@ void *miner_thread(void *userdata)
cycle = (can_roll(work) && should_roll(work)) ? 1 : def_cycle;
gettimeofday(&tv_workstart, NULL);
work->blk.nonce = 0;
+ cgpu->max_hashes = 0;
if (api->prepare_work && !api->prepare_work(mythr, work)) {
applog(LOG_ERR, "work prepare failed, exiting "
"mining thread %d", thr_id);
@@ -3321,6 +3322,8 @@ void *miner_thread(void *userdata)
if (unlikely(!hashes))
goto out;
hashes_done += hashes;
+ if (hashes > cgpu->max_hashes)
+ cgpu->max_hashes = hashes;
gettimeofday(&tv_end, NULL);
timeval_subtract(&diff, &tv_end, &tv_start);
@@ -3380,7 +3383,7 @@ void *miner_thread(void *userdata)
}
sdiff.tv_sec = sdiff.tv_usec = 0;
- } while (!abandon_work(work, &wdiff, hashes));
+ } while (!abandon_work(work, &wdiff, cgpu->max_hashes));
}
out:
diff --git a/device-gpu.c b/device-gpu.c
index 6fe53a3..2113dc9 100644
--- a/device-gpu.c
+++ b/device-gpu.c
@@ -1219,7 +1219,7 @@ static uint64_t opencl_scanhash(struct thr_info *thr, struct work *work,
}
set_threads_hashes(clState->preferred_vwidth, &threads, &hashes, globalThreads,
localThreads[0], gpu->intensity);
- if (gpu->dynamic && hashes > gpu->max_hashes)
+ if (hashes > gpu->max_hashes)
gpu->max_hashes = hashes;
status = thrdata->queue_kernel_parameters(clState, &work->blk);
if (unlikely(status != CL_SUCCESS)) {
@@ -1264,10 +1264,7 @@ static uint64_t opencl_scanhash(struct thr_info *thr, struct work *work,
/* The amount of work scanned can fluctuate when intensity changes
* and since we do this one cycle behind, we increment the work more
* than enough to prevent repeating work */
- if (gpu->dynamic)
- work->blk.nonce += gpu->max_hashes;
- else
- work->blk.nonce += hashes;
+ work->blk.nonce += gpu->max_hashes;
return hashes;
}