Commit c531f1bd04b1efa19da1b57d4a7b7b59acc73bc6

ckolivas 2012-02-15T10:34:26

Use the max_hashes variable to determine when to abandon work.

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;
 }