Skip to content

Commit 2e0a977

Browse files
committed
polytimos algo (6 chained algos with streebog)
1 parent e1575c5 commit 2e0a977

12 files changed

+242
-3
lines changed

Diff for: Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ ccminer_SOURCES = elist.h miner.h compat.h \
6464
sph/hamsi.c sph/hamsi_helper.c sph/streebog.c \
6565
sph/shabal.c sph/whirlpool.c sph/sha2big.c sph/haval.c \
6666
sph/ripemd.c sph/sph_sha2.c \
67+
polytimos.cu \
6768
lbry/lbry.cu lbry/cuda_sha256_lbry.cu lbry/cuda_sha512_lbry.cu lbry/cuda_lbry_merged.cu \
6869
qubit/qubit.cu qubit/qubit_luffa512.cu qubit/deep.cu qubit/luffa.cu \
6970
tribus/tribus.cu tribus/cuda_echo512_final.cu \

Diff for: README.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
ccminer 2.2.2 (Oct. 2017) "phi and hsr algos"
2+
ccminer 2.2.3-dev (Nov. 2017) "polytimos algo"
33
---------------------------------------------------------------
44

55
***************************************************************
@@ -104,6 +104,7 @@ its command line interface and options.
104104
nist5 use to mine TalkCoin
105105
penta use to mine Joincoin / Pentablake
106106
phi use to mine LUXCoin
107+
polytimos use to mine Polytimos
107108
quark use to mine Quarkcoin
108109
qubit use to mine Qubit
109110
scrypt use to mine Scrypt coins
@@ -280,6 +281,9 @@ so we can more efficiently implement new algorithms using the latest hardware
280281
features.
281282

282283
>>> RELEASE HISTORY <<<
284+
Nov. 16th 2017 v2.2.3
285+
Polytimos Algo
286+
283287
Oct. 09th 2017 v2.2.2
284288
Import and clean the hsr algo (x13 + custom hash)
285289
Import and optimise phi algo from LuxCoin repository

Diff for: algos.h

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ enum sha_algos {
3737
ALGO_NIST5,
3838
ALGO_PENTABLAKE,
3939
ALGO_PHI,
40+
ALGO_POLYTIMOS,
4041
ALGO_QUARK,
4142
ALGO_QUBIT,
4243
ALGO_SCRYPT,
@@ -104,6 +105,7 @@ static const char *algo_names[] = {
104105
"nist5",
105106
"penta",
106107
"phi",
108+
"polytimos",
107109
"quark",
108110
"qubit",
109111
"scrypt",

Diff for: bench.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ void algo_free_all(int thr_id)
7979
free_nist5(thr_id);
8080
free_pentablake(thr_id);
8181
free_phi(thr_id);
82+
free_polytimos(thr_id);
8283
free_quark(thr_id);
8384
free_qubit(thr_id);
8485
free_skeincoin(thr_id);

Diff for: ccminer.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ Options:\n\
267267
nist5 NIST5 (TalkCoin)\n\
268268
penta Pentablake hash (5x Blake 512)\n\
269269
phi BHCoin\n\
270+
polytimos Politimos\n\
270271
quark Quark\n\
271272
qubit Qubit\n\
272273
sha256d SHA256d (bitcoin)\n\
@@ -2230,6 +2231,7 @@ static void *miner_thread(void *userdata)
22302231
case ALGO_HSR:
22312232
case ALGO_LYRA2v2:
22322233
case ALGO_PHI:
2234+
case ALGO_POLYTIMOS:
22332235
case ALGO_S3:
22342236
case ALGO_SKUNK:
22352237
case ALGO_TIMETRAVEL:
@@ -2417,6 +2419,9 @@ static void *miner_thread(void *userdata)
24172419
case ALGO_PHI:
24182420
rc = scanhash_phi(thr_id, &work, max_nonce, &hashes_done);
24192421
break;
2422+
case ALGO_POLYTIMOS:
2423+
rc = scanhash_polytimos(thr_id, &work, max_nonce, &hashes_done);
2424+
break;
24202425
case ALGO_SCRYPT:
24212426
rc = scanhash_scrypt(thr_id, &work, max_nonce, &hashes_done,
24222427
NULL, &tv_start, &tv_end);

Diff for: ccminer.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@
526526
<CudaCompile Include="lyra2\lyra2Z.cu" />
527527
<CudaCompile Include="lyra2\cuda_lyra2Z.cu" />
528528
<ClInclude Include="lyra2\cuda_lyra2Z_sm5.cuh" />
529+
<CudaCompile Include="polytimos.cu" />
529530
<CudaCompile Include="sia\sia.cu" />
530531
<CudaCompile Include="skein.cu">
531532
<MaxRegCount>64</MaxRegCount>

Diff for: ccminer.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,9 @@
769769
<CudaCompile Include="pentablake.cu">
770770
<Filter>Source Files\CUDA</Filter>
771771
</CudaCompile>
772+
<CudaCompile Include="polytimos.cu">
773+
<Filter>Source Files\CUDA</Filter>
774+
</CudaCompile>
772775
<CudaCompile Include="skunk\skunk.cu">
773776
<Filter>Source Files\CUDA\skunk</Filter>
774777
</CudaCompile>

Diff for: compat/ccminer-config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
#define PACKAGE_URL "http://github.com/tpruvot/ccminer"
165165

166166
/* Define to the version of this package. */
167-
#define PACKAGE_VERSION "2.2.2"
167+
#define PACKAGE_VERSION "2.2.3"
168168

169169
/* If using the C implementation of alloca, define if you know the
170170
direction of stack growth for your system; otherwise it will be

Diff for: configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([ccminer], [2.2.2], [], [ccminer], [http://github.com/tpruvot/ccminer])
1+
AC_INIT([ccminer], [2.2.3], [], [ccminer], [http://github.com/tpruvot/ccminer])
22

33
AC_PREREQ([2.59c])
44
AC_CANONICAL_SYSTEM

Diff for: miner.h

+3
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ extern int scanhash_neoscrypt(int thr_id, struct work *work, uint32_t max_nonce,
302302
extern int scanhash_nist5(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done);
303303
extern int scanhash_pentablake(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done);
304304
extern int scanhash_phi(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
305+
extern int scanhash_polytimos(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
305306
extern int scanhash_quark(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done);
306307
extern int scanhash_qubit(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
307308
extern int scanhash_sha256d(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done);
@@ -365,6 +366,7 @@ extern void free_neoscrypt(int thr_id);
365366
extern void free_nist5(int thr_id);
366367
extern void free_pentablake(int thr_id);
367368
extern void free_phi(int thr_id);
369+
extern void free_polytimos(int thr_id);
368370
extern void free_quark(int thr_id);
369371
extern void free_qubit(int thr_id);
370372
extern void free_sha256d(int thr_id);
@@ -908,6 +910,7 @@ void neoscrypt(uchar *output, const uchar *input, uint32_t profile);
908910
void nist5hash(void *state, const void *input);
909911
void pentablakehash(void *output, const void *input);
910912
void phihash(void *output, const void *input);
913+
void polytimos_hash(void *output, const void *input);
911914
void quarkhash(void *state, const void *input);
912915
void qubithash(void *state, const void *input);
913916
void scrypthash(void* output, const void* input);

Diff for: polytimos.cu

+216
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
/*
2+
* Polytimos algorithm
3+
*/
4+
extern "C"
5+
{
6+
#include "sph/sph_skein.h"
7+
#include "sph/sph_shabal.h"
8+
#include "sph/sph_echo.h"
9+
#include "sph/sph_luffa.h"
10+
#include "sph/sph_fugue.h"
11+
#include "sph/sph_streebog.h"
12+
}
13+
14+
#include "miner.h"
15+
16+
#include "cuda_helper.h"
17+
#include "x11/cuda_x11.h"
18+
19+
static uint32_t *d_hash[MAX_GPUS];
20+
static uint32_t *d_resNonce[MAX_GPUS];
21+
22+
extern void skein512_cpu_setBlock_80(void *pdata);
23+
extern void skein512_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_hash, int swap);
24+
extern void x14_shabal512_cpu_init(int thr_id, uint32_t threads);
25+
extern void x14_shabal512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order);
26+
extern void x11_cubehash512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order);
27+
extern void x13_fugue512_cpu_init(int thr_id, uint32_t threads);
28+
extern void x13_fugue512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order);
29+
extern void x13_fugue512_cpu_free(int thr_id);
30+
extern void streebog_sm3_set_target(uint32_t* ptarget);
31+
extern void streebog_sm3_hash_64_final(int thr_id, uint32_t threads, uint32_t *d_hash, uint32_t* d_resNonce);
32+
extern void skunk_streebog_set_target(uint32_t* ptarget);
33+
extern void skunk_cuda_streebog(int thr_id, uint32_t threads, uint32_t *d_hash, uint32_t* d_resNonce);
34+
35+
// CPU Hash
36+
extern "C" void polytimos_hash(void *output, const void *input)
37+
{
38+
sph_skein512_context ctx_skein;
39+
sph_shabal512_context ctx_shabal;
40+
sph_echo512_context ctx_echo;
41+
sph_luffa512_context ctx_luffa;
42+
sph_fugue512_context ctx_fugue;
43+
sph_gost512_context ctx_gost;
44+
45+
uint32_t _ALIGN(128) hash[16];
46+
memset(hash, 0, sizeof hash);
47+
48+
sph_skein512_init(&ctx_skein);
49+
sph_skein512(&ctx_skein, input, 80);
50+
sph_skein512_close(&ctx_skein, (void*) hash);
51+
52+
sph_shabal512_init(&ctx_shabal);
53+
sph_shabal512(&ctx_shabal, hash, 64);
54+
sph_shabal512_close(&ctx_shabal, hash);
55+
56+
sph_echo512_init(&ctx_echo);
57+
sph_echo512(&ctx_echo, hash, 64);
58+
sph_echo512_close(&ctx_echo, hash);
59+
60+
sph_luffa512_init(&ctx_luffa);
61+
sph_luffa512(&ctx_luffa, hash, 64);
62+
sph_luffa512_close(&ctx_luffa, hash);
63+
64+
sph_fugue512_init(&ctx_fugue);
65+
sph_fugue512(&ctx_fugue, hash, 64);
66+
sph_fugue512_close(&ctx_fugue, hash);
67+
68+
sph_gost512_init(&ctx_gost);
69+
sph_gost512(&ctx_gost, (const void*) hash, 64);
70+
sph_gost512_close(&ctx_gost, (void*) hash);
71+
72+
memcpy(output, hash, 32);
73+
}
74+
75+
static bool init[MAX_GPUS] = { 0 };
76+
static bool use_compat_kernels[MAX_GPUS] = { 0 };
77+
78+
extern "C" int scanhash_polytimos(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done)
79+
{
80+
int dev_id = device_map[thr_id];
81+
uint32_t *pdata = work->data;
82+
uint32_t *ptarget = work->target;
83+
const uint32_t first_nonce = pdata[19];
84+
int intensity = (device_sm[dev_id] > 500 && !is_windows()) ? 20 : 19;
85+
uint32_t throughput = cuda_default_throughput(thr_id, 1 << intensity); // 19=256*256*8;
86+
//if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
87+
88+
if (opt_benchmark)
89+
((uint32_t*)ptarget)[7] = 0x000f;
90+
91+
if (!init[thr_id])
92+
{
93+
cudaSetDevice(dev_id);
94+
if (opt_cudaschedule == -1 && gpu_threads == 1) {
95+
cudaDeviceReset();
96+
// reduce cpu usage
97+
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
98+
CUDA_LOG_ERROR();
99+
}
100+
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
101+
102+
cuda_get_arch(thr_id);
103+
use_compat_kernels[thr_id] = (cuda_arch[dev_id] < 500);
104+
105+
quark_skein512_cpu_init(thr_id, throughput);
106+
x14_shabal512_cpu_init(thr_id, throughput);
107+
x11_echo512_cpu_init(thr_id, throughput);
108+
x11_luffa512_cpu_init(thr_id, throughput);
109+
x13_fugue512_cpu_init(thr_id, throughput);
110+
111+
CUDA_CALL_OR_RET_X(cudaMalloc(&d_hash[thr_id], 16 * sizeof(uint32_t) * throughput), 0);
112+
CUDA_CALL_OR_RET_X(cudaMalloc(&d_resNonce[thr_id], 2 * sizeof(uint32_t)), -1);
113+
114+
init[thr_id] = true;
115+
}
116+
117+
118+
uint32_t _ALIGN(64) h_resNonce[2];
119+
uint32_t _ALIGN(64) endiandata[20];
120+
for (int k=0; k < 20; k++)
121+
be32enc(&endiandata[k], pdata[k]);
122+
123+
124+
cudaMemset(d_resNonce[thr_id], 0xff, 2*sizeof(uint32_t));
125+
skein512_cpu_setBlock_80(endiandata);
126+
if (use_compat_kernels[thr_id]) {
127+
streebog_sm3_set_target(ptarget);
128+
} else {
129+
skunk_streebog_set_target(ptarget);
130+
}
131+
132+
do {
133+
int order = 0;
134+
135+
skein512_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id], order++);
136+
x14_shabal512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
137+
x11_echo512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
138+
x11_luffa512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
139+
x13_fugue512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
140+
if (use_compat_kernels[thr_id]) {
141+
streebog_sm3_hash_64_final(thr_id, throughput, d_hash[thr_id], d_resNonce[thr_id]);
142+
} else {
143+
skunk_cuda_streebog(thr_id, throughput, d_hash[thr_id], d_resNonce[thr_id]);
144+
}
145+
146+
*hashes_done = pdata[19] - first_nonce + throughput;
147+
148+
cudaMemcpy(h_resNonce, d_resNonce[thr_id], 2 * sizeof(uint32_t), cudaMemcpyDeviceToHost);
149+
CUDA_LOG_ERROR();
150+
151+
if (h_resNonce[0] != UINT32_MAX)
152+
{
153+
const uint32_t Htarg = ptarget[7];
154+
const uint32_t startNounce = pdata[19];
155+
uint32_t _ALIGN(64) vhash[8];
156+
157+
be32enc(&endiandata[19], startNounce + h_resNonce[0]);
158+
polytimos_hash(vhash, endiandata);
159+
if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) {
160+
work->valid_nonces = 1;
161+
work->nonces[0] = startNounce + h_resNonce[0];
162+
work_set_target_ratio(work, vhash);
163+
if (h_resNonce[1] != UINT32_MAX) {
164+
uint32_t secNonce = work->nonces[1] = startNounce + h_resNonce[1];
165+
be32enc(&endiandata[19], secNonce);
166+
polytimos_hash(vhash, endiandata);
167+
bn_set_target_ratio(work, vhash, 1);
168+
work->valid_nonces++;
169+
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
170+
} else {
171+
pdata[19] = work->nonces[0] + 1; // cursor
172+
}
173+
return work->valid_nonces;
174+
}
175+
else if (vhash[7] > Htarg) {
176+
gpu_increment_reject(thr_id);
177+
if (!opt_quiet)
178+
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]);
179+
cudaMemset(d_resNonce[thr_id], 0xff, 2*sizeof(uint32_t));
180+
pdata[19] = startNounce + h_resNonce[0] + 1;
181+
continue;
182+
}
183+
}
184+
185+
if ((uint64_t)throughput + pdata[19] >= max_nonce) {
186+
pdata[19] = max_nonce;
187+
break;
188+
}
189+
pdata[19] += throughput;
190+
191+
} while (!work_restart[thr_id].restart);
192+
193+
*hashes_done = pdata[19] - first_nonce;
194+
195+
CUDA_LOG_ERROR();
196+
197+
return 0;
198+
}
199+
200+
// cleanup
201+
extern "C" void free_polytimos(int thr_id)
202+
{
203+
if (!init[thr_id])
204+
return;
205+
206+
cudaThreadSynchronize();
207+
208+
cudaFree(d_hash[thr_id]);
209+
x13_fugue512_cpu_free(thr_id);
210+
cudaFree(d_resNonce[thr_id]);
211+
212+
CUDA_LOG_ERROR();
213+
214+
cudaDeviceSynchronize();
215+
init[thr_id] = false;
216+
}

Diff for: util.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -2246,6 +2246,9 @@ void print_hash_tests(void)
22462246
phihash(&hash[0], &buf[0]);
22472247
printpfx("phi", hash);
22482248

2249+
polytimos_hash(&hash[0], &buf[0]);
2250+
printpfx("polytimos", hash);
2251+
22492252
quarkhash(&hash[0], &buf[0]);
22502253
printpfx("quark", hash);
22512254

0 commit comments

Comments
 (0)