Make dynamic and scrypt opencl calls blocking.
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 59 60 61 62 63
diff --git a/driver-opencl.c b/driver-opencl.c
index 5e79d2b..ffe2fda 100644
--- a/driver-opencl.c
+++ b/driver-opencl.c
@@ -1395,6 +1395,7 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
_clState *clState = clStates[thr_id];
const cl_kernel *kernel = &clState->kernel;
const int dynamic_us = opt_dynamic_interval * 1000;
+ cl_bool blocking;
cl_int status;
size_t globalThreads[1];
@@ -1402,14 +1403,20 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
unsigned int threads;
int64_t hashes;
+ if (gpu->dynamic || opt_scrypt)
+ blocking = CL_TRUE;
+ else
+ blocking = CL_FALSE;
+
/* This finish flushes the readbuffer set with CL_FALSE later */
- clFinish(clState->commandQueue);
- gettimeofday(&gpu->tv_gpuend, NULL);
+ if (!blocking)
+ clFinish(clState->commandQueue);
if (gpu->dynamic) {
struct timeval diff;
suseconds_t gpu_us;
+ gettimeofday(&gpu->tv_gpuend, NULL);
timersub(&gpu->tv_gpuend, &gpu->tv_gpustart, &diff);
gpu_us = diff.tv_sec * 1000000 + diff.tv_usec;
if (likely(gpu_us >= 0)) {
@@ -1440,7 +1447,7 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
/* MAXBUFFERS entry is used as a flag to say nonces exist */
if (thrdata->res[FOUND]) {
/* Clear the buffer again */
- status = clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, CL_FALSE, 0,
+ status = clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, blocking, 0,
BUFFERSIZE, blank_res, 0, NULL, NULL);
if (unlikely(status != CL_SUCCESS)) {
applog(LOG_ERR, "Error: clEnqueueWriteBuffer failed.");
@@ -1455,7 +1462,8 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
postcalc_hash_async(thr, work, thrdata->res);
}
memset(thrdata->res, 0, BUFFERSIZE);
- clFinish(clState->commandQueue);
+ if (!blocking)
+ clFinish(clState->commandQueue);
}
gettimeofday(&gpu->tv_gpustart, NULL);
@@ -1474,7 +1482,7 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
return -1;
}
- status = clEnqueueReadBuffer(clState->commandQueue, clState->outputBuffer, CL_FALSE, 0,
+ status = clEnqueueReadBuffer(clState->commandQueue, clState->outputBuffer, blocking, 0,
BUFFERSIZE, thrdata->res, 0, NULL, NULL);
if (unlikely(status != CL_SUCCESS)) {
applog(LOG_ERR, "Error: clEnqueueReadBuffer failed error %d. (clEnqueueReadBuffer)", status);