Skip to content

Commit

Permalink
x16s algo, compatible with SM3+
Browse files Browse the repository at this point in the history
  • Loading branch information
tpruvot committed Mar 29, 2018
1 parent 5b1b77b commit 96adaf9
Show file tree
Hide file tree
Showing 11 changed files with 624 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 2 additions & 0 deletions algos.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ enum sha_algos {
ALGO_X14,
ALGO_X15,
ALGO_X16R,
ALGO_X16S,
ALGO_X17,
ALGO_VANILLA,
ALGO_VELTOR,
Expand Down Expand Up @@ -132,6 +133,7 @@ static const char *algo_names[] = {
"x14",
"x15",
"x16r",
"x16s",
"x17",
"vanilla",
"veltor",
Expand Down
1 change: 1 addition & 0 deletions bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions ccminer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion ccminer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down Expand Up @@ -622,4 +623,4 @@
<Target Name="AfterClean">
<Delete Files="@(FilesToCopy->'$(OutDir)%(Filename)%(Extension)')" TreatErrorsAsWarnings="true" />
</Target>
</Project>
</Project>
5 changes: 4 additions & 1 deletion ccminer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -1013,4 +1016,4 @@
<Filter>Ressources</Filter>
</Text>
</ItemGroup>
</Project>
</Project>
3 changes: 3 additions & 0 deletions miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
17 changes: 10 additions & 7 deletions util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
1 change: 1 addition & 0 deletions x16r/cuda_x16r.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 2 additions & 13 deletions x16r/x16r.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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];
Expand Down Expand Up @@ -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;
}
}
Expand Down
Loading

0 comments on commit 96adaf9

Please sign in to comment.