From d58490911a1c3245176a44a32ae7774a2a3402f0 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sun, 28 Feb 2016 18:03:12 +0100 Subject: [PATCH] decred: remove some useless double flip --- Algo256/decred.cu | 2 +- Algo256/vanilla.cu | 2 +- ccminer.cpp | 35 +++++++++++++++-------------------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/Algo256/decred.cu b/Algo256/decred.cu index 5ba4550..770cc38 100644 --- a/Algo256/decred.cu +++ b/Algo256/decred.cu @@ -36,7 +36,7 @@ extern "C" void decred_hash(void *output, const void *input) __constant__ uint32_t _ALIGN(4) d_data[24]; -/* 8 adapters max */ +/* 16 adapters max */ static uint32_t *d_resNonce[MAX_GPUS]; static uint32_t *h_resNonce[MAX_GPUS]; diff --git a/Algo256/vanilla.cu b/Algo256/vanilla.cu index d35ade4..c1dc40f 100644 --- a/Algo256/vanilla.cu +++ b/Algo256/vanilla.cu @@ -32,7 +32,7 @@ extern "C" { __constant__ uint32_t d_data[16]; -/* 8 adapters max */ +/* 16 gpu threads max */ static uint32_t *d_resNonce[MAX_GPUS]; static uint32_t *h_resNonce[MAX_GPUS]; diff --git a/ccminer.cpp b/ccminer.cpp index 48aef1f..2b7fd9c 100644 --- a/ccminer.cpp +++ b/ccminer.cpp @@ -1324,9 +1324,8 @@ err_out: static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work) { - uint32_t extraheader[32] = { 0 }; uchar merkle_root[64] = { 0 }; - int i, headersize = 0; + int i; if (!sctx->job.job_id) { // applog(LOG_WARNING, "stratum_gen_work: job not yet retrieved"); @@ -1349,10 +1348,7 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work) /* Generate merkle root */ switch (opt_algo) { case ALGO_DECRED: - // getwork over stratum, getwork merkle + header passed in coinb1 - memcpy(merkle_root, sctx->job.coinbase, 32); - headersize = min((int)sctx->job.coinbase_size - 32, sizeof(extraheader)); - memcpy(extraheader, &sctx->job.coinbase[32], headersize); + // getwork over stratum, no merkle to generate break; case ALGO_HEAVY: case ALGO_MJOLLNIR: @@ -1374,7 +1370,7 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work) memcpy(merkle_root + 32, sctx->job.merkle[i], 32); if (opt_algo == ALGO_HEAVY || opt_algo == ALGO_MJOLLNIR) heavycoin_hash(merkle_root, merkle_root, 64); - else if (!headersize) + else sha256d(merkle_root, merkle_root, 64); } @@ -1386,26 +1382,25 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work) work->data[0] = le32dec(sctx->job.version); for (i = 0; i < 8; i++) work->data[1 + i] = le32dec((uint32_t *)sctx->job.prevhash + i); - for (i = 0; i < 8; i++) - work->data[9 + i] = be32dec((uint32_t *)merkle_root + i); if (opt_algo == ALGO_DECRED) { - for (i = 0; i < 8; i++) // prevhash + for (i = 0; i < 8; i++) // reversed prevhash work->data[1 + i] = swab32(work->data[1 + i]); - for (i = 0; i < 8; i++) // merkle - work->data[9 + i] = swab32(work->data[9 + i]); - for (i = 0; i < headersize/4; i++) // header - work->data[17 + i] = extraheader[i]; + // decred header (coinb1) [merkle...nonce] + memcpy(&work->data[9], sctx->job.coinbase, 112); // extradata - uint32_t* extradata = (uint32_t*) sctx->xnonce1; - for (i = 0; i < sctx->xnonce1_size/4; i++) - work->data[36 + i] = extradata[i]; - for (i = 36 + sctx->xnonce1_size/4; i < 45; i++) - work->data[i] = 0; - work->data[37] = (rand()*4) << 8; + if (sctx->xnonce1_size > sizeof(work->data)-(36*4)) { + // should never happen... + applog(LOG_ERR, "extranonce size overflow!"); + sctx->xnonce1_size = sizeof(work->data)-(36*4); + } + memcpy(&work->data[36], sctx->xnonce1, sctx->xnonce1_size); + work->data[37] = (rand()*4) << 8; // random work data sctx->job.height = work->data[32]; //applog_hex(work->data, 180); } else { + for (i = 0; i < 8; i++) + work->data[9 + i] = be32dec((uint32_t *)merkle_root + i); work->data[17] = le32dec(sctx->job.ntime); work->data[18] = le32dec(sctx->job.nbits); work->data[20] = 0x80000000;