Browse Source

x16s algo, compatible with SM3+

pull/4/head
Tanguy Pruvot 7 years ago
parent
commit
96adaf986c
  1. 2
      Makefile.am
  2. 2
      algos.h
  3. 1
      bench.cpp
  4. 5
      ccminer.cpp
  5. 3
      ccminer.vcxproj
  6. 5
      ccminer.vcxproj.filters
  7. 3
      miner.h
  8. 17
      util.cpp
  9. 1
      x16r/cuda_x16r.h
  10. 15
      x16r/x16r.cu
  11. 593
      x16r/x16s.cu

2
Makefile.am

@ -76,7 +76,7 @@ ccminer_SOURCES = elist.h miner.h compat.h \ @@ -76,7 +76,7 @@ ccminer_SOURCES = elist.h miner.h compat.h \
x13/hsr.cu x13/cuda_hsr_sm3.cu x13/sm3.c \
x15/x14.cu x15/x15.cu x15/cuda_x14_shabal512.cu x15/cuda_x15_whirlpool.cu \
x15/whirlpool.cu x15/cuda_x15_whirlpool_sm3.cu \
x16r/x16r.cu x16r/cuda_x16_echo512.cu x16r/cuda_x16_fugue512.cu \
x16r/x16r.cu x16r/x16s.cu x16r/cuda_x16_echo512.cu x16r/cuda_x16_fugue512.cu \
x16r/cuda_x16_shabal512.cu x16r/cuda_x16_simd512_80.cu \
x17/x17.cu x17/hmq17.cu x17/cuda_x17_haval256.cu x17/cuda_x17_sha512.cu \
x11/phi.cu x11/cuda_streebog_maxwell.cu \

2
algos.h

@ -61,6 +61,7 @@ enum sha_algos { @@ -61,6 +61,7 @@ enum sha_algos {
ALGO_X14,
ALGO_X15,
ALGO_X16R,
ALGO_X16S,
ALGO_X17,
ALGO_VANILLA,
ALGO_VELTOR,
@ -132,6 +133,7 @@ static const char *algo_names[] = { @@ -132,6 +133,7 @@ static const char *algo_names[] = {
"x14",
"x15",
"x16r",
"x16s",
"x17",
"vanilla",
"veltor",

1
bench.cpp

@ -104,6 +104,7 @@ void algo_free_all(int thr_id) @@ -104,6 +104,7 @@ void algo_free_all(int thr_id)
free_x14(thr_id);
free_x15(thr_id);
free_x16r(thr_id);
free_x16s(thr_id);
free_x17(thr_id);
free_zr5(thr_id);
free_scrypt(thr_id);

5
ccminer.cpp

@ -295,6 +295,7 @@ Options:\n\ @@ -295,6 +295,7 @@ Options:\n\
x14 X14\n\
x15 X15\n\
x16r X16R (Raven)\n\
x16s X16S\n\
x17 X17\n\
wildkeccak Boolberry\n\
zr5 ZR5 (ZiftrCoin)\n\
@ -1708,6 +1709,7 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work) @@ -1708,6 +1709,7 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
case ALGO_TIMETRAVEL:
case ALGO_BITCORE:
case ALGO_X16R:
case ALGO_X16S:
work_set_target(work, sctx->job.diff / (256.0 * opt_difficulty));
break;
case ALGO_KECCAK:
@ -2509,6 +2511,9 @@ static void *miner_thread(void *userdata) @@ -2509,6 +2511,9 @@ static void *miner_thread(void *userdata)
case ALGO_X16R:
rc = scanhash_x16r(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_X16S:
rc = scanhash_x16s(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_X17:
rc = scanhash_x17(thr_id, &work, max_nonce, &hashes_done);
break;

3
ccminer.vcxproj

@ -591,6 +591,7 @@ @@ -591,6 +591,7 @@
<CudaCompile Include="x15\whirlpool.cu" />
<CudaCompile Include="x15\cuda_x15_whirlpool_sm3.cu" />
<CudaCompile Include="x16r\x16r.cu" />
<CudaCompile Include="x16r\x16s.cu" />
<CudaCompile Include="x16r\cuda_x16_echo512.cu" />
<CudaCompile Include="x16r\cuda_x16_fugue512.cu" />
<CudaCompile Include="x16r\cuda_x16_shabal512.cu" />
@ -622,4 +623,4 @@ @@ -622,4 +623,4 @@
<Target Name="AfterClean">
<Delete Files="@(FilesToCopy->'$(OutDir)%(Filename)%(Extension)')" TreatErrorsAsWarnings="true" />
</Target>
</Project>
</Project>

5
ccminer.vcxproj.filters

@ -997,6 +997,9 @@ @@ -997,6 +997,9 @@
<CudaCompile Include="x16r\x16r.cu">
<Filter>Source Files\CUDA\x16r</Filter>
</CudaCompile>
<CudaCompile Include="x16r\x16s.cu">
<Filter>Source Files\CUDA\x16r</Filter>
</CudaCompile>
</ItemGroup>
<ItemGroup>
<Image Include="res\ccminer.ico">
@ -1013,4 +1016,4 @@ @@ -1013,4 +1016,4 @@
<Filter>Ressources</Filter>
</Text>
</ItemGroup>
</Project>
</Project>

3
miner.h

@ -327,6 +327,7 @@ extern int scanhash_x13(int thr_id, struct work* work, uint32_t max_nonce, unsig @@ -327,6 +327,7 @@ extern int scanhash_x13(int thr_id, struct work* work, uint32_t max_nonce, unsig
extern int scanhash_x14(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
extern int scanhash_x15(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
extern int scanhash_x16r(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
extern int scanhash_x16s(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
extern int scanhash_x17(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
extern int scanhash_zr5(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done);
@ -393,6 +394,7 @@ extern void free_x13(int thr_id); @@ -393,6 +394,7 @@ extern void free_x13(int thr_id);
extern void free_x14(int thr_id);
extern void free_x15(int thr_id);
extern void free_x16r(int thr_id);
extern void free_x16s(int thr_id);
extern void free_x17(int thr_id);
extern void free_zr5(int thr_id);
//extern void free_sha256d(int thr_id);
@ -939,6 +941,7 @@ void x13hash(void *output, const void *input); @@ -939,6 +941,7 @@ void x13hash(void *output, const void *input);
void x14hash(void *output, const void *input);
void x15hash(void *output, const void *input);
void x16r_hash(void *output, const void *input);
void x16s_hash(void *output, const void *input);
void x17hash(void *output, const void *input);
void wildkeccak_hash(void *output, const void *input, uint64_t* scratchpad, uint64_t ssize);
void zr5hash(void *output, const void *input);

17
util.cpp

@ -2314,25 +2314,28 @@ void print_hash_tests(void) @@ -2314,25 +2314,28 @@ void print_hash_tests(void)
printpfx("x11evo", hash);
x11hash(&hash[0], &buf[0]);
printpfx("X11", hash);
printpfx("x11", hash);
x12hash(&hash[0], &buf[0]);
printpfx("X12", hash);
printpfx("x12", hash);
x13hash(&hash[0], &buf[0]);
printpfx("X13", hash);
printpfx("x13", hash);
x14hash(&hash[0], &buf[0]);
printpfx("X14", hash);
printpfx("x14", hash);
x15hash(&hash[0], &buf[0]);
printpfx("X15", hash);
printpfx("x15", hash);
x16r_hash(&hash[0], &buf[0]);
printpfx("X16r", hash);
printpfx("x16r", hash);
x16s_hash(&hash[0], &buf[0]);
printpfx("x16s", hash);
x17hash(&hash[0], &buf[0]);
printpfx("X17", hash);
printpfx("x17", hash);
//memcpy(buf, zrtest, 80);
zr5hash(&hash[0], &buf[0]);

1
x16r/cuda_x16r.h

@ -73,3 +73,4 @@ void x16_whirlpool512_hash_80(int thr_id, const uint32_t threads, const uint32_t @@ -73,3 +73,4 @@ void x16_whirlpool512_hash_80(int thr_id, const uint32_t threads, const uint32_t
void x16_sha512_setBlock_80(void *pdata);
void x16_sha512_cuda_hash_80(int thr_id, const uint32_t threads, const uint32_t startNonce, uint32_t *d_hash);

15
x16r/x16r.cu

@ -76,7 +76,6 @@ static const char* algo_strings[] = { @@ -76,7 +76,6 @@ static const char* algo_strings[] = {
};
static __thread uint32_t s_ntime = UINT32_MAX;
static __thread bool s_implemented = false;
static __thread char hashOrder[HASH_FUNC_COUNT + 1] = { 0 };
static void getAlgoString(const uint32_t* prevblock, char *output)
@ -287,8 +286,8 @@ extern "C" int scanhash_x16r(int thr_id, struct work* work, uint32_t max_nonce, @@ -287,8 +286,8 @@ extern "C" int scanhash_x16r(int thr_id, struct work* work, uint32_t max_nonce,
if (opt_benchmark) {
((uint32_t*)ptarget)[7] = 0x003f;
((uint8_t*)pdata)[8] = 0x90; // hashOrder[0] = '9'; for simd 80 + blake512 64
//((uint8_t*)pdata)[8] = 0xA0; // hashOrder[0] = 'A'; for echo 80 + blake512 64
//((uint8_t*)pdata)[8] = 0x90; // hashOrder[0] = '9'; for simd 80 + blake512 64
((uint8_t*)pdata)[8] = 0xAA; // hashOrder[0] = 'A'; for echo 80 + 64
//((uint8_t*)pdata)[8] = 0xB0; // hashOrder[0] = 'B'; for hamsi 80 + blake512 64
//((uint8_t*)pdata)[8] = 0xC0; // hashOrder[0] = 'C'; for fugue 80 + blake512 64
//((uint8_t*)pdata)[8] = 0xE0; // hashOrder[0] = 'E'; for whirlpool 80 + blake512 64
@ -302,15 +301,9 @@ extern "C" int scanhash_x16r(int thr_id, struct work* work, uint32_t max_nonce, @@ -302,15 +301,9 @@ extern "C" int scanhash_x16r(int thr_id, struct work* work, uint32_t max_nonce,
if (s_ntime != ntime) {
getAlgoString(&endiandata[1], hashOrder);
s_ntime = ntime;
s_implemented = true;
if (opt_debug && !thr_id) applog(LOG_DEBUG, "hash order %s (%08x)", hashOrder, ntime);
}
if (!s_implemented) {
sleep(1);
return -1;
}
cuda_check_cpu_setTarget(ptarget);
char elem = hashOrder[0];
@ -366,10 +359,6 @@ extern "C" int scanhash_x16r(int thr_id, struct work* work, uint32_t max_nonce, @@ -366,10 +359,6 @@ extern "C" int scanhash_x16r(int thr_id, struct work* work, uint32_t max_nonce,
x16_sha512_setBlock_80(endiandata);
break;
default: {
if (!thr_id)
applog(LOG_WARNING, "kernel %s %c unimplemented, order %s", algo_strings[algo80], elem, hashOrder);
s_implemented = false;
sleep(5);
return -1;
}
}

593
x16r/x16s.cu

@ -0,0 +1,593 @@ @@ -0,0 +1,593 @@
/**
* X16S algorithm (X16 with Shuffled chain order)
*
* tpruvot 2018 - GPL code
*/
#include <stdio.h>
#include <memory.h>
#include <unistd.h>
extern "C" {
#include "sph/sph_blake.h"
#include "sph/sph_bmw.h"
#include "sph/sph_groestl.h"
#include "sph/sph_skein.h"
#include "sph/sph_jh.h"
#include "sph/sph_keccak.h"
#include "sph/sph_luffa.h"
#include "sph/sph_cubehash.h"
#include "sph/sph_shavite.h"
#include "sph/sph_simd.h"
#include "sph/sph_echo.h"
#include "sph/sph_hamsi.h"
#include "sph/sph_fugue.h"
#include "sph/sph_shabal.h"
#include "sph/sph_whirlpool.h"
#include "sph/sph_sha2.h"
}
#include "miner.h"
#include "cuda_helper.h"
#include "cuda_x16r.h"
static uint32_t *d_hash[MAX_GPUS];
enum Algo {
BLAKE = 0,
BMW,
GROESTL,
JH,
KECCAK,
SKEIN,
LUFFA,
CUBEHASH,
SHAVITE,
SIMD,
ECHO,
HAMSI,
FUGUE,
SHABAL,
WHIRLPOOL,
SHA512,
HASH_FUNC_COUNT
};
static const char* algo_strings[] = {
"blake",
"bmw512",
"groestl",
"jh512",
"keccak",
"skein",
"luffa",
"cube",
"shavite",
"simd",
"echo",
"hamsi",
"fugue",
"shabal",
"whirlpool",
"sha512",
NULL
};
static __thread uint32_t s_ntime = UINT32_MAX;
static __thread char hashOrder[HASH_FUNC_COUNT + 1] = { 0 };
static void getAlgoString(const uint32_t* prevblock, char *output)
{
uint8_t* data = (uint8_t*)prevblock;
strcpy(output, "0123456789ABCDEF");
for (uint8_t i = 0; i < HASH_FUNC_COUNT; i++) {
uint8_t b = (15 - i) >> 1; // 16 ascii hex chars, reversed
uint8_t algoDigit = (i & 1) ? data[b] & 0xF : data[b] >> 4;
int offset = (int) algoDigit;
char oldVal = output[offset];
for(int j=offset; j-->0;)
output[j+1] = output[j];
output[0] = oldVal;
}
}
// X16S CPU Hash (Validation)
extern "C" void x16s_hash(void *output, const void *input)
{
unsigned char _ALIGN(64) hash[128];
sph_blake512_context ctx_blake;
sph_bmw512_context ctx_bmw;
sph_groestl512_context ctx_groestl;
sph_jh512_context ctx_jh;
sph_keccak512_context ctx_keccak;
sph_skein512_context ctx_skein;
sph_luffa512_context ctx_luffa;
sph_cubehash512_context ctx_cubehash;
sph_shavite512_context ctx_shavite;
sph_simd512_context ctx_simd;
sph_echo512_context ctx_echo;
sph_hamsi512_context ctx_hamsi;
sph_fugue512_context ctx_fugue;
sph_shabal512_context ctx_shabal;
sph_whirlpool_context ctx_whirlpool;
sph_sha512_context ctx_sha512;
void *in = (void*) input;
int size = 80;
uint32_t *in32 = (uint32_t*) input;
getAlgoString(&in32[1], hashOrder);
for (int i = 0; i < 16; i++)
{
const char elem = hashOrder[i];
const uint8_t algo = elem >= 'A' ? elem - 'A' + 10 : elem - '0';
switch (algo) {
case BLAKE:
sph_blake512_init(&ctx_blake);
sph_blake512(&ctx_blake, in, size);
sph_blake512_close(&ctx_blake, hash);
break;
case BMW:
sph_bmw512_init(&ctx_bmw);
sph_bmw512(&ctx_bmw, in, size);
sph_bmw512_close(&ctx_bmw, hash);
break;
case GROESTL:
sph_groestl512_init(&ctx_groestl);
sph_groestl512(&ctx_groestl, in, size);
sph_groestl512_close(&ctx_groestl, hash);
break;
case SKEIN:
sph_skein512_init(&ctx_skein);
sph_skein512(&ctx_skein, in, size);
sph_skein512_close(&ctx_skein, hash);
break;
case JH:
sph_jh512_init(&ctx_jh);
sph_jh512(&ctx_jh, in, size);
sph_jh512_close(&ctx_jh, hash);
break;
case KECCAK:
sph_keccak512_init(&ctx_keccak);
sph_keccak512(&ctx_keccak, in, size);
sph_keccak512_close(&ctx_keccak, hash);
break;
case LUFFA:
sph_luffa512_init(&ctx_luffa);
sph_luffa512(&ctx_luffa, in, size);
sph_luffa512_close(&ctx_luffa, hash);
break;
case CUBEHASH:
sph_cubehash512_init(&ctx_cubehash);
sph_cubehash512(&ctx_cubehash, in, size);
sph_cubehash512_close(&ctx_cubehash, hash);
break;
case SHAVITE:
sph_shavite512_init(&ctx_shavite);
sph_shavite512(&ctx_shavite, in, size);
sph_shavite512_close(&ctx_shavite, hash);
break;
case SIMD:
sph_simd512_init(&ctx_simd);
sph_simd512(&ctx_simd, in, size);
sph_simd512_close(&ctx_simd, hash);
break;
case ECHO:
sph_echo512_init(&ctx_echo);
sph_echo512(&ctx_echo, in, size);
sph_echo512_close(&ctx_echo, hash);
break;
case HAMSI:
sph_hamsi512_init(&ctx_hamsi);
sph_hamsi512(&ctx_hamsi, in, size);
sph_hamsi512_close(&ctx_hamsi, hash);
break;
case FUGUE:
sph_fugue512_init(&ctx_fugue);
sph_fugue512(&ctx_fugue, in, size);
sph_fugue512_close(&ctx_fugue, hash);
break;
case SHABAL:
sph_shabal512_init(&ctx_shabal);
sph_shabal512(&ctx_shabal, in, size);
sph_shabal512_close(&ctx_shabal, hash);
break;
case WHIRLPOOL:
sph_whirlpool_init(&ctx_whirlpool);
sph_whirlpool(&ctx_whirlpool, in, size);
sph_whirlpool_close(&ctx_whirlpool, hash);
break;
case SHA512:
sph_sha512_init(&ctx_sha512);
sph_sha512(&ctx_sha512,(const void*) in, size);
sph_sha512_close(&ctx_sha512,(void*) hash);
break;
}
in = (void*) hash;
size = 64;
}
memcpy(output, hash, 32);
}
#if 0 /* in x16r */
void whirlpool_midstate(void *state, const void *input)
{
sph_whirlpool_context ctx;
sph_whirlpool_init(&ctx);
sph_whirlpool(&ctx, input, 64);
memcpy(state, ctx.state, 64);
}
#endif
static bool init[MAX_GPUS] = { 0 };
//#define _DEBUG
#define _DEBUG_PREFIX "x16s-"
#include "cuda_debug.cuh"
extern "C" int scanhash_x16s(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done)
{
uint32_t *pdata = work->data;
uint32_t *ptarget = work->target;
const uint32_t first_nonce = pdata[19];
const int dev_id = device_map[thr_id];
int intensity = (device_sm[dev_id] > 500 && !is_windows()) ? 20 : 19;
if (strstr(device_name[dev_id], "GTX 1080")) intensity = 20;
uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity);
//if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
if (!init[thr_id])
{
cudaSetDevice(device_map[thr_id]);
if (opt_cudaschedule == -1 && gpu_threads == 1) {
cudaDeviceReset();
// reduce cpu usage
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
}
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
quark_blake512_cpu_init(thr_id, throughput);
quark_bmw512_cpu_init(thr_id, throughput);
quark_groestl512_cpu_init(thr_id, throughput);
quark_skein512_cpu_init(thr_id, throughput);
quark_jh512_cpu_init(thr_id, throughput);
quark_keccak512_cpu_init(thr_id, throughput);
qubit_luffa512_cpu_init(thr_id, throughput);
x11_luffa512_cpu_init(thr_id, throughput); // 64
x11_shavite512_cpu_init(thr_id, throughput);
x11_simd512_cpu_init(thr_id, throughput); // 64
x11_echo512_cpu_init(thr_id, throughput);
x16_echo512_cuda_init(thr_id, throughput);
x13_hamsi512_cpu_init(thr_id, throughput);
x13_fugue512_cpu_init(thr_id, throughput);
x16_fugue512_cpu_init(thr_id, throughput);
x14_shabal512_cpu_init(thr_id, throughput);
x15_whirlpool_cpu_init(thr_id, throughput, 0);
x16_whirlpool512_init(thr_id, throughput);
x17_sha512_cpu_init(thr_id, throughput);
CUDA_CALL_OR_RET_X(cudaMalloc(&d_hash[thr_id], (size_t) 64 * throughput), 0);
cuda_check_cpu_init(thr_id, throughput);
init[thr_id] = true;
}
if (opt_benchmark) {
((uint32_t*)ptarget)[7] = 0x003f;
//((uint8_t*)pdata)[8] = 0x90; // hashOrder[0] = '9'; for simd 80 + blake512 64
//((uint8_t*)pdata)[8] = 0x0A; // hashOrder[0] = 'A'; for echo 64
//((uint8_t*)pdata)[8] = 0xB0; // hashOrder[0] = 'B'; for hamsi 80 + blake512 64
//((uint8_t*)pdata)[8] = 0xC0; // hashOrder[0] = 'C'; for fugue 80 + blake512 64
//((uint8_t*)pdata)[8] = 0xE0; // hashOrder[0] = 'E'; for whirlpool 80 + blake512 64
}
uint32_t _ALIGN(64) endiandata[20];
for (int k=0; k < 19; k++)
be32enc(&endiandata[k], pdata[k]);
uint32_t ntime = swab32(pdata[17]);
if (s_ntime != ntime) {
getAlgoString(&endiandata[1], hashOrder);
s_ntime = ntime;
if (opt_debug && !thr_id) applog(LOG_DEBUG, "hash order %s (%08x)", hashOrder, ntime);
}
cuda_check_cpu_setTarget(ptarget);
char elem = hashOrder[0];
const uint8_t algo80 = elem >= 'A' ? elem - 'A' + 10 : elem - '0';
switch (algo80) {
case BLAKE:
quark_blake512_cpu_setBlock_80(thr_id, endiandata);
break;
case BMW:
quark_bmw512_cpu_setBlock_80(endiandata);
break;
case GROESTL:
groestl512_setBlock_80(thr_id, endiandata);
break;
case JH:
jh512_setBlock_80(thr_id, endiandata);
break;
case KECCAK:
keccak512_setBlock_80(thr_id, endiandata);
break;
case SKEIN:
skein512_cpu_setBlock_80((void*)endiandata);
break;
case LUFFA:
qubit_luffa512_cpu_setBlock_80((void*)endiandata);
break;
case CUBEHASH:
cubehash512_setBlock_80(thr_id, endiandata);
break;
case SHAVITE:
x11_shavite512_setBlock_80((void*)endiandata);
break;
case SIMD:
x16_simd512_setBlock_80((void*)endiandata);
break;
case ECHO:
x16_echo512_setBlock_80((void*)endiandata);
break;
case HAMSI:
x16_hamsi512_setBlock_80((void*)endiandata);
break;
case FUGUE:
x16_fugue512_setBlock_80((void*)pdata);
break;
case SHABAL:
x16_shabal512_setBlock_80((void*)endiandata);
break;
case WHIRLPOOL:
x16_whirlpool512_setBlock_80((void*)endiandata);
break;
case SHA512:
x16_sha512_setBlock_80(endiandata);
break;
default: {
return -1;
}
}
int warn = 0;
do {
int order = 0;
// Hash with CUDA
switch (algo80) {
case BLAKE:
quark_blake512_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++;
TRACE("blake80:");
break;
case BMW:
quark_bmw512_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id], order++);
TRACE("bmw80 :");
break;
case GROESTL:
groestl512_cuda_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++;
TRACE("grstl80:");
break;
case JH:
jh512_cuda_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++;
TRACE("jh51280:");
break;
case KECCAK:
keccak512_cuda_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++;
TRACE("kecck80:");
break;
case SKEIN:
skein512_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id], 1); order++;
TRACE("skein80:");
break;
case LUFFA:
qubit_luffa512_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id], order++);
TRACE("luffa80:");
break;
case CUBEHASH:
cubehash512_cuda_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++;
TRACE("cube 80:");
break;
case SHAVITE:
x11_shavite512_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id], order++);
TRACE("shavite:");
break;
case SIMD:
x16_simd512_cuda_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++;
TRACE("simd512:");
break;
case ECHO:
x16_echo512_cuda_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++;
TRACE("echo :");
break;
case HAMSI:
x16_hamsi512_cuda_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++;
TRACE("hamsi :");
break;
case FUGUE:
x16_fugue512_cuda_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++;
TRACE("fugue :");
break;
case SHABAL:
x16_shabal512_cuda_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++;
TRACE("shabal :");
break;
case WHIRLPOOL:
x16_whirlpool512_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++;
TRACE("whirl :");
break;
case SHA512:
x16_sha512_cuda_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++;
TRACE("sha512 :");
break;
}
for (int i = 1; i < 16; i++)
{
const char elem = hashOrder[i];
const uint8_t algo64 = elem >= 'A' ? elem - 'A' + 10 : elem - '0';
switch (algo64) {
case BLAKE:
quark_blake512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
TRACE("blake :");
break;
case BMW:
quark_bmw512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
TRACE("bmw :");
break;
case GROESTL:
quark_groestl512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
TRACE("groestl:");
break;
case JH:
quark_jh512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
TRACE("jh512 :");
break;
case KECCAK:
quark_keccak512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
TRACE("keccak :");
break;
case SKEIN:
quark_skein512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
TRACE("skein :");
break;
case LUFFA:
x11_luffa512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
TRACE("luffa :");
break;
case CUBEHASH:
x11_cubehash512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
TRACE("cube :");
break;
case SHAVITE:
x11_shavite512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
TRACE("shavite:");
break;
case SIMD:
x11_simd512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
TRACE("simd :");
break;
case ECHO:
x11_echo512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
TRACE("echo :");
break;
case HAMSI:
x13_hamsi512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
TRACE("hamsi :");
break;
case FUGUE:
x13_fugue512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
TRACE("fugue :");
break;
case SHABAL:
x14_shabal512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
TRACE("shabal :");
break;
case WHIRLPOOL:
x15_whirlpool_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
TRACE("shabal :");
break;
case SHA512:
x17_sha512_cpu_hash_64(thr_id, throughput, pdata[19], d_hash[thr_id]); order++;
TRACE("sha512 :");
break;
}
}
*hashes_done = pdata[19] - first_nonce + throughput;
work->nonces[0] = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]);
#ifdef _DEBUG
uint32_t _ALIGN(64) dhash[8];
be32enc(&endiandata[19], pdata[19]);
x16s_hash(dhash, endiandata);
applog_hash(dhash);
return -1;
#endif
if (work->nonces[0] != UINT32_MAX)
{
const uint32_t Htarg = ptarget[7];
uint32_t _ALIGN(64) vhash[8];
be32enc(&endiandata[19], work->nonces[0]);
x16s_hash(vhash, endiandata);
if (vhash[7] <= Htarg && fulltest(vhash, ptarget)) {
work->valid_nonces = 1;
work->nonces[1] = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1);
work_set_target_ratio(work, vhash);
if (work->nonces[1] != 0) {
be32enc(&endiandata[19], work->nonces[1]);
x16s_hash(vhash, endiandata);
bn_set_target_ratio(work, vhash, 1);
work->valid_nonces++;
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
} else {
pdata[19] = work->nonces[0] + 1; // cursor
}
//gpulog(LOG_INFO, thr_id, "hash found with %s 80 (%s)!", algo_strings[algo80], hashOrder);
return work->valid_nonces;
}
else if (vhash[7] > Htarg) {
// x11+ coins could do some random error, but not on retry
gpu_increment_reject(thr_id);
if (!warn) {
warn++;
pdata[19] = work->nonces[0] + 1;
continue;
} else {
if (!opt_quiet) gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU! %s %s",
work->nonces[0], algo_strings[algo80], hashOrder);
warn = 0;
}
}
}
if ((uint64_t)throughput + pdata[19] >= max_nonce) {
pdata[19] = max_nonce;
break;
}
pdata[19] += throughput;
} while (pdata[19] < max_nonce && !work_restart[thr_id].restart);
*hashes_done = pdata[19] - first_nonce;
return 0;
}
// cleanup
extern "C" void free_x16s(int thr_id)
{
if (!init[thr_id])
return;
cudaThreadSynchronize();
cudaFree(d_hash[thr_id]);
quark_blake512_cpu_free(thr_id);
quark_groestl512_cpu_free(thr_id);
x11_simd512_cpu_free(thr_id);
x13_fugue512_cpu_free(thr_id);
x16_fugue512_cpu_free(thr_id); // to merge with x13_fugue512 ?
x15_whirlpool_cpu_free(thr_id);
cuda_check_cpu_free(thr_id);
cudaDeviceSynchronize();
init[thr_id] = false;
}
Loading…
Cancel
Save