Browse Source

lyra2: fix cpu hash + validation

master
Tanguy Pruvot 10 years ago
parent
commit
5db46b74b5
  1. 19
      lyra2/lyra2RE.cu
  2. 4
      util.cpp

19
lyra2/lyra2RE.cu

@ -38,7 +38,7 @@ extern "C" void lyra_hash(void *state, const void *input)
sph_skein256_context ctx_skein; sph_skein256_context ctx_skein;
sph_groestl256_context ctx_groestl; sph_groestl256_context ctx_groestl;
uint32_t hashA[8], hashB[8], hash[8]; uint32_t hashA[8], hashB[8];
sph_blake256_init(&ctx_blake); sph_blake256_init(&ctx_blake);
sph_blake256(&ctx_blake, input, 80); sph_blake256(&ctx_blake, input, 80);
@ -56,10 +56,9 @@ extern "C" void lyra_hash(void *state, const void *input)
sph_groestl256_init(&ctx_groestl); sph_groestl256_init(&ctx_groestl);
sph_groestl256(&ctx_groestl, hashB, 32); sph_groestl256(&ctx_groestl, hashB, 32);
sph_groestl256_close(&ctx_groestl, hash); sph_groestl256_close(&ctx_groestl, hashA);
// seems wrong : hash or hashB ? memcpy(state, hashA, 32);
memcpy(state, hashB, 32);
} }
static bool init[8] = { 0 }; static bool init[8] = { 0 };
@ -108,20 +107,20 @@ extern "C" int scanhash_lyra(int thr_id, uint32_t *pdata,
skein256_cpu_hash_32(thr_id, throughput, pdata[19], d_hash[thr_id], order++); skein256_cpu_hash_32(thr_id, throughput, pdata[19], d_hash[thr_id], order++);
foundNonce = groestl256_cpu_hash_32(thr_id, throughput, pdata[19], d_hash[thr_id], order++); foundNonce = groestl256_cpu_hash_32(thr_id, throughput, pdata[19], d_hash[thr_id], order++);
if (foundNonce != 0xffffffff) if (foundNonce != UINT32_MAX)
{ {
// const uint32_t Htarg = ptarget[6]; const uint32_t Htarg = ptarget[7];
uint32_t vhash64[8]; uint32_t vhash64[8];
be32enc(&endiandata[19], foundNonce); be32enc(&endiandata[19], foundNonce);
lyra_hash(vhash64, endiandata); lyra_hash(vhash64, endiandata);
// if (vhash64[7]<=Htarg) { // && fulltest(vhash64, ptarget)) { if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) {
*hashes_done = pdata[19] - first_nonce + throughput; *hashes_done = pdata[19] - first_nonce + throughput;
pdata[19] = foundNonce; pdata[19] = foundNonce;
return 1; return 1;
// } else { } else {
// applog(LOG_INFO, "GPU #%d: result for nonce $%08X does not validate on CPU!", thr_id, foundNonce); applog(LOG_INFO, "GPU #%d: result for %08x does not validate on CPU!", thr_id, foundNonce);
// } }
} }
pdata[19] += throughput; pdata[19] += throughput;

4
util.cpp

@ -1644,11 +1644,11 @@ void print_hash_tests(void)
memset(hash, 0, sizeof hash); memset(hash, 0, sizeof hash);
doomhash(&hash[0], &buf[0]); doomhash(&hash[0], &buf[0]);
printpfx("luffa", hash); printpfx("luffa", hash);
/* to double check with a lyra2 cpu miner
memset(hash, 0, sizeof hash); memset(hash, 0, sizeof hash);
lyra_hash(&hash[0], &buf[0]); lyra_hash(&hash[0], &buf[0]);
printpfx("lyra2", hash); printpfx("lyra2", hash);
*/
memset(hash, 0, sizeof hash); memset(hash, 0, sizeof hash);
myriadhash(&hash[0], &buf[0]); myriadhash(&hash[0], &buf[0]);
printpfx("myriad", hash); printpfx("myriad", hash);

Loading…
Cancel
Save