|
|
@ -1818,7 +1818,7 @@ retry: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_OPENCL |
|
|
|
#ifdef HAVE_OPENCL |
|
|
|
static void reinit_thread(long thr_id); |
|
|
|
static void reinit_device(struct cgpu_info *cgpu); |
|
|
|
|
|
|
|
|
|
|
|
static void manage_gpu(void) |
|
|
|
static void manage_gpu(void) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1895,12 +1895,8 @@ retry: |
|
|
|
wlogprint("Invalid selection\n"); |
|
|
|
wlogprint("Invalid selection\n"); |
|
|
|
goto retry; |
|
|
|
goto retry; |
|
|
|
} |
|
|
|
} |
|
|
|
for (i = 0; i < gpu_threads; i++) { |
|
|
|
wlogprint("Attempting to restart threads of GPU %d\n", selected); |
|
|
|
if (dev_from_id(i) != selected) |
|
|
|
reinit_device(&gpus[selected]); |
|
|
|
continue; |
|
|
|
|
|
|
|
wlogprint("Attempting to restart thread %d\n", i); |
|
|
|
|
|
|
|
reinit_thread(i); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
clear_logwin(); |
|
|
|
clear_logwin(); |
|
|
@ -3101,9 +3097,12 @@ static void restart_longpoll(void) |
|
|
|
start_longpoll(); |
|
|
|
start_longpoll(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void *reinit_cputhread(void *userdata) |
|
|
|
static void *reinit_cpu(void *userdata) |
|
|
|
{ |
|
|
|
{ |
|
|
|
long thr_id = (long)userdata; |
|
|
|
#if 0 |
|
|
|
|
|
|
|
struct cgpu_info *cgpu = (struct cgpu_info *)userdata; |
|
|
|
|
|
|
|
int cpu = cgpu->cpu_gpu; |
|
|
|
|
|
|
|
long thr_id = ....(long)userdata; |
|
|
|
struct thr_info *thr = &thr_info[thr_id]; |
|
|
|
struct thr_info *thr = &thr_info[thr_id]; |
|
|
|
int cpu = dev_from_id(thr_id); |
|
|
|
int cpu = dev_from_id(thr_id); |
|
|
|
|
|
|
|
|
|
|
@ -3126,19 +3125,26 @@ static void *reinit_cputhread(void *userdata) |
|
|
|
tq_push(thr->q, &ping); |
|
|
|
tq_push(thr->q, &ping); |
|
|
|
|
|
|
|
|
|
|
|
applog(LOG_WARNING, "Thread %d restarted", thr_id); |
|
|
|
applog(LOG_WARNING, "Thread %d restarted", thr_id); |
|
|
|
|
|
|
|
#endif |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_OPENCL |
|
|
|
#ifdef HAVE_OPENCL |
|
|
|
static void *reinit_gputhread(void *userdata) |
|
|
|
static void *reinit_gpu(void *userdata) |
|
|
|
{ |
|
|
|
{ |
|
|
|
long thr_id = (long)userdata; |
|
|
|
struct cgpu_info *cgpu = (struct cgpu_info *)userdata; |
|
|
|
int gpu = dev_from_id(thr_id); |
|
|
|
int gpu = cgpu->cpu_gpu; |
|
|
|
struct thr_info *thr = &thr_info[thr_id]; |
|
|
|
struct thr_info *thr; |
|
|
|
char name[256]; |
|
|
|
char name[256]; |
|
|
|
|
|
|
|
int thr_id; |
|
|
|
|
|
|
|
|
|
|
|
gpus[gpu].alive = false; |
|
|
|
gpus[gpu].alive = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (thr_id = 0; thr_id < gpu_threads; thr_id ++) { |
|
|
|
|
|
|
|
if (dev_from_id(thr_id) != gpu) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
thr = &thr_info[thr_id]; |
|
|
|
thr->rolling = thr->cgpu->rolling = 0; |
|
|
|
thr->rolling = thr->cgpu->rolling = 0; |
|
|
|
tq_freeze(thr->q); |
|
|
|
tq_freeze(thr->q); |
|
|
|
if (!pthread_cancel(*thr->pth)) |
|
|
|
if (!pthread_cancel(*thr->pth)) |
|
|
@ -3167,26 +3173,27 @@ static void *reinit_gputhread(void *userdata) |
|
|
|
tq_push(thr->q, &ping); |
|
|
|
tq_push(thr->q, &ping); |
|
|
|
|
|
|
|
|
|
|
|
applog(LOG_WARNING, "Thread %d restarted", thr_id); |
|
|
|
applog(LOG_WARNING, "Thread %d restarted", thr_id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
#else |
|
|
|
#else |
|
|
|
static void *reinit_gputhread(void *userdata) |
|
|
|
static void *reinit_gpu(void *userdata) |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
static void reinit_thread(long thr_id) |
|
|
|
static void reinit_device(struct cgpu_info *cgpu) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pthread_t resus_thread; |
|
|
|
pthread_t resus_thread; |
|
|
|
void *reinit; |
|
|
|
void *reinit; |
|
|
|
|
|
|
|
|
|
|
|
if (thr_id < gpu_threads) |
|
|
|
if (cgpu->is_gpu) |
|
|
|
reinit = reinit_gputhread; |
|
|
|
reinit = reinit_gpu; |
|
|
|
else |
|
|
|
else |
|
|
|
reinit = reinit_cputhread; |
|
|
|
reinit = reinit_cpu; |
|
|
|
|
|
|
|
|
|
|
|
if (unlikely(pthread_create(&resus_thread, NULL, reinit, (void *)thr_id))) |
|
|
|
if (unlikely(pthread_create(&resus_thread, NULL, reinit, (void *)cgpu))) |
|
|
|
applog(LOG_ERR, "Failed to create reinit thread"); |
|
|
|
applog(LOG_ERR, "Failed to create reinit thread"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -3282,7 +3289,11 @@ static void *watchdog_thread(void *userdata) |
|
|
|
kill_work(); |
|
|
|
kill_work(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
reinit_thread(i); |
|
|
|
reinit_device(thr->cgpu); |
|
|
|
|
|
|
|
/* Only initialise the device once since there
|
|
|
|
|
|
|
|
* will be multiple threads on the same device |
|
|
|
|
|
|
|
* and it will be declared !alive */ |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|