Adjust opencl intensity when adjusting thread count to prevent it getting pegged at a value below the minimum threads possible.
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
diff --git a/driver-opencl.c b/driver-opencl.c
index 6883ada..ded20c3 100644
--- a/driver-opencl.c
+++ b/driver-opencl.c
@@ -1106,20 +1106,23 @@ static cl_int queue_scrypt_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_u
}
#endif
-static void set_threads_hashes(unsigned int vectors, unsigned int *threads,
- int64_t *hashes, size_t *globalThreads,
- unsigned int minthreads, int intensity)
+static void set_threads_hashes(unsigned int vectors,int64_t *hashes, size_t *globalThreads,
+ unsigned int minthreads, __maybe_unused int *intensity)
{
- if (opt_scrypt) {
- if (intensity < 0)
- intensity = 0;
- *threads = 1 << intensity;
- } else
- *threads = 1 << (15 + intensity);
- if (*threads < minthreads)
- *threads = minthreads;
- *globalThreads = *threads;
- *hashes = *threads * vectors;
+ unsigned int threads = 0;
+
+ while (threads < minthreads) {
+ threads = 1 << ((opt_scrypt ? 0 : 15) + *intensity);
+ if (threads < minthreads) {
+ if (likely(*intensity < MAX_INTENSITY))
+ (*intensity)++;
+ else
+ threads = minthreads;
+ }
+ }
+
+ *globalThreads = threads;
+ *hashes = threads * vectors;
}
#endif /* HAVE_OPENCL */
@@ -1499,15 +1502,13 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
cl_int status;
size_t globalThreads[1];
size_t localThreads[1] = { clState->wsize };
- unsigned int threads;
int64_t hashes;
/* This finish flushes the readbuffer set with CL_FALSE later */
if (!gpu->dynamic)
clFinish(clState->commandQueue);
- set_threads_hashes(clState->vwidth, &threads, &hashes, globalThreads,
- localThreads[0], gpu->intensity);
+ set_threads_hashes(clState->vwidth, &hashes, globalThreads, localThreads[0], &gpu->intensity);
if (hashes > gpu->max_hashes)
gpu->max_hashes = hashes;