From 95a989da4dcd28b78ea9f9d45343089f45f07dae Mon Sep 17 00:00:00 2001 From: ckolivas Date: Fri, 10 Feb 2012 13:18:16 +1100 Subject: [PATCH] Conflicting entries of cl_kernel may have been causing problems, and automatically chosen kernel type was not being passed on. Rename the enum to cl_kernels and store the chosen kernel in each clState. --- cgminer.c | 2 +- device-gpu.c | 8 +++----- miner.h | 4 ++-- ocl.c | 11 +++++------ ocl.h | 3 +++ 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cgminer.c b/cgminer.c index 5f510967..7ed8aae0 100644 --- a/cgminer.c +++ b/cgminer.c @@ -205,7 +205,7 @@ static bool config_loaded = false; static char *opt_stderr_cmd = NULL; #endif // defined(unix) -enum cl_kernel chosen_kernel; +enum cl_kernels chosen_kernel; bool ping = true; diff --git a/device-gpu.c b/device-gpu.c index 9091de54..7b219bc0 100644 --- a/device-gpu.c +++ b/device-gpu.c @@ -1078,8 +1078,9 @@ static bool opencl_thread_init(struct thr_info *thr) { const int thr_id = thr->id; struct cgpu_info *gpu = thr->cgpu; - struct opencl_thread_data *thrdata; + _clState *clState = clStates[thr_id]; + cl_int status; thrdata = calloc(1, sizeof(*thrdata)); thr->cgpu_data = thrdata; @@ -1088,7 +1089,7 @@ static bool opencl_thread_init(struct thr_info *thr) return false; } - switch (chosen_kernel) { + switch (clState->chosen_kernel) { case KL_POCLBM: thrdata->queue_kernel_parameters = &queue_poclbm_kernel; break; @@ -1109,9 +1110,6 @@ static bool opencl_thread_init(struct thr_info *thr) return false; } - _clState *clState = clStates[thr_id]; - cl_int status; - status = clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, CL_TRUE, 0, BUFFERSIZE, blank_res, 0, NULL, NULL); if (unlikely(status != CL_SUCCESS)) { diff --git a/miner.h b/miner.h index a13113c2..0c11a326 100644 --- a/miner.h +++ b/miner.h @@ -675,7 +675,7 @@ struct work { UT_hash_handle hh; }; -enum cl_kernel { +enum cl_kernels { KL_NONE, KL_POCLBM, KL_PHATK, @@ -701,7 +701,7 @@ extern void *tq_pop(struct thread_q *tq, const struct timespec *abstime); extern void tq_freeze(struct thread_q *tq); extern void tq_thaw(struct thread_q *tq); extern bool successful_connect; -extern enum cl_kernel chosen_kernel; +extern enum cl_kernels chosen_kernel; extern void adl(void); #endif /* __MINER_H__ */ diff --git a/ocl.c b/ocl.c index ea8ae108..3f9e29ce 100644 --- a/ocl.c +++ b/ocl.c @@ -356,22 +356,21 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize) * have otherwise created. The filename is: * name + kernelname +/i bitalign + v + vectors + w + work_size + sizeof(long) + .bin */ - enum cl_kernel this_kernel; char binaryfilename[255]; char filename[255]; char numbuf[10]; if (chosen_kernel == KL_NONE) { if (strstr(name, "Tahiti")) - this_kernel = KL_DIAKGCN; + clState->chosen_kernel = KL_DIAKGCN; else if (!clState->hasBitAlign) - this_kernel = KL_POCLBM; + clState->chosen_kernel = KL_POCLBM; else - this_kernel = KL_PHATK; + clState->chosen_kernel = KL_PHATK; } else - this_kernel = chosen_kernel; + clState->chosen_kernel = chosen_kernel; - switch (this_kernel) { + switch (clState->chosen_kernel) { case KL_DIAKGCN: strcpy(filename, DIAKGCN_KERNNAME".cl"); strcpy(binaryfilename, DIAKGCN_KERNNAME); diff --git a/ocl.h b/ocl.h index ccab8b87..1a2b80d0 100644 --- a/ocl.h +++ b/ocl.h @@ -11,6 +11,8 @@ #include #endif +#include "miner.h" + typedef struct { cl_context context; cl_kernel kernel; @@ -22,6 +24,7 @@ typedef struct { cl_uint preferred_vwidth; size_t max_work_size; size_t work_size; + enum cl_kernels chosen_kernel; } _clState; extern char *file_contents(const char *filename, int *length);