Browse Source

diff: rename functions like cpuminer-multi

more proper, intuitive...
2upstream
Tanguy Pruvot 9 years ago
parent
commit
b641bfdf8b
  1. 11
      Algo256/blake256.cu
  2. 6
      bignum.cpp
  3. 8
      ccminer.cpp
  4. 6
      miner.h
  5. 13
      util.cpp
  6. 2
      x15/whirlpool.cu

11
Algo256/blake256.cu

@ -436,6 +436,8 @@ extern "C" int scanhash_blake256(int thr_id, struct work* work, uint32_t max_non
// GPU FULL HASH // GPU FULL HASH
blake256_cpu_hash_80(thr_id, throughput, pdata[19], targetHigh, crcsum, blakerounds); blake256_cpu_hash_80(thr_id, throughput, pdata[19], targetHigh, crcsum, blakerounds);
#endif #endif
*hashes_done = pdata[19] - first_nonce + throughput;
if (foundNonce != UINT32_MAX) if (foundNonce != UINT32_MAX)
{ {
uint32_t vhashcpu[8]; uint32_t vhashcpu[8];
@ -447,27 +449,24 @@ extern "C" int scanhash_blake256(int thr_id, struct work* work, uint32_t max_non
be32enc(&endiandata[19], foundNonce); be32enc(&endiandata[19], foundNonce);
blake256hash(vhashcpu, endiandata, blakerounds); blake256hash(vhashcpu, endiandata, blakerounds);
//applog(LOG_BLUE, "%08x %16llx", vhashcpu[6], targetHigh);
if (vhashcpu[6] <= Htarg && fulltest(vhashcpu, ptarget)) if (vhashcpu[6] <= Htarg && fulltest(vhashcpu, ptarget))
{ {
rc = 1; rc = 1;
work_set_target_ratio(work, vhashcpu);
pdata[19] = foundNonce; pdata[19] = foundNonce;
*hashes_done = pdata[19] - first_nonce + 1;
#if NBN > 1 #if NBN > 1
if (extra_results[0] != UINT32_MAX) { if (extra_results[0] != UINT32_MAX) {
be32enc(&endiandata[19], extra_results[0]); be32enc(&endiandata[19], extra_results[0]);
blake256hash(vhashcpu, endiandata, blakerounds); blake256hash(vhashcpu, endiandata, blakerounds);
if (vhashcpu[6] <= Htarg /* && fulltest(vhashcpu, ptarget) */) { if (vhashcpu[6] <= Htarg && fulltest(vhashcpu, ptarget)) {
pdata[21] = extra_results[0]; pdata[21] = extra_results[0];
applog(LOG_BLUE, "1:%x 2:%x", foundNonce, extra_results[0]); applog(LOG_BLUE, "1:%x 2:%x", foundNonce, extra_results[0]);
*hashes_done = max(*hashes_done, extra_results[0] - first_nonce + 1); work_set_target_ratio(work, vhashcpu);
rc = 2; rc = 2;
} }
extra_results[0] = UINT32_MAX; extra_results[0] = UINT32_MAX;
} }
#endif #endif
//applog_hash((uint8_t*)ptarget);
//applog_compare_hash((uint8_t*)vhashcpu,(uint8_t*)ptarget);
return rc; return rc;
} }
else if (opt_debug) { else if (opt_debug) {

6
bignum.cpp

@ -78,3 +78,9 @@ extern "C" void bn_store_hash_target_ratio(uint32_t* hash, uint32_t* target, str
work->sharediff = work->targetdiff * work->shareratio; work->sharediff = work->targetdiff * work->shareratio;
} }
} }
extern "C" void work_set_target_ratio(struct work* work, uint32_t* hash)
{
bn_store_hash_target_ratio(hash, work->target, work);
}

8
ccminer.cpp

@ -1448,21 +1448,21 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
case ALGO_NEOSCRYPT: case ALGO_NEOSCRYPT:
case ALGO_SCRYPT: case ALGO_SCRYPT:
case ALGO_SCRYPT_JANE: case ALGO_SCRYPT_JANE:
diff_to_target(work, sctx->job.diff / (65536.0 * opt_difficulty)); work_set_target(work, sctx->job.diff / (65536.0 * opt_difficulty));
break; break;
case ALGO_DMD_GR: case ALGO_DMD_GR:
case ALGO_FRESH: case ALGO_FRESH:
case ALGO_FUGUE256: case ALGO_FUGUE256:
case ALGO_GROESTL: case ALGO_GROESTL:
case ALGO_LYRA2v2: case ALGO_LYRA2v2:
diff_to_target(work, sctx->job.diff / (256.0 * opt_difficulty)); work_set_target(work, sctx->job.diff / (256.0 * opt_difficulty));
break; break;
case ALGO_KECCAK: case ALGO_KECCAK:
case ALGO_LYRA2: case ALGO_LYRA2:
diff_to_target(work, sctx->job.diff / (128.0 * opt_difficulty)); work_set_target(work, sctx->job.diff / (128.0 * opt_difficulty));
break; break;
default: default:
diff_to_target(work, sctx->job.diff / opt_difficulty); work_set_target(work, sctx->job.diff / opt_difficulty);
} }
return true; return true;
} }

6
miner.h

@ -523,7 +523,8 @@ extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
extern int timeval_subtract(struct timeval *result, struct timeval *x, extern int timeval_subtract(struct timeval *result, struct timeval *x,
struct timeval *y); struct timeval *y);
extern bool fulltest(const uint32_t *hash, const uint32_t *target); extern bool fulltest(const uint32_t *hash, const uint32_t *target);
void diff_to_target(struct work* work, double diff); void diff_to_target(uint32_t* target, double diff);
void work_set_target(struct work* work, double diff);
double target_to_diff(uint32_t* target); double target_to_diff(uint32_t* target);
extern void get_currentalgo(char* buf, int sz); extern void get_currentalgo(char* buf, int sz);
extern uint32_t device_intensity(int thr_id, const char *func, uint32_t defcount); extern uint32_t device_intensity(int thr_id, const char *func, uint32_t defcount);
@ -534,6 +535,9 @@ void bn_nbits_to_uchar(const uint32_t nBits, uchar *target);
double bn_hash_target_ratio(uint32_t* hash, uint32_t* 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);
void work_set_target_ratio(struct work* work, uint32_t* hash);
struct stratum_job { struct stratum_job {
char *job_id; char *job_id;
unsigned char prevhash[32]; unsigned char prevhash[32];

13
util.cpp

@ -791,14 +791,11 @@ bool fulltest(const uint32_t *hash, const uint32_t *target)
} }
// Only used by stratum pools // Only used by stratum pools
void diff_to_target(struct work* work, double diff) void diff_to_target(uint32_t *target, double diff)
{ {
uint32_t *target = work->target;
uint64_t m; uint64_t m;
int k; int k;
work->targetdiff = diff;
for (k = 6; k > 0 && diff > 1.0; k--) for (k = 6; k > 0 && diff > 1.0; k--)
diff /= 4294967296.0; diff /= 4294967296.0;
m = (uint64_t)(4294901760.0 / diff); m = (uint64_t)(4294901760.0 / diff);
@ -811,6 +808,14 @@ void diff_to_target(struct work* work, double diff)
} }
} }
// Only used by stratum pools
void work_set_target(struct work* work, double diff)
{
diff_to_target(work->target, diff);
work->targetdiff = diff;
}
// Only used by longpoll pools // Only used by longpoll pools
double target_to_diff(uint32_t* target) double target_to_diff(uint32_t* target)
{ {

2
x15/whirlpool.cu

@ -97,7 +97,7 @@ extern "C" int scanhash_whirl(int thr_id, struct work* work, uint32_t max_nonce,
if (vhash[7] <= Htarg && fulltest(vhash, ptarget)) { if (vhash[7] <= Htarg && fulltest(vhash, ptarget)) {
int res = 1; int res = 1;
*hashes_done = pdata[19] - first_nonce + throughput; *hashes_done = pdata[19] - first_nonce + throughput;
bn_store_hash_target_ratio(vhash, ptarget, work); work_set_target_ratio(work, vhash);
#if 0 #if 0
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], 1);
if (secNonce != 0) { if (secNonce != 0) {

Loading…
Cancel
Save