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