|
|
@ -1325,9 +1325,10 @@ static bool opencl_thread_prepare(struct thr_info *thr) |
|
|
|
int virtual_gpu = cgpu->virtual_gpu; |
|
|
|
int virtual_gpu = cgpu->virtual_gpu; |
|
|
|
int i = thr->id; |
|
|
|
int i = thr->id; |
|
|
|
static bool failmessage = false; |
|
|
|
static bool failmessage = false; |
|
|
|
|
|
|
|
int buffersize = opt_scrypt ? SCRYPT_BUFFERSIZE : BUFFERSIZE; |
|
|
|
|
|
|
|
|
|
|
|
if (!blank_res) |
|
|
|
if (!blank_res) |
|
|
|
blank_res = calloc(BUFFERSIZE, 1); |
|
|
|
blank_res = calloc(buffersize, 1); |
|
|
|
if (!blank_res) { |
|
|
|
if (!blank_res) { |
|
|
|
applog(LOG_ERR, "Failed to calloc in opencl_thread_init"); |
|
|
|
applog(LOG_ERR, "Failed to calloc in opencl_thread_init"); |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -1406,6 +1407,7 @@ static bool opencl_thread_init(struct thr_info *thr) |
|
|
|
cl_int status = 0; |
|
|
|
cl_int status = 0; |
|
|
|
thrdata = calloc(1, sizeof(*thrdata)); |
|
|
|
thrdata = calloc(1, sizeof(*thrdata)); |
|
|
|
thr->cgpu_data = thrdata; |
|
|
|
thr->cgpu_data = thrdata; |
|
|
|
|
|
|
|
int buffersize = opt_scrypt ? SCRYPT_BUFFERSIZE : BUFFERSIZE; |
|
|
|
|
|
|
|
|
|
|
|
if (!thrdata) { |
|
|
|
if (!thrdata) { |
|
|
|
applog(LOG_ERR, "Failed to calloc in opencl_thread_init"); |
|
|
|
applog(LOG_ERR, "Failed to calloc in opencl_thread_init"); |
|
|
@ -1433,7 +1435,7 @@ static bool opencl_thread_init(struct thr_info *thr) |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
thrdata->res = calloc(BUFFERSIZE, 1); |
|
|
|
thrdata->res = calloc(buffersize, 1); |
|
|
|
|
|
|
|
|
|
|
|
if (!thrdata->res) { |
|
|
|
if (!thrdata->res) { |
|
|
|
free(thrdata); |
|
|
|
free(thrdata); |
|
|
@ -1442,7 +1444,7 @@ static bool opencl_thread_init(struct thr_info *thr) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
status |= clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, CL_TRUE, 0, |
|
|
|
status |= clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, CL_TRUE, 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."); |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -1483,6 +1485,8 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work, |
|
|
|
size_t globalThreads[1]; |
|
|
|
size_t globalThreads[1]; |
|
|
|
size_t localThreads[1] = { clState->wsize }; |
|
|
|
size_t localThreads[1] = { clState->wsize }; |
|
|
|
int64_t hashes; |
|
|
|
int64_t hashes; |
|
|
|
|
|
|
|
int found = opt_scrypt ? SCRYPT_FOUND : FOUND; |
|
|
|
|
|
|
|
int buffersize = opt_scrypt ? SCRYPT_BUFFERSIZE : BUFFERSIZE; |
|
|
|
|
|
|
|
|
|
|
|
/* 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) { |
|
|
@ -1527,7 +1531,7 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
status = clEnqueueReadBuffer(clState->commandQueue, clState->outputBuffer, CL_FALSE, 0, |
|
|
|
status = clEnqueueReadBuffer(clState->commandQueue, clState->outputBuffer, CL_FALSE, 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); |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
@ -1542,17 +1546,17 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work, |
|
|
|
clFinish(clState->commandQueue); |
|
|
|
clFinish(clState->commandQueue); |
|
|
|
|
|
|
|
|
|
|
|
/* FOUND entry is used as a counter to say how many nonces exist */ |
|
|
|
/* FOUND entry is used as a counter to say how many 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, CL_FALSE, 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."); |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
applog(LOG_DEBUG, "GPU %d found something?", gpu->device_id); |
|
|
|
applog(LOG_DEBUG, "GPU %d found something?", gpu->device_id); |
|
|
|
postcalc_hash_async(thr, work, thrdata->res); |
|
|
|
postcalc_hash_async(thr, work, thrdata->res); |
|
|
|
memset(thrdata->res, 0, BUFFERSIZE); |
|
|
|
memset(thrdata->res, 0, buffersize); |
|
|
|
/* This finish flushes the writebuffer set with CL_FALSE in clEnqueueWriteBuffer */ |
|
|
|
/* This finish flushes the writebuffer set with CL_FALSE in clEnqueueWriteBuffer */ |
|
|
|
clFinish(clState->commandQueue); |
|
|
|
clFinish(clState->commandQueue); |
|
|
|
} |
|
|
|
} |
|
|
|