Set scrypt settings and buffer size in ocl.c code to be future modifiable.
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
diff --git a/driver-opencl.c b/driver-opencl.c
index c086959..2ebb54f 100644
--- a/driver-opencl.c
+++ b/driver-opencl.c
@@ -1004,8 +1004,8 @@ static cl_int queue_scrypt_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint t
CL_SET_ARG(clState->CLbuffer0);
CL_SET_ARG(clState->outputBuffer);
CL_SET_ARG(clState->padbuffer8);
- CL_SET_VARG(4, &midstate[0]);
- CL_SET_VARG(4, &midstate[16]);
+ CL_SET_ARG(midstate[0]);
+ CL_SET_ARG(midstate[16]);
#if 0
clSetKernelArg(clState->kernel,0,sizeof(cl_mem), &clState->CLbuffer[0]);
diff --git a/ocl.c b/ocl.c
index 95f2562..2fc7e35 100644
--- a/ocl.c
+++ b/ocl.c
@@ -464,6 +464,13 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
return NULL;
}
+#ifdef USE_SCRYPT
+ if (opt_scrypt) {
+ clState->lookup_gap = 1;
+ clState->thread_concurrency = 1;
+ }
+#endif
+
strcat(binaryfilename, name);
if (clState->goffset)
strcat(binaryfilename, "g");
@@ -535,10 +542,13 @@ build:
/* create a cl program executable for all the devices specified */
char *CompilerOptions = calloc(1, 256);
- if (opt_scrypt) {
- sprintf(CompilerOptions, "-D LOOKUP_GAP=1 -D CONCURRENT_THREADS=1 -D WORKSIZE=%d",
- (int)clState->wsize);
- } else {
+#ifdef USE_SCRYPT
+ if (opt_scrypt)
+ sprintf(CompilerOptions, "-D LOOKUP_GAP=%d -D CONCURRENT_THREADS=%d -D WORKSIZE=%d",
+ (int)clState->lookup_gap, (int)clState->thread_concurrency, (int)clState->wsize);
+ else
+#endif
+ {
sprintf(CompilerOptions, "-D WORKSIZE=%d -D VECTORS%d -D WORKVEC=%d",
(int)clState->wsize, clState->vwidth, (int)clState->wsize * clState->vwidth);
}
@@ -734,8 +744,11 @@ built:
#ifdef USE_SCRYPT
if (opt_scrypt) {
+ size_t ipt = (1024 / clState->lookup_gap + (1024 % clState->lookup_gap > 0));
+ size_t bufsize = 128 * ipt * clState->thread_concurrency;
+
clState->CLbuffer0 = clCreateBuffer(clState->context, CL_MEM_READ_ONLY, 128, NULL, &status);
- clState->padbuffer8 = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, 131072, NULL, &status);
+ clState->padbuffer8 = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, bufsize, NULL, &status);
}
#endif
clState->outputBuffer = clCreateBuffer(clState->context, CL_MEM_WRITE_ONLY, BUFFERSIZE, NULL, &status);
diff --git a/ocl.h b/ocl.h
index fddcc67..b15c889 100644
--- a/ocl.h
+++ b/ocl.h
@@ -22,6 +22,8 @@ typedef struct {
#ifdef USE_SCRYPT
cl_mem CLbuffer0;
cl_mem padbuffer8;
+ size_t lookup_gap;
+ size_t thread_concurrency;
#endif
bool hasBitAlign;
bool hasOpenCL11plus;