Browse Source

Make scrypt buffers and midstate compatible with cgminer.

nfactor-troky
Con Kolivas 13 years ago
parent
commit
b085c338f6
  1. 23
      driver-opencl.c
  2. 4
      findnonce.c
  3. 3
      miner.h
  4. 6
      ocl.c
  5. 4
      ocl.h

23
driver-opencl.c

@ -995,8 +995,25 @@ static cl_int queue_diablo_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint t @@ -995,8 +995,25 @@ static cl_int queue_diablo_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint t
#ifdef USE_SCRYPT
static cl_int queue_scrypt_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint threads)
{
cl_uint4 *midstate = (cl_uint4 *)blk->midstate;
cl_kernel *kernel = &clState->kernel;
unsigned int num = 0;
cl_int status = 0;
int i;
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]);
#if 0
clSetKernelArg(clState->kernel,0,sizeof(cl_mem), &clState->CLbuffer[0]);
clSetKernelArg(clState->kernel,1,sizeof(cl_mem), &clState->CLbuffer[1]);
clSetKernelArg(clState->kernel,2,sizeof(cl_mem), &clState->padbuffer8);
clSetKernelArg(clState->kernel,3,sizeof(cl_uint4), &midstate[0]);
clSetKernelArg(clState->kernel,4,sizeof(cl_uint4), &midstate[16]);
#endif
return status;
}
#endif
@ -1330,6 +1347,10 @@ static bool opencl_thread_init(struct thr_info *thr) @@ -1330,6 +1347,10 @@ static bool opencl_thread_init(struct thr_info *thr)
return false;
}
#ifdef USE_SCRYPT
if (opt_scrypt)
status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, BUFFERSIZE, blank_res, 0, NULL,NULL);
#endif
status = clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, CL_TRUE, 0,
BUFFERSIZE, blank_res, 0, NULL, NULL);
if (unlikely(status != CL_SUCCESS)) {
@ -1456,7 +1477,7 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work, @@ -1456,7 +1477,7 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
status = clEnqueueReadBuffer(clState->commandQueue, clState->outputBuffer, CL_FALSE, 0,
BUFFERSIZE, thrdata->res, 0, NULL, NULL);
if (unlikely(status != CL_SUCCESS)) {
applog(LOG_ERR, "Error: clEnqueueReadBuffer failed. (clEnqueueReadBuffer)");
applog(LOG_ERR, "Error: clEnqueueReadBuffer failed error %d. (clEnqueueReadBuffer)", status);
return -1;
}

4
findnonce.c

@ -127,6 +127,10 @@ void precalc_hash(dev_blk_ctx *blk, uint32_t *state, uint32_t *data) { @@ -127,6 +127,10 @@ void precalc_hash(dev_blk_ctx *blk, uint32_t *state, uint32_t *data) {
blk->fiveA = blk->ctx_f + SHA256_K[5];
blk->sixA = blk->ctx_g + SHA256_K[6];
blk->sevenA = blk->ctx_h + SHA256_K[7];
#ifdef USE_SCRYPT
blk->midstate = (unsigned char *)state;
#endif
}
#define P(t) (W[(t)&0xF] = W[(t-16)&0xF] + (rotate(W[(t-15)&0xF], 25) ^ rotate(W[(t-15)&0xF], 14) ^ (W[(t-15)&0xF] >> 3)) + W[(t-7)&0xF] + (rotate(W[(t-2)&0xF], 15) ^ rotate(W[(t-2)&0xF], 13) ^ (W[(t-2)&0xF] >> 10)))

3
miner.h

@ -672,6 +672,9 @@ typedef struct { @@ -672,6 +672,9 @@ typedef struct {
cl_uint B1addK6, PreVal0addK7, W16addK16, W17addK17;
cl_uint zeroA, zeroB;
cl_uint oneA, twoA, threeA, fourA, fiveA, sixA, sevenA;
#ifdef USE_SCRYPT
unsigned char *midstate;
#endif
} dev_blk_ctx;
#else
typedef struct {

6
ocl.c

@ -536,7 +536,7 @@ build: @@ -536,7 +536,7 @@ build:
char *CompilerOptions = calloc(1, 256);
if (opt_scrypt) {
sprintf(CompilerOptions, "-D LOOKUP_GAP=2 -D CONCURRENT_THREADS=6144 -D WORKSIZE=%d",
sprintf(CompilerOptions, "-D LOOKUP_GAP=2 -D CONCURRENT_THREADS=512 -D WORKSIZE=%d",
(int)clState->wsize);
} else {
sprintf(CompilerOptions, "-D WORKSIZE=%d -D VECTORS%d -D WORKVEC=%d",
@ -732,6 +732,10 @@ built: @@ -732,6 +732,10 @@ built:
return NULL;
}
#ifdef USE_SCRYPT
if (opt_scrypt)
clState->CLbuffer0 = clCreateBuffer(clState->context, CL_MEM_READ_ONLY, 128, NULL, &status);
#endif
clState->outputBuffer = clCreateBuffer(clState->context, CL_MEM_WRITE_ONLY, BUFFERSIZE, NULL, &status);
if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error %d: clCreateBuffer (outputBuffer)", status);

4
ocl.h

@ -19,6 +19,10 @@ typedef struct { @@ -19,6 +19,10 @@ typedef struct {
cl_command_queue commandQueue;
cl_program program;
cl_mem outputBuffer;
#ifdef USE_SCRYPT
cl_mem CLbuffer0;
cl_mem padbuffer8;
#endif
bool hasBitAlign;
bool hasOpenCL11plus;
bool goffset;

Loading…
Cancel
Save