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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
diff --git a/cgminer.c b/cgminer.c
index 5f51096..7ed8aae 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 9091de5..7b219bc 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 a13113c..0c11a32 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 ea8ae10..3f9e29c 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 ccab8b8..1a2b80d 100644
--- a/ocl.h
+++ b/ocl.h
@@ -11,6 +11,8 @@
#include <CL/cl.h>
#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);