mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-22 20:44:19 +00:00
Do away with the flaky free_work api in the driver code which would often lose the work data in opencl and simply flush it before exiting the opencl scanhash.
This commit is contained in:
parent
c34ff36763
commit
217be6ed98
@ -5535,8 +5535,6 @@ void *miner_thread(void *userdata)
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
mythr->work_restart = false;
|
mythr->work_restart = false;
|
||||||
if (api->free_work && likely(work->pool))
|
|
||||||
api->free_work(mythr, work);
|
|
||||||
get_work(work, mythr, thr_id);
|
get_work(work, mythr, thr_id);
|
||||||
cgpu->new_work = true;
|
cgpu->new_work = true;
|
||||||
|
|
||||||
|
@ -1455,17 +1455,6 @@ static bool opencl_thread_init(struct thr_info *thr)
|
|||||||
return true;
|
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)
|
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 };
|
size_t localThreads[1] = { clState->wsize };
|
||||||
int64_t hashes;
|
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 */
|
/* Windows' timer resolution is only 15ms so oversample 5x */
|
||||||
if (gpu->dynamic && (++gpu->intervals * dynamic_us) > 70000) {
|
if (gpu->dynamic && (++gpu->intervals * dynamic_us) > 70000) {
|
||||||
struct timeval tv_gpuend;
|
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)
|
if (hashes > gpu->max_hashes)
|
||||||
gpu->max_hashes = 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]);
|
status = thrdata->queue_kernel_parameters(clState, &work->blk, globalThreads[0]);
|
||||||
if (unlikely(status != CL_SUCCESS)) {
|
if (unlikely(status != CL_SUCCESS)) {
|
||||||
applog(LOG_ERR, "Error: clSetKernelArg of all params failed.");
|
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 */
|
* than enough to prevent repeating work */
|
||||||
work->blk.nonce += gpu->max_hashes;
|
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;
|
return hashes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1599,7 +1589,6 @@ struct device_api opencl_api = {
|
|||||||
.get_statline = get_opencl_statline,
|
.get_statline = get_opencl_statline,
|
||||||
.thread_prepare = opencl_thread_prepare,
|
.thread_prepare = opencl_thread_prepare,
|
||||||
.thread_init = opencl_thread_init,
|
.thread_init = opencl_thread_init,
|
||||||
.free_work = opencl_free_work,
|
|
||||||
.prepare_work = opencl_prepare_work,
|
.prepare_work = opencl_prepare_work,
|
||||||
.scanhash = opencl_scanhash,
|
.scanhash = opencl_scanhash,
|
||||||
.thread_shutdown = opencl_thread_shutdown,
|
.thread_shutdown = opencl_thread_shutdown,
|
||||||
|
1
miner.h
1
miner.h
@ -268,7 +268,6 @@ struct device_api {
|
|||||||
bool (*thread_prepare)(struct thr_info*);
|
bool (*thread_prepare)(struct thr_info*);
|
||||||
uint64_t (*can_limit_work)(struct thr_info*);
|
uint64_t (*can_limit_work)(struct thr_info*);
|
||||||
bool (*thread_init)(struct thr_info*);
|
bool (*thread_init)(struct thr_info*);
|
||||||
void (*free_work)(struct thr_info*, struct work*);
|
|
||||||
bool (*prepare_work)(struct thr_info*, struct work*);
|
bool (*prepare_work)(struct thr_info*, struct work*);
|
||||||
int64_t (*scanhash)(struct thr_info*, struct work*, int64_t);
|
int64_t (*scanhash)(struct thr_info*, struct work*, int64_t);
|
||||||
void (*hw_error)(struct thr_info*);
|
void (*hw_error)(struct thr_info*);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user