From 69616b37ac447ec18d9592f43489196e4c702746 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Wed, 3 Sep 2014 13:53:01 +0200 Subject: [PATCH] hashlog: prepare store of scanned range --- blake32.cu | 8 ++++++-- ccminer.vcxproj | 3 ++- cpu-miner.c | 4 +++- hashlog.cpp | 27 +++++++++++++++++++-------- miner.h | 3 ++- 5 files changed, 32 insertions(+), 13 deletions(-) diff --git a/blake32.cu b/blake32.cu index b50a3ca..2b63ccf 100644 --- a/blake32.cu +++ b/blake32.cu @@ -304,11 +304,15 @@ extern "C" int scanhash_blake32(int thr_id, uint32_t *pdata, const uint32_t *pta uint32_t vhashcpu[8]; uint32_t Htarg = ptarget[7]; - applog(LOG_WARNING, "throughput=%u, start=%x, max=%x, pdata=%x", throughput, first_nonce, max_nonce, pdata[0]); - for (int k=0; k < 20; k++) be32enc(&endiandata[k], pdata[k]); + if (opt_debug && !opt_quiet) { + applog(LOG_DEBUG, "throughput=%u, start=%x, max=%x, pdata=%08x...%08x", + throughput, first_nonce, max_nonce, endiandata[0], endiandata[7]); + applog_hash((unsigned char *)pdata); + } + be32enc(&endiandata[19], foundNonce); blake32hash(vhashcpu, endiandata); diff --git a/ccminer.vcxproj b/ccminer.vcxproj index 509715b..7590d94 100644 --- a/ccminer.vcxproj +++ b/ccminer.vcxproj @@ -399,6 +399,7 @@ copy "$(CudaToolkitBinDir)\cudart64*.dll" "$(OutDir)" 64 + 64 --ptxas-options=-O2 %(AdditionalOptions) %(AdditionalOptions) @@ -561,4 +562,4 @@ copy "$(CudaToolkitBinDir)\cudart64*.dll" "$(OutDir)" - \ No newline at end of file + diff --git a/cpu-miner.c b/cpu-miner.c index 20bac21..e239081 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -494,7 +494,7 @@ static bool submit_upstream_work(CURL *curl, struct work *work) goto out; } - hashlog_remember_submit(work->job_id, nonce); + hashlog_remember_submit(work->job_id, nonce, 0); } else { @@ -834,6 +834,8 @@ static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work) diff_to_target(work->target, sctx->job.diff / (65536.0 * opt_difficulty)); else if (opt_algo == ALGO_FUGUE256 || opt_algo == ALGO_GROESTL || opt_algo == ALGO_DMD_GR || opt_algo == ALGO_FRESH) diff_to_target(work->target, sctx->job.diff / (256.0 * opt_difficulty)); + else if (opt_algo == ALGO_BLAKE) + diff_to_target(work->target, sctx->job.diff / (16.0 * opt_difficulty)); else diff_to_target(work->target, sctx->job.diff / opt_difficulty); } diff --git a/hashlog.cpp b/hashlog.cpp index 3948751..0b8b574 100644 --- a/hashlog.cpp +++ b/hashlog.cpp @@ -7,7 +7,13 @@ #define HI_DWORD(u64) ((uint32_t) (u64 >> 32)) #define LO_DWORD(u64) ((uint32_t) u64) -static std::map tlastshares; +struct hashlog_data { + uint32_t ntime; + uint32_t scanned_from; + uint32_t scanned_to; +}; + +static std::map tlastshares; #define LOG_PURGE_TIMEOUT 15*60 @@ -23,11 +29,15 @@ static uint64_t hextouint(char* jobid) /** * Store submitted nonces of a job */ -extern "C" void hashlog_remember_submit(char* jobid, uint32_t nonce) +extern "C" void hashlog_remember_submit(char* jobid, uint32_t nonce, uint64_t range) { uint64_t njobid = hextouint(jobid); uint64_t key = (njobid << 32) + nonce; - tlastshares[key] = (uint32_t) time(NULL); + struct hashlog_data data; + data.ntime = (uint32_t) time(NULL); + data.scanned_from = LO_DWORD(range); + data.scanned_to = HI_DWORD(range); + tlastshares[key] = data; } /** @@ -39,7 +49,7 @@ extern "C" uint32_t hashlog_get_last_sent(char* jobid) uint32_t ret = 0; uint64_t njobid = hextouint(jobid); uint64_t keypfx = (njobid << 32); - std::map::iterator i = tlastshares.begin(); + std::map::iterator i = tlastshares.begin(); while (i != tlastshares.end()) { if ((keypfx & i->first) == keypfx && LO_DWORD(i->first) > ret) { ret = LO_DWORD(i->first); @@ -61,7 +71,8 @@ extern "C" uint32_t hashlog_already_submittted(char* jobid, uint32_t nonce) // search last submitted nonce for job ret = hashlog_get_last_sent(jobid); } else if (tlastshares.find(key) != tlastshares.end()) { - ret = (uint32_t) tlastshares[key]; + hashlog_data data = tlastshares[key]; + ret = data.ntime; } return ret; } @@ -73,7 +84,7 @@ extern "C" void hashlog_purge_job(char* jobid) { uint64_t njobid = hextouint(jobid); uint64_t keypfx = (njobid << 32); - std::map::iterator i = tlastshares.begin(); + std::map::iterator i = tlastshares.begin(); while (i != tlastshares.end()) { if ((keypfx & i->first) == keypfx) tlastshares.erase(i); @@ -89,9 +100,9 @@ extern "C" void hashlog_purge_old(void) int deleted = 0; uint32_t now = (uint32_t) time(NULL); uint32_t sz = tlastshares.size(); - std::map::iterator i = tlastshares.begin(); + std::map::iterator i = tlastshares.begin(); while (i != tlastshares.end()) { - if ((now - i->second) > LOG_PURGE_TIMEOUT) { + if ((now - i->second.ntime) > LOG_PURGE_TIMEOUT) { deleted++; tlastshares.erase(i); } diff --git a/miner.h b/miner.h index 9101c61..79e3a15 100644 --- a/miner.h +++ b/miner.h @@ -286,6 +286,7 @@ struct work_restart { extern bool opt_debug; extern bool opt_debug_rpc; +extern bool opt_quiet; extern bool opt_protocol; extern int opt_timeout; extern bool want_longpoll; @@ -390,7 +391,7 @@ bool stratum_subscribe(struct stratum_ctx *sctx); bool stratum_authorize(struct stratum_ctx *sctx, const char *user, const char *pass); bool stratum_handle_method(struct stratum_ctx *sctx, const char *s); -void hashlog_remember_submit(char* jobid, uint32_t nounce); +void hashlog_remember_submit(char* jobid, uint32_t nounce, uint64_t range); uint32_t hashlog_already_submittted(char* jobid, uint32_t nounce); uint32_t hashlog_get_last_sent(char* jobid); void hashlog_purge_old(void);