Skip to content

Commit

Permalink
import xmr, to finish
Browse files Browse the repository at this point in the history
todo: fix jh cuda and wrong decimal diff (0xffff problem ?)
  • Loading branch information
tpruvot committed Jan 7, 2017
1 parent 2bbccc5 commit 066a569
Show file tree
Hide file tree
Showing 28 changed files with 4,961 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ config.sub

mingw32-config.cache

*/.dirstamp
.dirstamp
.DS_Store
Desktop.ini
Thumbs.db
Expand Down
5 changes: 5 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ ccminer_SOURCES = elist.h miner.h compat.h \
Algo256/blake2s.cu sph/blake2s.c \
Algo256/bmw.cu Algo256/cuda_bmw.cu \
crypto/xmr-rpc.cpp crypto/wildkeccak-cpu.cpp crypto/wildkeccak.cu \
crypto/cryptonight.cu crypto/cuda_cryptonight_core.cu crypto/cuda_cryptonight_extra.cu \
crypto/cryptonight-cpu.cpp crypto/oaes_lib.cpp crypto/aesb.cpp crypto/cpu/c_keccak.c \
JHA/jackpotcoin.cu JHA/cuda_jha_keccak512.cu \
JHA/cuda_jha_compactionTest.cu cuda_checkhash.cu \
quark/cuda_jh512.cu quark/cuda_quark_blake512.cu quark/cuda_quark_groestl512.cu quark/cuda_skein512.cu \
Expand Down Expand Up @@ -105,6 +107,9 @@ Algo256/blake256.o: Algo256/blake256.cu
Algo256/cuda_bmw.o: Algo256/cuda_bmw.cu
$(NVCC) $(nvcc_FLAGS) --maxrregcount=76 -o $@ -c $<

crypto/cuda_cryptonight_extra.o: crypto/cuda_cryptonight_extra.cu
$(NVCC) $(nvcc_FLAGS) -o $@ -c $<

heavy/cuda_hefty1.o: heavy/cuda_hefty1.cu
$(NVCC) $(nvcc_FLAGS) --maxrregcount=80 -o $@ -c $<

Expand Down
2 changes: 2 additions & 0 deletions algos.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ enum sha_algos {
ALGO_BLAKE2S,
ALGO_BMW,
ALGO_C11,
ALGO_CRYPTONIGHT,
ALGO_DEEP,
ALGO_DECRED,
ALGO_DMD_GR,
Expand Down Expand Up @@ -62,6 +63,7 @@ static const char *algo_names[] = {
"blake2s",
"bmw",
"c11",
"cryptonight",
"deep",
"decred",
"dmd-gr",
Expand Down
1 change: 1 addition & 0 deletions bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void algo_free_all(int thr_id)
free_blake2s(thr_id);
free_bmw(thr_id);
free_c11(thr_id);
free_cryptonight(thr_id);
free_decred(thr_id);
free_deep(thr_id);
free_keccak256(thr_id);
Expand Down
41 changes: 35 additions & 6 deletions ccminer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ static bool work_decode(const json_t *val, struct work *work)
data_size = 80;
adata_sz = data_size / 4;
break;
case ALGO_CRYPTONIGHT:
case ALGO_WILDKECCAK:
return rpc2_job_decode(val, work);
default:
Expand Down Expand Up @@ -1766,12 +1767,15 @@ static void *miner_thread(void *userdata)
nonceptr = (uint32_t*) (((char*)work.data) + 1);
wcmpoft = 2;
wcmplen = 32;
} else if (opt_algo == ALGO_CRYPTONIGHT) {
nonceptr = (uint32_t*) (((char*)work.data) + 39);
wcmplen = 39;
}

if (have_stratum) {
uint32_t sleeptime = 0;

if (opt_algo == ALGO_DECRED || stratum.rpc2)
if (opt_algo == ALGO_DECRED || opt_algo == ALGO_WILDKECCAK /* getjob */)
work_done = true; // force "regen" hash
while (!work_done && time(NULL) >= (g_work_time + opt_scantime)) {
usleep(100*1000);
Expand All @@ -1798,6 +1802,8 @@ static void *miner_thread(void *userdata)
extrajob = false;
if (stratum_gen_work(&stratum, &g_work))
g_work_time = time(NULL);
if (opt_algo == ALGO_CRYPTONIGHT)
nonceptr[0] += 0x100000;
}
} else {
uint32_t secs = 0;
Expand Down Expand Up @@ -1839,7 +1845,20 @@ static void *miner_thread(void *userdata)
wcmplen -= 4;
}

if (memcmp(&work.data[wcmpoft], &g_work.data[wcmpoft], wcmplen)) {
if (opt_algo == ALGO_CRYPTONIGHT) {
uint32_t oldpos = nonceptr[0];
if (memcmp(&work.data[wcmpoft], &g_work.data[wcmpoft], wcmplen)) {
memcpy(&work, &g_work, sizeof(struct work));
nonceptr[0] = (UINT32_MAX / opt_n_threads) * thr_id; // reset cursor
}
// also check the end, nonce in the middle
else if (memcmp(&work.data[44/4], &g_work.data[0], 76-44)) {
memcpy(&work, &g_work, sizeof(struct work));
}
if (oldpos & 0xFFFF) nonceptr[0] = oldpos + 0x100000;
}

else if (memcmp(&work.data[wcmpoft], &g_work.data[wcmpoft], wcmplen)) {
#if 0
if (opt_debug) {
for (int n=0; n <= (wcmplen-8); n+=8) {
Expand Down Expand Up @@ -1916,7 +1935,7 @@ static void *miner_thread(void *userdata)
gpulog(LOG_DEBUG, thr_id, "no data");
continue;
}
if (stratum.rpc2 && !scratchpad_size) {
if (opt_algo == ALGO_WILDKECCAK && !scratchpad_size) {
sleep(1);
if (!thr_id) pools[cur_pooln].wait_time += 1;
continue;
Expand Down Expand Up @@ -2078,6 +2097,7 @@ static void *miner_thread(void *userdata)
case ALGO_VELTOR:
minmax = 0x80000;
break;
case ALGO_CRYPTONIGHT:
case ALGO_SCRYPT_JANE:
minmax = 0x1000;
break;
Expand Down Expand Up @@ -2140,6 +2160,9 @@ static void *miner_thread(void *userdata)
case ALGO_C11:
rc = scanhash_c11(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_CRYPTONIGHT:
rc = scanhash_cryptonight(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_DECRED:
//applog(LOG_BLUE, "version %x, nbits %x, ntime %x extra %x",
// work.data[0], work.data[29], work.data[34], work.data[38]);
Expand Down Expand Up @@ -2283,6 +2306,7 @@ static void *miner_thread(void *userdata)
// todo: update all algos to use work->nonces and pdata[19] as counter
switch (opt_algo) {
case ALGO_BLAKE2S:
case ALGO_CRYPTONIGHT:
case ALGO_DECRED:
case ALGO_LBRY:
case ALGO_SIA:
Expand Down Expand Up @@ -2710,7 +2734,7 @@ static void *stratum_thread(void *userdata)
}
}

if (opt_algo == ALGO_WILDKECCAK) {
if (stratum.rpc2) {
rpc2_stratum_thread_stuff(pool);
}

Expand Down Expand Up @@ -2806,7 +2830,7 @@ static void show_usage_and_exit(int status)
if (opt_algo == ALGO_SCRYPT || opt_algo == ALGO_SCRYPT_JANE) {
printf(scrypt_usage);
}
if (opt_algo == ALGO_WILDKECCAK) {
if (opt_algo == ALGO_WILDKECCAK || opt_algo == ALGO_CRYPTONIGHT) {
printf(xmr_usage);
}
proper_exit(status);
Expand Down Expand Up @@ -3661,9 +3685,14 @@ int main(int argc, char *argv[])
allow_mininginfo = false;
}

if (opt_algo == ALGO_CRYPTONIGHT) {
rpc2_init();
if (!opt_quiet) applog(LOG_INFO, "Using JSON-RPC 2.0");
}

if (opt_algo == ALGO_WILDKECCAK) {
rpc2_init();
applog(LOG_INFO, "Using CryptoNote JSON-RPC 2.0");
if (!opt_quiet) applog(LOG_INFO, "Using JSON-RPC 2.0");
GetScratchpad();
}

Expand Down
22 changes: 18 additions & 4 deletions ccminer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@
<ClCompile Include="crypto\mman.c" />
<ClCompile Include="crypto\wildkeccak-cpu.cpp" />
<ClCompile Include="crypto\xmr-rpc.cpp" />
<ClCompile Include="crypto\aesb.cpp" />
<ClCompile Include="crypto\oaes_lib.cpp" />
<ClCompile Include="crypto\cryptonight-cpu.cpp" />
<ClCompile Include="crypto\cpu\c_keccak.c" />
<ClCompile Include="nvapi.cpp" />
<ClCompile Include="pools.cpp" />
<ClCompile Include="util.cpp" />
Expand All @@ -251,9 +255,6 @@
<ClCompile Include="myriadgroestl.cpp" />
<ClCompile Include="lyra2\Lyra2.c" />
<ClCompile Include="lyra2\Sponge.c" />
<ClInclude Include="crypto\mman.h" />
<ClInclude Include="crypto\wildkeccak.h" />
<ClInclude Include="crypto\xmr-rpc.h" />
<ClInclude Include="lyra2\cuda_lyra2_sm2.cuh" />
<ClInclude Include="neoscrypt\neoscrypt.h" />
<ClCompile Include="neoscrypt\neoscrypt.cpp" />
Expand All @@ -264,8 +265,17 @@
<CudaCompile Include="Algo256\cuda_bmw.cu">
<MaxRegCount>76</MaxRegCount>
</CudaCompile>
<CudaCompile Include="crypto\cryptonight.cu">
<MaxRegCount>128</MaxRegCount>
</CudaCompile>
<CudaCompile Include="crypto\cuda_cryptonight_core.cu">
<MaxRegCount>128</MaxRegCount>
</CudaCompile>
<CudaCompile Include="crypto\cuda_cryptonight_extra.cu">
<MaxRegCount>255</MaxRegCount>
</CudaCompile>
<CudaCompile Include="crypto\wildkeccak.cu">
<MaxRegCount Condition="'$(Configuration)|$(Platform)'=='Release|x64'">128</MaxRegCount>
<MaxRegCount>128</MaxRegCount>
</CudaCompile>
<CudaCompile Include="neoscrypt\cuda_neoscrypt.cu">
<MaxRegCount>160</MaxRegCount>
Expand Down Expand Up @@ -319,6 +329,10 @@
<ClInclude Include="compat\unistd.h" />
<ClInclude Include="compat\winansi.h" />
<ClInclude Include="compat\ccminer-config.h" />
<ClInclude Include="crypto\mman.h" />
<ClInclude Include="crypto\cryptonight.h" />
<ClInclude Include="crypto\wildkeccak.h" />
<ClInclude Include="crypto\xmr-rpc.h" />
<ClInclude Include="cuda_groestlcoin.h" />
<ClInclude Include="cuda_helper.h" />
<ClInclude Include="cuda_vector_uint2x4.h" />
Expand Down
47 changes: 38 additions & 9 deletions ccminer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
<Filter Include="Source Files\crypto">
<UniqueIdentifier>{fea0fce3-c0fe-42f7-aa37-0cbba10b008a}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\crypto\xmr">
<UniqueIdentifier>{af52b078-ed91-4c6e-b07a-e9243acc85d2}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\crypto\bbr">
<UniqueIdentifier>{af387eac-e9e6-4e91-a5e8-637b1e7a8d93}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="compat\jansson\dump.c">
Expand Down Expand Up @@ -285,11 +291,23 @@
<ClCompile Include="crypto\xmr-rpc.cpp">
<Filter>Source Files\crypto</Filter>
</ClCompile>
<ClCompile Include="crypto\aesb.cpp">
<Filter>Source Files\crypto\xmr</Filter>
</ClCompile>
<ClCompile Include="crypto\cpu\c_keccak.c">
<Filter>Source Files\crypto\xmr</Filter>
</ClCompile>
<ClCompile Include="crypto\oaes_lib.cpp">
<Filter>Source Files\crypto\xmr</Filter>
</ClCompile>
<ClCompile Include="crypto\cryptonight-cpu.cpp">
<Filter>Source Files\crypto\xmr</Filter>
</ClCompile>
<ClCompile Include="crypto\mman.c">
<Filter>Source Files\crypto</Filter>
<Filter>Source Files\crypto\bbr</Filter>
</ClCompile>
<ClCompile Include="crypto\wildkeccak-cpu.cpp">
<Filter>Source Files\crypto</Filter>
<Filter>Source Files\crypto\bbr</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -494,14 +512,17 @@
<ClInclude Include="sia\sia-rpc.h">
<Filter>Source Files\sia</Filter>
</ClInclude>
<ClInclude Include="crypto\mman.h">
<ClInclude Include="crypto\xmr-rpc.h">
<Filter>Source Files\crypto</Filter>
</ClInclude>
<ClInclude Include="crypto\wildkeccak.h">
<Filter>Source Files\crypto</Filter>
<ClInclude Include="crypto\cryptonight.h">
<Filter>Source Files\crypto\xmr</Filter>
</ClInclude>
<ClInclude Include="crypto\xmr-rpc.h">
<Filter>Source Files\crypto</Filter>
<ClInclude Include="crypto\mman.h">
<Filter>Source Files\crypto\bbr</Filter>
</ClInclude>
<ClInclude Include="crypto\wildkeccak.h">
<Filter>Source Files\crypto\bbr</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -784,6 +805,15 @@
<CudaCompile Include="crypto\wildkeccak.cu">
<Filter>Source Files\crypto</Filter>
</CudaCompile>
<CudaCompile Include="crypto\cryptonight.cu">
<Filter>Source Files\crypto</Filter>
</CudaCompile>
<CudaCompile Include="crypto\cuda_cryptonight_core.cu">
<Filter>Source Files\crypto</Filter>
</CudaCompile>
<CudaCompile Include="crypto\cuda_cryptonight_extra.cu">
<Filter>Source Files\crypto</Filter>
</CudaCompile>
</ItemGroup>
<ItemGroup>
<Image Include="res\ccminer.ico">
Expand All @@ -800,5 +830,4 @@
<Filter>Ressources</Filter>
</Text>
</ItemGroup>
</Project>

</Project>
Loading

0 comments on commit 066a569

Please sign in to comment.