Permalink
Browse files

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).
  • Loading branch information...
1 parent 2f57ee9 commit 9eead770272f0b3a2fa9611e4a2494b64e9b04ef @tpruvot committed Sep 27, 2016
Showing with 113 additions and 74 deletions.
  1. +1 −1 Algo256/blake256.cu
  2. +11 −3 Algo256/blake2s.cu
  3. +1 −1 Algo256/decred.cu
  4. +1 −1 Algo256/vanilla.cu
  5. +1 −1 JHA/jackpotcoin.cu
  6. +1 −1 README.txt
  7. +13 −6 bignum.cpp
  8. +39 −18 ccminer.cpp
  9. +1 −1 lbry/lbry.cu
  10. +1 −1 lyra2/lyra2RE.cu
  11. +1 −1 lyra2/lyra2REv2.cu
  12. +9 −5 miner.h
  13. +4 −4 myriadgroestl.cpp
  14. +1 −1 quark/nist5.cu
  15. +1 −1 qubit/deep.cu
  16. +1 −1 qubit/qubit.cu
  17. +1 −1 sia.cu
  18. +1 −1 skein.cu
  19. +9 −12 skein2.cpp
  20. +1 −1 x11/c11.cu
  21. +1 −1 x11/fresh.cu
  22. +1 −1 x11/s3.cu
  23. +1 −1 x11/sib.cu
  24. +4 −2 x11/veltor.cu
  25. +1 −1 x11/x11.cu
  26. +1 −1 x11/x11evo.cu
  27. +1 −1 x13/x13.cu
  28. +1 −1 x15/x14.cu
  29. +1 −1 x15/x15.cu
  30. +1 −1 x17/x17.cu
  31. +1 −1 zr5.cu
View
@@ -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]);
}
View
@@ -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);
View
@@ -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]);
}
View
@@ -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]);
}
View
@@ -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++;
View
@@ -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
View
@@ -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);
}
View
@@ -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...");
View
@@ -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]);
}
View
@@ -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++;
View
@@ -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]);
}
View
@@ -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;
View
@@ -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;
View
@@ -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++;
View
@@ -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++;
View
@@ -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++;
View
@@ -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]);
}
View
@@ -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++;
Oops, something went wrong.

0 comments on commit 9eead77

Please sign in to comment.