Browse Source

hashlog: prepare store of scanned range

master
Tanguy Pruvot 10 years ago
parent
commit
69616b37ac
  1. 8
      blake32.cu
  2. 3
      ccminer.vcxproj
  3. 4
      cpu-miner.c
  4. 27
      hashlog.cpp
  5. 3
      miner.h

8
blake32.cu

@ -304,11 +304,15 @@ extern "C" int scanhash_blake32(int thr_id, uint32_t *pdata, const uint32_t *pta @@ -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);

3
ccminer.vcxproj

@ -399,6 +399,7 @@ copy "$(CudaToolkitBinDir)\cudart64*.dll" "$(OutDir)"</Command> @@ -399,6 +399,7 @@ copy "$(CudaToolkitBinDir)\cudart64*.dll" "$(OutDir)"</Command>
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
</CudaCompile>
<CudaCompile Include="blake32.cu">
<MaxRegCount>64</MaxRegCount>
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
</CudaCompile>
@ -561,4 +562,4 @@ copy "$(CudaToolkitBinDir)\cudart64*.dll" "$(OutDir)"</Command> @@ -561,4 +562,4 @@ copy "$(CudaToolkitBinDir)\cudart64*.dll" "$(OutDir)"</Command>
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 6.5.targets" />
</ImportGroup>
</Project>
</Project>

4
cpu-miner.c

@ -494,7 +494,7 @@ static bool submit_upstream_work(CURL *curl, struct work *work) @@ -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) @@ -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);
}

27
hashlog.cpp

@ -7,7 +7,13 @@ @@ -7,7 +7,13 @@
#define HI_DWORD(u64) ((uint32_t) (u64 >> 32))
#define LO_DWORD(u64) ((uint32_t) u64)
static std::map<uint64_t, uint32_t> tlastshares;
struct hashlog_data {
uint32_t ntime;
uint32_t scanned_from;
uint32_t scanned_to;
};
static std::map<uint64_t, hashlog_data> tlastshares;
#define LOG_PURGE_TIMEOUT 15*60
@ -23,11 +29,15 @@ static uint64_t hextouint(char* jobid) @@ -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) @@ -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<uint64_t, uint32_t>::iterator i = tlastshares.begin();
std::map<uint64_t, hashlog_data>::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) @@ -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) @@ -73,7 +84,7 @@ extern "C" void hashlog_purge_job(char* jobid)
{
uint64_t njobid = hextouint(jobid);
uint64_t keypfx = (njobid << 32);
std::map<uint64_t, uint32_t>::iterator i = tlastshares.begin();
std::map<uint64_t, hashlog_data>::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) @@ -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<uint64_t, uint32_t>::iterator i = tlastshares.begin();
std::map<uint64_t, hashlog_data>::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);
}

3
miner.h

@ -286,6 +286,7 @@ struct work_restart { @@ -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); @@ -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);

Loading…
Cancel
Save