Use global offset parameter to diablo and poclbm kernel ONLY for 1 vector kernels.
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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
diff --git a/device-gpu.c b/device-gpu.c
index 9aef31e..34c115d 100644
--- a/device-gpu.c
+++ b/device-gpu.c
@@ -743,10 +743,8 @@ static _clState *clStates[MAX_GPUDEVICES];
static cl_int queue_poclbm_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint threads)
{
cl_kernel *kernel = &clState->kernel;
- cl_uint vwidth = clState->vwidth;
- unsigned int i, num = 0;
+ unsigned int num = 0;
cl_int status = 0;
- uint *nonces;
CL_SET_BLKARG(ctx_a);
CL_SET_BLKARG(ctx_b);
@@ -765,10 +763,15 @@ static cl_int queue_poclbm_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint t
CL_SET_BLKARG(cty_g);
CL_SET_BLKARG(cty_h);
- nonces = alloca(sizeof(uint) * vwidth);
- for (i = 0; i < vwidth; i++)
- nonces[i] = blk->nonce + (i * threads);
- CL_SET_VARG(vwidth, nonces);
+ if (!clState->goffset) {
+ cl_uint vwidth = clState->vwidth;
+ uint *nonces = alloca(sizeof(uint) * vwidth);
+ unsigned int i;
+
+ for (i = 0; i < vwidth; i++)
+ nonces[i] = blk->nonce + (i * threads);
+ CL_SET_VARG(vwidth, nonces);
+ }
CL_SET_BLKARG(fW0);
CL_SET_BLKARG(fW1);
@@ -896,15 +899,19 @@ static cl_int queue_diakgcn_kernel(_clState *clState, dev_blk_ctx *blk,
static cl_int queue_diablo_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint threads)
{
cl_kernel *kernel = &clState->kernel;
- cl_uint vwidth = clState->vwidth;
- unsigned int i, num = 0;
+ unsigned int num = 0;
cl_int status = 0;
- uint *nonces;
- nonces = alloca(sizeof(uint) * vwidth);
- for (i = 0; i < vwidth; i++)
- nonces[i] = blk->nonce + (i * threads);
- CL_SET_VARG(vwidth, nonces);
+ if (!clState->goffset) {
+ cl_uint vwidth = clState->vwidth;
+ uint *nonces = alloca(sizeof(uint) * vwidth);
+ unsigned int i;
+
+ for (i = 0; i < vwidth; i++)
+ nonces[i] = blk->nonce + (i * threads);
+ CL_SET_VARG(vwidth, nonces);
+ }
+
CL_SET_BLKARG(PreVal0);
CL_SET_BLKARG(PreVal0addK7);
@@ -1338,8 +1345,16 @@ static uint64_t opencl_scanhash(struct thr_info *thr, struct work *work,
memset(thrdata->res, 0, BUFFERSIZE);
clFinish(clState->commandQueue);
}
- status = clEnqueueNDRangeKernel(clState->commandQueue, *kernel, 1, NULL,
- globalThreads, localThreads, 0, NULL, NULL);
+
+ if (clState->goffset) {
+ size_t global_work_offset[1];
+
+ global_work_offset[0] = work->blk.nonce;
+ status = clEnqueueNDRangeKernel(clState->commandQueue, *kernel, 1, global_work_offset,
+ globalThreads, localThreads, 0, NULL, NULL);
+ } else
+ status = clEnqueueNDRangeKernel(clState->commandQueue, *kernel, 1, NULL,
+ globalThreads, localThreads, 0, NULL, NULL);
if (unlikely(status != CL_SUCCESS)) {
applog(LOG_ERR, "Error: Enqueueing kernel onto command queue. (clEnqueueNDRangeKernel)");
return 0;
diff --git a/diablo120222.cl b/diablo120222.cl
index c8a6c48..01d3a4c 100644
--- a/diablo120222.cl
+++ b/diablo120222.cl
@@ -48,7 +48,9 @@ __kernel
__attribute__((vec_type_hint(z)))
__attribute__((reqd_work_group_size(WORKSIZE, 1, 1)))
void search(
+#ifndef GOFFSET
const z base,
+#endif
const uint PreVal4_state0, const uint PreVal4_state0_k7,
const uint PreVal4_T1,
const uint W18, const uint W19,
@@ -65,7 +67,11 @@ void search(
z ZA[25];
+#ifdef GOFFSET
+ const z Znonce = (uint)(get_global_id(0));
+#else
const z Znonce = base + (uint)(get_global_id(0));
+#endif
ZA[2]=Znonce;
ZA[2]+=PreVal4_state0;
diff --git a/ocl.c b/ocl.c
index 04992cb..a15fc45 100644
--- a/ocl.c
+++ b/ocl.c
@@ -335,7 +335,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
/* Create binary filename based on parameters passed to opencl
* compiler to ensure we only load a binary that matches what would
* have otherwise created. The filename is:
- * name + kernelname + v + vectors + w + work_size + l + sizeof(long) + .bin
+ * name + kernelname +/- g(offset) + v + vectors + w + work_size + l + sizeof(long) + .bin
*/
char binaryfilename[255];
char filename[255];
@@ -398,6 +398,10 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
gpus[gpu].vwidth = preferred_vwidth;
}
+ if ((clState->chosen_kernel == KL_POCLBM || clState->chosen_kernel == KL_DIABLO) &&
+ clState->vwidth == 1 && clState->hasOpenCL11plus)
+ clState->goffset = true;
+
if (gpus[gpu].work_size && gpus[gpu].work_size <= clState->max_work_size)
clState->wsize = gpus[gpu].work_size;
else if (strstr(name, "Tahiti"))
@@ -431,7 +435,8 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
}
strcat(binaryfilename, name);
-
+ if (clState->goffset)
+ strcat(binaryfilename, "g");
strcat(binaryfilename, "v");
sprintf(numbuf, "%d", clState->vwidth);
strcat(binaryfilename, numbuf);
@@ -533,6 +538,9 @@ build:
} else
applog(LOG_DEBUG, "BFI_INT patch requiring device not found, will not BFI_INT patch");
+ if (clState->goffset)
+ strcat(CompilerOptions, " -D GOFFSET");
+
applog(LOG_DEBUG, "CompilerOptions: %s", CompilerOptions);
status = clBuildProgram(clState->program, 1, &devices[gpu], CompilerOptions , NULL, NULL);
free(CompilerOptions);
diff --git a/ocl.h b/ocl.h
index 6a4b728..2f2f2c2 100644
--- a/ocl.h
+++ b/ocl.h
@@ -21,6 +21,7 @@ typedef struct {
cl_mem outputBuffer;
bool hasBitAlign;
bool hasOpenCL11plus;
+ bool goffset;
cl_uint vwidth;
size_t max_work_size;
size_t wsize;
diff --git a/poclbm120222.cl b/poclbm120222.cl
index bc73ce9..92bc707 100644
--- a/poclbm120222.cl
+++ b/poclbm120222.cl
@@ -73,7 +73,9 @@ void search(const uint state0, const uint state1, const uint state2, const uint
const uint state4, const uint state5, const uint state6, const uint state7,
const uint b1, const uint c1,
const uint f1, const uint g1, const uint h1,
+#ifndef GOFFSET
const u base,
+#endif
const uint fw0, const uint fw1, const uint fw2, const uint fw3, const uint fw15, const uint fw01r,
const uint D1A, const uint C1addK5, const uint B1addK6,
const uint W16addK16, const uint W17addK17,
@@ -83,8 +85,11 @@ void search(const uint state0, const uint state1, const uint state2, const uint
u W[24];
u *Vals = &W[16]; // Now put at W[16] to be in same array
+#ifdef GOFFSET
+ const u nonce = (uint)(get_global_id(0));
+#else
const u nonce = base + (uint)(get_global_id(0));
-
+#endif
Vals[0]=Preval0;
Vals[0]+=nonce;