|
|
@ -13,7 +13,13 @@ extern "C" |
|
|
|
#include "cuda_helper.h" |
|
|
|
#include "cuda_helper.h" |
|
|
|
#include "cuda_quark.h" |
|
|
|
#include "cuda_quark.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern uint32_t quark_filter_cpu_sm2(const int thr_id, const uint32_t threads, const uint32_t *inpHashes, uint32_t* d_branch2); |
|
|
|
|
|
|
|
extern void quark_merge_cpu_sm2(const int thr_id, const uint32_t threads, uint32_t *outpHashes, uint32_t* d_branch2); |
|
|
|
|
|
|
|
|
|
|
|
static uint32_t *d_hash[MAX_GPUS]; |
|
|
|
static uint32_t *d_hash[MAX_GPUS]; |
|
|
|
|
|
|
|
static uint32_t* d_hash_br2[MAX_GPUS]; // SM 2 |
|
|
|
|
|
|
|
|
|
|
|
// Speicher zur Generierung der Noncevektoren für die bedingten Hashes |
|
|
|
// Speicher zur Generierung der Noncevektoren für die bedingten Hashes |
|
|
|
static uint32_t *d_branch1Nonces[MAX_GPUS]; |
|
|
|
static uint32_t *d_branch1Nonces[MAX_GPUS]; |
|
|
@ -102,10 +108,10 @@ extern "C" void quarkhash(void *state, const void *input) |
|
|
|
#define TRACE(algo) { \ |
|
|
|
#define TRACE(algo) { \ |
|
|
|
if (max_nonce == 1 && pdata[19] <= 1) { \ |
|
|
|
if (max_nonce == 1 && pdata[19] <= 1) { \ |
|
|
|
uint32_t* debugbuf = NULL; \ |
|
|
|
uint32_t* debugbuf = NULL; \ |
|
|
|
cudaMallocHost(&debugbuf, 8*sizeof(uint32_t)); \ |
|
|
|
cudaMallocHost(&debugbuf, 32); \ |
|
|
|
cudaMemcpy(debugbuf, d_hash[thr_id], 8*sizeof(uint32_t), cudaMemcpyDeviceToHost); \ |
|
|
|
cudaMemcpy(debugbuf, d_hash[thr_id], 32, cudaMemcpyDeviceToHost); \ |
|
|
|
printf("quark %s %08x %08x %08x %08x...\n", algo, swab32(debugbuf[0]), swab32(debugbuf[1]), \ |
|
|
|
printf("quark %s %08x %08x %08x %08x...%08x... \n", algo, swab32(debugbuf[0]), swab32(debugbuf[1]), \ |
|
|
|
swab32(debugbuf[2]), swab32(debugbuf[3])); \ |
|
|
|
swab32(debugbuf[2]), swab32(debugbuf[3]), swab32(debugbuf[7])); \ |
|
|
|
cudaFreeHost(debugbuf); \ |
|
|
|
cudaFreeHost(debugbuf); \ |
|
|
|
} \ |
|
|
|
} \ |
|
|
|
} |
|
|
|
} |
|
|
@ -121,9 +127,10 @@ extern "C" int scanhash_quark(int thr_id, struct work* work, uint32_t max_nonce, |
|
|
|
uint32_t *pdata = work->data; |
|
|
|
uint32_t *pdata = work->data; |
|
|
|
uint32_t *ptarget = work->target; |
|
|
|
uint32_t *ptarget = work->target; |
|
|
|
const uint32_t first_nonce = pdata[19]; |
|
|
|
const uint32_t first_nonce = pdata[19]; |
|
|
|
int dev_id = device_map[thr_id]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t throughput = cuda_default_throughput(thr_id, 1U << 20); // 256*4096 |
|
|
|
int dev_id = device_map[thr_id]; |
|
|
|
|
|
|
|
uint32_t def_thr = 1U << 20; // 256*4096 |
|
|
|
|
|
|
|
uint32_t throughput = cuda_default_throughput(thr_id, def_thr); |
|
|
|
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce); |
|
|
|
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce); |
|
|
|
|
|
|
|
|
|
|
|
if (opt_benchmark) |
|
|
|
if (opt_benchmark) |
|
|
@ -131,7 +138,7 @@ extern "C" int scanhash_quark(int thr_id, struct work* work, uint32_t max_nonce, |
|
|
|
|
|
|
|
|
|
|
|
if (!init[thr_id]) |
|
|
|
if (!init[thr_id]) |
|
|
|
{ |
|
|
|
{ |
|
|
|
cudaSetDevice(device_map[thr_id]); |
|
|
|
cudaSetDevice(dev_id); |
|
|
|
|
|
|
|
|
|
|
|
cudaGetLastError(); |
|
|
|
cudaGetLastError(); |
|
|
|
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], (size_t) 64 * throughput)); |
|
|
|
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], (size_t) 64 * throughput)); |
|
|
@ -142,20 +149,19 @@ extern "C" int scanhash_quark(int thr_id, struct work* work, uint32_t max_nonce, |
|
|
|
quark_bmw512_cpu_init(thr_id, throughput); |
|
|
|
quark_bmw512_cpu_init(thr_id, throughput); |
|
|
|
quark_keccak512_cpu_init(thr_id, throughput); |
|
|
|
quark_keccak512_cpu_init(thr_id, throughput); |
|
|
|
quark_jh512_cpu_init(thr_id, throughput); |
|
|
|
quark_jh512_cpu_init(thr_id, throughput); |
|
|
|
cuda_check_cpu_init(thr_id, throughput); |
|
|
|
|
|
|
|
quark_compactTest_cpu_init(thr_id, throughput); |
|
|
|
quark_compactTest_cpu_init(thr_id, throughput); |
|
|
|
|
|
|
|
|
|
|
|
cudaMalloc(&d_branch1Nonces[thr_id], sizeof(uint32_t)*throughput); |
|
|
|
if (cuda_arch[dev_id] >= 300) { |
|
|
|
cudaMalloc(&d_branch2Nonces[thr_id], sizeof(uint32_t)*throughput); |
|
|
|
cudaMalloc(&d_branch1Nonces[thr_id], sizeof(uint32_t)*throughput); |
|
|
|
cudaMalloc(&d_branch3Nonces[thr_id], sizeof(uint32_t)*throughput); |
|
|
|
cudaMalloc(&d_branch2Nonces[thr_id], sizeof(uint32_t)*throughput); |
|
|
|
CUDA_SAFE_CALL(cudaGetLastError()); |
|
|
|
cudaMalloc(&d_branch3Nonces[thr_id], sizeof(uint32_t)*throughput); |
|
|
|
|
|
|
|
} else { |
|
|
|
if (device_sm[dev_id] < 300 || cuda_arch[dev_id] < 300) { |
|
|
|
cudaMalloc(&d_hash_br2[thr_id], (size_t) 64 * throughput); |
|
|
|
gpulog(LOG_ERR, thr_id, "Device SM 3.0 or more recent required!"); |
|
|
|
|
|
|
|
proper_exit(1); |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cuda_check_cpu_init(thr_id, throughput); |
|
|
|
|
|
|
|
CUDA_SAFE_CALL(cudaGetLastError()); |
|
|
|
|
|
|
|
|
|
|
|
init[thr_id] = true; |
|
|
|
init[thr_id] = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -167,58 +173,95 @@ extern "C" int scanhash_quark(int thr_id, struct work* work, uint32_t max_nonce, |
|
|
|
|
|
|
|
|
|
|
|
do { |
|
|
|
do { |
|
|
|
int order = 0; |
|
|
|
int order = 0; |
|
|
|
|
|
|
|
uint32_t foundNonce; |
|
|
|
uint32_t nrm1=0, nrm2=0, nrm3=0; |
|
|
|
uint32_t nrm1=0, nrm2=0, nrm3=0; |
|
|
|
|
|
|
|
|
|
|
|
quark_blake512_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++; |
|
|
|
quark_blake512_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++; |
|
|
|
TRACE("blake :"); |
|
|
|
TRACE("blake :"); |
|
|
|
|
|
|
|
|
|
|
|
// das ist der unbedingte Branch für BMW512 |
|
|
|
|
|
|
|
quark_bmw512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); |
|
|
|
quark_bmw512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); |
|
|
|
|
|
|
|
TRACE("bmw :"); |
|
|
|
|
|
|
|
|
|
|
|
quark_compactTest_single_false_cpu_hash_64(thr_id, throughput, pdata[19], d_hash[thr_id], NULL, |
|
|
|
if (cuda_arch[dev_id] >= 300) { |
|
|
|
d_branch3Nonces[thr_id], &nrm3, |
|
|
|
|
|
|
|
|
|
|
|
quark_compactTest_single_false_cpu_hash_64(thr_id, throughput, pdata[19], d_hash[thr_id], NULL, |
|
|
|
|
|
|
|
d_branch3Nonces[thr_id], &nrm3, order++); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// nur den Skein Branch weiterverfolgen |
|
|
|
|
|
|
|
quark_skein512_cpu_hash_64(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// das ist der unbedingte Branch für Groestl512 |
|
|
|
|
|
|
|
quark_groestl512_cpu_hash_64(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// das ist der unbedingte Branch für JH512 |
|
|
|
|
|
|
|
quark_jh512_cpu_hash_64(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// quarkNonces in branch1 und branch2 aufsplitten gemäss if (hash[0] & 0x8) |
|
|
|
|
|
|
|
quark_compactTest_cpu_hash_64(thr_id, nrm3, pdata[19], d_hash[thr_id], d_branch3Nonces[thr_id], |
|
|
|
|
|
|
|
d_branch1Nonces[thr_id], &nrm1, |
|
|
|
|
|
|
|
d_branch2Nonces[thr_id], &nrm2, |
|
|
|
order++); |
|
|
|
order++); |
|
|
|
|
|
|
|
|
|
|
|
// nur den Skein Branch weiterverfolgen |
|
|
|
// das ist der bedingte Branch für Blake512 |
|
|
|
quark_skein512_cpu_hash_64(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
quark_blake512_cpu_hash_64(thr_id, nrm1, pdata[19], d_branch1Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
|
|
|
|
|
|
|
|
// das ist der unbedingte Branch für Groestl512 |
|
|
|
// das ist der bedingte Branch für Bmw512 |
|
|
|
quark_groestl512_cpu_hash_64(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
quark_bmw512_cpu_hash_64(thr_id, nrm2, pdata[19], d_branch2Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
|
|
|
|
|
|
|
|
// das ist der unbedingte Branch für JH512 |
|
|
|
// das ist der unbedingte Branch für Keccak512 |
|
|
|
quark_jh512_cpu_hash_64(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
quark_keccak512_cpu_hash_64(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
|
|
|
|
|
|
|
|
// quarkNonces in branch1 und branch2 aufsplitten gemäss if (hash[0] & 0x8) |
|
|
|
// das ist der unbedingte Branch für Skein512 |
|
|
|
quark_compactTest_cpu_hash_64(thr_id, nrm3, pdata[19], d_hash[thr_id], d_branch3Nonces[thr_id], |
|
|
|
quark_skein512_cpu_hash_64(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
d_branch1Nonces[thr_id], &nrm1, |
|
|
|
|
|
|
|
d_branch2Nonces[thr_id], &nrm2, |
|
|
|
|
|
|
|
order++); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// das ist der bedingte Branch für Blake512 |
|
|
|
// quarkNonces in branch1 und branch2 aufsplitten gemäss if (hash[0] & 0x8) |
|
|
|
quark_blake512_cpu_hash_64(thr_id, nrm1, pdata[19], d_branch1Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
quark_compactTest_cpu_hash_64(thr_id, nrm3, pdata[19], d_hash[thr_id], d_branch3Nonces[thr_id], |
|
|
|
|
|
|
|
d_branch1Nonces[thr_id], &nrm1, |
|
|
|
|
|
|
|
d_branch2Nonces[thr_id], &nrm2, |
|
|
|
|
|
|
|
order++); |
|
|
|
|
|
|
|
|
|
|
|
// das ist der bedingte Branch für Bmw512 |
|
|
|
quark_keccak512_cpu_hash_64(thr_id, nrm1, pdata[19], d_branch1Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
quark_bmw512_cpu_hash_64(thr_id, nrm2, pdata[19], d_branch2Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
quark_jh512_cpu_hash_64(thr_id, nrm2, pdata[19], d_branch2Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
|
|
|
|
|
|
|
|
// das ist der unbedingte Branch für Keccak512 |
|
|
|
foundNonce = cuda_check_hash_branch(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
quark_keccak512_cpu_hash_64(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// das ist der unbedingte Branch für Skein512 |
|
|
|
} else { |
|
|
|
quark_skein512_cpu_hash_64(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
/* algo permutations are made with 2 different buffers */ |
|
|
|
|
|
|
|
|
|
|
|
// quarkNonces in branch1 und branch2 aufsplitten gemäss if (hash[0] & 0x8) |
|
|
|
quark_filter_cpu_sm2(thr_id, throughput, d_hash[thr_id], d_hash_br2[thr_id]); |
|
|
|
quark_compactTest_cpu_hash_64(thr_id, nrm3, pdata[19], d_hash[thr_id], d_branch3Nonces[thr_id], |
|
|
|
quark_groestl512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); |
|
|
|
d_branch1Nonces[thr_id], &nrm1, |
|
|
|
quark_skein512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash_br2[thr_id], order++); |
|
|
|
d_branch2Nonces[thr_id], &nrm2, |
|
|
|
quark_merge_cpu_sm2(thr_id, throughput, d_hash[thr_id], d_hash_br2[thr_id]); |
|
|
|
order++); |
|
|
|
TRACE("perm1 :"); |
|
|
|
|
|
|
|
|
|
|
|
quark_keccak512_cpu_hash_64(thr_id, nrm1, pdata[19], d_branch1Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
quark_groestl512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); |
|
|
|
quark_jh512_cpu_hash_64(thr_id, nrm2, pdata[19], d_branch2Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
TRACE("groestl:"); |
|
|
|
|
|
|
|
quark_jh512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); |
|
|
|
|
|
|
|
TRACE("jh512 :"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
quark_filter_cpu_sm2(thr_id, throughput, d_hash[thr_id], d_hash_br2[thr_id]); |
|
|
|
|
|
|
|
quark_blake512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); |
|
|
|
|
|
|
|
quark_bmw512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash_br2[thr_id], order++); |
|
|
|
|
|
|
|
quark_merge_cpu_sm2(thr_id, throughput, d_hash[thr_id], d_hash_br2[thr_id]); |
|
|
|
|
|
|
|
TRACE("perm2 :"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
quark_keccak512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); |
|
|
|
|
|
|
|
TRACE("keccak :"); |
|
|
|
|
|
|
|
quark_skein512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); |
|
|
|
|
|
|
|
TRACE("skein :"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
quark_filter_cpu_sm2(thr_id, throughput, d_hash[thr_id], d_hash_br2[thr_id]); |
|
|
|
|
|
|
|
quark_keccak512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++); |
|
|
|
|
|
|
|
quark_jh512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash_br2[thr_id], order++); |
|
|
|
|
|
|
|
quark_merge_cpu_sm2(thr_id, throughput, d_hash[thr_id], d_hash_br2[thr_id]); |
|
|
|
|
|
|
|
TRACE("perm3 :"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CUDA_LOG_ERROR(); |
|
|
|
|
|
|
|
foundNonce = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
*hashes_done = pdata[19] - first_nonce + 1; |
|
|
|
*hashes_done = pdata[19] - first_nonce + 1; |
|
|
|
|
|
|
|
|
|
|
|
uint32_t foundNonce = cuda_check_hash_branch(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++); |
|
|
|
if (foundNonce != UINT32_MAX) |
|
|
|
if (foundNonce != UINT32_MAX) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
uint32_t vhash[8]; |
|
|
|
uint32_t vhash[8]; |
|
|
|
be32enc(&endiandata[19], foundNonce); |
|
|
|
be32enc(&endiandata[19], foundNonce); |
|
|
|