From 5308898d1cfa9fe70365fb06a5ac1f873557d480 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Wed, 23 Sep 2015 11:56:47 +0200 Subject: [PATCH] start v1.7, apply new prototypes to all algos --- Algo256/blake256.cu | 9 ++- Algo256/bmw.cu | 8 +- Algo256/keccak256.cu | 9 ++- JHA/jackpotcoin.cu | 13 +++- README.txt | 5 +- ccminer.cpp | 149 ++++++++++++-------------------------- configure.ac | 2 +- cpuminer-config.h | 6 +- cuda_nist5.cu | 16 ++-- fuguecoin.cpp | 21 +++--- groestlcoin.cpp | 14 ++-- heavy/heavy.cu | 29 ++++---- lyra2/lyra2RE.cu | 9 ++- miner.h | 157 +++++++++------------------------------- myriadgroestl.cpp | 12 +-- neoscrypt/neoscrypt.cpp | 7 +- pentablake.cu | 22 ++++-- quark/quarkcoin.cu | 16 ++-- qubit/deep.cu | 13 +++- qubit/luffa.cu | 7 +- qubit/qubit.cu | 16 ++-- scrypt-jane.cpp | 7 +- scrypt.cpp | 7 +- skein.cu | 10 ++- skein2.cpp | 11 ++- sph/sha2.c | 18 +++-- x11/c11.cu | 12 ++- x11/fresh.cu | 13 +++- x11/s3.cu | 14 +++- x11/x11.cu | 11 ++- x13/x13.cu | 25 ++++--- x15/whirlpoolx.cu | 10 ++- x15/x14.cu | 14 +++- x15/x15.cu | 14 +++- x17/x17.cu | 14 +++- 35 files changed, 348 insertions(+), 372 deletions(-) diff --git a/Algo256/blake256.cu b/Algo256/blake256.cu index b0709f3..edcaa8e 100644 --- a/Algo256/blake256.cu +++ b/Algo256/blake256.cu @@ -379,17 +379,18 @@ void blake256_cpu_setBlock_16(uint32_t *penddata, const uint32_t *midstate, cons static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_blake256(int thr_id, uint32_t *pdata, const uint32_t *ptarget, - uint32_t max_nonce, unsigned long *hashes_done, int8_t blakerounds=14) +extern "C" int scanhash_blake256(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done, int8_t blakerounds=14) { - const uint32_t first_nonce = pdata[19]; - uint64_t targetHigh = ((uint64_t*)ptarget)[3]; uint32_t _ALIGN(64) endiandata[20]; #if PRECALC64 uint32_t _ALIGN(64) midstate[8]; #else uint32_t crcsum; #endif + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; + const uint32_t first_nonce = pdata[19]; + uint64_t targetHigh = ((uint64_t*)ptarget)[3]; int intensity = (device_sm[device_map[thr_id]] > 500) ? 22 : 20; uint32_t throughput = device_intensity(thr_id, __func__, 1U << intensity); throughput = min(throughput, max_nonce - first_nonce); diff --git a/Algo256/bmw.cu b/Algo256/bmw.cu index 1b0d556..a71b092 100644 --- a/Algo256/bmw.cu +++ b/Algo256/bmw.cu @@ -37,9 +37,11 @@ static __inline uint32_t swab32_if(uint32_t val, bool iftrue) { return iftrue ? swab32(val) : val; } -extern "C" int scanhash_bmw(int thr_id, uint32_t *pdata, const uint32_t *ptarget, - uint32_t max_nonce, unsigned long *hashes_done) +extern "C" int scanhash_bmw(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t _ALIGN(64) endiandata[20]; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; bool swapnonce = true; uint32_t throughput = device_intensity(thr_id, __func__, 1U << 21); @@ -59,7 +61,6 @@ extern "C" int scanhash_bmw(int thr_id, uint32_t *pdata, const uint32_t *ptarget init[thr_id] = true; } - uint32_t endiandata[20]; for (int k=0; k < 20; k++) { be32enc(&endiandata[k], ((uint32_t*)pdata)[k]); } @@ -80,6 +81,7 @@ extern "C" int scanhash_bmw(int thr_id, uint32_t *pdata, const uint32_t *ptarget if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) { *hashes_done = foundNonce - first_nonce + 1; pdata[19] = swab32_if(foundNonce,!swapnonce); + bn_store_hash_target_ratio(vhash64, ptarget, work); return 1; } else { diff --git a/Algo256/keccak256.cu b/Algo256/keccak256.cu index ecb181e..1b91ee1 100644 --- a/Algo256/keccak256.cu +++ b/Algo256/keccak256.cu @@ -35,10 +35,11 @@ extern "C" void keccak256_hash(void *state, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_keccak256(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done) +extern "C" int scanhash_keccak256(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t _ALIGN(64) endiandata[20]; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; uint32_t throughput = device_intensity(thr_id, __func__, 1U << 21); // 256*256*8*4 throughput = min(throughput, max_nonce - first_nonce); @@ -55,7 +56,6 @@ extern "C" int scanhash_keccak256(int thr_id, uint32_t *pdata, init[thr_id] = true; } - uint32_t endiandata[20]; for (int k=0; k < 20; k++) { be32enc(&endiandata[k], pdata[k]); } @@ -74,6 +74,7 @@ extern "C" int scanhash_keccak256(int thr_id, uint32_t *pdata, keccak256_hash(vhash64, endiandata); if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) { + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[19] = foundNonce; return 1; } diff --git a/JHA/jackpotcoin.cu b/JHA/jackpotcoin.cu index f58101e..8edcd58 100644 --- a/JHA/jackpotcoin.cu +++ b/JHA/jackpotcoin.cu @@ -87,10 +87,11 @@ extern "C" unsigned int jackpothash(void *state, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_jackpot(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done) +extern "C" int scanhash_jackpot(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t _ALIGN(64) endiandata[22]; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; uint32_t throughput = device_intensity(thr_id, __func__, 1U << 20); @@ -123,7 +124,6 @@ extern "C" int scanhash_jackpot(int thr_id, uint32_t *pdata, init[thr_id] = true; } - uint32_t endiandata[22]; for (int k=0; k < 22; k++) be32enc(&endiandata[k], pdata[k]); @@ -221,7 +221,12 @@ extern "C" int scanhash_jackpot(int thr_id, uint32_t *pdata, if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) { int res = 1; uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); + bn_store_hash_target_ratio(vhash64, ptarget, work); if (secNonce != 0) { + be32enc(&endiandata[19], secNonce); + nist5hash(vhash64, endiandata); + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[21] = secNonce; res++; } diff --git a/README.txt b/README.txt index 393d766..f53ffa4 100644 --- a/README.txt +++ b/README.txt @@ -142,6 +142,7 @@ its command line interface and options. --pstate=0 will force the Geforce 9xx to run in P0 P-State --plimit=150W set the gpu power limit, allow multiple values for N cards --keep-clocks prevent reset clocks and/or power limit on exit + --show-diff display submitted block and net difficulty -B, --background run the miner in the background --benchmark run in offline benchmark mode --cputest debug hashes from cpu algorithms @@ -226,8 +227,10 @@ features. >>> RELEASE HISTORY <<< - Under Dev... v1.6.7 + Under Dev... v1.7 Add --cuda-schedule parameter + Add --show-diff parameter, which display shares diff, + and is able to detect real solved blocks on pools. Aug. 28th 2015 v1.6.6 Allow to load remote config with curl (-c http://...) diff --git a/ccminer.cpp b/ccminer.cpp index 7ea7977..0178a58 100644 --- a/ccminer.cpp +++ b/ccminer.cpp @@ -1873,165 +1873,106 @@ static void *miner_thread(void *userdata) /* scan nonces for a proof-of-work hash */ switch (opt_algo) { - case ALGO_HEAVY: - rc = scanhash_heavy(thr_id, work.data, work.target, - max_nonce, &hashes_done, work.maxvote, HEAVYCOIN_BLKHDR_SZ); - break; - - case ALGO_KECCAK: - rc = scanhash_keccak256(thr_id, work.data, work.target, - max_nonce, &hashes_done); - break; - - case ALGO_MJOLLNIR: - rc = scanhash_heavy(thr_id, work.data, work.target, - max_nonce, &hashes_done, 0, MNR_BLKHDR_SZ); - break; - - case ALGO_DEEP: - rc = scanhash_deep(thr_id, work.data, work.target, - max_nonce, &hashes_done); - break; - - case ALGO_LUFFA: - rc = scanhash_luffa(thr_id, work.data, work.target, - max_nonce, &hashes_done); - break; - case ALGO_BLAKECOIN: - rc = scanhash_blake256(thr_id, work.data, work.target, - max_nonce, &hashes_done, 8); + rc = scanhash_blake256(thr_id, &work, max_nonce, &hashes_done, 8); break; - case ALGO_BLAKE: - rc = scanhash_blake256(thr_id, work.data, work.target, - max_nonce, &hashes_done, 14); + rc = scanhash_blake256(thr_id, &work, max_nonce, &hashes_done, 14); break; - case ALGO_BMW: - rc = scanhash_bmw(thr_id, work.data, work.target, max_nonce, &hashes_done); + rc = scanhash_bmw(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_C11: - rc = scanhash_c11(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_c11(thr_id, &work, max_nonce, &hashes_done); + break; + case ALGO_DEEP: + rc = scanhash_deep(thr_id, &work, max_nonce, &hashes_done); + break; + case ALGO_FRESH: + rc = scanhash_fresh(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_FUGUE256: - rc = scanhash_fugue256(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_fugue256(thr_id, &work, max_nonce, &hashes_done); break; case ALGO_GROESTL: case ALGO_DMD_GR: - rc = scanhash_groestlcoin(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_groestlcoin(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_MYR_GR: - rc = scanhash_myriad(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_myriad(thr_id, &work, max_nonce, &hashes_done); break; + case ALGO_HEAVY: + rc = scanhash_heavy(thr_id, &work, max_nonce, &hashes_done, work.maxvote, HEAVYCOIN_BLKHDR_SZ); + break; + case ALGO_MJOLLNIR: + rc = scanhash_heavy(thr_id, &work, max_nonce, &hashes_done, 0, MNR_BLKHDR_SZ); + break; + case ALGO_KECCAK: + rc = scanhash_keccak256(thr_id, &work, max_nonce, &hashes_done); + break; case ALGO_JACKPOT: - rc = scanhash_jackpot(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_jackpot(thr_id, &work, max_nonce, &hashes_done); + break; + case ALGO_LUFFA: + rc = scanhash_luffa(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_QUARK: - rc = scanhash_quark(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_quark(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_QUBIT: - rc = scanhash_qubit(thr_id, work.data, work.target, - max_nonce, &hashes_done); - break; - - case ALGO_FRESH: - rc = scanhash_fresh(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_qubit(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_LYRA2: - rc = scanhash_lyra2(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_lyra2(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_LYRA2v2: rc = scanhash_lyra2v2(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_NEOSCRYPT: - rc = scanhash_neoscrypt(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_neoscrypt(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_NIST5: - rc = scanhash_nist5(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_nist5(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_PENTABLAKE: - rc = scanhash_pentablake(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_pentablake(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_SCRYPT: - rc = scanhash_scrypt(thr_id, work.data, work.target, NULL, - max_nonce, &hashes_done, &tv_start, &tv_end); + rc = scanhash_scrypt(thr_id, &work, max_nonce, &hashes_done, + NULL, &tv_start, &tv_end); break; - case ALGO_SCRYPT_JANE: - rc = scanhash_scrypt_jane(thr_id, work.data, work.target, NULL, - max_nonce, &hashes_done, &tv_start, &tv_end); + rc = scanhash_scrypt_jane(thr_id, &work, max_nonce, &hashes_done, + NULL, &tv_start, &tv_end); break; - case ALGO_SKEIN: - rc = scanhash_skeincoin(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_skeincoin(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_SKEIN2: - rc = scanhash_skein2(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_skein2(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_S3: - rc = scanhash_s3(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_s3(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_WHIRLPOOLX: - rc = scanhash_whirlpoolx(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_whirlx(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_X11: - rc = scanhash_x11(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_x11(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_X13: - rc = scanhash_x13(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_x13(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_X14: - rc = scanhash_x14(thr_id, work.data, work.target, - max_nonce, &hashes_done); - break; - + rc = scanhash_x14(thr_id, &work, max_nonce, &hashes_done); case ALGO_X15: - rc = scanhash_x15(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_x15(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_X17: - rc = scanhash_x17(thr_id, work.data, work.target, - max_nonce, &hashes_done); + rc = scanhash_x17(thr_id, &work, max_nonce, &hashes_done); break; - case ALGO_ZR5: rc = scanhash_zr5(thr_id, &work, max_nonce, &hashes_done); break; diff --git a/configure.ac b/configure.ac index 18bd776..8370b3e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([ccminer], [1.6.7-dev]) +AC_INIT([ccminer], [1.7-dev]) AC_PREREQ([2.59c]) AC_CANONICAL_SYSTEM diff --git a/cpuminer-config.h b/cpuminer-config.h index 203b281..230750b 100644 --- a/cpuminer-config.h +++ b/cpuminer-config.h @@ -162,7 +162,7 @@ #define PACKAGE_NAME "ccminer" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "ccminer 1.6.6" +#define PACKAGE_STRING "ccminer 1.7-dev" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "ccminer" @@ -171,7 +171,7 @@ #define PACKAGE_URL "http://github.com/tpruvot/ccminer" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.6.6" +#define PACKAGE_VERSION "1.7-dev" /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be @@ -185,7 +185,7 @@ #define STDC_HEADERS 1 /* Version number of package */ -#define VERSION "1.6.6" +#define VERSION "1.7-dev" /* Define curl_free() as free() if our version of curl lacks curl_free. */ /* #undef curl_free */ diff --git a/cuda_nist5.cu b/cuda_nist5.cu index 8287ca1..75582ea 100644 --- a/cuda_nist5.cu +++ b/cuda_nist5.cu @@ -66,10 +66,11 @@ extern "C" void nist5hash(void *state, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_nist5(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done) +extern "C" int scanhash_nist5(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t _ALIGN(64) endiandata[20]; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; uint32_t throughput = device_intensity(thr_id, __func__, 1 << 20); // 256*256*16 @@ -95,7 +96,6 @@ extern "C" int scanhash_nist5(int thr_id, uint32_t *pdata, init[thr_id] = true; } - uint32_t endiandata[20]; for (int k=0; k < 20; k++) be32enc(&endiandata[k], pdata[k]); @@ -112,6 +112,8 @@ extern "C" int scanhash_nist5(int thr_id, uint32_t *pdata, quark_keccak512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); quark_skein512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); + *hashes_done = pdata[19] - first_nonce + throughput; + uint32_t foundNonce = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]); if (foundNonce != UINT32_MAX) { @@ -123,8 +125,12 @@ extern "C" int scanhash_nist5(int thr_id, uint32_t *pdata, if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) { int res = 1; uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); - *hashes_done = pdata[19] - first_nonce + throughput; + bn_store_hash_target_ratio(vhash64, ptarget, work); if (secNonce != 0) { + be32enc(&endiandata[19], secNonce); + nist5hash(vhash64, endiandata); + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[21] = secNonce; res++; } diff --git a/fuguecoin.cpp b/fuguecoin.cpp index 77ef653..056f92d 100644 --- a/fuguecoin.cpp +++ b/fuguecoin.cpp @@ -22,9 +22,11 @@ extern "C" void my_fugue256_addbits_and_close(void *cc, unsigned ub, unsigned n, static bool init[MAX_GPUS] = { 0 }; -int scanhash_fugue256(int thr_id, uint32_t *pdata, const uint32_t *ptarget, - uint32_t max_nonce, unsigned long *hashes_done) +int scanhash_fugue256(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t _ALIGN(64) endiandata[20]; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; uint32_t start_nonce = pdata[19]++; int intensity = (device_sm[device_map[thr_id]] > 500) ? 22 : 19; uint32_t throughput = device_intensity(thr_id, __func__, 1 << intensity); // 256*256*8 @@ -42,8 +44,7 @@ int scanhash_fugue256(int thr_id, uint32_t *pdata, const uint32_t *ptarget, init[thr_id] = true; } - // Endian Drehung ist notwendig - uint32_t endiandata[20]; + // Endian for (int kk=0; kk < 20; kk++) be32enc(&endiandata[kk], pdata[kk]); @@ -57,17 +58,17 @@ int scanhash_fugue256(int thr_id, uint32_t *pdata, const uint32_t *ptarget, if (foundNounce < UINT32_MAX) { - uint32_t hash[8]; - const uint32_t Htarg = ptarget[7]; - - endiandata[19] = SWAP32(foundNounce); + uint32_t vhash[8]; sph_fugue256_context ctx_fugue; + endiandata[19] = SWAP32(foundNounce); + sph_fugue256_init(&ctx_fugue); sph_fugue256 (&ctx_fugue, endiandata, 80); - sph_fugue256_close(&ctx_fugue, &hash); + sph_fugue256_close(&ctx_fugue, &vhash); - if (hash[7] <= Htarg && fulltest(hash, ptarget)) + if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) { + bn_store_hash_target_ratio(vhash, ptarget, work); pdata[19] = foundNounce; *hashes_done = foundNounce - start_nonce + 1; return 1; diff --git a/groestlcoin.cpp b/groestlcoin.cpp index bf39c8f..9c81aa5 100644 --- a/groestlcoin.cpp +++ b/groestlcoin.cpp @@ -27,10 +27,11 @@ void groestlhash(void *state, const void *input) static bool init[MAX_GPUS] = { 0 }; -int scanhash_groestlcoin(int thr_id, uint32_t *pdata, const uint32_t *ptarget, - uint32_t max_nonce, unsigned long *hashes_done) +int scanhash_groestlcoin(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done) { - uint32_t _ALIGN(64) endiandata[20]; + uint32_t _ALIGN(64) endiandata[32]; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; uint32_t start_nonce = pdata[19]; uint32_t throughput = device_intensity(thr_id, __func__, 1 << 19); // 256*256*8 throughput = min(throughput, max_nonce - start_nonce); @@ -62,11 +63,12 @@ int scanhash_groestlcoin(int thr_id, uint32_t *pdata, const uint32_t *ptarget, if (foundNounce < UINT32_MAX) { - uint32_t _ALIGN(64) tmpHash[8]; + uint32_t _ALIGN(64) vhash[8]; endiandata[19] = swab32(foundNounce); - groestlhash(tmpHash, endiandata); + groestlhash(vhash, endiandata); - if (tmpHash[7] <= ptarget[7] && fulltest(tmpHash, ptarget)) { + if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) { + bn_store_hash_target_ratio(vhash, ptarget, work); pdata[19] = foundNounce; free(outputHash); return true; diff --git a/heavy/heavy.cu b/heavy/heavy.cu index 03f535d..023f780 100644 --- a/heavy/heavy.cu +++ b/heavy/heavy.cu @@ -130,10 +130,10 @@ struct check_nonce_for_remove static bool init[MAX_GPUS] = { 0 }; __host__ -int scanhash_heavy(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done, uint32_t maxvote, int blocklen) +int scanhash_heavy(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done, uint32_t maxvote, int blocklen) { + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; // CUDA will process thousands of threads. uint32_t throughput = device_intensity(thr_id, __func__, (1U << 19) - 256); @@ -271,18 +271,17 @@ int scanhash_heavy(int thr_id, uint32_t *pdata, { uint32_t nonce = cpu_nonceVector[i]; uint32_t *foundhash = &hash[8*i]; - if (foundhash[7] <= ptarget[7]) { - if (fulltest(foundhash, ptarget)) { - uint32_t verification[8]; - pdata[19] += nonce - pdata[19]; - heavycoin_hash((uchar*)verification, (uchar*)pdata, blocklen); - if (memcmp(verification, foundhash, 8*sizeof(uint32_t))) { - applog(LOG_ERR, "hash for nonce=$%08X does not validate on CPU!\n", nonce); - } else { - *hashes_done = pdata[19] - first_nonce; - rc = 1; - goto exit; - } + if (foundhash[7] <= ptarget[7] && fulltest(foundhash, ptarget)) { + uint32_t vhash[8]; + pdata[19] += nonce - pdata[19]; + heavycoin_hash((uchar*)vhash, (uchar*)pdata, blocklen); + if (memcmp(vhash, foundhash, 8*sizeof(uint32_t))) { + applog(LOG_ERR, "hash for nonce %08x does not validate on CPU!\n", nonce); + } else { + *hashes_done = pdata[19] - first_nonce; + bn_store_hash_target_ratio(vhash, ptarget, work); + rc = 1; + goto exit; } } } diff --git a/lyra2/lyra2RE.cu b/lyra2/lyra2RE.cu index a44ca05..ce95449 100644 --- a/lyra2/lyra2RE.cu +++ b/lyra2/lyra2RE.cu @@ -75,10 +75,10 @@ extern "C" void lyra2re_hash(void *state, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_lyra2(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done) +extern "C" int scanhash_lyra2(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; int intensity = (device_sm[device_map[thr_id]] >= 500 && !is_windows()) ? 18 : 17; uint32_t throughput = device_intensity(thr_id, __func__, 1U << intensity); // 18=256*256*4; @@ -135,6 +135,7 @@ extern "C" int scanhash_lyra2(int thr_id, uint32_t *pdata, if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) { int res = 1; uint32_t secNonce = groestl256_getSecNonce(thr_id, 1); + bn_store_hash_target_ratio(vhash64, ptarget, work); if (secNonce != UINT32_MAX) { be32enc(&endiandata[19], secNonce); @@ -142,6 +143,8 @@ extern "C" int scanhash_lyra2(int thr_id, uint32_t *pdata, if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) { if (opt_debug) applog(LOG_BLUE, "GPU #%d: found second nonce %08x", device_map[thr_id], secNonce); + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[21] = secNonce; res++; } diff --git a/miner.h b/miner.h index e87ef13..e17c754 100644 --- a/miner.h +++ b/miner.h @@ -264,128 +264,41 @@ void sha256d(unsigned char *hash, const unsigned char *data, int len); struct work; -extern int scanhash_sha256d(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done); - -extern int scanhash_deep(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_luffa(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_fugue256(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_groestlcoin(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_heavy(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done, uint32_t maxvote, int blocklen); - -extern int scanhash_keccak256(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_myriad(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_jackpot(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_quark(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_blake256(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done, int8_t blakerounds); - -extern int scanhash_bmw(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_c11(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_fresh(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_lyra2(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done); - -extern int scanhash_lyra2v2(int thr_id, struct work *work, - uint32_t max_nonce, unsigned long *hashes_done); - -extern int scanhash_neoscrypt(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done); - -extern int scanhash_nist5(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_pentablake(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_qubit(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_scrypt(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, unsigned char *scratchbuf, uint32_t max_nonce, - unsigned long *hashes_done, struct timeval *tv_start, struct timeval *tv_end); - -extern int scanhash_scrypt_jane(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, unsigned char *scratchbuf, uint32_t max_nonce, - unsigned long *hashes_done, struct timeval *tv_start, struct timeval *tv_end); - -extern int scanhash_skeincoin(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_skein2(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_s3(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_x11(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_x13(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_x14(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_x15(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_x17(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_whirlpoolx(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done); - -extern int scanhash_zr5(int thr_id, struct work *work, uint32_t max_nonce, - unsigned long *hashes_done); +extern int scanhash_blake256(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done, int8_t blakerounds); +extern int scanhash_bmw(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_c11(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_deep(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_keccak256(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_fresh(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_fugue256(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_groestlcoin(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_heavy(int thr_id,struct work *work, uint32_t max_nonce, unsigned long *hashes_done, uint32_t maxvote, int blocklen); +extern int scanhash_jackpot(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_luffa(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_lyra2(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_lyra2v2(int thr_id,struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_myriad(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_neoscrypt(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_nist5(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_pentablake(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_quark(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_qubit(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_skeincoin(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_skein2(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_s3(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_whirlx(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_x11(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_x13(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_x14(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_x15(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_x17(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_zr5(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done); + +extern int scanhash_sha256d(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_scrypt(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done, + unsigned char *scratchbuf, struct timeval *tv_start, struct timeval *tv_end); +extern int scanhash_scrypt_jane(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done, + unsigned char *scratchbuf, struct timeval *tv_start, struct timeval *tv_end); /* api related */ void *api_thread(void *userdata); diff --git a/myriadgroestl.cpp b/myriadgroestl.cpp index 13b85f4..5bdbc5c 100644 --- a/myriadgroestl.cpp +++ b/myriadgroestl.cpp @@ -30,10 +30,11 @@ void myriadhash(void *state, const void *input) static bool init[MAX_GPUS] = { 0 }; -int scanhash_myriad(int thr_id, uint32_t *pdata, const uint32_t *ptarget, - uint32_t max_nonce, unsigned long *hashes_done) +int scanhash_myriad(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done) { uint32_t _ALIGN(64) endiandata[32]; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; uint32_t start_nonce = pdata[19]; uint32_t throughput = device_intensity(thr_id, __func__, 1 << 17); throughput = min(throughput, max_nonce - start_nonce); @@ -67,10 +68,11 @@ int scanhash_myriad(int thr_id, uint32_t *pdata, const uint32_t *ptarget, if (foundNounce < UINT32_MAX) { - uint32_t _ALIGN(64) tmpHash[8]; + uint32_t _ALIGN(64) vhash[8]; endiandata[19] = swab32(foundNounce); - myriadhash(tmpHash, endiandata); - if (tmpHash[7] <= ptarget[7] && fulltest(tmpHash, ptarget)) { + myriadhash(vhash, endiandata); + if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) { + bn_store_hash_target_ratio(vhash, ptarget, work); pdata[19] = foundNounce; free(outputHash); return 1; diff --git a/neoscrypt/neoscrypt.cpp b/neoscrypt/neoscrypt.cpp index 9e38abe..cb1bed4 100644 --- a/neoscrypt/neoscrypt.cpp +++ b/neoscrypt/neoscrypt.cpp @@ -8,8 +8,11 @@ extern uint32_t neoscrypt_cpu_hash_k4(int thr_id, uint32_t threads, uint32_t sta static bool init[MAX_GPUS] = { 0 }; -int scanhash_neoscrypt(int thr_id, uint32_t *pdata, const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done) +int scanhash_neoscrypt(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t _ALIGN(64) endiandata[20]; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; int intensity = is_windows() ? 18 : 19; @@ -37,7 +40,6 @@ int scanhash_neoscrypt(int thr_id, uint32_t *pdata, const uint32_t *ptarget, uin init[thr_id] = true; } - uint32_t endiandata[20]; if (have_stratum) { for (int k = 0; k < 20; k++) be32enc(&endiandata[k], pdata[k]); @@ -64,6 +66,7 @@ int scanhash_neoscrypt(int thr_id, uint32_t *pdata, const uint32_t *ptarget, uin neoscrypt((uchar*)vhash64, (uchar*) endiandata, 0x80000620U); if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) { + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[19] = foundNonce; return 1; } else { diff --git a/pentablake.cu b/pentablake.cu index f539902..e777bb8 100644 --- a/pentablake.cu +++ b/pentablake.cu @@ -364,11 +364,12 @@ void pentablake_cpu_setBlock_80(uint32_t *pdata, const uint32_t *ptarget) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_pentablake(int thr_id, uint32_t *pdata, const uint32_t *ptarget, - uint32_t max_nonce, unsigned long *hashes_done) +extern "C" int scanhash_pentablake(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t _ALIGN(64) endiandata[20]; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; - uint32_t endiandata[20]; int rc = 0; uint32_t throughput = device_intensity(thr_id, __func__, 128U * 2560); // 18.5 throughput = min(throughput, max_nonce - first_nonce); @@ -403,20 +404,25 @@ extern "C" int scanhash_pentablake(int thr_id, uint32_t *pdata, const uint32_t * pentablake_cpu_hash_64(thr_id, throughput, pdata[19], d_hash[thr_id], order++); pentablake_cpu_hash_64(thr_id, throughput, pdata[19], d_hash[thr_id], order++); + *hashes_done = pdata[19] - first_nonce + throughput; + uint32_t foundNonce = pentablake_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id], order++); if (foundNonce != UINT32_MAX) { - const uint32_t Htarg = ptarget[7]; - uint32_t vhashcpu[8]; + uint32_t vhash[8]; be32enc(&endiandata[19], foundNonce); - pentablakehash(vhashcpu, endiandata); + pentablakehash(vhash, endiandata); - if (vhashcpu[7] <= Htarg && fulltest(vhashcpu, ptarget)) { + if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) { rc = 1; - *hashes_done = pdata[19] - first_nonce + throughput; + bn_store_hash_target_ratio(vhash, ptarget, work); if (extra_results[0] != UINT32_MAX) { // Rare but possible if the throughput is big + be32enc(&endiandata[19], extra_results[0]); + pentablakehash(vhash, endiandata); + if (bn_hash_target_ratio(vhash, ptarget) > work->shareratio) + bn_store_hash_target_ratio(vhash, ptarget, work); applog(LOG_NOTICE, "GPU found more than one result yippee!"); pdata[21] = extra_results[0]; extra_results[0] = UINT32_MAX; diff --git a/quark/quarkcoin.cu b/quark/quarkcoin.cu index 4480785..dc266dd 100644 --- a/quark/quarkcoin.cu +++ b/quark/quarkcoin.cu @@ -131,10 +131,11 @@ extern "C" void quarkhash(void *state, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_quark(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done) +extern "C" int scanhash_quark(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t _ALIGN(64) endiandata[20]; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; uint32_t throughput = device_intensity(thr_id, __func__, 1 << 20); // 256*4096 @@ -166,7 +167,6 @@ extern "C" int scanhash_quark(int thr_id, uint32_t *pdata, init[thr_id] = true; } - uint32_t endiandata[20]; for (int k=0; k < 20; k++) be32enc(&endiandata[k], pdata[k]); @@ -226,19 +226,19 @@ extern "C" int scanhash_quark(int thr_id, uint32_t *pdata, // das ist der bedingte Branch für JH512 quark_jh512_cpu_hash_64(thr_id, nrm2, pdata[19], d_branch2Nonces[thr_id], d_hash[thr_id], order++); + *hashes_done = pdata[19] - first_nonce + 1; + // Scan nach Gewinner Hashes auf der GPU uint32_t foundNonce = cuda_check_hash_branch(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++); if (foundNonce != 0xffffffff) { - const uint32_t Htarg = ptarget[7]; uint32_t vhash64[8]; be32enc(&endiandata[19], foundNonce); quarkhash(vhash64, endiandata); - if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) { - + if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) { + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[19] = foundNonce; - *hashes_done = foundNonce - first_nonce + 1; return 1; } else { applog(LOG_WARNING, "GPU #%d: result for nonce %08x does not validate on CPU!", device_map[thr_id], foundNonce); diff --git a/qubit/deep.cu b/qubit/deep.cu index 4041f40..b0b1fbb 100644 --- a/qubit/deep.cu +++ b/qubit/deep.cu @@ -52,10 +52,11 @@ extern "C" void deephash(void *state, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_deep(int thr_id, uint32_t *pdata, const uint32_t *ptarget, - uint32_t max_nonce, unsigned long *hashes_done) +extern "C" int scanhash_deep(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { uint32_t _ALIGN(64) endiandata[20]; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; uint32_t throughput = device_intensity(thr_id, __func__, 1U << 19); // 256*256*8 throughput = min(throughput, (max_nonce - first_nonce)); @@ -91,6 +92,8 @@ extern "C" int scanhash_deep(int thr_id, uint32_t *pdata, const uint32_t *ptarge x11_cubehash512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); x11_echo512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); + *hashes_done = pdata[19] - first_nonce + throughput; + uint32_t foundNonce = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]); if (foundNonce != UINT32_MAX) { @@ -101,8 +104,12 @@ extern "C" int scanhash_deep(int thr_id, uint32_t *pdata, const uint32_t *ptarge if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) { int res = 1; uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); - *hashes_done = pdata[19] - first_nonce + throughput; + bn_store_hash_target_ratio(vhash64, ptarget, work); if (secNonce != 0) { + be32enc(&endiandata[19], secNonce); + deephash(vhash64, endiandata); + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[21] = secNonce; res++; } diff --git a/qubit/luffa.cu b/qubit/luffa.cu index e0960c9..6b2fe75 100644 --- a/qubit/luffa.cu +++ b/qubit/luffa.cu @@ -30,10 +30,11 @@ extern "C" void luffa_hash(void *state, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_luffa(int thr_id, uint32_t *pdata, const uint32_t *ptarget, - uint32_t max_nonce, unsigned long *hashes_done) +extern "C" int scanhash_luffa(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { uint32_t _ALIGN(64) endiandata[20]; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; uint32_t throughput = device_intensity(thr_id, __func__, 1U << 22); // 256*256*8*8 throughput = min(throughput, max_nonce - first_nonce); @@ -75,7 +76,7 @@ extern "C" int scanhash_luffa(int thr_id, uint32_t *pdata, const uint32_t *ptarg luffa_hash(vhash64, endiandata); if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) { - //*hashes_done = min(max_nonce - first_nonce, (uint64_t) pdata[19] - first_nonce + throughput); + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[19] = foundNonce; return 1; } else { diff --git a/qubit/qubit.cu b/qubit/qubit.cu index 133cec3..6c69d72 100644 --- a/qubit/qubit.cu +++ b/qubit/qubit.cu @@ -74,11 +74,11 @@ extern "C" void qubithash(void *state, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_qubit(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done) +extern "C" int scanhash_qubit(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { - uint32_t endiandata[20]; + uint32_t _ALIGN(64) endiandata[20]; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; uint32_t throughput = device_intensity(thr_id, __func__, 1U << 19); // 256*256*8 throughput = min(throughput, max_nonce - first_nonce); @@ -119,6 +119,8 @@ extern "C" int scanhash_qubit(int thr_id, uint32_t *pdata, x11_simd512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); x11_echo512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); + *hashes_done = pdata[19] - first_nonce + throughput; + uint32_t foundNonce = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]); if (foundNonce != UINT32_MAX) { @@ -130,8 +132,12 @@ extern "C" int scanhash_qubit(int thr_id, uint32_t *pdata, if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) { int res = 1; uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); - *hashes_done = pdata[19] - first_nonce + throughput; + bn_store_hash_target_ratio(vhash64, ptarget, work); if (secNonce != 0) { + be32enc(&endiandata[19], secNonce); + qubithash(vhash64, endiandata); + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[21] = secNonce; res++; } diff --git a/scrypt-jane.cpp b/scrypt-jane.cpp index 82556fe..eb20ea5 100644 --- a/scrypt-jane.cpp +++ b/scrypt-jane.cpp @@ -430,9 +430,11 @@ unsigned char GetNfactor(unsigned int nTimestamp) | (((x) >> 8) & 0x0000ff00u) | (((x) >> 24) & 0x000000ffu)) static int s_Nfactor = 0; -int scanhash_scrypt_jane(int thr_id, uint32_t *pdata, const uint32_t *ptarget, unsigned char *scratchbuf, - uint32_t max_nonce, unsigned long *hashes_done, struct timeval *tv_start, struct timeval *tv_end) +int scanhash_scrypt_jane(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done, + unsigned char *scratchbuf, struct timeval *tv_start, struct timeval *tv_end) { + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t Htarg = ptarget[7]; uint32_t N; @@ -594,6 +596,7 @@ int scanhash_scrypt_jane(int thr_id, uint32_t *pdata, const uint32_t *ptarget, u if (memcmp(thash, &hash[cur][8*i], 32) == 0) { + bn_store_hash_target_ratio(thash, ptarget, work); *hashes_done = n - pdata[19]; pdata[19] = tmp_nonce; scrypt_free(&Vbuf); diff --git a/scrypt.cpp b/scrypt.cpp index f858d24..e63139d 100644 --- a/scrypt.cpp +++ b/scrypt.cpp @@ -689,10 +689,12 @@ static void computeGold(uint32_t* const input, uint32_t *reference, uchar *scrat // using SSE2 vectorized HMAC SHA256 on CPU and // a salsa core implementation on GPU with CUDA // -int scanhash_scrypt(int thr_id, uint32_t *pdata, const uint32_t *ptarget, unsigned char *scratchbuf, - uint32_t max_nonce, unsigned long *hashes_done, struct timeval *tv_start, struct timeval *tv_end) +int scanhash_scrypt(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done, + unsigned char *scratchbuf, struct timeval *tv_start, struct timeval *tv_end) { int result = 0; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; int throughput = cuda_throughput(thr_id); if(throughput == 0) @@ -904,6 +906,7 @@ int scanhash_scrypt(int thr_id, uint32_t *pdata, const uint32_t *ptarget, unsign device_map[thr_id], device_name[thr_id], i, cur); } else { *hashes_done = n - pdata[19]; + bn_store_hash_target_ratio(refhash, ptarget, work); pdata[19] = nonce[cur] + i; result = 1; goto byebye; diff --git a/skein.cu b/skein.cu index 3290e4a..3b52178 100644 --- a/skein.cu +++ b/skein.cu @@ -346,10 +346,11 @@ static __inline uint32_t swab32_if(uint32_t val, bool iftrue) { static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_skeincoin(int thr_id, uint32_t *pdata, const uint32_t *ptarget, - uint32_t max_nonce, unsigned long *hashes_done) +extern "C" int scanhash_skeincoin(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { uint32_t _ALIGN(64) endiandata[20]; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; const int swap = 1; @@ -425,7 +426,12 @@ extern "C" int scanhash_skeincoin(int thr_id, uint32_t *pdata, const uint32_t *p endiandata[19] = swab32_if(secNonce, swap); skeincoinhash(vhash64, endiandata); if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) { + bn_store_hash_target_ratio(vhash64, ptarget, work); // todo: use 19 20 21... zr5 pok to adapt... + endiandata[19] = swab32_if(secNonce, swap); + skeincoinhash(vhash64, endiandata); + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[19+res*2] = swab32_if(secNonce, !swap); res++; } diff --git a/skein2.cpp b/skein2.cpp index e9b2d55..8a6fcef 100644 --- a/skein2.cpp +++ b/skein2.cpp @@ -36,9 +36,10 @@ void skein2hash(void *output, const void *input) static bool init[MAX_GPUS] = { 0 }; -int scanhash_skein2(int thr_id, uint32_t *pdata, const uint32_t *ptarget, - uint32_t max_nonce, unsigned long *hashes_done) +int scanhash_skein2(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; uint32_t throughput = device_intensity(thr_id, __func__, 1 << 19); // 256*256*8 @@ -88,9 +89,15 @@ int scanhash_skein2(int thr_id, uint32_t *pdata, const uint32_t *ptarget, if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) { int res = 1; uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); + bn_store_hash_target_ratio(vhash64, ptarget, work); if (secNonce != 0) { if (!opt_quiet) applog(LOG_BLUE, "GPU #%d: found second nonce %08x !", device_map[thr_id], swab32(secNonce)); + + endiandata[19] = secNonce; + skein2hash(vhash64, endiandata); + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[21] = swab32(secNonce); res++; } diff --git a/sph/sha2.c b/sph/sha2.c index 8c5df1e..4838692 100644 --- a/sph/sha2.c +++ b/sph/sha2.c @@ -468,8 +468,8 @@ static inline void sha256d_ms(uint32_t *hash, uint32_t *W, void sha256d_ms_4way(uint32_t *hash, uint32_t *data, const uint32_t *midstate, const uint32_t *prehash); -static inline int scanhash_sha256d_4way(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done) +static inline int scanhash_sha256d_4way(int thr_id, uint32_t *pdata, + const uint32_t *ptarget uint32_t max_nonce, unsigned long *hashes_done) { uint32_t data[4 * 64] __attribute__((aligned(128))); uint32_t hash[4 * 8] __attribute__((aligned(32))); @@ -508,6 +508,7 @@ static inline int scanhash_sha256d_4way(int thr_id, uint32_t *pdata, pdata[19] = data[4 * 3 + i]; sha256d_80_swap(hash, pdata); if (fulltest(hash, ptarget)) { + bn_store_hash_target_ratio(hash, ptarget, work); *hashes_done = n - first_nonce + 1; return 1; } @@ -581,13 +582,14 @@ static inline int scanhash_sha256d_8way(int thr_id, uint32_t *pdata, #endif /* HAVE_SHA256_8WAY */ -int scanhash_sha256d(int thr_id, uint32_t *pdata, const uint32_t *ptarget, - uint32_t max_nonce, unsigned long *hashes_done) +int scanhash_sha256d(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { - uint32_t data[64] /* __attribute__((aligned(128))) */; - uint32_t hash[8] /* __attribute__((aligned(32))) */; - uint32_t midstate[8] /* __attribute__((aligned(32))) */; - uint32_t prehash[8] /* __attribute__((aligned(32))) */; + uint32_t _ALIGN(128) data[64]; + uint32_t hash[8]; + uint32_t midstate[8]; + uint32_t prehash[8]; + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; uint32_t n = pdata[19] - 1; const uint32_t first_nonce = pdata[19]; const uint32_t Htarg = ptarget[7]; diff --git a/x11/c11.cu b/x11/c11.cu index ae1ba45..c0cffdc 100644 --- a/x11/c11.cu +++ b/x11/c11.cu @@ -142,8 +142,10 @@ extern "C" void c11hash(void *output, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_c11(int thr_id, uint32_t *pdata, const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done) +extern "C" int scanhash_c11(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; int intensity = (device_sm[device_map[thr_id]] >= 500 && !is_windows()) ? 20 : 19; uint32_t throughput = device_intensity(thr_id, __func__, 1U << intensity); // 19=256*256*8; @@ -208,6 +210,8 @@ extern "C" int scanhash_c11(int thr_id, uint32_t *pdata, const uint32_t *ptarget x11_echo512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); TRACE("echo => "); + *hashes_done = pdata[19] - first_nonce + throughput; + foundNonce = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]); if (foundNonce != UINT32_MAX) { @@ -220,8 +224,12 @@ extern "C" int scanhash_c11(int thr_id, uint32_t *pdata, const uint32_t *ptarget int res = 1; // check if there was some other ones... uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); - *hashes_done = pdata[19] - first_nonce + throughput; + bn_store_hash_target_ratio(vhash64, ptarget, work); if (secNonce != 0) { + be32enc(&endiandata[19], secNonce); + c11hash(vhash64, endiandata); + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[21] = secNonce; res++; } diff --git a/x11/fresh.cu b/x11/fresh.cu index 1d6a6c9..e667baf 100644 --- a/x11/fresh.cu +++ b/x11/fresh.cu @@ -70,10 +70,10 @@ extern "C" void fresh_hash(void *state, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_fresh(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done) +extern "C" int scanhash_fresh(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; uint32_t endiandata[20]; @@ -122,6 +122,7 @@ extern "C" int scanhash_fresh(int thr_id, uint32_t *pdata, CUDA_SAFE_CALL(cudaThreadSynchronize()); print_hash((unsigned char*)buf); printf("\n"); #endif + *hashes_done = pdata[19] - first_nonce + throughput; foundNonce = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]); if (foundNonce != UINT32_MAX) @@ -133,8 +134,12 @@ extern "C" int scanhash_fresh(int thr_id, uint32_t *pdata, if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) { int res = 1; uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); - *hashes_done = pdata[19] - first_nonce + throughput; + bn_store_hash_target_ratio(vhash64, ptarget, work); if (secNonce != 0) { + be32enc(&endiandata[19], secNonce); + fresh_hash(vhash64, endiandata); + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[21] = secNonce; res++; } diff --git a/x11/s3.cu b/x11/s3.cu index f0ebbd6..0f517f0 100644 --- a/x11/s3.cu +++ b/x11/s3.cu @@ -52,10 +52,10 @@ extern "C" void s3hash(void *output, const void *input) static bool init[MAX_GPUS] = { 0 }; /* Main S3 entry point */ -extern "C" int scanhash_s3(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done) +extern "C" int scanhash_s3(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; int intensity = 20; // 256*256*8*2; #ifdef WIN32 @@ -99,6 +99,8 @@ extern "C" int scanhash_s3(int thr_id, uint32_t *pdata, x11_simd512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); quark_skein512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); + *hashes_done = pdata[19] - first_nonce + throughput; + foundNonce = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]); if (foundNonce != UINT32_MAX) @@ -110,8 +112,12 @@ extern "C" int scanhash_s3(int thr_id, uint32_t *pdata, if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) { int res = 1; uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); - *hashes_done = pdata[19] - first_nonce + throughput; + bn_store_hash_target_ratio(vhash64, ptarget, work); if (secNonce != 0) { + be32enc(&endiandata[19], secNonce); + s3hash(vhash64, endiandata); + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[21] = secNonce; res++; } diff --git a/x11/x11.cu b/x11/x11.cu index 65e87db..b13aff5 100644 --- a/x11/x11.cu +++ b/x11/x11.cu @@ -142,10 +142,10 @@ extern "C" void x11hash(void *output, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_x11(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done) +extern "C" int scanhash_x11(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; int intensity = (device_sm[device_map[thr_id]] >= 500 && !is_windows()) ? 20 : 19; uint32_t throughput = device_intensity(thr_id, __func__, 1U << intensity); // 19=256*256*8; @@ -222,8 +222,13 @@ extern "C" int scanhash_x11(int thr_id, uint32_t *pdata, int res = 1; // check if there was some other ones... uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); + bn_store_hash_target_ratio(vhash64, ptarget, work); *hashes_done = pdata[19] - first_nonce + throughput; if (secNonce != 0) { + be32enc(&endiandata[19], secNonce); + x11hash(vhash64, endiandata); + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[21] = secNonce; res++; } diff --git a/x13/x13.cu b/x13/x13.cu index 75e69aa..dea8709 100644 --- a/x13/x13.cu +++ b/x13/x13.cu @@ -145,10 +145,10 @@ extern "C" void x13hash(void *output, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_x13(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done) +extern "C" int scanhash_x13(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; int intensity = 19; // (device_sm[device_map[thr_id]] > 500 && !is_windows()) ? 20 : 19; uint32_t throughput = device_intensity(thr_id, __func__, 1 << intensity); // 19=256*256*8; @@ -207,23 +207,30 @@ extern "C" int scanhash_x13(int thr_id, uint32_t *pdata, x13_hamsi512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); x13_fugue512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); + *hashes_done = pdata[19] - first_nonce + throughput; + foundNonce = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]); if (foundNonce != UINT32_MAX) { - const uint32_t Htarg = ptarget[7]; - uint32_t vhash64[8]; + uint32_t vhash[8]; be32enc(&endiandata[19], foundNonce); - x13hash(vhash64, endiandata); + x13hash(vhash, endiandata); - if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) { + if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) { int res = 1; uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); - *hashes_done = pdata[19] - first_nonce + throughput; + bn_store_hash_target_ratio(vhash, ptarget, work); + pdata[19] = foundNonce; if (secNonce != 0) { + be32enc(&endiandata[19], secNonce); + x13hash(vhash, endiandata); pdata[21] = secNonce; + if (bn_hash_target_ratio(vhash, ptarget) > work->shareratio) { + bn_store_hash_target_ratio(vhash, ptarget, work); + xchg(pdata[19], pdata[21]); + } res++; } - pdata[19] = foundNonce; return res; } else { applog(LOG_WARNING, "GPU #%d: result for %08x does not validate on CPU!", device_map[thr_id], foundNonce); diff --git a/x15/whirlpoolx.cu b/x15/whirlpoolx.cu index c9a448e..4aa4346 100644 --- a/x15/whirlpoolx.cu +++ b/x15/whirlpoolx.cu @@ -37,9 +37,10 @@ extern "C" void whirlxHash(void *state, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_whirlpoolx(int thr_id, uint32_t *pdata, const uint32_t *ptarget, - uint32_t max_nonce, unsigned long *hashes_done) +extern "C" int scanhash_whirlx(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; uint32_t endiandata[20]; int intensity = is_windows() ? 20 : 22; @@ -65,6 +66,7 @@ extern "C" int scanhash_whirlpoolx(int thr_id, uint32_t *pdata, const uint32_t * whirlpoolx_setBlock_80((void*)endiandata, ptarget); whirlpoolx_precompute(thr_id); + do { uint32_t foundNonce = whirlpoolx_cpu_hash(thr_id, throughput, pdata[19]); if (foundNonce != UINT32_MAX) @@ -74,8 +76,10 @@ extern "C" int scanhash_whirlpoolx(int thr_id, uint32_t *pdata, const uint32_t * be32enc(&endiandata[19], foundNonce); whirlxHash(vhash64, endiandata); + *hashes_done = pdata[19] - first_nonce + throughput; + if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) { - *hashes_done = pdata[19] - first_nonce + throughput; + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[19] = foundNonce; return 1; } else { diff --git a/x15/x14.cu b/x15/x14.cu index 5d1a054..337b746 100644 --- a/x15/x14.cu +++ b/x15/x14.cu @@ -157,10 +157,10 @@ extern "C" void x14hash(void *output, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_x14(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done) +extern "C" int scanhash_x14(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; uint32_t endiandata[20]; @@ -216,6 +216,8 @@ extern "C" int scanhash_x14(int thr_id, uint32_t *pdata, x13_fugue512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); x14_shabal512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); + *hashes_done = pdata[19] - first_nonce + throughput; + uint32_t foundNonce = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]); if (foundNonce != UINT32_MAX) { @@ -228,8 +230,12 @@ extern "C" int scanhash_x14(int thr_id, uint32_t *pdata, if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) { int res = 1; uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); - *hashes_done = pdata[19] - first_nonce + throughput; + bn_store_hash_target_ratio(vhash64, ptarget, work); if (secNonce != 0) { + be32enc(&endiandata[19], secNonce); + x14hash(vhash64, endiandata); + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[21] = secNonce; res++; } diff --git a/x15/x15.cu b/x15/x15.cu index 5fe394f..e569875 100644 --- a/x15/x15.cu +++ b/x15/x15.cu @@ -167,10 +167,10 @@ extern "C" void x15hash(void *output, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_x15(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done) +extern "C" int scanhash_x15(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; uint32_t endiandata[20]; @@ -228,6 +228,8 @@ extern "C" int scanhash_x15(int thr_id, uint32_t *pdata, x14_shabal512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); x15_whirlpool_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); + *hashes_done = pdata[19] - first_nonce + throughput; + uint32_t foundNonce = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]); if (foundNonce != UINT32_MAX) { @@ -240,8 +242,12 @@ extern "C" int scanhash_x15(int thr_id, uint32_t *pdata, if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) { int res = 1; uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); - *hashes_done = pdata[19] - first_nonce + throughput; + bn_store_hash_target_ratio(vhash64, ptarget, work); if (secNonce != 0) { + be32enc(&endiandata[19], secNonce); + x15hash(vhash64, endiandata); + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[21] = secNonce; res++; } diff --git a/x17/x17.cu b/x17/x17.cu index 12b3999..2193d32 100644 --- a/x17/x17.cu +++ b/x17/x17.cu @@ -186,10 +186,10 @@ extern "C" void x17hash(void *output, const void *input) static bool init[MAX_GPUS] = { 0 }; -extern "C" int scanhash_x17(int thr_id, uint32_t *pdata, - const uint32_t *ptarget, uint32_t max_nonce, - unsigned long *hashes_done) +extern "C" int scanhash_x17(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) { + uint32_t *pdata = work->data; + uint32_t *ptarget = work->target; const uint32_t first_nonce = pdata[19]; uint32_t throughput = device_intensity(thr_id, __func__, 1U << 19); // 19=256*256*8; @@ -254,6 +254,8 @@ extern "C" int scanhash_x17(int thr_id, uint32_t *pdata, x17_sha512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); x17_haval256_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); + *hashes_done = pdata[19] - first_nonce + throughput; + uint32_t foundNonce = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]); if (foundNonce != UINT32_MAX) { @@ -265,8 +267,12 @@ extern "C" int scanhash_x17(int thr_id, uint32_t *pdata, if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) { int res = 1; uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); - *hashes_done = pdata[19] - first_nonce + throughput; + bn_store_hash_target_ratio(vhash64, ptarget, work); if (secNonce != 0) { + be32enc(&endiandata[19], secNonce); + x17hash(vhash64, endiandata); + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + bn_store_hash_target_ratio(vhash64, ptarget, work); pdata[21] = secNonce; res++; }