|
|
@ -1057,7 +1057,7 @@ static void set_threads_hashes(unsigned int vectors, unsigned int compute_shader |
|
|
|
* GPU */ |
|
|
|
* GPU */ |
|
|
|
void *reinit_gpu(void *userdata) |
|
|
|
void *reinit_gpu(void *userdata) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct thr_info *mythr = userdata; |
|
|
|
struct thr_info *mythr = (struct thr_info *)userdata; |
|
|
|
struct cgpu_info *cgpu; |
|
|
|
struct cgpu_info *cgpu; |
|
|
|
struct thr_info *thr; |
|
|
|
struct thr_info *thr; |
|
|
|
struct timeval now; |
|
|
|
struct timeval now; |
|
|
@ -1068,7 +1068,7 @@ void *reinit_gpu(void *userdata) |
|
|
|
pthread_detach(pthread_self()); |
|
|
|
pthread_detach(pthread_self()); |
|
|
|
|
|
|
|
|
|
|
|
select_cgpu: |
|
|
|
select_cgpu: |
|
|
|
cgpu = tq_pop(mythr->q, NULL); |
|
|
|
cgpu = (struct cgpu_info *)tq_pop(mythr->q, NULL); |
|
|
|
if (!cgpu) |
|
|
|
if (!cgpu) |
|
|
|
goto out; |
|
|
|
goto out; |
|
|
|
|
|
|
|
|
|
|
@ -1257,7 +1257,7 @@ static bool opencl_thread_prepare(struct thr_info *thr) |
|
|
|
int buffersize = BUFFERSIZE; |
|
|
|
int buffersize = BUFFERSIZE; |
|
|
|
|
|
|
|
|
|
|
|
if (!blank_res) |
|
|
|
if (!blank_res) |
|
|
|
blank_res = calloc(buffersize, 1); |
|
|
|
blank_res = (uint32_t *)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; |
|
|
@ -1327,7 +1327,7 @@ static bool opencl_thread_init(struct thr_info *thr) |
|
|
|
struct opencl_thread_data *thrdata; |
|
|
|
struct opencl_thread_data *thrdata; |
|
|
|
_clState *clState = clStates[thr_id]; |
|
|
|
_clState *clState = clStates[thr_id]; |
|
|
|
cl_int status = 0; |
|
|
|
cl_int status = 0; |
|
|
|
thrdata = calloc(1, sizeof(*thrdata)); |
|
|
|
thrdata = (struct opencl_thread_data *)calloc(1, sizeof(*thrdata)); |
|
|
|
thr->cgpu_data = thrdata; |
|
|
|
thr->cgpu_data = thrdata; |
|
|
|
int buffersize = BUFFERSIZE; |
|
|
|
int buffersize = BUFFERSIZE; |
|
|
|
|
|
|
|
|
|
|
@ -1348,7 +1348,7 @@ static bool opencl_thread_init(struct thr_info *thr) |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
thrdata->res = calloc(buffersize, 1); |
|
|
|
thrdata->res = (uint32_t *)calloc(buffersize, 1); |
|
|
|
|
|
|
|
|
|
|
|
if (!thrdata->res) { |
|
|
|
if (!thrdata->res) { |
|
|
|
free(thrdata); |
|
|
|
free(thrdata); |
|
|
@ -1383,7 +1383,7 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work, |
|
|
|
int64_t __maybe_unused max_nonce) |
|
|
|
int64_t __maybe_unused max_nonce) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const int thr_id = thr->id; |
|
|
|
const int thr_id = thr->id; |
|
|
|
struct opencl_thread_data *thrdata = thr->cgpu_data; |
|
|
|
struct opencl_thread_data *thrdata = (struct opencl_thread_data *)thr->cgpu_data; |
|
|
|
struct cgpu_info *gpu = thr->cgpu; |
|
|
|
struct cgpu_info *gpu = thr->cgpu; |
|
|
|
_clState *clState = clStates[thr_id]; |
|
|
|
_clState *clState = clStates[thr_id]; |
|
|
|
const cl_kernel *kernel = &clState->kernel; |
|
|
|
const cl_kernel *kernel = &clState->kernel; |
|
|
@ -1485,18 +1485,36 @@ static void opencl_thread_shutdown(struct thr_info *thr) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
struct device_drv opencl_drv = { |
|
|
|
struct device_drv opencl_drv = { |
|
|
|
.drv_id = DRIVER_opencl, |
|
|
|
/*.drv_id = */ DRIVER_opencl, |
|
|
|
.dname = "opencl", |
|
|
|
/*.dname = */ "opencl", |
|
|
|
.name = "GPU", |
|
|
|
/*.name = */ "GPU", |
|
|
|
.drv_detect = opencl_detect, |
|
|
|
/*.drv_detect = */ opencl_detect, |
|
|
|
.reinit_device = reinit_opencl_device, |
|
|
|
/*.reinit_device = */ reinit_opencl_device, |
|
|
|
#ifdef HAVE_ADL |
|
|
|
#ifdef HAVE_ADL |
|
|
|
.get_statline_before = get_opencl_statline_before, |
|
|
|
/*.get_statline_before = */ get_opencl_statline_before, |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
NULL, |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
.get_statline = get_opencl_statline, |
|
|
|
/*.get_statline = */ get_opencl_statline, |
|
|
|
.thread_prepare = opencl_thread_prepare, |
|
|
|
/*.api_data = */ NULL, |
|
|
|
.thread_init = opencl_thread_init, |
|
|
|
/*.get_stats = */ NULL, |
|
|
|
.prepare_work = opencl_prepare_work, |
|
|
|
/*.identify_device = */ NULL, |
|
|
|
.scanhash = opencl_scanhash, |
|
|
|
/*.set_device = */ NULL, |
|
|
|
.thread_shutdown = opencl_thread_shutdown, |
|
|
|
|
|
|
|
|
|
|
|
/*.thread_prepare = */ opencl_thread_prepare, |
|
|
|
|
|
|
|
/*.can_limit_work = */ NULL, |
|
|
|
|
|
|
|
/*.thread_init = */ opencl_thread_init, |
|
|
|
|
|
|
|
/*.prepare_work = */ opencl_prepare_work, |
|
|
|
|
|
|
|
/*.hash_work = */ NULL, |
|
|
|
|
|
|
|
/*.scanhash = */ opencl_scanhash, |
|
|
|
|
|
|
|
/*.scanwork = */ NULL, |
|
|
|
|
|
|
|
/*.queue_full = */ NULL, |
|
|
|
|
|
|
|
/*.flush_work = */ NULL, |
|
|
|
|
|
|
|
/*.update_work = */ NULL, |
|
|
|
|
|
|
|
/*.hw_error = */ NULL, |
|
|
|
|
|
|
|
/*.thread_shutdown = */ opencl_thread_shutdown, |
|
|
|
|
|
|
|
/*.thread_enable =*/ NULL, |
|
|
|
|
|
|
|
false, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
0 |
|
|
|
}; |
|
|
|
}; |
|
|
|