mirror of
https://github.com/GOSTSec/sgminer
synced 2025-08-26 05:41:55 +00:00
Don't enqueuewrite buffer at all for pad8 and pass work details around for scrypt in dev_blk.
This commit is contained in:
parent
a9a0bba18b
commit
6ac14f4280
@ -3983,11 +3983,15 @@ bool hashtest(const struct work *work)
|
|||||||
|
|
||||||
bool test_nonce(struct work *work, uint32_t nonce)
|
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 + 0] = (nonce >> 0) & 0xff;
|
||||||
work->data[64 + 12 + 1] = (nonce >> 8) & 0xff;
|
work->data[64 + 12 + 1] = (nonce >> 8) & 0xff;
|
||||||
work->data[64 + 12 + 2] = (nonce >> 16) & 0xff;
|
work->data[64 + 12 + 2] = (nonce >> 16) & 0xff;
|
||||||
work->data[64 + 12 + 3] = (nonce >> 24) & 0xff;
|
work->data[64 + 12 + 3] = (nonce >> 24) & 0xff;
|
||||||
|
#endif
|
||||||
if (opt_scrypt)
|
if (opt_scrypt)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -993,14 +993,14 @@ static cl_int queue_diablo_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint t
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_SCRYPT
|
#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;
|
cl_kernel *kernel = &clState->kernel;
|
||||||
unsigned int num = 0;
|
unsigned int num = 0;
|
||||||
cl_int status = 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);
|
status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 80, clState->cldata, 0, NULL,NULL);
|
||||||
|
|
||||||
CL_SET_ARG(clState->CLbuffer0);
|
CL_SET_ARG(clState->CLbuffer0);
|
||||||
@ -1349,13 +1349,6 @@ static bool opencl_thread_init(struct thr_info *thr)
|
|||||||
return false;
|
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,
|
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)) {
|
||||||
@ -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)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1446,9 +1444,6 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
|
|||||||
if (hashes > gpu->max_hashes)
|
if (hashes > gpu->max_hashes)
|
||||||
gpu->max_hashes = hashes;
|
gpu->max_hashes = hashes;
|
||||||
|
|
||||||
#ifdef USE_SCRYPT
|
|
||||||
clState->cldata = work->data;
|
|
||||||
#endif
|
|
||||||
status = thrdata->queue_kernel_parameters(clState, &work->blk, globalThreads[0]);
|
status = thrdata->queue_kernel_parameters(clState, &work->blk, globalThreads[0]);
|
||||||
if (unlikely(status != CL_SUCCESS)) {
|
if (unlikely(status != CL_SUCCESS)) {
|
||||||
applog(LOG_ERR, "Error: clSetKernelArg of all params failed.");
|
applog(LOG_ERR, "Error: clSetKernelArg of all params failed.");
|
||||||
|
@ -45,7 +45,8 @@ const uint32_t SHA256_K[64] = {
|
|||||||
d = d + h; \
|
d = d + h; \
|
||||||
h = h + (rotate(a, 30) ^ rotate(a, 19) ^ rotate(a, 10)) + ((a & b) | (c & (a | b)))
|
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;
|
cl_uint A, B, C, D, E, F, G, H;
|
||||||
|
|
||||||
A = state[0];
|
A = state[0];
|
||||||
@ -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->fiveA = blk->ctx_f + SHA256_K[5];
|
||||||
blk->sixA = blk->ctx_g + SHA256_K[6];
|
blk->sixA = blk->ctx_g + SHA256_K[6];
|
||||||
blk->sevenA = blk->ctx_h + SHA256_K[7];
|
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)))
|
#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
2
miner.h
@ -671,7 +671,7 @@ typedef struct {
|
|||||||
cl_uint zeroA, zeroB;
|
cl_uint zeroA, zeroB;
|
||||||
cl_uint oneA, twoA, threeA, fourA, fiveA, sixA, sevenA;
|
cl_uint oneA, twoA, threeA, fourA, fiveA, sixA, sevenA;
|
||||||
#ifdef USE_SCRYPT
|
#ifdef USE_SCRYPT
|
||||||
unsigned char *midstate;
|
struct work *work;
|
||||||
#endif
|
#endif
|
||||||
} dev_blk_ctx;
|
} dev_blk_ctx;
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user