Skip to content

Commit 5340f8d

Browse files
authored
Merge pull request #19 from fancyIX/feature/#18
Feature/#18
2 parents 9d061fa + 8df32a6 commit 5340f8d

11 files changed

+258
-7
lines changed

Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ ccminer_SOURCES = elist.h miner.h compat.h \
8282
x15/whirlpool.cu x15/cuda_x15_whirlpool_sm3.cu \
8383
x17/x17.cu x17/hmq17.cu x17/cuda_x17_haval256.cu x17/cuda_x17_sha512.cu \
8484
x11/phi.cu x11/cuda_streebog_maxwell.cu \
85-
x11/c11.cu x11/s3.cu x11/sib.cu x11/veltor.cu x11/cuda_streebog.cu
85+
x11/c11.cu x11/s3.cu x11/sib.cu x11/veltor.cu x11/cuda_streebog.cu x11/0x10.cu
8686

8787
# scrypt
8888
ccminer_SOURCES += scrypt.cpp scrypt-jane.cpp \

algos.h

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ enum sha_algos {
5757
ALGO_TRIBUS,
5858
ALGO_BITCORE,
5959
ALGO_X11EVO,
60+
ALGO_0X10,
6061
ALGO_X11,
6162
ALGO_X13,
6263
ALGO_X14,
@@ -128,6 +129,7 @@ static const char *algo_names[] = {
128129
"tribus",
129130
"bitcore",
130131
"x11evo",
132+
"0x10",
131133
"x11",
132134
"x13",
133135
"x14",

ccminer.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2246,6 +2246,7 @@ static void *miner_thread(void *userdata)
22462246
case ALGO_TIMETRAVEL:
22472247
case ALGO_BITCORE:
22482248
case ALGO_X11EVO:
2249+
case ALGO_0X10:
22492250
case ALGO_X11:
22502251
case ALGO_X13:
22512252
case ALGO_WHIRLCOIN:
@@ -2486,6 +2487,9 @@ static void *miner_thread(void *userdata)
24862487
case ALGO_X11EVO:
24872488
rc = scanhash_x11evo(thr_id, &work, max_nonce, &hashes_done);
24882489
break;
2490+
case ALGO_0X10:
2491+
rc = scanhash_hash0x10(thr_id, &work, max_nonce, &hashes_done);
2492+
break;
24892493
case ALGO_X11:
24902494
rc = scanhash_x11(thr_id, &work, max_nonce, &hashes_done);
24912495
break;

ccminer.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@
550550
<CudaCompile Include="x11\bitcore.cu" />
551551
<CudaCompile Include="x11\veltor.cu" />
552552
<CudaCompile Include="x11\x11.cu" />
553+
<CudaCompile Include="x11\0x10.cu" />
553554
<CudaCompile Include="x11\x11evo.cu" />
554555
<CudaCompile Include="x13\cuda_x13_hamsi512.cu">
555556
<MaxRegCount>72</MaxRegCount>

ccminer.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,9 @@
730730
<CudaCompile Include="x11\x11.cu">
731731
<Filter>Source Files\CUDA\x11</Filter>
732732
</CudaCompile>
733+
<CudaCompile Include="x11\0x10.cu">
734+
<Filter>Source Files\CUDA\x11</Filter>
735+
</CudaCompile>
733736
<CudaCompile Include="x11\x11evo.cu">
734737
<Filter>Source Files\CUDA\x11</Filter>
735738
</CudaCompile>

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 "0.4.0"
167+
#define PACKAGE_VERSION "0.5.0"
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

configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([ccminer-fancyIX], [0.4.0], [], [ccminer-fancyIX], [https://github.com/fancyIX/ccminer])
1+
AC_INIT([ccminer-fancyIX], [0.5.0], [], [ccminer-fancyIX], [https://github.com/fancyIX/ccminer])
22

33
AC_PREREQ([2.59c])
44
AC_CANONICAL_SYSTEM

miner.h

+2
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ extern int scanhash_veltor(int thr_id, struct work* work, uint32_t max_nonce, un
322322
extern int scanhash_whirl(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
323323
extern int scanhash_wildkeccak(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
324324
extern int scanhash_x11evo(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
325+
extern int scanhash_hash0x10(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
325326
extern int scanhash_x11(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
326327
extern int scanhash_x13(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
327328
extern int scanhash_x14(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
@@ -924,6 +925,7 @@ void veltorhash(void *output, const void *input);
924925
void wcoinhash(void *state, const void *input);
925926
void whirlxHash(void *state, const void *input);
926927
void x11evo_hash(void *output, const void *input);
928+
void hash0x10(void *output, const void *input);
927929
void x11hash(void *output, const void *input);
928930
void x13hash(void *output, const void *input);
929931
void x14hash(void *output, const void *input);

res/ccminer.rc

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ IDI_ICON1 ICON "ccminer.ico"
6060
//
6161

6262
VS_VERSION_INFO VERSIONINFO
63-
FILEVERSION 0,4,0,0
64-
PRODUCTVERSION 0,4,0,0
63+
FILEVERSION 0,5,0,0
64+
PRODUCTVERSION 0,5,0,0
6565
FILEFLAGSMASK 0x3fL
6666
#ifdef _DEBUG
6767
FILEFLAGS 0x21L
@@ -76,10 +76,10 @@ BEGIN
7676
BEGIN
7777
BLOCK "040904e4"
7878
BEGIN
79-
VALUE "FileVersion", "0.4.0"
79+
VALUE "FileVersion", "0.5.0"
8080
VALUE "LegalCopyright", "Copyright (C) 2022"
8181
VALUE "ProductName", "ccminer-fancyIX"
82-
VALUE "ProductVersion", "0.4.0"
82+
VALUE "ProductVersion", "0.5.0"
8383
END
8484
END
8585
BLOCK "VarFileInfo"

util.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -2309,6 +2309,9 @@ void print_hash_tests(void)
23092309
x11evo_hash(&hash[0], &buf[0]);
23102310
printpfx("x11evo", hash);
23112311

2312+
hash0x10(&hash[0], &buf[0]);
2313+
printpfx("0x10", hash);
2314+
23122315
x11hash(&hash[0], &buf[0]);
23132316
printpfx("X11", hash);
23142317

x11/0x10.cu

+236
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
extern "C" {
2+
#include "sph/sph_blake.h"
3+
#include "sph/sph_bmw.h"
4+
#include "sph/sph_groestl.h"
5+
#include "sph/sph_skein.h"
6+
#include "sph/sph_jh.h"
7+
#include "sph/sph_keccak.h"
8+
#include "sph/sph_luffa.h"
9+
#include "sph/sph_cubehash.h"
10+
#include "sph/sph_shavite.h"
11+
#include "sph/sph_simd.h"
12+
#include "sph/sph_echo.h"
13+
}
14+
15+
#include "miner.h"
16+
#include "cuda_helper.h"
17+
#include "cuda_x11.h"
18+
19+
#include <stdio.h>
20+
#include <memory.h>
21+
22+
static uint32_t *d_hash[MAX_GPUS];
23+
24+
// 0X10 CPU Hash
25+
extern "C" void hash0x10(void *output, const void *input)
26+
{
27+
unsigned char _ALIGN(128) hash[128] = { 0 };
28+
29+
// blake1-skein4-bmw2-grs3-jh5-luffa7-keccak6-cubehash8-simd10-shavite9-echo11
30+
31+
sph_blake512_context ctx_blake;
32+
sph_bmw512_context ctx_bmw;
33+
sph_groestl512_context ctx_groestl;
34+
sph_jh512_context ctx_jh;
35+
sph_keccak512_context ctx_keccak;
36+
sph_skein512_context ctx_skein;
37+
sph_luffa512_context ctx_luffa;
38+
sph_cubehash512_context ctx_cubehash;
39+
sph_shavite512_context ctx_shavite;
40+
sph_simd512_context ctx_simd;
41+
sph_echo512_context ctx_echo;
42+
43+
sph_blake512_init(&ctx_blake);
44+
sph_blake512 (&ctx_blake, input, 80);
45+
sph_blake512_close(&ctx_blake, (void*) hash);
46+
47+
sph_skein512_init(&ctx_skein);
48+
sph_skein512 (&ctx_skein, (const void*) hash, 64);
49+
sph_skein512_close(&ctx_skein, (void*) hash);
50+
51+
sph_bmw512_init(&ctx_bmw);
52+
sph_bmw512 (&ctx_bmw, (const void*) hash, 64);
53+
sph_bmw512_close(&ctx_bmw, (void*) hash);
54+
55+
sph_groestl512_init(&ctx_groestl);
56+
sph_groestl512 (&ctx_groestl, (const void*) hash, 64);
57+
sph_groestl512_close(&ctx_groestl, (void*) hash);
58+
59+
sph_jh512_init(&ctx_jh);
60+
sph_jh512 (&ctx_jh, (const void*) hash, 64);
61+
sph_jh512_close(&ctx_jh, (void*) hash);
62+
63+
sph_luffa512_init(&ctx_luffa);
64+
sph_luffa512 (&ctx_luffa, (const void*) hash, 64);
65+
sph_luffa512_close (&ctx_luffa, (void*) hash);
66+
67+
sph_keccak512_init(&ctx_keccak);
68+
sph_keccak512 (&ctx_keccak, (const void*) hash, 64);
69+
sph_keccak512_close(&ctx_keccak, (void*) hash);
70+
71+
sph_cubehash512_init(&ctx_cubehash);
72+
sph_cubehash512 (&ctx_cubehash, (const void*) hash, 64);
73+
sph_cubehash512_close(&ctx_cubehash, (void*) hash);
74+
75+
sph_simd512_init(&ctx_simd);
76+
sph_simd512 (&ctx_simd, (const void*) hash, 64);
77+
sph_simd512_close(&ctx_simd, (void*) hash);
78+
79+
sph_shavite512_init(&ctx_shavite);
80+
sph_shavite512 (&ctx_shavite, (const void*) hash, 64);
81+
sph_shavite512_close(&ctx_shavite, (void*) hash);
82+
83+
sph_echo512_init(&ctx_echo);
84+
sph_echo512 (&ctx_echo, (const void*) hash, 64);
85+
sph_echo512_close(&ctx_echo, (void*) hash);
86+
87+
memcpy(output, hash, 32);
88+
}
89+
90+
//#define _DEBUG
91+
#define _DEBUG_PREFIX "x11"
92+
#include "cuda_debug.cuh"
93+
94+
static bool init[MAX_GPUS] = { 0 };
95+
96+
extern "C" int scanhash_hash0x10(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done)
97+
{
98+
uint32_t *pdata = work->data;
99+
uint32_t *ptarget = work->target;
100+
const uint32_t first_nonce = pdata[19];
101+
int intensity = (device_sm[device_map[thr_id]] >= 500 && !is_windows()) ? 20 : 19;
102+
uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity); // 19=256*256*8;
103+
//if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
104+
105+
if (opt_benchmark)
106+
ptarget[7] = 0x5;
107+
108+
if (!init[thr_id])
109+
{
110+
cudaSetDevice(device_map[thr_id]);
111+
if (opt_cudaschedule == -1 && gpu_threads == 1) {
112+
cudaDeviceReset();
113+
// reduce cpu usage
114+
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
115+
CUDA_LOG_ERROR();
116+
}
117+
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
118+
119+
quark_blake512_cpu_init(thr_id, throughput);
120+
quark_skein512_cpu_init(thr_id, throughput);
121+
quark_bmw512_cpu_init(thr_id, throughput);
122+
quark_groestl512_cpu_init(thr_id, throughput);
123+
quark_jh512_cpu_init(thr_id, throughput);
124+
x11_luffa512_cpu_init(thr_id, throughput);
125+
quark_keccak512_cpu_init(thr_id, throughput);
126+
x11_cubehash512_cpu_init(thr_id, throughput);
127+
if (x11_simd512_cpu_init(thr_id, throughput) != 0) {
128+
return 0;
129+
}
130+
x11_shavite512_cpu_init(thr_id, throughput);
131+
x11_echo512_cpu_init(thr_id, throughput);
132+
CUDA_CALL_OR_RET_X(cudaMalloc(&d_hash[thr_id], (size_t) 64 * throughput), 0);
133+
134+
cuda_check_cpu_init(thr_id, throughput);
135+
136+
init[thr_id] = true;
137+
}
138+
139+
uint32_t endiandata[20];
140+
for (int k=0; k < 20; k++)
141+
be32enc(&endiandata[k], pdata[k]);
142+
143+
quark_blake512_cpu_setBlock_80(thr_id, endiandata);
144+
cuda_check_cpu_setTarget(ptarget);
145+
146+
do {
147+
int order = 0;
148+
149+
// Hash with CUDA
150+
quark_blake512_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id]); order++;
151+
TRACE("blake :");
152+
quark_skein512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
153+
TRACE("skein :");
154+
quark_bmw512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
155+
TRACE("bmw :");
156+
quark_groestl512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
157+
TRACE("groestl:");
158+
quark_jh512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
159+
TRACE("jh512 :");
160+
x11_luffa512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
161+
TRACE("luffa+c:");
162+
quark_keccak512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
163+
TRACE("keccak :");
164+
x11_cubehash512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
165+
TRACE("cubehash :");
166+
x11_simd512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
167+
TRACE("simd :");
168+
x11_shavite512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
169+
TRACE("shavite:");
170+
x11_echo512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
171+
TRACE("echo => ");
172+
173+
*hashes_done = pdata[19] - first_nonce + throughput;
174+
175+
work->nonces[0] = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]);
176+
if (work->nonces[0] != UINT32_MAX)
177+
{
178+
const uint32_t Htarg = ptarget[7];
179+
uint32_t _ALIGN(64) vhash[8];
180+
be32enc(&endiandata[19], work->nonces[0]);
181+
hash0x10(vhash, endiandata);
182+
183+
if (vhash[7] <= Htarg && fulltest(vhash, ptarget)) {
184+
work->valid_nonces = 1;
185+
work_set_target_ratio(work, vhash);
186+
work->nonces[1] = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1);
187+
if (work->nonces[1] != 0) {
188+
be32enc(&endiandata[19], work->nonces[1]);
189+
hash0x10(vhash, endiandata);
190+
bn_set_target_ratio(work, vhash, 1);
191+
work->valid_nonces++;
192+
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
193+
} else {
194+
pdata[19] = work->nonces[0] + 1; // cursor
195+
}
196+
return work->valid_nonces;
197+
} else {
198+
gpu_increment_reject(thr_id);
199+
if (!opt_quiet)
200+
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]);
201+
pdata[19] = work->nonces[0] + 1;
202+
continue;
203+
}
204+
}
205+
206+
if ((uint64_t) throughput + pdata[19] >= max_nonce) {
207+
pdata[19] = max_nonce;
208+
break;
209+
}
210+
pdata[19] += throughput;
211+
212+
} while (!work_restart[thr_id].restart);
213+
214+
*hashes_done = pdata[19] - first_nonce;
215+
return 0;
216+
}
217+
218+
// cleanup
219+
extern "C" void free_hash0x10(int thr_id)
220+
{
221+
if (!init[thr_id])
222+
return;
223+
224+
cudaThreadSynchronize();
225+
226+
cudaFree(d_hash[thr_id]);
227+
228+
quark_blake512_cpu_free(thr_id);
229+
quark_groestl512_cpu_free(thr_id);
230+
x11_simd512_cpu_free(thr_id);
231+
232+
cuda_check_cpu_free(thr_id);
233+
init[thr_id] = false;
234+
235+
cudaDeviceSynchronize();
236+
}

0 commit comments

Comments
 (0)