|
|
@ -1,6 +1,9 @@ |
|
|
|
extern "C" { |
|
|
|
/** |
|
|
|
|
|
|
|
* SKEIN512 80 + SKEIN512 64 (Woodcoin) |
|
|
|
|
|
|
|
* by tpruvot@github - 2015 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
#include "sph/sph_skein.h" |
|
|
|
#include "sph/sph_skein.h" |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "miner.h" |
|
|
|
#include "miner.h" |
|
|
|
#include "cuda_helper.h" |
|
|
|
#include "cuda_helper.h" |
|
|
@ -8,21 +11,19 @@ extern "C" { |
|
|
|
static uint32_t *d_hash[MAX_GPUS]; |
|
|
|
static uint32_t *d_hash[MAX_GPUS]; |
|
|
|
|
|
|
|
|
|
|
|
extern void skein512_cpu_setBlock_80(void *pdata); |
|
|
|
extern void skein512_cpu_setBlock_80(void *pdata); |
|
|
|
extern void skein512_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_hash, int order); |
|
|
|
extern void skein512_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_hash, int swap); |
|
|
|
|
|
|
|
|
|
|
|
extern void quark_skein512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order); |
|
|
|
extern void quark_skein512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order); |
|
|
|
|
|
|
|
|
|
|
|
extern "C" void skein2hash(void *output, const void *input) |
|
|
|
extern "C" void skein2hash(void *output, const void *input) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
uint32_t _ALIGN(64) hash[16]; |
|
|
|
sph_skein512_context ctx_skein; |
|
|
|
sph_skein512_context ctx_skein; |
|
|
|
|
|
|
|
|
|
|
|
uint32_t hash[16]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sph_skein512_init(&ctx_skein); |
|
|
|
sph_skein512_init(&ctx_skein); |
|
|
|
sph_skein512(&ctx_skein, input, 80); |
|
|
|
sph_skein512(&ctx_skein, input, 80); |
|
|
|
sph_skein512_close(&ctx_skein, hash); |
|
|
|
sph_skein512_close(&ctx_skein, hash); |
|
|
|
//applog_hash((uchar*)hash); |
|
|
|
|
|
|
|
//applog_hash((uchar*)&hash[8]); |
|
|
|
|
|
|
|
sph_skein512_init(&ctx_skein); |
|
|
|
sph_skein512_init(&ctx_skein); |
|
|
|
sph_skein512(&ctx_skein, hash, 64); |
|
|
|
sph_skein512(&ctx_skein, hash, 64); |
|
|
|
sph_skein512_close(&ctx_skein, hash); |
|
|
|
sph_skein512_close(&ctx_skein, hash); |
|
|
@ -30,21 +31,6 @@ extern "C" void skein2hash(void *output, const void *input) |
|
|
|
memcpy(output, hash, 32); |
|
|
|
memcpy(output, hash, 32); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG |
|
|
|
|
|
|
|
#define TRACE(algo) { \ |
|
|
|
|
|
|
|
if (max_nonce == 1 && pdata[19] <= 1) { \ |
|
|
|
|
|
|
|
uint32_t* debugbuf = NULL; \ |
|
|
|
|
|
|
|
cudaMallocHost(&debugbuf, 16*sizeof(uint32_t)); \ |
|
|
|
|
|
|
|
cudaMemcpy(debugbuf, d_hash[thr_id], 16*sizeof(uint32_t), cudaMemcpyDeviceToHost); \ |
|
|
|
|
|
|
|
printf("SK2 %s %08x %08x %08x %08x...\n", algo, \ |
|
|
|
|
|
|
|
swab32(debugbuf[0]), swab32(debugbuf[1]), swab32(debugbuf[2]), swab32(debugbuf[3])); \ |
|
|
|
|
|
|
|
cudaFree(debugbuf); \ |
|
|
|
|
|
|
|
} \ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
#define TRACE(algo) {} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool init[MAX_GPUS] = { 0 }; |
|
|
|
static bool init[MAX_GPUS] = { 0 }; |
|
|
|
|
|
|
|
|
|
|
|
extern "C" int scanhash_skein2(int thr_id, uint32_t *pdata, |
|
|
|
extern "C" int scanhash_skein2(int thr_id, uint32_t *pdata, |
|
|
@ -57,21 +43,21 @@ extern "C" int scanhash_skein2(int thr_id, uint32_t *pdata, |
|
|
|
throughput = min(throughput, (max_nonce - first_nonce)); |
|
|
|
throughput = min(throughput, (max_nonce - first_nonce)); |
|
|
|
|
|
|
|
|
|
|
|
if (opt_benchmark) |
|
|
|
if (opt_benchmark) |
|
|
|
((uint32_t*)ptarget)[7] = 0x0FFF; |
|
|
|
((uint32_t*)ptarget)[7] = 0; |
|
|
|
|
|
|
|
|
|
|
|
if (!init[thr_id]) |
|
|
|
if (!init[thr_id]) |
|
|
|
{ |
|
|
|
{ |
|
|
|
cudaDeviceReset(); |
|
|
|
cudaDeviceReset(); |
|
|
|
cudaSetDevice(device_map[thr_id]); |
|
|
|
cudaSetDevice(device_map[thr_id]); |
|
|
|
|
|
|
|
|
|
|
|
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], 64 * throughput)); |
|
|
|
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], 64UL * throughput)); |
|
|
|
|
|
|
|
|
|
|
|
cuda_check_cpu_init(thr_id, throughput); |
|
|
|
cuda_check_cpu_init(thr_id, throughput); |
|
|
|
init[thr_id] = true; |
|
|
|
init[thr_id] = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint32_t endiandata[20]; |
|
|
|
uint32_t endiandata[20]; |
|
|
|
for (int k=0; k < 20; k++) |
|
|
|
for (int k=0; k < 19; k++) |
|
|
|
be32enc(&endiandata[k], pdata[k]); |
|
|
|
be32enc(&endiandata[k], pdata[k]); |
|
|
|
|
|
|
|
|
|
|
|
skein512_cpu_setBlock_80((void*)endiandata); |
|
|
|
skein512_cpu_setBlock_80((void*)endiandata); |
|
|
@ -81,24 +67,22 @@ extern "C" int scanhash_skein2(int thr_id, uint32_t *pdata, |
|
|
|
int order = 0; |
|
|
|
int order = 0; |
|
|
|
|
|
|
|
|
|
|
|
// Hash with CUDA |
|
|
|
// Hash with CUDA |
|
|
|
skein512_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id], order++); |
|
|
|
skein512_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id], 0); |
|
|
|
TRACE("80:"); |
|
|
|
|
|
|
|
quark_skein512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); |
|
|
|
quark_skein512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); |
|
|
|
TRACE("64:"); |
|
|
|
|
|
|
|
|
|
|
|
*hashes_done = pdata[19] - first_nonce + throughput; |
|
|
|
|
|
|
|
|
|
|
|
uint32_t foundNonce = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]); |
|
|
|
uint32_t foundNonce = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]); |
|
|
|
if (foundNonce != UINT32_MAX) |
|
|
|
if (foundNonce != UINT32_MAX) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint32_t vhash64[8]; |
|
|
|
uint32_t _ALIGN(64) vhash64[8]; |
|
|
|
|
|
|
|
|
|
|
|
endiandata[19] = foundNonce; |
|
|
|
endiandata[19] = foundNonce; |
|
|
|
skein2hash(vhash64, endiandata); |
|
|
|
skein2hash(vhash64, endiandata); |
|
|
|
|
|
|
|
|
|
|
|
#define Htarg ptarget[7] |
|
|
|
if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) { |
|
|
|
if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) { |
|
|
|
|
|
|
|
int res = 1; |
|
|
|
int res = 1; |
|
|
|
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); |
|
|
|
*hashes_done = pdata[19] - first_nonce + throughput; |
|
|
|
|
|
|
|
if (secNonce != 0) { |
|
|
|
if (secNonce != 0) { |
|
|
|
if (!opt_quiet) |
|
|
|
if (!opt_quiet) |
|
|
|
applog(LOG_BLUE, "GPU #%d: found second nonce %08x !", device_map[thr_id], swab32(secNonce)); |
|
|
|
applog(LOG_BLUE, "GPU #%d: found second nonce %08x !", device_map[thr_id], swab32(secNonce)); |
|
|
@ -113,10 +97,13 @@ extern "C" int scanhash_skein2(int thr_id, uint32_t *pdata, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (((uint64_t) throughput + pdata[19]) > max_nonce) { |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pdata[19] += throughput; |
|
|
|
pdata[19] += throughput; |
|
|
|
|
|
|
|
|
|
|
|
} while (pdata[19] < max_nonce && !work_restart[thr_id].restart); |
|
|
|
} while (!work_restart[thr_id].restart); |
|
|
|
|
|
|
|
|
|
|
|
*hashes_done = pdata[19] - first_nonce + 1; |
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|