From 9eead770272f0b3a2fa9611e4a2494b64e9b04ef Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Tue, 27 Sep 2016 09:03:24 +0200 Subject: [PATCH] diff: show by default, rework shares diff storage This will allow later more gpu candidates. Note: This is an unfinished work, we keep the previous behavior for now To finish this, all algos solutions should be migrated and submitted nonces attributes stored. Its required to handle the different share diff per nonce and fix the possible solved count error (if 1/2 nonces is solved). --- Algo256/blake256.cu | 2 +- Algo256/blake2s.cu | 14 ++++++++--- Algo256/decred.cu | 2 +- Algo256/vanilla.cu | 2 +- JHA/jackpotcoin.cu | 2 +- README.txt | 2 +- bignum.cpp | 19 ++++++++++----- ccminer.cpp | 57 +++++++++++++++++++++++++++++++-------------- lbry/lbry.cu | 2 +- lyra2/lyra2RE.cu | 2 +- lyra2/lyra2REv2.cu | 2 +- miner.h | 14 +++++++---- myriadgroestl.cpp | 8 +++---- quark/nist5.cu | 2 +- qubit/deep.cu | 2 +- qubit/qubit.cu | 2 +- sia.cu | 2 +- skein.cu | 2 +- skein2.cpp | 21 +++++++---------- x11/c11.cu | 2 +- x11/fresh.cu | 2 +- x11/s3.cu | 2 +- x11/sib.cu | 2 +- x11/veltor.cu | 6 +++-- x11/x11.cu | 2 +- x11/x11evo.cu | 2 +- x13/x13.cu | 2 +- x15/x14.cu | 2 +- x15/x15.cu | 2 +- x17/x17.cu | 2 +- zr5.cu | 2 +- 31 files changed, 113 insertions(+), 74 deletions(-) diff --git a/Algo256/blake256.cu b/Algo256/blake256.cu index 6366bbb..9d6e138 100644 --- a/Algo256/blake256.cu +++ b/Algo256/blake256.cu @@ -544,7 +544,7 @@ extern "C" int scanhash_blake256(int thr_id, struct work* work, uint32_t max_non blake256hash(vhashcpu, endiandata, blakerounds); if (vhashcpu[6] <= Htarg && fulltest(vhashcpu, ptarget)) { pdata[21] = extra_results[0]; - if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio) { + if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio[0]) { work_set_target_ratio(work, vhashcpu); xchg(pdata[21], pdata[19]); } diff --git a/Algo256/blake2s.cu b/Algo256/blake2s.cu index 3ff5cb6..747174a 100644 --- a/Algo256/blake2s.cu +++ b/Algo256/blake2s.cu @@ -468,22 +468,30 @@ extern "C" int scanhash_blake2s(int thr_id, struct work *work, uint32_t max_nonc if (vhashcpu[7] <= target.y && fulltest(vhashcpu, ptarget)) { work_set_target_ratio(work, vhashcpu); - pdata[19] = work->nonces[0] = swab32_if(foundNonce, !swap); + work->nonces[0] = swab32_if(foundNonce, !swap); + work->valid_nonces = 1; #if NBN > 1 if (extra_results[0] != UINT32_MAX) { endiandata[19] = swab32_if(extra_results[0], swap); blake2s_hash_end(vhashcpu, endiandata); if (vhashcpu[7] <= target.y && fulltest(vhashcpu, ptarget)) { work->nonces[1] = swab32_if(extra_results[0], !swap); - if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio) { + if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio[0]) { + work->shareratio[1] = work->shareratio[0]; + work->sharediff[1] = work->sharediff[0]; work_set_target_ratio(work, vhashcpu); - xchg(work->nonces[1], pdata[19]); + xchg(work->nonces[0], work->nonces[1]); + } else { + bn_set_target_ratio(work, vhashcpu, 1); } + work->valid_nonces++; + pdata[19] = max(work->nonces[0], work->nonces[1]); return 2; } extra_results[0] = UINT32_MAX; } #endif + pdata[19] = max(work->nonces[0], work->nonces[1]); return 1; } else { gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", foundNonce); diff --git a/Algo256/decred.cu b/Algo256/decred.cu index 996af17..72690c0 100644 --- a/Algo256/decred.cu +++ b/Algo256/decred.cu @@ -419,7 +419,7 @@ extern "C" int scanhash_decred(int thr_id, struct work* work, uint32_t max_nonce work->nonces[1] = swab32(h_resNonce[thr_id][j]); if(!opt_quiet) gpulog(LOG_NOTICE, thr_id, "second nonce found %u / %08x - %u / %08x", i, work->nonces[0], j, work->nonces[1]); - if(bn_hash_target_ratio(vhash, ptarget) > work->shareratio) { + if(bn_hash_target_ratio(vhash, ptarget) > work->shareratio[0]) { work_set_target_ratio(work, vhash); xchg(work->nonces[1], work->nonces[0]); } diff --git a/Algo256/vanilla.cu b/Algo256/vanilla.cu index e3a4aff..c089ad8 100644 --- a/Algo256/vanilla.cu +++ b/Algo256/vanilla.cu @@ -438,7 +438,7 @@ extern "C" int scanhash_vanilla(int thr_id, struct work* work, uint32_t max_nonc be32enc(&endiandata[19], h_resNonce[thr_id][1]); vanillahash(vhashcpu, endiandata, blakerounds); pdata[21] = h_resNonce[thr_id][1]; - if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio) { + if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio[0]) { work_set_target_ratio(work, vhashcpu); xchg(pdata[19], pdata[21]); } diff --git a/JHA/jackpotcoin.cu b/JHA/jackpotcoin.cu index 10370ac..b902b82 100644 --- a/JHA/jackpotcoin.cu +++ b/JHA/jackpotcoin.cu @@ -232,7 +232,7 @@ extern "C" int scanhash_jackpot(int thr_id, struct work *work, uint32_t max_nonc if (secNonce != 0) { be32enc(&endiandata[19], secNonce); nist5hash(vhash64, endiandata); - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash64); pdata[21] = secNonce; res++; diff --git a/README.txt b/README.txt index 1745fd3..bc2d4f3 100644 --- a/README.txt +++ b/README.txt @@ -157,7 +157,7 @@ its command line interface and options. --plimit=150W set the gpu power limit, allow multiple values for N cards --tlimit=85 Set the gpu thermal limit (windows only) --keep-clocks prevent reset clocks and/or power limit on exit - --show-diff display submitted block and net difficulty + --hide-diff hide 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 diff --git a/bignum.cpp b/bignum.cpp index 3ed285c..1a68654 100644 --- a/bignum.cpp +++ b/bignum.cpp @@ -70,17 +70,24 @@ extern "C" double bn_hash_target_ratio(uint32_t* hash, uint32_t* target) } // store ratio in work struct -extern "C" void bn_store_hash_target_ratio(uint32_t* hash, uint32_t* target, struct work* work) +extern "C" void bn_store_hash_target_ratio(uint32_t* hash, uint32_t* target, struct work* work, int nonce) { // only if the option is enabled (to reduce cpu usage) - if (opt_showdiff) { - work->shareratio = bn_hash_target_ratio(hash, target); - work->sharediff = work->targetdiff * work->shareratio; - } + if (!opt_showdiff) return; + + work->shareratio[nonce] = bn_hash_target_ratio(hash, target); + work->sharediff[nonce] = work->targetdiff * work->shareratio[nonce]; +} + +// new method to save all nonce(s) share diff/ration +extern "C" void bn_set_target_ratio(struct work* work, uint32_t* hash, int nonce) +{ + bn_store_hash_target_ratio(hash, work->target, work, nonce); } +// compat (only store single nonce share diff per work) extern "C" void work_set_target_ratio(struct work* work, uint32_t* hash) { - bn_store_hash_target_ratio(hash, work->target, work); + bn_store_hash_target_ratio(hash, work->target, work, 0); } diff --git a/ccminer.cpp b/ccminer.cpp index ca954f4..4802065 100644 --- a/ccminer.cpp +++ b/ccminer.cpp @@ -82,7 +82,7 @@ bool opt_debug_diff = false; bool opt_debug_threads = false; bool opt_protocol = false; bool opt_benchmark = false; -bool opt_showdiff = false; +bool opt_showdiff = true; // todo: limit use of these flags, // prefer the pools[] attributes @@ -321,7 +321,7 @@ Options:\n\ --syslog-prefix=... allow to change syslog tool name\n" #endif "\ - --show-diff display submitted block and net difficulty\n\ + --hide-diff hide submitted block and net difficulty (old mode)\n\ -B, --background run the miner in the background\n\ --benchmark run in offline benchmark mode\n\ --cputest debug hashes from cpu algorithms\n\ @@ -384,6 +384,7 @@ struct option options[] = { { "retry-pause", 1, NULL, 'R' }, { "scantime", 1, NULL, 's' }, { "show-diff", 0, NULL, 1013 }, + { "hide-diff", 0, NULL, 1014 }, { "statsavg", 1, NULL, 'N' }, { "gpu-clock", 1, NULL, 1070 }, { "mem-clock", 1, NULL, 1071 }, @@ -871,7 +872,7 @@ bool sia_submit(CURL *curl, struct pool_infos *pool, struct work *work) applog(LOG_ERR, "submit err %ld %s", errcode, curl_err_str); res = 0; } - share_result(res, work->pooln, work->sharediff, res ? NULL : (char*) all_data.buf); + share_result(res, work->pooln, work->sharediff[0], res ? NULL : (char*) all_data.buf); curl_slist_free_all(headers); return true; @@ -943,6 +944,7 @@ static bool submit_upstream_work(CURL *curl, struct work *work) struct pool_infos *pool = &pools[work->pooln]; json_t *val, *res, *reason; bool stale_work = false; + int idnonce = 0; /* discard if a newer block was received */ stale_work = work->height && work->height < g_work.height; @@ -1057,7 +1059,7 @@ static bool submit_upstream_work(CURL *curl, struct work *work) } // store to keep/display the solved ratio/diff - stratum.sharediff = work->sharediff; + stratum.sharediff = work->sharediff[idnonce]; if (net_diff && stratum.sharediff > net_diff && (opt_debug || opt_debug_diff)) applog(LOG_INFO, "share diff: %.5f, possible block found!!!", @@ -1069,13 +1071,13 @@ static bool submit_upstream_work(CURL *curl, struct work *work) if (opt_vote) { // ALGO_HEAVY ALGO_DECRED nvotestr = bin2hex((const uchar*)(&nvote), 2); sprintf(s, "{\"method\": \"mining.submit\", \"params\": [" - "\"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\"], \"id\":4}", - pool->user, work->job_id + 8, xnonce2str, ntimestr, noncestr, nvotestr); + "\"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\"], \"id\":%d}", + pool->user, work->job_id + 8, xnonce2str, ntimestr, noncestr, nvotestr, 10+idnonce); free(nvotestr); } else { sprintf(s, "{\"method\": \"mining.submit\", \"params\": [" - "\"%s\", \"%s\", \"%s\", \"%s\", \"%s\"], \"id\":4}", - pool->user, work->job_id + 8, xnonce2str, ntimestr, noncestr); + "\"%s\", \"%s\", \"%s\", \"%s\", \"%s\"], \"id\":%d}", + pool->user, work->job_id + 8, xnonce2str, ntimestr, noncestr, 10+idnonce); } free(xnonce2str); free(ntimestr); @@ -1120,7 +1122,7 @@ static bool submit_upstream_work(CURL *curl, struct work *work) /* build JSON-RPC request */ sprintf(s, - "{\"method\": \"getwork\", \"params\": [\"%s\"], \"id\":4}\r\n", + "{\"method\": \"getwork\", \"params\": [\"%s\"], \"id\":10}\r\n", str); /* issue JSON-RPC request */ @@ -1132,7 +1134,7 @@ static bool submit_upstream_work(CURL *curl, struct work *work) res = json_object_get(val, "result"); reason = json_object_get(val, "reject-reason"); - if (!share_result(json_is_true(res), work->pooln, work->sharediff, + if (!share_result(json_is_true(res), work->pooln, work->sharediff[0], reason ? json_string_value(reason) : NULL)) { if (check_dups) @@ -2398,12 +2400,23 @@ static void *miner_thread(void *userdata) /* record scanhash elapsed time */ gettimeofday(&tv_end, NULL); - // todo: update all algos to use work->nonces - if (opt_algo != ALGO_SIA) // reversed endian - work.nonces[0] = nonceptr[0]; - if (opt_algo != ALGO_DECRED && opt_algo != ALGO_BLAKE2S && opt_algo != ALGO_LBRY && opt_algo != ALGO_SIA) { - if (opt_algo != ALGO_VELTOR) - work.nonces[1] = nonceptr[2]; + // todo: update all algos to use work->nonces and pdata[19] as counter + switch (opt_algo) { + case ALGO_BLAKE2S: + case ALGO_DECRED: + case ALGO_LBRY: + case ALGO_SIA: + case ALGO_VELTOR: + // migrated algos + break; + case ALGO_ZR5: + // algos with only work.nonces[1] set + work.nonces[0] = nonceptr[0]; + break; + default: + // algos with 2 results in pdata and work.nonces unset + work.nonces[0] = nonceptr[0]; + work.nonces[1] = nonceptr[2]; } if (rc > 0 && opt_debug) @@ -2686,6 +2699,7 @@ static bool stratum_handle_response(char *buf) json_t *val, *err_val, *res_val, *id_val; json_error_t err; struct timeval tv_answer, diff; + int num = 0; bool ret = false; val = JSON_LOADS(buf, &err); @@ -2701,10 +2715,14 @@ static bool stratum_handle_response(char *buf) if (!id_val || json_is_null(id_val) || !res_val) goto out; - // ignore subscribe late answer (yaamp) - if (json_integer_value(id_val) < 4) + // ignore late login answers + num = (int) json_integer_value(id_val); + if (num < 4) goto out; + // todo: use request id to index nonce diff data + // num = num % 10; + gettimeofday(&tv_answer, NULL); timeval_subtract(&diff, &tv_answer, &stratum.tv_submit); // store time required to the pool to answer to a submit @@ -3316,6 +3334,9 @@ void parse_arg(int key, char *arg) case 1013: opt_showdiff = true; break; + case 1014: + opt_showdiff = false; + break; case 'S': case 1018: applog(LOG_INFO, "Now logging to syslog..."); diff --git a/lbry/lbry.cu b/lbry/lbry.cu index 6aaeb15..0f11f20 100644 --- a/lbry/lbry.cu +++ b/lbry/lbry.cu @@ -171,7 +171,7 @@ extern "C" int scanhash_lbry(int thr_id, struct work *work, uint32_t max_nonce, endiandata[LBC_NONCE_OFT32] = swab32_if(resNonces[1], !swap); lbry_hash(vhash, endiandata); work->nonces[1] = swab32_if(resNonces[1], swap); - if (bn_hash_target_ratio(vhash, ptarget) > work->shareratio) { + if (bn_hash_target_ratio(vhash, ptarget) > work->shareratio[0]) { work_set_target_ratio(work, vhash); xchg(work->nonces[0], work->nonces[1]); } diff --git a/lyra2/lyra2RE.cu b/lyra2/lyra2RE.cu index cd3ca6a..668d99e 100644 --- a/lyra2/lyra2RE.cu +++ b/lyra2/lyra2RE.cu @@ -165,7 +165,7 @@ extern "C" int scanhash_lyra2(int thr_id, struct work* work, uint32_t max_nonce, if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) { if (opt_debug) gpulog(LOG_BLUE, thr_id, "found second nonce %08x", secNonce); - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash64); pdata[21] = secNonce; res++; diff --git a/lyra2/lyra2REv2.cu b/lyra2/lyra2REv2.cu index f6699ac..6866fed 100644 --- a/lyra2/lyra2REv2.cu +++ b/lyra2/lyra2REv2.cu @@ -177,7 +177,7 @@ extern "C" int scanhash_lyra2v2(int thr_id, struct work* work, uint32_t max_nonc be32enc(&endiandata[19], foundNonces[1]); lyra2v2_hash(vhash64, endiandata); pdata[21] = foundNonces[1]; - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) { + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) { work_set_target_ratio(work, vhash64); xchg(pdata[19], pdata[21]); } diff --git a/miner.h b/miner.h index 2b0ca15..7028d84 100644 --- a/miner.h +++ b/miner.h @@ -569,7 +569,8 @@ extern void get_currentalgo(char* buf, int sz); double bn_convert_nbits(const uint32_t nbits); void bn_nbits_to_uchar(const uint32_t nBits, uchar *target); double bn_hash_target_ratio(uint32_t* hash, uint32_t* target); -void bn_store_hash_target_ratio(uint32_t* hash, uint32_t* target, struct work* work); +void bn_store_hash_target_ratio(uint32_t* hash, uint32_t* target, struct work* work, int nonce); +void bn_set_target_ratio(struct work* work, uint32_t* hash, int nonce); void work_set_target_ratio(struct work* work, uint32_t* hash); // bench @@ -632,6 +633,7 @@ struct tx { uint32_t len; }; +#define MAX_NONCES 2 struct work { uint32_t data[48]; uint32_t target[8]; @@ -646,13 +648,15 @@ struct work { uint64_t u64[1]; } noncerange; - uint32_t nonces[2]; + uint8_t pooln; + uint8_t valid_nonces; + uint32_t nonces[MAX_NONCES]; + double sharediff[MAX_NONCES]; + double shareratio[MAX_NONCES]; double targetdiff; - double shareratio; - double sharediff; + uint32_t height; - uint8_t pooln; uint32_t scanned_from; uint32_t scanned_to; diff --git a/myriadgroestl.cpp b/myriadgroestl.cpp index fdc6a2f..7c834c8 100644 --- a/myriadgroestl.cpp +++ b/myriadgroestl.cpp @@ -81,15 +81,15 @@ int scanhash_myriad(int thr_id, struct work *work, uint32_t max_nonce, unsigned myriadhash(vhash, endiandata); if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) { work_set_target_ratio(work, vhash); + work->nonces[0] = foundNonces[0]; pdata[19] = foundNonces[0]; // search for another nonce if (foundNonces[1] != UINT32_MAX) { endiandata[19] = swab32(foundNonces[1]); myriadhash(vhash, endiandata); - pdata[21] = foundNonces[1]; - if(bn_hash_target_ratio(vhash, ptarget) > work->shareratio) { - work_set_target_ratio(work, vhash); - } + pdata[21] = foundNonces[1]; // to drop + work->nonces[1] = foundNonces[1]; + bn_set_target_ratio(work, vhash, 1); return 2; } return 1; diff --git a/quark/nist5.cu b/quark/nist5.cu index ddd4363..2574bbe 100644 --- a/quark/nist5.cu +++ b/quark/nist5.cu @@ -128,7 +128,7 @@ extern "C" int scanhash_nist5(int thr_id, struct work *work, uint32_t max_nonce, if (secNonce != 0) { be32enc(&endiandata[19], secNonce); nist5hash(vhash64, endiandata); - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash64); pdata[21] = secNonce; res++; diff --git a/qubit/deep.cu b/qubit/deep.cu index b681a47..affaca3 100644 --- a/qubit/deep.cu +++ b/qubit/deep.cu @@ -110,7 +110,7 @@ extern "C" int scanhash_deep(int thr_id, struct work* work, uint32_t max_nonce, if (secNonce != 0) { be32enc(&endiandata[19], secNonce); deephash(vhash64, endiandata); - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash64); pdata[21] = secNonce; res++; diff --git a/qubit/qubit.cu b/qubit/qubit.cu index 927c93b..38802d5 100644 --- a/qubit/qubit.cu +++ b/qubit/qubit.cu @@ -127,7 +127,7 @@ extern "C" int scanhash_qubit(int thr_id, struct work* work, uint32_t max_nonce, if (secNonce != 0) { be32enc(&endiandata[19], secNonce); qubithash(vhash64, endiandata); - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash64); pdata[21] = secNonce; res++; diff --git a/sia.cu b/sia.cu index ee08e40..80370ea 100644 --- a/sia.cu +++ b/sia.cu @@ -258,7 +258,7 @@ int scanhash_sia(int thr_id, struct work *work, uint32_t max_nonce, unsigned lon swab256(vhashcpu, hash); if (fulltest(vhashcpu, ptarget)) { work->nonces[1] = secNonce; - if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio) { + if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio[0]) { work_set_target_ratio(work, vhashcpu); xchg(work->nonces[0], work->nonces[1]); } diff --git a/skein.cu b/skein.cu index 12e08d7..b928f5d 100644 --- a/skein.cu +++ b/skein.cu @@ -439,7 +439,7 @@ extern "C" int scanhash_skeincoin(int thr_id, struct work* work, uint32_t max_no // todo: use 19 20 21... zr5 pok to adapt... endiandata[19] = swab32_if(secNonce, swap); skeincoinhash(vhash, endiandata); - if (bn_hash_target_ratio(vhash, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash); pdata[19+res*2] = swab32_if(secNonce, !swap); res++; diff --git a/skein2.cpp b/skein2.cpp index a27e5dc..1987205 100644 --- a/skein2.cpp +++ b/skein2.cpp @@ -93,27 +93,24 @@ int scanhash_skein2(int thr_id, struct work* work, uint32_t max_nonce, unsigned uint32_t foundNonce = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]); if (foundNonce != UINT32_MAX) { - uint32_t _ALIGN(64) vhash64[8]; + uint32_t _ALIGN(64) vhash[8]; endiandata[19] = swab32_if(foundNonce, swap); - skein2hash(vhash64, endiandata); + skein2hash(vhash, endiandata); - if (vhash64[7] <= ptarget[7] && 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); - work_set_target_ratio(work, vhash64); + work_set_target_ratio(work, vhash); if (secNonce != 0) { - if (!opt_quiet) - applog(LOG_BLUE, "GPU #%d: found second nonce %08x !", dev_id, swab32(secNonce)); - endiandata[19] = swab32_if(secNonce, swap); - skein2hash(vhash64, endiandata); - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) - work_set_target_ratio(work, vhash64); - pdata[21] = swab32_if(secNonce, !swap); + skein2hash(vhash, endiandata); + bn_set_target_ratio(work, vhash, 1); + pdata[21] = work->nonces[1] = swab32_if(secNonce, !swap); + gpulog(LOG_DEBUG, thr_id, "found second nonce %08x!", swab32(secNonce)); res++; } - pdata[19] = swab32_if(foundNonce, !swap); + pdata[19] = work->nonces[0] = swab32_if(foundNonce, !swap); return res; } else { gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", foundNonce); diff --git a/x11/c11.cu b/x11/c11.cu index 048cd69..4cfd217 100644 --- a/x11/c11.cu +++ b/x11/c11.cu @@ -197,7 +197,7 @@ extern "C" int scanhash_c11(int thr_id, struct work* work, uint32_t max_nonce, u if (secNonce != 0) { be32enc(&endiandata[19], secNonce); c11hash(vhash64, endiandata); - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash64); pdata[21] = secNonce; res++; diff --git a/x11/fresh.cu b/x11/fresh.cu index 9c426c6..7e58ba0 100644 --- a/x11/fresh.cu +++ b/x11/fresh.cu @@ -140,7 +140,7 @@ extern "C" int scanhash_fresh(int thr_id, struct work* work, uint32_t max_nonce, if (secNonce != 0) { be32enc(&endiandata[19], secNonce); fresh_hash(vhash64, endiandata); - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash64); pdata[21] = secNonce; res++; diff --git a/x11/s3.cu b/x11/s3.cu index e2887bf..1ecb879 100644 --- a/x11/s3.cu +++ b/x11/s3.cu @@ -135,7 +135,7 @@ extern "C" int scanhash_s3(int thr_id, struct work* work, uint32_t max_nonce, un if (secNonce != 0) { be32enc(&endiandata[19], secNonce); s3hash(vhash64, endiandata); - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash64); pdata[21] = secNonce; res++; diff --git a/x11/sib.cu b/x11/sib.cu index ca7bb77..5629cc2 100644 --- a/x11/sib.cu +++ b/x11/sib.cu @@ -193,7 +193,7 @@ extern "C" int scanhash_sib(int thr_id, struct work* work, uint32_t max_nonce, u if (secNonce != 0) { be32enc(&endiandata[19], secNonce); sibhash(vhash64, endiandata); - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash64); pdata[21] = secNonce; res++; diff --git a/x11/veltor.cu b/x11/veltor.cu index f77334c..ddcb9ce 100644 --- a/x11/veltor.cu +++ b/x11/veltor.cu @@ -125,15 +125,17 @@ extern "C" int scanhash_veltor(int thr_id, struct work* work, uint32_t max_nonce if (vhash[7] <= Htarg && fulltest(vhash, ptarget)) { int res = 1; // check if there was another one... - uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); + uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], res); work_set_target_ratio(work, vhash); if (secNonce != 0) { be32enc(&endiandata[19], secNonce); veltorhash(vhash, endiandata); work->nonces[1] = secNonce; - if (bn_hash_target_ratio(vhash, ptarget) > work->shareratio) { + if (bn_hash_target_ratio(vhash, ptarget) > work->shareratio[0]) { work_set_target_ratio(work, vhash); xchg(work->nonces[1], work->nonces[0]); + } else { + bn_set_target_ratio(work, vhash, res); } res++; } diff --git a/x11/x11.cu b/x11/x11.cu index df7dd84..1701a4e 100644 --- a/x11/x11.cu +++ b/x11/x11.cu @@ -185,7 +185,7 @@ extern "C" int scanhash_x11(int thr_id, struct work* work, uint32_t max_nonce, u if (secNonce != 0) { be32enc(&endiandata[19], secNonce); x11hash(vhash64, endiandata); - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash64); pdata[21] = secNonce; res++; diff --git a/x11/x11evo.cu b/x11/x11evo.cu index da208ac..b5713ff 100644 --- a/x11/x11evo.cu +++ b/x11/x11evo.cu @@ -366,7 +366,7 @@ extern "C" int scanhash_x11evo(int thr_id, struct work* work, uint32_t max_nonce if (secNonce != 0) { be32enc(&endiandata[19], secNonce); x11evo_hash(vhash64, endiandata); - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash64); pdata[21] = secNonce; res++; diff --git a/x13/x13.cu b/x13/x13.cu index ad3d02a..501e9cb 100644 --- a/x13/x13.cu +++ b/x13/x13.cu @@ -201,7 +201,7 @@ extern "C" int scanhash_x13(int thr_id, struct work* work, uint32_t max_nonce, u be32enc(&endiandata[19], secNonce); x13hash(vhash, endiandata); pdata[21] = secNonce; - if (bn_hash_target_ratio(vhash, ptarget) > work->shareratio) { + if (bn_hash_target_ratio(vhash, ptarget) > work->shareratio[0]) { work_set_target_ratio(work, vhash); xchg(pdata[19], pdata[21]); } diff --git a/x15/x14.cu b/x15/x14.cu index 926f1e8..2094c1a 100644 --- a/x15/x14.cu +++ b/x15/x14.cu @@ -215,7 +215,7 @@ extern "C" int scanhash_x14(int thr_id, struct work* work, uint32_t max_nonce, if (secNonce != 0) { be32enc(&endiandata[19], secNonce); x14hash(vhash64, endiandata); - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash64); pdata[21] = secNonce; res++; diff --git a/x15/x15.cu b/x15/x15.cu index 45d94fc..5abc577 100644 --- a/x15/x15.cu +++ b/x15/x15.cu @@ -221,7 +221,7 @@ extern "C" int scanhash_x15(int thr_id, struct work* work, uint32_t max_nonce, if (secNonce != 0) { be32enc(&endiandata[19], secNonce); x15hash(vhash64, endiandata); - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash64); pdata[21] = secNonce; res++; diff --git a/x17/x17.cu b/x17/x17.cu index 8b804e5..59002b1 100644 --- a/x17/x17.cu +++ b/x17/x17.cu @@ -245,7 +245,7 @@ extern "C" int scanhash_x17(int thr_id, struct work* work, uint32_t max_nonce, u if (secNonce != 0) { be32enc(&endiandata[19], secNonce); x17hash(vhash64, endiandata); - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash64); pdata[21] = secNonce; res++; diff --git a/zr5.cu b/zr5.cu index e5281c3..c9a34fc 100644 --- a/zr5.cu +++ b/zr5.cu @@ -458,7 +458,7 @@ extern "C" int scanhash_zr5(int thr_id, struct work *work, tmpdata[0] = pok; tmpdata[19] = secNonce; zr5hash(vhash64, tmpdata); if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) { - if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio) + if (bn_hash_target_ratio(vhash64, ptarget) > work->shareratio[0]) work_set_target_ratio(work, vhash64); pdata[21] = secNonce; pdata[22] = pok;