mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-09 14:28:12 +00:00
Revert "Restart threads by abstracting out the clcontext initialisation and using that instead of probing all cards."
This reverts commit 8f186e61e2
.
This commit is contained in:
parent
cf543507c6
commit
42d49ffdc7
24
main.c
24
main.c
@ -3376,22 +3376,30 @@ static void *reinit_gpu(void *userdata)
|
|||||||
struct cgpu_info *cgpu = (struct cgpu_info *)userdata;
|
struct cgpu_info *cgpu = (struct cgpu_info *)userdata;
|
||||||
int gpu = cgpu->cpu_gpu;
|
int gpu = cgpu->cpu_gpu;
|
||||||
struct thr_info *thr;
|
struct thr_info *thr;
|
||||||
|
char name[256];
|
||||||
int thr_id;
|
int thr_id;
|
||||||
_clState *clState;
|
_clState *clState;
|
||||||
|
|
||||||
/* Send threads message to stop */
|
/* Send threads message to stop */
|
||||||
gpu_devices[gpu] = false;
|
gpu_devices[gpu] = false;
|
||||||
|
sleep(5);
|
||||||
|
|
||||||
for (thr_id = 0; thr_id < gpu_threads; thr_id ++) {
|
for (thr_id = 0; thr_id < gpu_threads; thr_id ++) {
|
||||||
if (dev_from_id(thr_id) != gpu)
|
if (dev_from_id(thr_id) != gpu)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
clState = clStates[thr_id];
|
||||||
|
/* Send it a command. If it responds we can restart */
|
||||||
|
applog(LOG_WARNING, "Attempting to send GPU command");
|
||||||
|
clFlush(clState->commandQueue);
|
||||||
|
clFinish(clState->commandQueue);
|
||||||
|
|
||||||
thr = &thr_info[thr_id];
|
thr = &thr_info[thr_id];
|
||||||
thr->rolling = thr->cgpu->rolling = 0;
|
thr->rolling = thr->cgpu->rolling = 0;
|
||||||
if (!pthread_cancel(*thr->pth)) {
|
if (!pthread_cancel(*thr->pth)) {
|
||||||
applog(LOG_WARNING, "Thread still exists, killing it off");
|
applog(LOG_WARNING, "Thread still exists, killing it off");
|
||||||
} else
|
} else
|
||||||
applog(LOG_WARNING, "Thread no longer exists!");
|
applog(LOG_WARNING, "Thread no longer exists");
|
||||||
|
|
||||||
/* Lose this ram cause we may get stuck here! */
|
/* Lose this ram cause we may get stuck here! */
|
||||||
//tq_freeze(thr->q);
|
//tq_freeze(thr->q);
|
||||||
@ -3400,13 +3408,17 @@ static void *reinit_gpu(void *userdata)
|
|||||||
if (!thr->q)
|
if (!thr->q)
|
||||||
quit(1, "Failed to tq_new in reinit_gpu");
|
quit(1, "Failed to tq_new in reinit_gpu");
|
||||||
|
|
||||||
/* Create a new clstate */
|
|
||||||
applog(LOG_WARNING, "Attempting to create a new clState");
|
|
||||||
clState = initCQ(clStates[thr_id], gpu);
|
|
||||||
|
|
||||||
/* Lose this ram cause we may dereference in the dying thread! */
|
/* Lose this ram cause we may dereference in the dying thread! */
|
||||||
//free(clState);
|
//free(clState);
|
||||||
applog(LOG_WARNING, "Command successful, attempting to create new thread");
|
applog(LOG_WARNING, "Command successful, attempting to reinit device");
|
||||||
|
|
||||||
|
applog(LOG_INFO, "Reinit GPU thread %d", thr_id);
|
||||||
|
clState = initCl(gpu, name, sizeof(name));
|
||||||
|
if (!clState) {
|
||||||
|
applog(LOG_ERR, "Failed to reinit GPU thread %d", thr_id);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
applog(LOG_INFO, "initCl() finished. Found %s", name);
|
||||||
|
|
||||||
if (unlikely(thr_info_create(thr, NULL, gpuminer_thread, thr))) {
|
if (unlikely(thr_info_create(thr, NULL, gpuminer_thread, thr))) {
|
||||||
applog(LOG_ERR, "thread %d create failed", thr_id);
|
applog(LOG_ERR, "thread %d create failed", thr_id);
|
||||||
|
93
ocl.c
93
ocl.c
@ -173,55 +173,6 @@ void patch_opcodes(char *w, unsigned remaining)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_clState *initCQ(_clState *clState, unsigned int gpu)
|
|
||||||
{
|
|
||||||
cl_int status = 0;
|
|
||||||
cl_device_id *devices = clState->devices;
|
|
||||||
|
|
||||||
/* create a cl program executable for all the devices specified */
|
|
||||||
status = clBuildProgram(clState->program, 1, &devices[gpu], NULL, NULL, NULL);
|
|
||||||
if (status != CL_SUCCESS)
|
|
||||||
{
|
|
||||||
applog(LOG_ERR, "Error: Building Program (clBuildProgram)");
|
|
||||||
size_t logSize;
|
|
||||||
status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, 0, NULL, &logSize);
|
|
||||||
|
|
||||||
char *log = malloc(logSize);
|
|
||||||
status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, logSize, log, NULL);
|
|
||||||
applog(LOG_INFO, "%s", log);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get a kernel object handle for a kernel with the given name */
|
|
||||||
clState->kernel = clCreateKernel(clState->program, "search", &status);
|
|
||||||
if (status != CL_SUCCESS)
|
|
||||||
{
|
|
||||||
applog(LOG_ERR, "Error: Creating Kernel from program. (clCreateKernel)");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Create an OpenCL command queue
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
clState->commandQueue = clCreateCommandQueue(clState->context, devices[gpu],
|
|
||||||
CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &status);
|
|
||||||
if (status != CL_SUCCESS) /* Try again without OOE enable */
|
|
||||||
clState->commandQueue = clCreateCommandQueue(clState->context, devices[gpu], 0 , &status);
|
|
||||||
if (status != CL_SUCCESS)
|
|
||||||
{
|
|
||||||
applog(LOG_ERR, "Creating Command Queue. (clCreateCommandQueue)");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
clState->outputBuffer = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, BUFFERSIZE, NULL, &status);
|
|
||||||
if (status != CL_SUCCESS) {
|
|
||||||
applog(LOG_ERR, "Error: clCreateBuffer (outputBuffer)");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return clState;
|
|
||||||
}
|
|
||||||
|
|
||||||
_clState *initCl(unsigned int gpu, char *name, size_t nameSize)
|
_clState *initCl(unsigned int gpu, char *name, size_t nameSize)
|
||||||
{
|
{
|
||||||
int patchbfi = 0;
|
int patchbfi = 0;
|
||||||
@ -285,7 +236,6 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
|
|||||||
cl_device_id *devices;
|
cl_device_id *devices;
|
||||||
if (numDevices > 0 ) {
|
if (numDevices > 0 ) {
|
||||||
devices = (cl_device_id *)malloc(numDevices*sizeof(cl_device_id));
|
devices = (cl_device_id *)malloc(numDevices*sizeof(cl_device_id));
|
||||||
clState->devices = devices;
|
|
||||||
|
|
||||||
/* Now, get the device list data */
|
/* Now, get the device list data */
|
||||||
|
|
||||||
@ -676,7 +626,48 @@ built:
|
|||||||
applog(LOG_INFO, "Initialising kernel %s with%s BFI_INT patching, %d vectors and worksize %d",
|
applog(LOG_INFO, "Initialising kernel %s with%s BFI_INT patching, %d vectors and worksize %d",
|
||||||
filename, patchbfi ? "" : "out", clState->preferred_vwidth, clState->work_size);
|
filename, patchbfi ? "" : "out", clState->preferred_vwidth, clState->work_size);
|
||||||
|
|
||||||
return initCQ(clState, gpu);
|
/* create a cl program executable for all the devices specified */
|
||||||
|
status = clBuildProgram(clState->program, 1, &devices[gpu], NULL, NULL, NULL);
|
||||||
|
if (status != CL_SUCCESS)
|
||||||
|
{
|
||||||
|
applog(LOG_ERR, "Error: Building Program (clBuildProgram)");
|
||||||
|
size_t logSize;
|
||||||
|
status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, 0, NULL, &logSize);
|
||||||
|
|
||||||
|
char *log = malloc(logSize);
|
||||||
|
status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, logSize, log, NULL);
|
||||||
|
applog(LOG_INFO, "%s", log);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get a kernel object handle for a kernel with the given name */
|
||||||
|
clState->kernel = clCreateKernel(clState->program, "search", &status);
|
||||||
|
if (status != CL_SUCCESS)
|
||||||
|
{
|
||||||
|
applog(LOG_ERR, "Error: Creating Kernel from program. (clCreateKernel)");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////
|
||||||
|
// Create an OpenCL command queue
|
||||||
|
/////////////////////////////////////////////////////////////////
|
||||||
|
clState->commandQueue = clCreateCommandQueue(clState->context, devices[gpu],
|
||||||
|
CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &status);
|
||||||
|
if (status != CL_SUCCESS) /* Try again without OOE enable */
|
||||||
|
clState->commandQueue = clCreateCommandQueue(clState->context, devices[gpu], 0 , &status);
|
||||||
|
if (status != CL_SUCCESS)
|
||||||
|
{
|
||||||
|
applog(LOG_ERR, "Creating Command Queue. (clCreateCommandQueue)");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
clState->outputBuffer = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, BUFFERSIZE, NULL, &status);
|
||||||
|
if (status != CL_SUCCESS) {
|
||||||
|
applog(LOG_ERR, "Error: clCreateBuffer (outputBuffer)");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return clState;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_OPENCL */
|
#endif /* HAVE_OPENCL */
|
||||||
|
|
||||||
|
2
ocl.h
2
ocl.h
@ -18,12 +18,10 @@ typedef struct {
|
|||||||
cl_uint preferred_vwidth;
|
cl_uint preferred_vwidth;
|
||||||
size_t max_work_size;
|
size_t max_work_size;
|
||||||
size_t work_size;
|
size_t work_size;
|
||||||
cl_device_id *devices;
|
|
||||||
} _clState;
|
} _clState;
|
||||||
|
|
||||||
extern char *file_contents(const char *filename, int *length);
|
extern char *file_contents(const char *filename, int *length);
|
||||||
extern int clDevicesNum();
|
extern int clDevicesNum();
|
||||||
extern _clState *initCQ(_clState *clState, unsigned int gpu);
|
|
||||||
extern _clState *initCl(unsigned int gpu, char *name, size_t nameSize);
|
extern _clState *initCl(unsigned int gpu, char *name, size_t nameSize);
|
||||||
#endif /* HAVE_OPENCL */
|
#endif /* HAVE_OPENCL */
|
||||||
#endif /* __OCL_H__ */
|
#endif /* __OCL_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user