Browse Source

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.

nfactor-troky
ckolivas 13 years ago
parent
commit
02c94272b4
  1. 2
      cgminer.c
  2. 8
      device-gpu.c
  3. 4
      miner.h
  4. 11
      ocl.c
  5. 3
      ocl.h

2
cgminer.c

@ -205,7 +205,7 @@ static bool config_loaded = false;
static char *opt_stderr_cmd = NULL; static char *opt_stderr_cmd = NULL;
#endif // defined(unix) #endif // defined(unix)
enum cl_kernel chosen_kernel; enum cl_kernels chosen_kernel;
bool ping = true; bool ping = true;

8
device-gpu.c

@ -1078,8 +1078,9 @@ static bool opencl_thread_init(struct thr_info *thr)
{ {
const int thr_id = thr->id; const int thr_id = thr->id;
struct cgpu_info *gpu = thr->cgpu; struct cgpu_info *gpu = thr->cgpu;
struct opencl_thread_data *thrdata; struct opencl_thread_data *thrdata;
_clState *clState = clStates[thr_id];
cl_int status;
thrdata = calloc(1, sizeof(*thrdata)); thrdata = calloc(1, sizeof(*thrdata));
thr->cgpu_data = thrdata; thr->cgpu_data = thrdata;
@ -1088,7 +1089,7 @@ static bool opencl_thread_init(struct thr_info *thr)
return false; return false;
} }
switch (chosen_kernel) { switch (clState->chosen_kernel) {
case KL_POCLBM: case KL_POCLBM:
thrdata->queue_kernel_parameters = &queue_poclbm_kernel; thrdata->queue_kernel_parameters = &queue_poclbm_kernel;
break; break;
@ -1109,9 +1110,6 @@ static bool opencl_thread_init(struct thr_info *thr)
return false; return false;
} }
_clState *clState = clStates[thr_id];
cl_int status;
status = clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, CL_TRUE, 0, status = clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, CL_TRUE, 0,
BUFFERSIZE, blank_res, 0, NULL, NULL); BUFFERSIZE, blank_res, 0, NULL, NULL);
if (unlikely(status != CL_SUCCESS)) { if (unlikely(status != CL_SUCCESS)) {

4
miner.h

@ -675,7 +675,7 @@ struct work {
UT_hash_handle hh; UT_hash_handle hh;
}; };
enum cl_kernel { enum cl_kernels {
KL_NONE, KL_NONE,
KL_POCLBM, KL_POCLBM,
KL_PHATK, 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_freeze(struct thread_q *tq);
extern void tq_thaw(struct thread_q *tq); extern void tq_thaw(struct thread_q *tq);
extern bool successful_connect; extern bool successful_connect;
extern enum cl_kernel chosen_kernel; extern enum cl_kernels chosen_kernel;
extern void adl(void); extern void adl(void);
#endif /* __MINER_H__ */ #endif /* __MINER_H__ */

11
ocl.c

@ -356,22 +356,21 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
* have otherwise created. The filename is: * have otherwise created. The filename is:
* name + kernelname +/i bitalign + v + vectors + w + work_size + sizeof(long) + .bin * name + kernelname +/i bitalign + v + vectors + w + work_size + sizeof(long) + .bin
*/ */
enum cl_kernel this_kernel;
char binaryfilename[255]; char binaryfilename[255];
char filename[255]; char filename[255];
char numbuf[10]; char numbuf[10];
if (chosen_kernel == KL_NONE) { if (chosen_kernel == KL_NONE) {
if (strstr(name, "Tahiti")) if (strstr(name, "Tahiti"))
this_kernel = KL_DIAKGCN; clState->chosen_kernel = KL_DIAKGCN;
else if (!clState->hasBitAlign) else if (!clState->hasBitAlign)
this_kernel = KL_POCLBM; clState->chosen_kernel = KL_POCLBM;
else else
this_kernel = KL_PHATK; clState->chosen_kernel = KL_PHATK;
} else } else
this_kernel = chosen_kernel; clState->chosen_kernel = chosen_kernel;
switch (this_kernel) { switch (clState->chosen_kernel) {
case KL_DIAKGCN: case KL_DIAKGCN:
strcpy(filename, DIAKGCN_KERNNAME".cl"); strcpy(filename, DIAKGCN_KERNNAME".cl");
strcpy(binaryfilename, DIAKGCN_KERNNAME); strcpy(binaryfilename, DIAKGCN_KERNNAME);

3
ocl.h

@ -11,6 +11,8 @@
#include <CL/cl.h> #include <CL/cl.h>
#endif #endif
#include "miner.h"
typedef struct { typedef struct {
cl_context context; cl_context context;
cl_kernel kernel; cl_kernel kernel;
@ -22,6 +24,7 @@ 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;
enum cl_kernels chosen_kernel;
} _clState; } _clState;
extern char *file_contents(const char *filename, int *length); extern char *file_contents(const char *filename, int *length);

Loading…
Cancel
Save