|
|
@@ -1455,17 +1455,6 @@ static bool opencl_thread_init(struct thr_info *thr)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-static void opencl_free_work(struct thr_info *thr, struct work *work)
|
|
|
-{
|
|
|
- const int thr_id = thr->id;
|
|
|
- struct opencl_thread_data *thrdata = thr->cgpu_data;
|
|
|
- _clState *clState = clStates[thr_id];
|
|
|
-
|
|
|
- clFinish(clState->commandQueue);
|
|
|
-
|
|
|
- if (thrdata->res[FOUND])
|
|
|
- thrdata->last_work = copy_work(work);
|
|
|
-}
|
|
|
|
|
|
static bool opencl_prepare_work(struct thr_info __maybe_unused *thr, struct work *work)
|
|
|
{
|
|
|
@@ -1495,9 +1484,6 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
|
|
|
size_t localThreads[1] = { clState->wsize };
|
|
|
int64_t hashes;
|
|
|
|
|
|
- /* This finish flushes the readbuffer set with CL_FALSE later */
|
|
|
- clFinish(clState->commandQueue);
|
|
|
-
|
|
|
/* Windows' timer resolution is only 15ms so oversample 5x */
|
|
|
if (gpu->dynamic && (++gpu->intervals * dynamic_us) > 70000) {
|
|
|
struct timeval tv_gpuend;
|
|
|
@@ -1520,28 +1506,6 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
|
|
|
if (hashes > gpu->max_hashes)
|
|
|
gpu->max_hashes = hashes;
|
|
|
|
|
|
- /* FOUND entry is used as a counter to say how many nonces exist */
|
|
|
- if (thrdata->res[FOUND]) {
|
|
|
- /* Clear the buffer again */
|
|
|
- status = clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, CL_FALSE, 0,
|
|
|
- BUFFERSIZE, blank_res, 0, NULL, NULL);
|
|
|
- if (unlikely(status != CL_SUCCESS)) {
|
|
|
- applog(LOG_ERR, "Error: clEnqueueWriteBuffer failed.");
|
|
|
- return -1;
|
|
|
- }
|
|
|
- if (unlikely(thrdata->last_work)) {
|
|
|
- applog(LOG_DEBUG, "GPU %d found something in last work?", gpu->device_id);
|
|
|
- postcalc_hash_async(thr, thrdata->last_work, thrdata->res);
|
|
|
- free_work(thrdata->last_work);
|
|
|
- thrdata->last_work = NULL;
|
|
|
- } else {
|
|
|
- applog(LOG_DEBUG, "GPU %d found something?", gpu->device_id);
|
|
|
- postcalc_hash_async(thr, work, thrdata->res);
|
|
|
- }
|
|
|
- memset(thrdata->res, 0, BUFFERSIZE);
|
|
|
- clFinish(clState->commandQueue);
|
|
|
- }
|
|
|
-
|
|
|
status = thrdata->queue_kernel_parameters(clState, &work->blk, globalThreads[0]);
|
|
|
if (unlikely(status != CL_SUCCESS)) {
|
|
|
applog(LOG_ERR, "Error: clSetKernelArg of all params failed.");
|
|
|
@@ -1574,6 +1538,32 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
|
|
|
* than enough to prevent repeating work */
|
|
|
work->blk.nonce += gpu->max_hashes;
|
|
|
|
|
|
+ /* This finish flushes the readbuffer set with CL_FALSE in clEnqueueReadBuffer */
|
|
|
+ clFinish(clState->commandQueue);
|
|
|
+
|
|
|
+ /* FOUND entry is used as a counter to say how many nonces exist */
|
|
|
+ if (thrdata->res[FOUND]) {
|
|
|
+ /* Clear the buffer again */
|
|
|
+ status = clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, CL_FALSE, 0,
|
|
|
+ BUFFERSIZE, blank_res, 0, NULL, NULL);
|
|
|
+ if (unlikely(status != CL_SUCCESS)) {
|
|
|
+ applog(LOG_ERR, "Error: clEnqueueWriteBuffer failed.");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ if (unlikely(thrdata->last_work)) {
|
|
|
+ applog(LOG_DEBUG, "GPU %d found something in last work?", gpu->device_id);
|
|
|
+ postcalc_hash_async(thr, thrdata->last_work, thrdata->res);
|
|
|
+ free_work(thrdata->last_work);
|
|
|
+ thrdata->last_work = NULL;
|
|
|
+ } else {
|
|
|
+ applog(LOG_DEBUG, "GPU %d found something?", gpu->device_id);
|
|
|
+ postcalc_hash_async(thr, work, thrdata->res);
|
|
|
+ }
|
|
|
+ memset(thrdata->res, 0, BUFFERSIZE);
|
|
|
+ /* This finish flushes the writebuffer set with CL_FALSE in clEnqueueWriteBuffer */
|
|
|
+ clFinish(clState->commandQueue);
|
|
|
+ }
|
|
|
+
|
|
|
return hashes;
|
|
|
}
|
|
|
|
|
|
@@ -1599,7 +1589,6 @@ struct device_api opencl_api = {
|
|
|
.get_statline = get_opencl_statline,
|
|
|
.thread_prepare = opencl_thread_prepare,
|
|
|
.thread_init = opencl_thread_init,
|
|
|
- .free_work = opencl_free_work,
|
|
|
.prepare_work = opencl_prepare_work,
|
|
|
.scanhash = opencl_scanhash,
|
|
|
.thread_shutdown = opencl_thread_shutdown,
|