Browse Source

Don't enqueuewrite buffer at all for pad8 and pass work details around for scrypt in dev_blk.

nfactor-troky
Con Kolivas 13 years ago
parent
commit
6ac14f4280
  1. 6
      cgminer.c
  2. 23
      driver-opencl.c
  3. 7
      findnonce.c
  4. 2
      miner.h

6
cgminer.c

@ -3983,11 +3983,15 @@ bool hashtest(const struct work *work) @@ -3983,11 +3983,15 @@ bool hashtest(const struct work *work)
bool test_nonce(struct work *work, uint32_t nonce)
{
uint32_t *work_nonce = (uint32_t *)(work->data + 64 + 12);
*work_nonce = htobe32(nonce);
#if 0
work->data[64 + 12 + 0] = (nonce >> 0) & 0xff;
work->data[64 + 12 + 1] = (nonce >> 8) & 0xff;
work->data[64 + 12 + 2] = (nonce >> 16) & 0xff;
work->data[64 + 12 + 3] = (nonce >> 24) & 0xff;
#endif
if (opt_scrypt)
return true;

23
driver-opencl.c

@ -993,14 +993,14 @@ static cl_int queue_diablo_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint t @@ -993,14 +993,14 @@ 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)
static cl_int queue_scrypt_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_unused cl_uint threads)
{
cl_uint4 *midstate = (cl_uint4 *)blk->midstate;
cl_uint4 *midstate = (cl_uint4 *)blk->work->midstate;
cl_kernel *kernel = &clState->kernel;
unsigned int num = 0;
cl_int status = 0;
int i;
clState->cldata = blk->work->data;
status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 80, clState->cldata, 0, NULL,NULL);
CL_SET_ARG(clState->CLbuffer0);
@ -1349,13 +1349,6 @@ static bool opencl_thread_init(struct thr_info *thr) @@ -1349,13 +1349,6 @@ static bool opencl_thread_init(struct thr_info *thr)
return false;
}
#ifdef USE_SCRYPT
if (opt_scrypt) {
if (clState->padbufsize > BUFFERSIZE)
blank_res = realloc(blank_res, clState->padbufsize);
status = clEnqueueWriteBuffer(clState->commandQueue, clState->padbuffer8, true, 0, clState->padbufsize, 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)) {
@ -1385,7 +1378,12 @@ static void opencl_free_work(struct thr_info *thr, struct work *work) @@ -1385,7 +1378,12 @@ static void opencl_free_work(struct thr_info *thr, struct work *work)
static bool opencl_prepare_work(struct thr_info __maybe_unused *thr, struct work *work)
{
precalc_hash(&work->blk, (uint32_t *)(work->midstate), (uint32_t *)(work->data + 64));
#ifdef USE_SCRYPT
if (opt_scrypt)
work->blk.work = work;
else
#endif
precalc_hash(&work->blk, (uint32_t *)(work->midstate), (uint32_t *)(work->data + 64));
return true;
}
@ -1446,9 +1444,6 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work, @@ -1446,9 +1444,6 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
if (hashes > gpu->max_hashes)
gpu->max_hashes = hashes;
#ifdef USE_SCRYPT
clState->cldata = work->data;
#endif
status = thrdata->queue_kernel_parameters(clState, &work->blk, globalThreads[0]);
if (unlikely(status != CL_SUCCESS)) {
applog(LOG_ERR, "Error: clSetKernelArg of all params failed.");

7
findnonce.c

@ -45,7 +45,8 @@ const uint32_t SHA256_K[64] = { @@ -45,7 +45,8 @@ const uint32_t SHA256_K[64] = {
d = d + h; \
h = h + (rotate(a, 30) ^ rotate(a, 19) ^ rotate(a, 10)) + ((a & b) | (c & (a | b)))
void precalc_hash(dev_blk_ctx *blk, uint32_t *state, uint32_t *data) {
void precalc_hash(dev_blk_ctx *blk, uint32_t *state, uint32_t *data)
{
cl_uint A, B, C, D, E, F, G, H;
A = state[0];
@ -127,10 +128,6 @@ void precalc_hash(dev_blk_ctx *blk, uint32_t *state, uint32_t *data) { @@ -127,10 +128,6 @@ 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)))

2
miner.h

@ -671,7 +671,7 @@ typedef struct { @@ -671,7 +671,7 @@ typedef struct {
cl_uint zeroA, zeroB;
cl_uint oneA, twoA, threeA, fourA, fiveA, sixA, sevenA;
#ifdef USE_SCRYPT
unsigned char *midstate;
struct work *work;
#endif
} dev_blk_ctx;
#else

Loading…
Cancel
Save