├── .gitignore ├── Algo256 ├── blake256.cu ├── blake2s.cu ├── bmw.cu ├── cuda_blake256.cu ├── cuda_bmw.cu ├── cuda_bmw256.cu ├── cuda_cubehash256.cu ├── cuda_fugue256.cu ├── cuda_groestl256.cu ├── cuda_keccak256.cu ├── cuda_skein256.cu ├── decred.cu ├── keccak256.cu └── vanilla.cu ├── INSTALL ├── JHA ├── cuda_jha_compactionTest.cu ├── cuda_jha_keccak512.cu ├── jackpotcoin.cu └── jha.cu ├── LICENSE.txt ├── Makefile.am ├── README.md ├── README.txt ├── algos.h ├── api.cpp ├── api ├── index.php ├── local-sample.php ├── summary.pl └── websocket.htm ├── autogen.sh ├── bench.cpp ├── bignum.cpp ├── bignum.hpp ├── build.cmd ├── build.sh ├── ccminer.conf ├── ccminer.cpp ├── ccminer.sln ├── ccminer.vcxproj ├── ccminer.vcxproj.filters ├── compat.h ├── compat ├── Makefile.am ├── ccminer-config.h ├── curl-for-windows │ ├── curl │ │ └── include │ │ │ └── curl │ │ │ ├── curl.h │ │ │ ├── curlbuild.h │ │ │ ├── curlrules.h │ │ │ ├── curlver.h │ │ │ ├── easy.h │ │ │ ├── mprintf.h │ │ │ ├── multi.h │ │ │ ├── stdcheaders.h │ │ │ └── typecheck-gcc.h │ ├── openssl │ │ ├── config │ │ │ └── opensslconf.h │ │ └── openssl │ │ │ ├── crypto │ │ │ ├── opensslconf.h │ │ │ └── sha │ │ │ │ └── sha.h │ │ │ ├── e_os2.h │ │ │ └── include │ │ │ └── openssl │ │ │ ├── bn.h │ │ │ ├── crypto.h │ │ │ ├── e_os2.h │ │ │ ├── opensslconf.h │ │ │ ├── opensslv.h │ │ │ ├── ossl_typ.h │ │ │ ├── safestack.h │ │ │ ├── sha.h │ │ │ ├── stack.h │ │ │ └── symhacks.h │ ├── out │ │ ├── x64 │ │ │ └── Release │ │ │ │ └── lib │ │ │ │ ├── libcurl.x64.lib │ │ │ │ ├── openssl.x64.lib │ │ │ │ └── zlib.x64.lib │ │ └── x86 │ │ │ └── Release │ │ │ └── lib │ │ │ ├── libcurl.x86.lib │ │ │ ├── openssl.x86.lib │ │ │ └── zlib.x86.lib │ └── zlib │ │ ├── zconf.h │ │ └── zlib.h ├── getopt │ ├── getopt.h │ └── getopt_long.c ├── gettimeofday.c ├── inttypes.h ├── jansson │ ├── .gitignore │ ├── Makefile.am │ ├── configure.ac │ ├── dump.c │ ├── error.c │ ├── hashtable.c │ ├── hashtable.h │ ├── jansson.h │ ├── jansson_config.h │ ├── jansson_config.h.in │ ├── jansson_private.h │ ├── jansson_private_config.h │ ├── jansson_private_config.h.in │ ├── load.c │ ├── memory.c │ ├── pack_unpack.c │ ├── strbuffer.c │ ├── strbuffer.h │ ├── strconv.c │ ├── utf.c │ ├── utf.h │ ├── util.h │ └── value.c ├── nvapi │ ├── NVAPI.url │ ├── amd64 │ │ └── nvapi64.lib │ ├── nvHLSLExtns.h │ ├── nvHLSLExtnsInternal.h │ ├── nvShaderExtnEnums.h │ ├── nvapi.h │ ├── nvapi_ccminer.h │ ├── nvapi_lite_common.h │ ├── nvapi_lite_d3dext.h │ ├── nvapi_lite_salend.h │ ├── nvapi_lite_salstart.h │ ├── nvapi_lite_sli.h │ ├── nvapi_lite_stereo.h │ ├── nvapi_lite_surround.h │ └── x86 │ │ └── nvapi.lib ├── pthreads │ ├── pthread.h │ ├── pthread_barrier.hpp │ ├── sched.h │ ├── x64 │ │ └── pthreadVC2.lib │ └── x86 │ │ └── pthreadVC2.lib ├── stdbool.h ├── sys │ └── time.h ├── unistd.h ├── winansi.c └── winansi.h ├── compile ├── config.guess ├── configure.ac ├── configure.sh ├── crc32.c ├── crypto ├── aesb.cpp ├── cn_aes.cuh ├── cn_blake.cuh ├── cn_groestl.cuh ├── cn_jh.cuh ├── cn_keccak.cuh ├── cn_skein.cuh ├── cpu │ ├── c_keccak.c │ └── c_keccak.h ├── cryptolight-core.cu ├── cryptolight-cpu.cpp ├── cryptolight.cu ├── cryptolight.h ├── cryptonight-core.cu ├── cryptonight-cpu.cpp ├── cryptonight-extra.cu ├── cryptonight.cu ├── cryptonight.h ├── int128_c.h ├── mman.c ├── mman.h ├── oaes_config.h ├── oaes_lib.cpp ├── oaes_lib.h ├── wildkeccak-cpu.cpp ├── wildkeccak.cu ├── wildkeccak.h ├── xmr-rpc.cpp └── xmr-rpc.h ├── cuda.cpp ├── cuda_checkhash.cu ├── cuda_debug.cuh ├── cuda_fugue256.h ├── cuda_groestlcoin.cu ├── cuda_groestlcoin.h ├── cuda_helper.h ├── cuda_myriadgroestl.cu ├── cuda_skeincoin.cu ├── cuda_vector_uint2x4.h ├── cuda_vectors.h ├── elist.h ├── equi ├── blake2 │ ├── blake2-config.h │ ├── blake2-impl.h │ ├── blake2-round.h │ ├── blake2.h │ ├── blake2b-load-sse2.h │ ├── blake2b-load-sse41.h │ ├── blake2b-round.h │ └── blake2bx.cpp ├── cuda_equi.cu ├── eqcuda.hpp ├── equi-stratum.cpp ├── equi.cpp ├── equihash.cpp └── equihash.h ├── fuguecoin.cpp ├── groestlcoin.cpp ├── hashlog.cpp ├── heavy ├── bastion.cu ├── cuda_bastion.cu ├── cuda_blake512.cu ├── cuda_combine.cu ├── cuda_groestl512.cu ├── cuda_hefty1.cu ├── cuda_keccak512.cu ├── cuda_sha256.cu ├── heavy.cu └── heavy.h ├── hefty1.c ├── hefty1.h ├── install-sh ├── lbry ├── cuda_lbry_merged.cu ├── cuda_sha256_lbry.cu ├── cuda_sha512_lbry.cu └── lbry.cu ├── lyra2 ├── Lyra2.c ├── Lyra2.h ├── Lyra2Z.c ├── Lyra2Z.h ├── Sponge.c ├── Sponge.h ├── cuda_lyra2.cu ├── cuda_lyra2Z.cu ├── cuda_lyra2Z_sm5.cuh ├── cuda_lyra2_sm2.cuh ├── cuda_lyra2_sm5.cuh ├── cuda_lyra2_vectors.h ├── cuda_lyra2v2.cu ├── lyra2RE.cu ├── lyra2REv2.cu └── lyra2Z.cu ├── miner.h ├── myriadgroestl.cpp ├── neoscrypt ├── cuda_neoscrypt.cu ├── cuda_vectors.h ├── neoscrypt-cpu.c ├── neoscrypt.cpp └── neoscrypt.h ├── nvapi.cpp ├── nvml.cpp ├── nvml.h ├── nvsettings.cpp ├── pentablake.cu ├── pools.conf ├── pools.cpp ├── quark ├── cuda_bmw512.cu ├── cuda_bmw512_sm3.cuh ├── cuda_jh512.cu ├── cuda_quark.h ├── cuda_quark_blake512.cu ├── cuda_quark_blake512_sp.cuh ├── cuda_quark_compactionTest.cu ├── cuda_quark_groestl512.cu ├── cuda_quark_groestl512_sm2.cuh ├── cuda_quark_keccak512.cu ├── cuda_skein512.cu ├── groestl_functions_quad.h ├── groestl_simple.cuh ├── groestl_transf_quad.h ├── nist5.cu └── quarkcoin.cu ├── qubit ├── deep.cu ├── luffa.cu ├── qubit.cu └── qubit_luffa512.cu ├── res ├── ccminer.ico ├── ccminer.rc └── resource.h ├── scrypt-jane.cpp ├── scrypt.cpp ├── scrypt ├── blake.cu ├── code │ ├── scrypt-conf.h │ ├── scrypt-jane-chacha.h │ ├── scrypt-jane-mix_chacha.h │ ├── scrypt-jane-portable-x86.h │ ├── scrypt-jane-portable.h │ ├── scrypt-jane-romix-basic.h │ └── scrypt-jane-romix-template.h ├── fermi_kernel.cu ├── fermi_kernel.h ├── keccak.cu ├── keccak.h ├── kepler_kernel.cu ├── kepler_kernel.h ├── nv_kernel.cu ├── nv_kernel.h ├── nv_kernel2.cu ├── nv_kernel2.h ├── salsa_kernel.cu ├── salsa_kernel.h ├── scrypt-jane.h ├── sha256.cu ├── sha256.h ├── test_kernel.cu ├── test_kernel.h ├── titan_kernel.cu └── titan_kernel.h ├── serialize.hpp ├── sha256 ├── cuda_sha256d.cu ├── cuda_sha256t.cu ├── sha256d.cu └── sha256t.cu ├── sia ├── sia-rpc.cpp ├── sia-rpc.h └── sia.cu ├── skein.cu ├── skein2.cpp ├── skunk ├── cuda_skunk.cu ├── cuda_skunk_streebog.cu ├── skein_header.h ├── skunk.cu └── streebog_arrays.cuh ├── sph ├── aes_helper.c ├── blake.c ├── blake2b.c ├── blake2b.h ├── blake2s.c ├── blake2s.h ├── bmw.c ├── cubehash.c ├── echo.c ├── fugue.c ├── groestl.c ├── hamsi.c ├── hamsi_helper.c ├── haval.c ├── haval_helper.c ├── jh.c ├── keccak.c ├── luffa.c ├── md_helper.c ├── ripemd.c ├── sha2.c ├── sha2big.c ├── shabal.c ├── shavite.c ├── simd.c ├── skein.c ├── sph_blake.h ├── sph_bmw.h ├── sph_cubehash.h ├── sph_echo.h ├── sph_fugue.h ├── sph_groestl.h ├── sph_hamsi.h ├── sph_haval.h ├── sph_jh.h ├── sph_keccak.h ├── sph_luffa.h ├── sph_ripemd.h ├── sph_sha2.c ├── sph_sha2.h ├── sph_shabal.h ├── sph_shavite.h ├── sph_simd.h ├── sph_skein.h ├── sph_streebog.h ├── sph_types.h ├── sph_whirlpool.h ├── streebog.c └── whirlpool.c ├── stats.cpp ├── sysinfos.cpp ├── tribus.cu ├── uint256.h ├── util.cpp ├── x11 ├── bitcore.cu ├── c11.cu ├── cuda_streebog.cu ├── cuda_x11.h ├── cuda_x11_aes.cuh ├── cuda_x11_cubehash512.cu ├── cuda_x11_echo.cu ├── cuda_x11_luffa512.cu ├── cuda_x11_luffa512_Cubehash.cu ├── cuda_x11_shavite512.cu ├── cuda_x11_simd512.cu ├── cuda_x11_simd512_func.cuh ├── cuda_x11_simd512_sm2.cuh ├── fresh.cu ├── s3.cu ├── sib.cu ├── timetravel.cu ├── veltor.cu ├── x11.cu └── x11evo.cu ├── x13 ├── cuda_x13_fugue512.cu ├── cuda_x13_hamsi512.cu └── x13.cu ├── x15 ├── cuda_whirlpool_tables.cuh ├── cuda_whirlpoolx.cu ├── cuda_x14_shabal512.cu ├── cuda_x15_whirlpool.cu ├── cuda_x15_whirlpool_sm3.cu ├── whirlpool.cu ├── whirlpoolx.cu ├── x14.cu └── x15.cu ├── x17 ├── cuda_x17_haval256.cu ├── cuda_x17_sha512.cu ├── hmq17.cu └── x17.cu └── zr5.cu /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | ccminer 3 | *.o 4 | 5 | autom4te.cache 6 | .deps 7 | 8 | Makefile 9 | Makefile.in 10 | INSTALL 11 | aclocal.m4 12 | configure 13 | configure.lineno 14 | depcomp 15 | missing 16 | install-sh 17 | stamp-h1 18 | ccminer-config.h* 19 | compile 20 | config.log 21 | config.status 22 | config.status.lineno 23 | config.guess 24 | config.sub 25 | 26 | mingw32-config.cache 27 | 28 | .dirstamp 29 | .DS_Store 30 | Desktop.ini 31 | Thumbs.db 32 | 33 | *.iml 34 | 35 | Debug/ 36 | Release/ 37 | x64/Debug/ 38 | x64/Release/ 39 | *.suo 40 | *.user 41 | *.opensdf 42 | *.sdf 43 | *.pdb 44 | *.VC.opendb 45 | *.VC.db 46 | 47 | .settings/ 48 | .project 49 | .metadata 50 | .classpath 51 | .loadpath 52 | .cproject 53 | .buildpath 54 | 55 | compat/curl-for-windows/ 56 | 57 | *.ptx 58 | *.i 59 | *.ii 60 | *.gpu 61 | *.cubin 62 | *.stub.c 63 | *.module_id 64 | *.hash 65 | *.fatbin.c 66 | *.fatbin 67 | *.cudafe1.cpp 68 | *.cudafe1.c 69 | *.cudafe2.c 70 | 71 | -------------------------------------------------------------------------------- /Algo256/bmw.cu: -------------------------------------------------------------------------------- 1 | /** 2 | * bmw-256 MDT 3 | * tpruvot - 2015 4 | */ 5 | extern "C" { 6 | #include "sph/sph_bmw.h" 7 | } 8 | 9 | #include 10 | #include 11 | 12 | static uint32_t *d_hash[MAX_GPUS]; 13 | 14 | extern void bmw256_midstate_init(int thr_id, uint32_t threads); 15 | extern void bmw256_midstate_free(int thr_id); 16 | extern void bmw256_setBlock_80(int thr_id, void *pdata); 17 | extern void bmw256_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_outputHash, int swap); 18 | 19 | extern uint32_t cuda_check_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_inputHash); 20 | 21 | // CPU Hash 22 | extern "C" void bmw_hash(void *state, const void *input) 23 | { 24 | uint32_t _ALIGN(64) hash[16]; 25 | sph_bmw256_context ctx; 26 | 27 | sph_bmw256_init(&ctx); 28 | sph_bmw256(&ctx, input, 80); 29 | sph_bmw256_close(&ctx, (void*) hash); 30 | 31 | memcpy(state, hash, 32); 32 | } 33 | 34 | static bool init[MAX_GPUS] = { 0 }; 35 | 36 | extern "C" int scanhash_bmw(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) 37 | { 38 | uint32_t _ALIGN(64) endiandata[20]; 39 | uint32_t *pdata = work->data; 40 | uint32_t *ptarget = work->target; 41 | const uint32_t first_nonce = pdata[19]; 42 | uint32_t throughput = cuda_default_throughput(thr_id, 1U << 21); 43 | if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce); 44 | 45 | if (opt_benchmark) 46 | ptarget[7] = 0x0005; 47 | 48 | if (!init[thr_id]) { 49 | cudaSetDevice(device_map[thr_id]); 50 | if (opt_cudaschedule == -1 && gpu_threads == 1) { 51 | cudaDeviceReset(); 52 | // reduce cpu usage 53 | cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync); 54 | } 55 | gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput); 56 | 57 | cuda_check_cpu_init(thr_id, throughput); 58 | bmw256_midstate_init(thr_id, throughput); 59 | 60 | CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], (size_t)32 * throughput)); 61 | 62 | init[thr_id] = true; 63 | } 64 | 65 | for (int k=0; k < 20; k++) { 66 | be32enc(&endiandata[k], ((uint32_t*)pdata)[k]); 67 | } 68 | 69 | cudaGetLastError(); 70 | bmw256_setBlock_80(thr_id, (void*)endiandata); 71 | 72 | cuda_check_cpu_setTarget(ptarget); 73 | 74 | do { 75 | bmw256_cpu_hash_80(thr_id, (int) throughput, pdata[19], d_hash[thr_id], 1); 76 | 77 | *hashes_done = pdata[19] - first_nonce + throughput; 78 | 79 | work->nonces[0] = cuda_check_hash_32(thr_id, throughput, pdata[19], d_hash[thr_id]); 80 | if (work->nonces[0] != UINT32_MAX) 81 | { 82 | const uint32_t Htarg = ptarget[7]; 83 | uint32_t _ALIGN(64) vhash[8]; 84 | be32enc(&endiandata[19], work->nonces[0]); 85 | bmw_hash(vhash, endiandata); 86 | 87 | if (vhash[7] <= Htarg && fulltest(vhash, ptarget)) { 88 | work->valid_nonces = 1; 89 | work_set_target_ratio(work, vhash); 90 | work->nonces[1] = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); 91 | if (work->nonces[1] != 0) { 92 | be32enc(&endiandata[19], work->nonces[1]); 93 | bmw_hash(vhash, endiandata); 94 | bn_set_target_ratio(work, vhash, 1); 95 | work->valid_nonces++; 96 | pdata[19] = max(work->nonces[0], work->nonces[1]) + 1; 97 | } else { 98 | pdata[19] = work->nonces[0] + 1; // cursor 99 | } 100 | return work->valid_nonces; 101 | } 102 | else if (vhash[7] > Htarg) { 103 | gpu_increment_reject(thr_id); 104 | if (!opt_quiet) 105 | gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]); 106 | pdata[19] = work->nonces[0] + 1; 107 | continue; 108 | } 109 | } 110 | 111 | if ((uint64_t) throughput + pdata[19] >= max_nonce) { 112 | pdata[19] = max_nonce; 113 | break; 114 | } 115 | 116 | pdata[19] += throughput; 117 | 118 | } while (!work_restart[thr_id].restart); 119 | 120 | *hashes_done = pdata[19] - first_nonce; 121 | return 0; 122 | } 123 | 124 | // cleanup 125 | extern "C" void free_bmw(int thr_id) 126 | { 127 | if (!init[thr_id]) 128 | return; 129 | 130 | cudaThreadSynchronize(); 131 | 132 | cudaFree(d_hash[thr_id]); 133 | bmw256_midstate_free(thr_id); 134 | cuda_check_cpu_free(thr_id); 135 | 136 | cudaDeviceSynchronize(); 137 | init[thr_id] = false; 138 | } 139 | -------------------------------------------------------------------------------- /Algo256/keccak256.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * Keccak 256 3 | * 4 | */ 5 | 6 | extern "C" 7 | { 8 | #include "sph/sph_shavite.h" 9 | #include "sph/sph_simd.h" 10 | #include "sph/sph_keccak.h" 11 | 12 | #include "miner.h" 13 | } 14 | 15 | #include "cuda_helper.h" 16 | 17 | static uint32_t *d_hash[MAX_GPUS]; 18 | 19 | extern void keccak256_cpu_init(int thr_id, uint32_t threads); 20 | extern void keccak256_cpu_free(int thr_id); 21 | extern void keccak256_setBlock_80(void *pdata,const void *ptarget); 22 | extern uint32_t keccak256_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_hash, int order); 23 | 24 | // CPU Hash 25 | extern "C" void keccak256_hash(void *state, const void *input) 26 | { 27 | uint32_t _ALIGN(64) hash[16]; 28 | sph_keccak_context ctx_keccak; 29 | 30 | sph_keccak256_init(&ctx_keccak); 31 | sph_keccak256 (&ctx_keccak, input, 80); 32 | sph_keccak256_close(&ctx_keccak, (void*) hash); 33 | 34 | memcpy(state, hash, 32); 35 | } 36 | 37 | static bool init[MAX_GPUS] = { 0 }; 38 | 39 | extern "C" int scanhash_keccak256(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) 40 | { 41 | uint32_t _ALIGN(64) endiandata[20]; 42 | uint32_t *pdata = work->data; 43 | uint32_t *ptarget = work->target; 44 | const uint32_t first_nonce = pdata[19]; 45 | uint32_t throughput = cuda_default_throughput(thr_id, 1U << 21); // 256*256*8*4 46 | if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce); 47 | 48 | if (opt_benchmark) 49 | ptarget[7] = 0x000f; 50 | 51 | if (!init[thr_id]) 52 | { 53 | cudaSetDevice(device_map[thr_id]); 54 | if (opt_cudaschedule == -1 && gpu_threads == 1) { 55 | cudaDeviceReset(); 56 | // reduce cpu usage 57 | cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync); 58 | CUDA_LOG_ERROR(); 59 | } 60 | gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput); 61 | 62 | CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], throughput * 64)); 63 | keccak256_cpu_init(thr_id, throughput); 64 | 65 | init[thr_id] = true; 66 | } 67 | 68 | for (int k=0; k < 19; k++) { 69 | be32enc(&endiandata[k], pdata[k]); 70 | } 71 | 72 | keccak256_setBlock_80((void*)endiandata, ptarget); 73 | do { 74 | int order = 0; 75 | 76 | *hashes_done = pdata[19] - first_nonce + throughput; 77 | 78 | work->nonces[0] = keccak256_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id], order++); 79 | if (work->nonces[0] != UINT32_MAX && bench_algo < 0) 80 | { 81 | const uint32_t Htarg = ptarget[7]; 82 | uint32_t _ALIGN(64) vhash[8]; 83 | 84 | be32enc(&endiandata[19], work->nonces[0]); 85 | keccak256_hash(vhash, endiandata); 86 | 87 | if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) { 88 | work->valid_nonces = 1; 89 | work_set_target_ratio(work, vhash); 90 | pdata[19] = work->nonces[0] + 1; 91 | return work->valid_nonces; 92 | } 93 | else if (vhash[7] > Htarg) { 94 | gpu_increment_reject(thr_id); 95 | if (!opt_quiet) 96 | gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]); 97 | pdata[19] = work->nonces[0] + 1; 98 | continue; 99 | } 100 | } 101 | 102 | if ((uint64_t) throughput + pdata[19] >= max_nonce) { 103 | pdata[19] = max_nonce; 104 | break; 105 | } 106 | 107 | pdata[19] += throughput; 108 | 109 | } while (!work_restart[thr_id].restart); 110 | 111 | *hashes_done = pdata[19] - first_nonce; 112 | return 0; 113 | } 114 | 115 | // cleanup 116 | extern "C" void free_keccak256(int thr_id) 117 | { 118 | if (!init[thr_id]) 119 | return; 120 | 121 | cudaThreadSynchronize(); 122 | 123 | cudaFree(d_hash[thr_id]); 124 | 125 | keccak256_cpu_free(thr_id); 126 | 127 | cudaDeviceSynchronize(); 128 | init[thr_id] = false; 129 | } 130 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | 2 | You can use ./build.sh to configure and build with default options. 3 | 4 | It is advised to run ./autogen.sh before ./configure (autoconf and automake 5 | need to be installed on your system for autogen.sh to work) 6 | 7 | ./configure has an option named --with-cuda that allows you to specify 8 | where your CUDA 6.5 toolkit is installed (usually /usr/local/cuda, 9 | but some distros may have a different default location) 10 | 11 | 12 | ** How to compile on Fedora 25 ** 13 | 14 | Note: You may find an alternative method via rpms : 15 | see https://negativo17.org/nvidia-driver/ and https://negativo17.org/repos/multimedia/ 16 | 17 | 18 | # Step 1: gcc and dependencies 19 | dnf install gcc gcc-c++ autoconf automake 20 | dnf install jansson-devel openssl-devel libcurl-devel zlib-devel 21 | 22 | # Step 2: nvidia drivers (Download common linux drivers from nvidia site) 23 | dnf install kernel-devel 24 | dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm 25 | dnf check-update 26 | dnf install xorg-x11-drv-nvidia-cuda kmod-nvidia 27 | ln -s libnvidia-ml.so.1 /usr/lib64/libnvidia-ml.so 28 | 29 | # Step 3: CUDA SDK (Download from nvidia the generic ".run" archive) 30 | # --override is required to ignore "too recent" gcc 6.3 31 | # --silent is required to install only the toolkit (no kmod) 32 | ./cuda_8.0.61_375.26_linux.run --toolkit --silent --override 33 | nvcc --version 34 | 35 | # add the nvcc binary path to the system 36 | ln -s /usr/local/cuda-8.0 /usr/local/cuda # (if not already made) 37 | echo 'export PATH=$PATH:/usr/local/cuda/bin' > /etc/profile.d/cuda.sh 38 | 39 | # add the cudart library path to the system 40 | echo /usr/local/cuda/lib64 > /etc/ld.so.conf.d/cuda.conf 41 | ldconfig 42 | 43 | # Step 4: Fix the toolkit incompatibility with gcc 6 44 | 45 | # You need to build yourself an older GCC/G++ version, i recommend the 5.4 46 | # see https://gcc.gnu.org/mirrors.html 47 | # Note: this manual method will override the default gcc, it could be better to use a custom toolchain prefix 48 | 49 | wget ftp://ftp.lip6.fr/pub/gcc/releases/gcc-5.4.0/gcc-5.4.0.tar.bz2 50 | dnf install libmpc-devel mpfr-devel gmp-devel 51 | ./configure --prefix=/usr/local --enable-languages=c,c++,lto --disable-multilib 52 | make -j 8 && make install 53 | (while this step, you have the time to cook something :p) 54 | 55 | # or, for previous fedora versions, edit the file /usr/local/cuda/include/host_config.h 56 | # and comment/delete the line 121 : #error -- unsupported GNU version! gcc versions later than 5 are not supported! 57 | 58 | ./build.sh 59 | 60 | ./ccminer -n 61 | 62 | 63 | ** How to compile on macOS ** 64 | 65 | # Step 1: download and install CUDA Toolkit 8 or more recent 66 | # https://developer.nvidia.com/cuda-toolkit-archive 67 | 68 | # Step 2: install Homebrew 69 | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 70 | 71 | # Step 3: dependencies 72 | brew install pkg-config autoconf automake curl openssl llvm 73 | 74 | ./build.sh 75 | 76 | ./ccminer -n 77 | 78 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ccminer 2 | ======= 3 | 4 | Based on Christian Buchner's & Christian H.'s CUDA project, no more active on github since 2014. 5 | 6 | Check the [README.txt](README.txt) for the additions 7 | 8 | BTC donation address: 1AJdfCpLWPNoAMDfHF1wD5y8VgKSSTHxPo (tpruvot) 9 | 10 | A part of the recent algos were originally written by [djm34](https://github.com/djm34) and [alexis78](https://github.com/alexis78) 11 | 12 | This variant was tested and built on Linux (ubuntu server 14.04, 16.04, Fedora 22 to 25) 13 | It is also built for Windows 7 to 10 with VStudio 2013, to stay compatible with Windows Vista. 14 | 15 | Note that the x86 releases are generally faster than x64 ones on Windows, but that tend to change with the recent drivers. 16 | 17 | The recommended CUDA Toolkit version was the [6.5.19](http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda_6.5.19_windows_general_64.exe), but some light algos could be faster with the version 7.5 and 8.0 (like lbry, decred and skein). 18 | 19 | About source code dependencies 20 | ------------------------------ 21 | 22 | This project requires some libraries to be built : 23 | 24 | - OpenSSL (prebuilt for win) 25 | 26 | - Curl (prebuilt for win) 27 | 28 | - pthreads (prebuilt for win) 29 | 30 | The tree now contains recent prebuilt openssl and curl .lib for both x86 and x64 platforms (windows). 31 | 32 | To rebuild them, you need to clone this repository and its submodules : 33 | git clone https://github.com/peters/curl-for-windows.git compat/curl-for-windows 34 | 35 | On Linux, you can use the helper ./build.sh (edit configure.sh and the Makefile.am if required) 36 | 37 | -------------------------------------------------------------------------------- /algos.h: -------------------------------------------------------------------------------- 1 | #ifndef ALGOS_H 2 | #define ALGOS_H 3 | 4 | #include 5 | #include "compat.h" 6 | 7 | enum sha_algos { 8 | ALGO_BLAKECOIN = 0, 9 | ALGO_BLAKE, 10 | ALGO_BLAKE2S, 11 | ALGO_BMW, 12 | ALGO_BASTION, 13 | ALGO_C11, 14 | ALGO_CRYPTOLIGHT, 15 | ALGO_CRYPTONIGHT, 16 | ALGO_DEEP, 17 | ALGO_DECRED, 18 | ALGO_DMD_GR, 19 | ALGO_EQUIHASH, 20 | ALGO_FRESH, 21 | ALGO_FUGUE256, /* Fugue256 */ 22 | ALGO_GROESTL, 23 | ALGO_HEAVY, /* Heavycoin hash */ 24 | ALGO_HMQ1725, 25 | ALGO_KECCAK, 26 | ALGO_JACKPOT, 27 | ALGO_JHA, 28 | ALGO_LBRY, 29 | ALGO_LUFFA, 30 | ALGO_LYRA2, 31 | ALGO_LYRA2v2, 32 | ALGO_LYRA2Z, 33 | ALGO_MJOLLNIR, /* Hefty hash */ 34 | ALGO_MYR_GR, 35 | ALGO_NEOSCRYPT, 36 | ALGO_NIST5, 37 | ALGO_PENTABLAKE, 38 | ALGO_QUARK, 39 | ALGO_QUBIT, 40 | ALGO_SCRYPT, 41 | ALGO_SCRYPT_JANE, 42 | ALGO_SHA256D, 43 | ALGO_SHA256T, 44 | ALGO_SIA, 45 | ALGO_SIB, 46 | ALGO_SKEIN, 47 | ALGO_SKEIN2, 48 | ALGO_SKUNK, 49 | ALGO_S3, 50 | ALGO_TIMETRAVEL, 51 | ALGO_TRIBUS, 52 | ALGO_BITCORE, 53 | ALGO_X11EVO, 54 | ALGO_X11, 55 | ALGO_X13, 56 | ALGO_X14, 57 | ALGO_X15, 58 | ALGO_X17, 59 | ALGO_VANILLA, 60 | ALGO_VELTOR, 61 | ALGO_WHIRLCOIN, 62 | ALGO_WHIRLPOOL, 63 | ALGO_WHIRLPOOLX, 64 | ALGO_WILDKECCAK, 65 | ALGO_ZR5, 66 | ALGO_AUTO, 67 | ALGO_COUNT 68 | }; 69 | 70 | extern volatile enum sha_algos opt_algo; 71 | 72 | static const char *algo_names[] = { 73 | "blakecoin", 74 | "blake", 75 | "blake2s", 76 | "bmw", 77 | "bastion", 78 | "c11", 79 | "cryptolight", 80 | "cryptonight", 81 | "deep", 82 | "decred", 83 | "dmd-gr", 84 | "equihash", 85 | "fresh", 86 | "fugue256", 87 | "groestl", 88 | "heavy", 89 | "hmq1725", 90 | "keccak", 91 | "jackpot", 92 | "jha", 93 | "lbry", 94 | "luffa", 95 | "lyra2", 96 | "lyra2v2", 97 | "lyra2z", 98 | "mjollnir", 99 | "myr-gr", 100 | "neoscrypt", 101 | "nist5", 102 | "penta", 103 | "quark", 104 | "qubit", 105 | "scrypt", 106 | "scrypt-jane", 107 | "sha256d", 108 | "sha256t", 109 | "sia", 110 | "sib", 111 | "skein", 112 | "skein2", 113 | "skunk", 114 | "s3", 115 | "timetravel", 116 | "tribus", 117 | "bitcore", 118 | "x11evo", 119 | "x11", 120 | "x13", 121 | "x14", 122 | "x15", 123 | "x17", 124 | "vanilla", 125 | "veltor", 126 | "whirlcoin", 127 | "whirlpool", 128 | "whirlpoolx", 129 | "wildkeccak", 130 | "zr5", 131 | "auto", /* reserved for multi algo */ 132 | "" 133 | }; 134 | 135 | // string to int/enum 136 | static inline int algo_to_int(char* arg) 137 | { 138 | int i; 139 | 140 | for (i = 0; i < ALGO_COUNT; i++) { 141 | if (algo_names[i] && !strcasecmp(arg, algo_names[i])) { 142 | return i; 143 | } 144 | } 145 | 146 | if (i == ALGO_COUNT) { 147 | // some aliases... 148 | if (!strcasecmp("all", arg)) 149 | i = ALGO_AUTO; 150 | else if (!strcasecmp("cryptonight-light", arg)) 151 | i = ALGO_CRYPTOLIGHT; 152 | else if (!strcasecmp("cryptonight-lite", arg)) 153 | i = ALGO_CRYPTOLIGHT; 154 | else if (!strcasecmp("flax", arg)) 155 | i = ALGO_C11; 156 | else if (!strcasecmp("diamond", arg)) 157 | i = ALGO_DMD_GR; 158 | else if (!strcasecmp("equi", arg)) 159 | i = ALGO_EQUIHASH; 160 | else if (!strcasecmp("doom", arg)) 161 | i = ALGO_LUFFA; 162 | else if (!strcasecmp("hmq17", arg)) 163 | i = ALGO_HMQ1725; 164 | //else if (!strcasecmp("jackpot", arg)) 165 | // i = ALGO_JHA; 166 | else if (!strcasecmp("lyra2re", arg)) 167 | i = ALGO_LYRA2; 168 | else if (!strcasecmp("lyra2rev2", arg)) 169 | i = ALGO_LYRA2v2; 170 | else if (!strcasecmp("bitcoin", arg)) 171 | i = ALGO_SHA256D; 172 | else if (!strcasecmp("sha256", arg)) 173 | i = ALGO_SHA256D; 174 | else if (!strcasecmp("thorsriddle", arg)) 175 | i = ALGO_VELTOR; 176 | else if (!strcasecmp("timetravel10", arg)) 177 | i = ALGO_BITCORE; 178 | else if (!strcasecmp("whirl", arg)) 179 | i = ALGO_WHIRLPOOL; 180 | else if (!strcasecmp("ziftr", arg)) 181 | i = ALGO_ZR5; 182 | else 183 | i = -1; 184 | } 185 | 186 | return i; 187 | } 188 | 189 | #endif 190 | -------------------------------------------------------------------------------- /api/local-sample.php: -------------------------------------------------------------------------------- 1 | 0) { 27 | $err = socket_last_error($socket); 28 | echo "."; 29 | if ($timeout > 1 && ($err == 115 || $err == 114)) { 30 | $timeout--; 31 | usleep(50); 32 | $res = socket_connect($socket, API_HOST, $port); 33 | continue; 34 | } 35 | $error = socket_strerror($err); 36 | $msg = "socket connect($port) failed"; 37 | echo "ERR: $msg '$error'\n"; 38 | socket_close($socket); 39 | return NULL; 40 | } 41 | 42 | socket_set_block($socket); 43 | 44 | return $socket; 45 | } 46 | 47 | function readsockline($socket) 48 | { 49 | $line = ''; 50 | while (true) { 51 | $byte = socket_read($socket, 1); 52 | if ($byte === false || $byte === '') 53 | break; 54 | if ($byte === "\0") 55 | break; 56 | $line .= $byte; 57 | } 58 | return $line; 59 | } 60 | 61 | 62 | function request($cmd) 63 | { 64 | $socket = getsock(API_PORT); 65 | if ($socket == null) 66 | return NULL; 67 | 68 | socket_write($socket, $cmd, strlen($cmd)); 69 | $line = readsockline($socket); 70 | socket_close($socket); 71 | 72 | if (strlen($line) == 0) { 73 | echo "WARN: '$cmd' returned nothing\n"; 74 | return $line; 75 | } 76 | 77 | echo "$cmd returned '$line'\n"; 78 | 79 | $data = array(); 80 | 81 | $objs = explode('|', $line); 82 | foreach ($objs as $obj) 83 | { 84 | if (strlen($obj) > 0) 85 | { 86 | $items = explode(';', $obj); 87 | $item = $items[0]; 88 | $id = explode('=', $items[0], 2); 89 | if (count($id) == 1) 90 | $name = $id[0]; 91 | else 92 | $name = $id[0].$id[1]; 93 | 94 | if (strlen($name) == 0) 95 | $name = 'null'; 96 | 97 | if (isset($data[$name])) { 98 | $num = 1; 99 | while (isset($data[$name.$num])) 100 | $num++; 101 | $name .= $num; 102 | } 103 | 104 | $counter = 0; 105 | foreach ($items as $item) 106 | { 107 | $id = explode('=', $item, 2); 108 | if (count($id) == 2) 109 | $data[$name][$id[0]] = $id[1]; 110 | else 111 | $data[$name][$counter] = $id[0]; 112 | 113 | $counter++; 114 | } 115 | 116 | } 117 | } 118 | if ($cmd == 'summary') 119 | return array_pop($data); 120 | else 121 | return $data; 122 | } 123 | 124 | ob_start(); 125 | 126 | error_reporting(0); 127 | 128 | $summary = request('summary'); 129 | $threads = request('threads'); 130 | $pool = request('pool'); 131 | 132 | ob_end_clean(); /* swap to debug */ 133 | //echo ob_get_clean()."\n"; 134 | 135 | header("Content-Type: application/json"); 136 | echo json_encode(compact('summary', 'threads', 'pool'))."\n"; 137 | ?> 138 | -------------------------------------------------------------------------------- /api/summary.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # sample script to query ccminer API 4 | 5 | my $command = "summary|"; 6 | 7 | use Socket; 8 | use IO::Socket::INET; 9 | 10 | my $sock = new IO::Socket::INET ( 11 | PeerAddr => '127.0.0.1', 12 | PeerPort => 4068, 13 | Proto => 'tcp', 14 | ReuseAddr => 1, 15 | Timeout => 10, 16 | ); 17 | 18 | if ($sock) { 19 | 20 | print $sock $command; 21 | my $res = ""; 22 | 23 | while(<$sock>) { 24 | $res .= $_; 25 | } 26 | 27 | close($sock); 28 | print("$res\n"); 29 | 30 | } else { 31 | 32 | print("ccminer socket failed\n"); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /api/websocket.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | aclocal && autoheader && automake --add-missing --gnu --copy && autoconf 2 | -------------------------------------------------------------------------------- /bignum.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Wrapper to OpenSSL BIGNUM used by net diff (nBits) 3 | */ 4 | 5 | #include 6 | 7 | #include "uint256.h" 8 | #include "bignum.hpp" 9 | 10 | #include "miner.h" // hex2bin 11 | 12 | extern "C" double bn_convert_nbits(const uint32_t nBits) 13 | { 14 | uint256 bn = CBigNum().SetCompact(nBits).getuint256(); 15 | return bn.getdouble(); 16 | } 17 | 18 | // copy the big number to 32-bytes uchar 19 | extern "C" void bn_nbits_to_uchar(const uint32_t nBits, unsigned char *target) 20 | { 21 | char buff[65]; 22 | uint256 bn = CBigNum().SetCompact(nBits).getuint256(); 23 | 24 | snprintf(buff, 65, "%s\n", bn.ToString().c_str()); buff[64] = '\0'; 25 | hex2bin(target, buff, 32); 26 | } 27 | 28 | // unused, but should allow more than 256bits targets 29 | #if 0 30 | extern "C" double bn_hash_target_ratio(uint32_t* hash, uint32_t* target) 31 | { 32 | double dhash; 33 | 34 | if (!opt_showdiff) 35 | return 0.0; 36 | 37 | CBigNum h(0), t(0); 38 | std::vector vch(32); 39 | 40 | memcpy(&vch[0], (void*) target, 32); 41 | t.setvch(vch); 42 | memcpy(&vch[0], (void*) hash, 32); 43 | h.setvch(vch); 44 | 45 | dhash = h.getuint256().getdouble(); 46 | if (dhash > 0.) 47 | return t.getuint256().getdouble() / dhash; 48 | else 49 | return dhash; 50 | } 51 | #endif 52 | 53 | // compute the diff ratio between a found hash and the target 54 | extern "C" double bn_hash_target_ratio(uint32_t* hash, uint32_t* target) 55 | { 56 | uint256 h, t; 57 | double dhash; 58 | 59 | if (!opt_showdiff) 60 | return 0.0; 61 | 62 | memcpy(&t, (void*) target, 32); 63 | memcpy(&h, (void*) hash, 32); 64 | 65 | dhash = h.getdouble(); 66 | if (dhash > 0.) 67 | return t.getdouble() / dhash; 68 | else 69 | return dhash; 70 | } 71 | 72 | // store ratio in work struct 73 | extern "C" void bn_store_hash_target_ratio(uint32_t* hash, uint32_t* target, struct work* work, int nonce) 74 | { 75 | // only if the option is enabled (to reduce cpu usage) 76 | if (!opt_showdiff) return; 77 | if (nonce < 0 || nonce >= MAX_NONCES) return; 78 | 79 | work->shareratio[nonce] = bn_hash_target_ratio(hash, target); 80 | work->sharediff[nonce] = work->targetdiff * work->shareratio[nonce]; 81 | } 82 | 83 | // new method to save all nonce(s) share diff/ration 84 | extern "C" void bn_set_target_ratio(struct work* work, uint32_t* hash, int nonce) 85 | { 86 | bn_store_hash_target_ratio(hash, work->target, work, nonce); 87 | } 88 | 89 | // compat (only store single nonce share diff per work) 90 | extern "C" void work_set_target_ratio(struct work* work, uint32_t* hash) 91 | { 92 | bn_store_hash_target_ratio(hash, work->target, work, work->submit_nonce_id); 93 | } 94 | 95 | -------------------------------------------------------------------------------- /build.cmd: -------------------------------------------------------------------------------- 1 | REM COMMAND LINE MS BUILD 2 | REM Note: /m:2 = 2 threads, but for host code only... 3 | 4 | msbuild ccminer.vcxproj /m /p:Configuration=Release 5 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Simple script to create the Makefile and build 4 | 5 | # export PATH="$PATH:/usr/local/cuda/bin/" 6 | 7 | make distclean || echo clean 8 | 9 | rm -f Makefile.in 10 | rm -f config.status 11 | ./autogen.sh || echo done 12 | 13 | # CFLAGS="-O2" ./configure 14 | ./configure.sh 15 | 16 | make -j 4 17 | -------------------------------------------------------------------------------- /ccminer.conf: -------------------------------------------------------------------------------- 1 | { 2 | "_comment1" : "Possible keys are the long options (ccminer --help)", 3 | "_comment2" : "todo: support /* comments */", 4 | 5 | "algo" : "lbry", 6 | "intensity": 22, 7 | 8 | "api-bind": "127.0.0.1:4068", 9 | "statsavg": 20, 10 | 11 | "max-log-rate": 60, 12 | "quiet" : false, 13 | "debug" : false, 14 | "protocol" : false, 15 | "cpu-priority" : 3, 16 | 17 | "url" : "stratum+tcp://yiimp.ccminer.org:3334", 18 | "user" : "bK2wcSFJv2nnNjFvTN5Q7VX8X8unJktJsa", 19 | "pass" : "donate" 20 | } 21 | -------------------------------------------------------------------------------- /ccminer.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 15 3 | VisualStudioVersion = 15.0.26403.7 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ccminer", "ccminer.vcxproj", "{36DC07F9-A4A6-4877-A146-1B960083CF6F}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|Win32 = Debug|Win32 10 | Debug|x64 = Debug|x64 11 | Release|Win32 = Release|Win32 12 | Release|x64 = Release|x64 13 | EndGlobalSection 14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 15 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Debug|Win32.ActiveCfg = Debug|Win32 16 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Debug|Win32.Build.0 = Debug|Win32 17 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Debug|x64.ActiveCfg = Debug|x64 18 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Debug|x64.Build.0 = Debug|x64 19 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Release|Win32.ActiveCfg = Release|Win32 20 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Release|Win32.Build.0 = Release|Win32 21 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Release|x64.ActiveCfg = Release|x64 22 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Release|x64.Build.0 = Release|x64 23 | EndGlobalSection 24 | GlobalSection(SolutionProperties) = preSolution 25 | HideSolutionNode = FALSE 26 | EndGlobalSection 27 | EndGlobal 28 | -------------------------------------------------------------------------------- /compat.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMPAT_H__ 2 | #define __COMPAT_H__ 3 | 4 | #ifdef WIN32 5 | 6 | #include 7 | #include 8 | 9 | #define localtime_r(src, dst) localtime_s(dst, src) 10 | 11 | static __inline void sleep(int secs) 12 | { 13 | Sleep(secs * 1000); 14 | } 15 | 16 | enum { 17 | PRIO_PROCESS = 0, 18 | }; 19 | 20 | extern int opt_priority; 21 | 22 | static __inline int setpriority(int which, int who, int prio) 23 | { 24 | switch (opt_priority) { 25 | case 5: 26 | prio = THREAD_PRIORITY_TIME_CRITICAL; 27 | break; 28 | case 4: 29 | prio = THREAD_PRIORITY_HIGHEST; 30 | break; 31 | case 3: 32 | prio = THREAD_PRIORITY_ABOVE_NORMAL; 33 | break; 34 | case 2: 35 | prio = THREAD_PRIORITY_NORMAL; 36 | break; 37 | case 1: 38 | prio = THREAD_PRIORITY_BELOW_NORMAL; 39 | break; 40 | case 0: 41 | default: 42 | prio = THREAD_PRIORITY_IDLE; 43 | } 44 | return -!SetThreadPriority(GetCurrentThread(), prio); 45 | } 46 | 47 | #ifdef _MSC_VER 48 | #define snprintf(...) _snprintf(__VA_ARGS__) 49 | #define strdup(...) _strdup(__VA_ARGS__) 50 | #define strncasecmp(x,y,z) _strnicmp(x,y,z) 51 | #define strcasecmp(x,y) _stricmp(x,y) 52 | typedef int ssize_t; 53 | 54 | __inline int msver(void) { 55 | switch (_MSC_VER) { 56 | case 1500: return 2008; 57 | case 1600: return 2010; 58 | case 1700: return 2012; 59 | case 1800: return 2013; 60 | case 1900: return 2015; 61 | default: return (_MSC_VER/100); 62 | } 63 | } 64 | 65 | #include 66 | static __inline char * dirname(char *file) { 67 | char buffer[_MAX_PATH] = { 0 }; 68 | char drive[_MAX_DRIVE]; 69 | char dir[_MAX_DIR]; 70 | char fname[_MAX_FNAME]; 71 | char ext[_MAX_EXT]; 72 | _splitpath_s(file, drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT); 73 | sprintf(buffer, "%s%s", drive, dir); 74 | return strdup(buffer); 75 | } 76 | #endif 77 | 78 | #endif /* WIN32 */ 79 | 80 | #ifdef _MSC_VER 81 | # define __func__ __FUNCTION__ 82 | # define __thread __declspec(thread) 83 | # define _ALIGN(x) __declspec(align(x)) 84 | #else 85 | # define _ALIGN(x) __attribute__ ((aligned(x))) 86 | /* dirname() for linux/mingw */ 87 | #include 88 | #endif 89 | 90 | #ifndef WIN32 91 | #define MAX_PATH PATH_MAX 92 | #endif 93 | 94 | #endif /* __COMPAT_H__ */ 95 | -------------------------------------------------------------------------------- /compat/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | if WANT_JANSSON 3 | SUBDIRS = jansson 4 | else 5 | SUBDIRS = 6 | endif 7 | 8 | -------------------------------------------------------------------------------- /compat/curl-for-windows/curl/include/curl/curlver.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_CURLVER_H 2 | #define __CURL_CURLVER_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at http://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | /* This header file contains nothing but libcurl version info, generated by 26 | a script at release-time. This was made its own header file in 7.11.2 */ 27 | 28 | /* This is the global package copyright */ 29 | #define LIBCURL_COPYRIGHT "1996 - 2014 Daniel Stenberg, ." 30 | 31 | /* This is the version number of the libcurl package from which this header 32 | file origins: */ 33 | #define LIBCURL_VERSION "7.38.0" 34 | 35 | /* The numeric version number is also available "in parts" by using these 36 | defines: */ 37 | #define LIBCURL_VERSION_MAJOR 7 38 | #define LIBCURL_VERSION_MINOR 38 39 | #define LIBCURL_VERSION_PATCH 0 40 | 41 | /* This is the numeric version of the libcurl version number, meant for easier 42 | parsing and comparions by programs. The LIBCURL_VERSION_NUM define will 43 | always follow this syntax: 44 | 45 | 0xXXYYZZ 46 | 47 | Where XX, YY and ZZ are the main version, release and patch numbers in 48 | hexadecimal (using 8 bits each). All three numbers are always represented 49 | using two digits. 1.2 would appear as "0x010200" while version 9.11.7 50 | appears as "0x090b07". 51 | 52 | This 6-digit (24 bits) hexadecimal number does not show pre-release number, 53 | and it is always a greater number in a more recent release. It makes 54 | comparisons with greater than and less than work. 55 | */ 56 | #define LIBCURL_VERSION_NUM 0x072600 57 | 58 | /* 59 | * This is the date and time when the full source package was created. The 60 | * timestamp is not stored in git, as the timestamp is properly set in the 61 | * tarballs by the maketgz script. 62 | * 63 | * The format of the date should follow this template: 64 | * 65 | * "Mon Feb 12 11:35:33 UTC 2007" 66 | */ 67 | #define LIBCURL_TIMESTAMP "Mon Nov 03 12:00:00 UTC 2014" 68 | 69 | #endif /* __CURL_CURLVER_H */ 70 | -------------------------------------------------------------------------------- /compat/curl-for-windows/curl/include/curl/easy.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_EASY_H 2 | #define __CURL_EASY_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at http://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | CURL_EXTERN CURL *curl_easy_init(void); 29 | CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...); 30 | CURL_EXTERN CURLcode curl_easy_perform(CURL *curl); 31 | CURL_EXTERN void curl_easy_cleanup(CURL *curl); 32 | 33 | /* 34 | * NAME curl_easy_getinfo() 35 | * 36 | * DESCRIPTION 37 | * 38 | * Request internal information from the curl session with this function. The 39 | * third argument MUST be a pointer to a long, a pointer to a char * or a 40 | * pointer to a double (as the documentation describes elsewhere). The data 41 | * pointed to will be filled in accordingly and can be relied upon only if the 42 | * function returns CURLE_OK. This function is intended to get used *AFTER* a 43 | * performed transfer, all results from this function are undefined until the 44 | * transfer is completed. 45 | */ 46 | CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...); 47 | 48 | 49 | /* 50 | * NAME curl_easy_duphandle() 51 | * 52 | * DESCRIPTION 53 | * 54 | * Creates a new curl session handle with the same options set for the handle 55 | * passed in. Duplicating a handle could only be a matter of cloning data and 56 | * options, internal state info and things like persistent connections cannot 57 | * be transferred. It is useful in multithreaded applications when you can run 58 | * curl_easy_duphandle() for each new thread to avoid a series of identical 59 | * curl_easy_setopt() invokes in every thread. 60 | */ 61 | CURL_EXTERN CURL* curl_easy_duphandle(CURL *curl); 62 | 63 | /* 64 | * NAME curl_easy_reset() 65 | * 66 | * DESCRIPTION 67 | * 68 | * Re-initializes a CURL handle to the default values. This puts back the 69 | * handle to the same state as it was in when it was just created. 70 | * 71 | * It does keep: live connections, the Session ID cache, the DNS cache and the 72 | * cookies. 73 | */ 74 | CURL_EXTERN void curl_easy_reset(CURL *curl); 75 | 76 | /* 77 | * NAME curl_easy_recv() 78 | * 79 | * DESCRIPTION 80 | * 81 | * Receives data from the connected socket. Use after successful 82 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. 83 | */ 84 | CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, 85 | size_t *n); 86 | 87 | /* 88 | * NAME curl_easy_send() 89 | * 90 | * DESCRIPTION 91 | * 92 | * Sends data over the connected socket. Use after successful 93 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. 94 | */ 95 | CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer, 96 | size_t buflen, size_t *n); 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /compat/curl-for-windows/curl/include/curl/mprintf.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_MPRINTF_H 2 | #define __CURL_MPRINTF_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at http://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | #include 26 | #include /* needed for FILE */ 27 | 28 | #include "curl.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | CURL_EXTERN int curl_mprintf(const char *format, ...); 35 | CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...); 36 | CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...); 37 | CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength, 38 | const char *format, ...); 39 | CURL_EXTERN int curl_mvprintf(const char *format, va_list args); 40 | CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args); 41 | CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args); 42 | CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength, 43 | const char *format, va_list args); 44 | CURL_EXTERN char *curl_maprintf(const char *format, ...); 45 | CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args); 46 | 47 | #ifdef _MPRINTF_REPLACE 48 | # undef printf 49 | # undef fprintf 50 | # undef sprintf 51 | # undef vsprintf 52 | # undef snprintf 53 | # undef vprintf 54 | # undef vfprintf 55 | # undef vsnprintf 56 | # undef aprintf 57 | # undef vaprintf 58 | # define printf curl_mprintf 59 | # define fprintf curl_mfprintf 60 | #ifdef CURLDEBUG 61 | /* When built with CURLDEBUG we define away the sprintf functions since we 62 | don't want internal code to be using them */ 63 | # define sprintf sprintf_was_used 64 | # define vsprintf vsprintf_was_used 65 | #else 66 | # define sprintf curl_msprintf 67 | # define vsprintf curl_mvsprintf 68 | #endif 69 | # define snprintf curl_msnprintf 70 | # define vprintf curl_mvprintf 71 | # define vfprintf curl_mvfprintf 72 | # define vsnprintf curl_mvsnprintf 73 | # define aprintf curl_maprintf 74 | # define vaprintf curl_mvaprintf 75 | #endif 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* __CURL_MPRINTF_H */ 82 | -------------------------------------------------------------------------------- /compat/curl-for-windows/curl/include/curl/stdcheaders.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDC_HEADERS_H 2 | #define __STDC_HEADERS_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at http://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | #include 26 | 27 | size_t fread (void *, size_t, size_t, FILE *); 28 | size_t fwrite (const void *, size_t, size_t, FILE *); 29 | 30 | int strcasecmp(const char *, const char *); 31 | int strncasecmp(const char *, const char *, size_t); 32 | 33 | #endif /* __STDC_HEADERS_H */ 34 | -------------------------------------------------------------------------------- /compat/curl-for-windows/openssl/openssl/crypto/opensslconf.h: -------------------------------------------------------------------------------- 1 | #include "../../config/opensslconf.h" 2 | -------------------------------------------------------------------------------- /compat/curl-for-windows/openssl/openssl/include/openssl/e_os2.h: -------------------------------------------------------------------------------- 1 | #include "../../e_os2.h" 2 | -------------------------------------------------------------------------------- /compat/curl-for-windows/openssl/openssl/include/openssl/opensslconf.h: -------------------------------------------------------------------------------- 1 | #include "../../crypto/opensslconf.h" 2 | -------------------------------------------------------------------------------- /compat/curl-for-windows/openssl/openssl/include/openssl/opensslv.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_OPENSSLV_H 2 | #define HEADER_OPENSSLV_H 3 | 4 | /* Numeric release version identifier: 5 | * MNNFFPPS: major minor fix patch status 6 | * The status nibble has one of the values 0 for development, 1 to e for betas 7 | * 1 to 14, and f for release. The patch level is exactly that. 8 | * For example: 9 | * 0.9.3-dev 0x00903000 10 | * 0.9.3-beta1 0x00903001 11 | * 0.9.3-beta2-dev 0x00903002 12 | * 0.9.3-beta2 0x00903002 (same as ...beta2-dev) 13 | * 0.9.3 0x0090300f 14 | * 0.9.3a 0x0090301f 15 | * 0.9.4 0x0090400f 16 | * 1.2.3z 0x102031af 17 | * 18 | * For continuity reasons (because 0.9.5 is already out, and is coded 19 | * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level 20 | * part is slightly different, by setting the highest bit. This means 21 | * that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start 22 | * with 0x0090600S... 23 | * 24 | * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) 25 | * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for 26 | * major minor fix final patch/beta) 27 | */ 28 | #define OPENSSL_VERSION_NUMBER 0x1000109fL 29 | #ifdef OPENSSL_FIPS 30 | #define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1i-fips 6 Aug 2014" 31 | #else 32 | #define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1i 6 Aug 2014" 33 | #endif 34 | #define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT 35 | 36 | 37 | /* The macros below are to be used for shared library (.so, .dll, ...) 38 | * versioning. That kind of versioning works a bit differently between 39 | * operating systems. The most usual scheme is to set a major and a minor 40 | * number, and have the runtime loader check that the major number is equal 41 | * to what it was at application link time, while the minor number has to 42 | * be greater or equal to what it was at application link time. With this 43 | * scheme, the version number is usually part of the file name, like this: 44 | * 45 | * libcrypto.so.0.9 46 | * 47 | * Some unixen also make a softlink with the major verson number only: 48 | * 49 | * libcrypto.so.0 50 | * 51 | * On Tru64 and IRIX 6.x it works a little bit differently. There, the 52 | * shared library version is stored in the file, and is actually a series 53 | * of versions, separated by colons. The rightmost version present in the 54 | * library when linking an application is stored in the application to be 55 | * matched at run time. When the application is run, a check is done to 56 | * see if the library version stored in the application matches any of the 57 | * versions in the version string of the library itself. 58 | * This version string can be constructed in any way, depending on what 59 | * kind of matching is desired. However, to implement the same scheme as 60 | * the one used in the other unixen, all compatible versions, from lowest 61 | * to highest, should be part of the string. Consecutive builds would 62 | * give the following versions strings: 63 | * 64 | * 3.0 65 | * 3.0:3.1 66 | * 3.0:3.1:3.2 67 | * 4.0 68 | * 4.0:4.1 69 | * 70 | * Notice how version 4 is completely incompatible with version, and 71 | * therefore give the breach you can see. 72 | * 73 | * There may be other schemes as well that I haven't yet discovered. 74 | * 75 | * So, here's the way it works here: first of all, the library version 76 | * number doesn't need at all to match the overall OpenSSL version. 77 | * However, it's nice and more understandable if it actually does. 78 | * The current library version is stored in the macro SHLIB_VERSION_NUMBER, 79 | * which is just a piece of text in the format "M.m.e" (Major, minor, edit). 80 | * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways, 81 | * we need to keep a history of version numbers, which is done in the 82 | * macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and 83 | * should only keep the versions that are binary compatible with the current. 84 | */ 85 | #define SHLIB_VERSION_HISTORY "" 86 | #define SHLIB_VERSION_NUMBER "1.0.0" 87 | 88 | 89 | #endif /* HEADER_OPENSSLV_H */ 90 | -------------------------------------------------------------------------------- /compat/curl-for-windows/openssl/openssl/include/openssl/sha.h: -------------------------------------------------------------------------------- 1 | #include "../../crypto/sha/sha.h" 2 | -------------------------------------------------------------------------------- /compat/curl-for-windows/out/x64/Release/lib/libcurl.x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/curl-for-windows/out/x64/Release/lib/libcurl.x64.lib -------------------------------------------------------------------------------- /compat/curl-for-windows/out/x64/Release/lib/openssl.x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/curl-for-windows/out/x64/Release/lib/openssl.x64.lib -------------------------------------------------------------------------------- /compat/curl-for-windows/out/x64/Release/lib/zlib.x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/curl-for-windows/out/x64/Release/lib/zlib.x64.lib -------------------------------------------------------------------------------- /compat/curl-for-windows/out/x86/Release/lib/libcurl.x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/curl-for-windows/out/x86/Release/lib/libcurl.x86.lib -------------------------------------------------------------------------------- /compat/curl-for-windows/out/x86/Release/lib/openssl.x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/curl-for-windows/out/x86/Release/lib/openssl.x86.lib -------------------------------------------------------------------------------- /compat/curl-for-windows/out/x86/Release/lib/zlib.x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/curl-for-windows/out/x86/Release/lib/zlib.x86.lib -------------------------------------------------------------------------------- /compat/getopt/getopt.h: -------------------------------------------------------------------------------- 1 | /* $Id: getopt.h,v 1.1 2009/10/16 19:50:28 rodney Exp rodney $ */ 2 | /* $OpenBSD: getopt.h,v 1.1 2002/12/03 20:24:29 millert Exp $ */ 3 | /* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */ 4 | 5 | /*- 6 | * Copyright (c) 2000 The NetBSD Foundation, Inc. 7 | * All rights reserved. 8 | * 9 | * This code is derived from software contributed to The NetBSD Foundation 10 | * by Dieter Baron and Thomas Klausner. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the NetBSD 23 | * Foundation, Inc. and its contributors. 24 | * 4. Neither the name of The NetBSD Foundation nor the names of its 25 | * contributors may be used to endorse or promote products derived 26 | * from this software without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 29 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 30 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 31 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 32 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | */ 40 | 41 | #ifndef _GETOPT_H_ 42 | #define _GETOPT_H_ 43 | 44 | #if 0 45 | #include 46 | #endif 47 | 48 | /* 49 | * GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions 50 | */ 51 | #define no_argument 0 52 | #define required_argument 1 53 | #define optional_argument 2 54 | 55 | struct option { 56 | /* name of long option */ 57 | const char *name; 58 | /* 59 | * one of no_argument, required_argument, and optional_argument: 60 | * whether option takes an argument 61 | */ 62 | int has_arg; 63 | /* if not NULL, set *flag to val when option found */ 64 | int *flag; 65 | /* if flag not NULL, value to set *flag to; else return value */ 66 | int val; 67 | }; 68 | 69 | #ifdef __cplusplus 70 | extern "C" { 71 | #endif 72 | 73 | int getopt_long(int, char * const *, const char *, 74 | const struct option *, int *); 75 | int getopt_long_only(int, char * const *, const char *, 76 | const struct option *, int *); 77 | #ifndef _GETOPT_DEFINED 78 | #define _GETOPT_DEFINED 79 | int getopt(int, char * const *, const char *); 80 | int getsubopt(char **, char * const *, char **); 81 | 82 | extern char *optarg; /* getopt(3) external variables */ 83 | extern int opterr; 84 | extern int optind; 85 | extern int optopt; 86 | extern int optreset; 87 | extern char *suboptarg; /* getsubopt(3) external variable */ 88 | #endif /* _GETOPT_DEFINED */ 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | #endif /* !_GETOPT_H_ */ 94 | -------------------------------------------------------------------------------- /compat/gettimeofday.c: -------------------------------------------------------------------------------- 1 | #include < time.h > 2 | #include //I've ommited this line. 3 | #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) 4 | #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 5 | #else 6 | #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL 7 | #endif 8 | 9 | struct timezone 10 | { 11 | int tz_minuteswest; /* minutes W of Greenwich */ 12 | int tz_dsttime; /* type of dst correction */ 13 | }; 14 | 15 | int gettimeofday(struct timeval *tv, struct timezone *tz) 16 | { 17 | FILETIME ft; 18 | unsigned __int64 tmpres = 0; 19 | static int tzflag; 20 | 21 | if (NULL != tv) 22 | { 23 | GetSystemTimeAsFileTime(&ft); 24 | 25 | tmpres |= ft.dwHighDateTime; 26 | tmpres <<= 32; 27 | tmpres |= ft.dwLowDateTime; 28 | 29 | /*converting file time to unix epoch*/ 30 | tmpres /= 10; /*convert into microseconds*/ 31 | tmpres -= DELTA_EPOCH_IN_MICROSECS; 32 | tv->tv_sec = (long)(tmpres / 1000000UL); 33 | tv->tv_usec = (long)(tmpres % 1000000UL); 34 | } 35 | 36 | if (NULL != tz) 37 | { 38 | if (!tzflag) 39 | { 40 | _tzset(); 41 | tzflag++; 42 | } 43 | tz->tz_minuteswest = _timezone / 60; 44 | tz->tz_dsttime = _daylight; 45 | } 46 | 47 | return 0; 48 | } 49 | 50 | void usleep(__int64 waitTime) 51 | { 52 | if (waitTime > 0) 53 | { 54 | if (waitTime > 100) 55 | { 56 | // use a waitable timer for larger intervals > 0.1ms 57 | 58 | HANDLE timer; 59 | LARGE_INTEGER ft; 60 | 61 | ft.QuadPart = -(10*waitTime); // Convert to 100 nanosecond interval, negative value indicates relative time 62 | 63 | timer = CreateWaitableTimer(NULL, TRUE, NULL); 64 | SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); 65 | WaitForSingleObject(timer, INFINITE); 66 | CloseHandle(timer); 67 | } 68 | else 69 | { 70 | // use a polling loop for short intervals <= 100ms 71 | 72 | LARGE_INTEGER perfCnt, start, now; 73 | __int64 elapsed; 74 | 75 | QueryPerformanceFrequency(&perfCnt); 76 | QueryPerformanceCounter(&start); 77 | do { 78 | QueryPerformanceCounter((LARGE_INTEGER*) &now); 79 | elapsed = (__int64)((now.QuadPart - start.QuadPart) / (float)perfCnt.QuadPart * 1000 * 1000); 80 | } while ( elapsed < waitTime ); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /compat/inttypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | -------------------------------------------------------------------------------- /compat/jansson/.gitignore: -------------------------------------------------------------------------------- 1 | *.h.in~ 2 | libtool 3 | libjansson.a 4 | -------------------------------------------------------------------------------- /compat/jansson/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | noinst_LIBRARIES = libjansson.a 3 | 4 | libjansson_a_SOURCES = \ 5 | jansson_private_config.h \ 6 | dump.c \ 7 | error.c \ 8 | hashtable.c hashtable.h \ 9 | jansson.h \ 10 | jansson_config.h \ 11 | jansson_private.h \ 12 | load.c \ 13 | memory.c \ 14 | pack_unpack.c \ 15 | strbuffer.c strbuffer.h \ 16 | strconv.c \ 17 | utf.c utf.h \ 18 | util.h \ 19 | value.c 20 | 21 | -------------------------------------------------------------------------------- /compat/jansson/configure.ac: -------------------------------------------------------------------------------- 1 | AC_PREREQ([2.60]) 2 | AC_INIT([jansson], [2.6], [petri@digip.org]) 3 | 4 | AC_CONFIG_MACRO_DIR([m4]) 5 | 6 | AM_INIT_AUTOMAKE([1.10 foreign]) 7 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 8 | 9 | AC_CONFIG_SRCDIR([value.c]) 10 | AC_CONFIG_HEADERS([jansson_private_config.h]) 11 | 12 | # Checks for programs. 13 | AC_PROG_CC 14 | AC_PROG_LIBTOOL 15 | AM_CONDITIONAL([GCC], [test x$GCC = xyes]) 16 | 17 | # Checks for libraries. 18 | 19 | # Checks for header files. 20 | AC_CHECK_HEADERS([endian.h fcntl.h locale.h sched.h unistd.h sys/param.h sys/stat.h sys/time.h sys/types.h]) 21 | 22 | # Checks for typedefs, structures, and compiler characteristics. 23 | AC_TYPE_INT32_T 24 | AC_TYPE_UINT32_T 25 | AC_TYPE_LONG_LONG_INT 26 | 27 | AC_C_INLINE 28 | case $ac_cv_c_inline in 29 | yes) json_inline=inline;; 30 | no) json_inline=;; 31 | *) json_inline=$ac_cv_c_inline;; 32 | esac 33 | AC_SUBST([json_inline]) 34 | 35 | # Checks for library functions. 36 | AC_CHECK_FUNCS([close getpid gettimeofday localeconv open read sched_yield strtoll]) 37 | 38 | AC_MSG_CHECKING([for gcc __sync builtins]) 39 | have_sync_builtins=no 40 | AC_TRY_LINK( 41 | [], [unsigned long val; __sync_bool_compare_and_swap(&val, 0, 1);], 42 | [have_sync_builtins=yes], 43 | ) 44 | if test "x$have_sync_builtins" = "xyes"; then 45 | AC_DEFINE([HAVE_SYNC_BUILTINS], [1], 46 | [Define to 1 if gcc's __sync builtins are available]) 47 | fi 48 | AC_MSG_RESULT([$have_sync_builtins]) 49 | 50 | AC_MSG_CHECKING([for gcc __atomic builtins]) 51 | have_atomic_builtins=no 52 | AC_TRY_LINK( 53 | [], [char l; unsigned long v; __atomic_test_and_set(&l, __ATOMIC_RELAXED); __atomic_store_n(&v, 1, __ATOMIC_ACQ_REL); __atomic_load_n(&v, __ATOMIC_ACQUIRE);], 54 | [have_atomic_builtins=yes], 55 | ) 56 | if test "x$have_atomic_builtins" = "xyes"; then 57 | AC_DEFINE([HAVE_ATOMIC_BUILTINS], [1], 58 | [Define to 1 if gcc's __atomic builtins are available]) 59 | fi 60 | AC_MSG_RESULT([$have_atomic_builtins]) 61 | 62 | case "$ac_cv_type_long_long_int$ac_cv_func_strtoll" in 63 | yesyes) json_have_long_long=1;; 64 | *) json_have_long_long=0;; 65 | esac 66 | AC_SUBST([json_have_long_long]) 67 | 68 | case "$ac_cv_header_locale_h$ac_cv_func_localeconv" in 69 | yesyes) json_have_localeconv=1;; 70 | *) json_have_localeconv=0;; 71 | esac 72 | AC_SUBST([json_have_localeconv]) 73 | 74 | # Features 75 | AC_ARG_ENABLE([urandom], 76 | [AS_HELP_STRING([--disable-urandom], 77 | [Don't use /dev/urandom to seed the hash function])], 78 | [use_urandom=$enableval], [use_urandom=yes]) 79 | 80 | if test "x$use_urandom" = xyes; then 81 | AC_DEFINE([USE_URANDOM], [1], 82 | [Define to 1 if /dev/urandom should be used for seeding the hash function]) 83 | fi 84 | 85 | AC_ARG_ENABLE([windows-cryptoapi], 86 | [AS_HELP_STRING([--disable-windows-cryptoapi], 87 | [Don't use CryptGenRandom to seed the hash function])], 88 | [use_windows_cryptoapi=$enableval], [use_windows_cryptoapi=yes]) 89 | 90 | if test "x$use_windows_cryptoapi" = xyes; then 91 | AC_DEFINE([USE_WINDOWS_CRYPTOAPI], [1], 92 | [Define to 1 if CryptGenRandom should be used for seeding the hash function]) 93 | fi 94 | 95 | AC_CONFIG_FILES([ 96 | Makefile 97 | ]) 98 | AC_OUTPUT 99 | -------------------------------------------------------------------------------- /compat/jansson/error.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "jansson_private.h" 3 | 4 | void jsonp_error_init(json_error_t *error, const char *source) 5 | { 6 | if(error) 7 | { 8 | error->text[0] = '\0'; 9 | error->line = -1; 10 | error->column = -1; 11 | error->position = 0; 12 | if(source) 13 | jsonp_error_set_source(error, source); 14 | else 15 | error->source[0] = '\0'; 16 | } 17 | } 18 | 19 | void jsonp_error_set_source(json_error_t *error, const char *source) 20 | { 21 | size_t length; 22 | 23 | if(!error || !source) 24 | return; 25 | 26 | length = strlen(source); 27 | if(length < JSON_ERROR_SOURCE_LENGTH) 28 | strcpy(error->source, source); 29 | else { 30 | size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4; 31 | strcpy(error->source, "..."); 32 | strcpy(error->source + 3, source + extra); 33 | } 34 | } 35 | 36 | void jsonp_error_set(json_error_t *error, int line, int column, 37 | size_t position, const char *msg, ...) 38 | { 39 | va_list ap; 40 | 41 | va_start(ap, msg); 42 | jsonp_error_vset(error, line, column, position, msg, ap); 43 | va_end(ap); 44 | } 45 | 46 | void jsonp_error_vset(json_error_t *error, int line, int column, 47 | size_t position, const char *msg, va_list ap) 48 | { 49 | if(!error) 50 | return; 51 | 52 | if(error->text[0] != '\0') { 53 | /* error already set */ 54 | return; 55 | } 56 | 57 | error->line = line; 58 | error->column = column; 59 | error->position = position; 60 | 61 | vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH, msg, ap); 62 | error->text[JSON_ERROR_TEXT_LENGTH - 1] = '\0'; 63 | } 64 | -------------------------------------------------------------------------------- /compat/jansson/jansson_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2013 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | * 7 | * 8 | * This file specifies a part of the site-specific configuration for 9 | * Jansson, namely those things that affect the public API in 10 | * jansson.h. 11 | * 12 | * The configure script copies this file to jansson_config.h and 13 | * replaces @var@ substitutions by values that fit your system. If you 14 | * cannot run the configure script, you can do the value substitution 15 | * by hand. 16 | */ 17 | 18 | #ifndef JANSSON_CONFIG_H 19 | #define JANSSON_CONFIG_H 20 | /* If your compiler supports the inline keyword in C, JSON_INLINE is 21 | defined to `inline', otherwise empty. In C++, the inline is always 22 | supported. */ 23 | 24 | #ifdef _MSC_VER 25 | #define inline __inline 26 | #if !defined(HAVE_STRUCT_TIMESPEC) && _MSC_VER >= 1900 27 | #define HAVE_STRUCT_TIMESPEC 28 | #endif 29 | #endif 30 | 31 | #ifdef __cplusplus 32 | #define JSON_INLINE inline 33 | #else 34 | #define JSON_INLINE inline 35 | #endif 36 | 37 | /* If your compiler supports the `long long` type and the strtoll() 38 | library function, JSON_INTEGER_IS_LONG_LONG is defined to 1, 39 | otherwise to 0. */ 40 | #define JSON_INTEGER_IS_LONG_LONG 1 41 | 42 | /* If locale.h and localeconv() are available, define to 1, 43 | otherwise to 0. */ 44 | #define JSON_HAVE_LOCALECONV 1 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /compat/jansson/jansson_config.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2014 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | * 7 | * 8 | * This file specifies a part of the site-specific configuration for 9 | * Jansson, namely those things that affect the public API in 10 | * jansson.h. 11 | * 12 | * The configure script copies this file to jansson_config.h and 13 | * replaces @var@ substitutions by values that fit your system. If you 14 | * cannot run the configure script, you can do the value substitution 15 | * by hand. 16 | */ 17 | 18 | #ifndef JANSSON_CONFIG_H 19 | #define JANSSON_CONFIG_H 20 | 21 | /* If your compiler supports the inline keyword in C, JSON_INLINE is 22 | defined to `inline', otherwise empty. In C++, the inline is always 23 | supported. */ 24 | #ifdef __cplusplus 25 | #define JSON_INLINE inline 26 | #else 27 | #define JSON_INLINE @json_inline@ 28 | #endif 29 | 30 | /* If your compiler supports the `long long` type and the strtoll() 31 | library function, JSON_INTEGER_IS_LONG_LONG is defined to 1, 32 | otherwise to 0. */ 33 | #define JSON_INTEGER_IS_LONG_LONG @json_have_long_long@ 34 | 35 | /* If locale.h and localeconv() are available, define to 1, 36 | otherwise to 0. */ 37 | #define JSON_HAVE_LOCALECONV @json_have_localeconv@ 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /compat/jansson/jansson_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef JANSSON_PRIVATE_H 9 | #define JANSSON_PRIVATE_H 10 | 11 | #include 12 | #include "jansson.h" 13 | #include "hashtable.h" 14 | #include "strbuffer.h" 15 | 16 | #define container_of(ptr_, type_, member_) \ 17 | ((type_ *)((char *)ptr_ - offsetof(type_, member_))) 18 | 19 | /* On some platforms, max() may already be defined */ 20 | #ifndef max 21 | #define max(a, b) ((a) > (b) ? (a) : (b)) 22 | #endif 23 | 24 | /* va_copy is a C99 feature. In C89 implementations, it's sometimes 25 | available as __va_copy. If not, memcpy() should do the trick. */ 26 | #ifndef va_copy 27 | #ifdef __va_copy 28 | #define va_copy __va_copy 29 | #else 30 | #define va_copy(a, b) memcpy(&(a), &(b), sizeof(va_list)) 31 | #endif 32 | #endif 33 | 34 | typedef struct { 35 | json_t json; 36 | hashtable_t hashtable; 37 | size_t serial; 38 | int visited; 39 | } json_object_t; 40 | 41 | typedef struct { 42 | json_t json; 43 | size_t size; 44 | size_t entries; 45 | json_t **table; 46 | int visited; 47 | } json_array_t; 48 | 49 | typedef struct { 50 | json_t json; 51 | char *value; 52 | } json_string_t; 53 | 54 | typedef struct { 55 | json_t json; 56 | double value; 57 | } json_real_t; 58 | 59 | typedef struct { 60 | json_t json; 61 | json_int_t value; 62 | } json_integer_t; 63 | 64 | #define json_to_object(json_) container_of(json_, json_object_t, json) 65 | #define json_to_array(json_) container_of(json_, json_array_t, json) 66 | #define json_to_string(json_) container_of(json_, json_string_t, json) 67 | #define json_to_real(json_) container_of(json_, json_real_t, json) 68 | #define json_to_integer(json_) container_of(json_, json_integer_t, json) 69 | 70 | void jsonp_error_init(json_error_t *error, const char *source); 71 | void jsonp_error_set_source(json_error_t *error, const char *source); 72 | void jsonp_error_set(json_error_t *error, int line, int column, 73 | size_t position, const char *msg, ...); 74 | void jsonp_error_vset(json_error_t *error, int line, int column, 75 | size_t position, const char *msg, va_list ap); 76 | 77 | /* Locale independent string<->double conversions */ 78 | int jsonp_strtod(strbuffer_t *strbuffer, double *out); 79 | int jsonp_dtostr(char *buffer, size_t size, double value); 80 | 81 | /* Wrappers for custom memory functions */ 82 | void* jsonp_malloc(size_t size); 83 | void jsonp_free(void *ptr); 84 | char *jsonp_strndup(const char *str, size_t length); 85 | char *jsonp_strdup(const char *str); 86 | 87 | /* Windows compatibility */ 88 | #ifdef _WIN32 89 | #define snprintf _snprintf 90 | #define vsnprintf _vsnprintf 91 | #endif 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /compat/jansson/memory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Petri Lehtinen 3 | * Copyright (c) 2011-2012 Basile Starynkevitch 4 | * 5 | * Jansson is free software; you can redistribute it and/or modify it 6 | * under the terms of the MIT license. See LICENSE for details. 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | #include "jansson.h" 13 | #include "jansson_private.h" 14 | 15 | /* memory function pointers */ 16 | static json_malloc_t do_malloc = malloc; 17 | static json_free_t do_free = free; 18 | 19 | void *jsonp_malloc(size_t size) 20 | { 21 | if(!size) 22 | return NULL; 23 | 24 | return (*do_malloc)(size); 25 | } 26 | 27 | void jsonp_free(void *ptr) 28 | { 29 | if(!ptr) 30 | return; 31 | 32 | (*do_free)(ptr); 33 | } 34 | 35 | char *jsonp_strdup(const char *str) 36 | { 37 | char *new_str; 38 | size_t len; 39 | 40 | len = strlen(str); 41 | if(len == (size_t)-1) 42 | return NULL; 43 | 44 | new_str = jsonp_malloc(len + 1); 45 | if(!new_str) 46 | return NULL; 47 | 48 | memcpy(new_str, str, len + 1); 49 | return new_str; 50 | } 51 | 52 | void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn) 53 | { 54 | do_malloc = malloc_fn; 55 | do_free = free_fn; 56 | } 57 | -------------------------------------------------------------------------------- /compat/jansson/strbuffer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef _GNU_SOURCE 9 | #define _GNU_SOURCE 10 | #endif 11 | 12 | #include 13 | #include 14 | #include "jansson_private.h" 15 | #include "strbuffer.h" 16 | 17 | #define STRBUFFER_MIN_SIZE 16 18 | #define STRBUFFER_FACTOR 2 19 | #define STRBUFFER_SIZE_MAX ((size_t)-1) 20 | 21 | int strbuffer_init(strbuffer_t *strbuff) 22 | { 23 | strbuff->size = STRBUFFER_MIN_SIZE; 24 | strbuff->length = 0; 25 | 26 | strbuff->value = jsonp_malloc(strbuff->size); 27 | if(!strbuff->value) 28 | return -1; 29 | 30 | /* initialize to empty */ 31 | strbuff->value[0] = '\0'; 32 | return 0; 33 | } 34 | 35 | void strbuffer_close(strbuffer_t *strbuff) 36 | { 37 | if(strbuff->value) 38 | jsonp_free(strbuff->value); 39 | 40 | strbuff->size = 0; 41 | strbuff->length = 0; 42 | strbuff->value = NULL; 43 | } 44 | 45 | void strbuffer_clear(strbuffer_t *strbuff) 46 | { 47 | strbuff->length = 0; 48 | strbuff->value[0] = '\0'; 49 | } 50 | 51 | const char *strbuffer_value(const strbuffer_t *strbuff) 52 | { 53 | return strbuff->value; 54 | } 55 | 56 | char *strbuffer_steal_value(strbuffer_t *strbuff) 57 | { 58 | char *result = strbuff->value; 59 | strbuff->value = NULL; 60 | return result; 61 | } 62 | 63 | int strbuffer_append(strbuffer_t *strbuff, const char *string) 64 | { 65 | return strbuffer_append_bytes(strbuff, string, strlen(string)); 66 | } 67 | 68 | int strbuffer_append_byte(strbuffer_t *strbuff, char byte) 69 | { 70 | return strbuffer_append_bytes(strbuff, &byte, 1); 71 | } 72 | 73 | int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size) 74 | { 75 | if(size >= strbuff->size - strbuff->length) 76 | { 77 | size_t new_size; 78 | char *new_value; 79 | 80 | /* avoid integer overflow */ 81 | if (strbuff->size > STRBUFFER_SIZE_MAX / STRBUFFER_FACTOR 82 | || size > STRBUFFER_SIZE_MAX - 1 83 | || strbuff->length > STRBUFFER_SIZE_MAX - 1 - size) 84 | return -1; 85 | 86 | new_size = max(strbuff->size * STRBUFFER_FACTOR, 87 | strbuff->length + size + 1); 88 | 89 | new_value = jsonp_malloc(new_size); 90 | if(!new_value) 91 | return -1; 92 | 93 | memcpy(new_value, strbuff->value, strbuff->length); 94 | 95 | jsonp_free(strbuff->value); 96 | strbuff->value = new_value; 97 | strbuff->size = new_size; 98 | } 99 | 100 | memcpy(strbuff->value + strbuff->length, data, size); 101 | strbuff->length += size; 102 | strbuff->value[strbuff->length] = '\0'; 103 | 104 | return 0; 105 | } 106 | 107 | char strbuffer_pop(strbuffer_t *strbuff) 108 | { 109 | if(strbuff->length > 0) { 110 | char c = strbuff->value[--strbuff->length]; 111 | strbuff->value[strbuff->length] = '\0'; 112 | return c; 113 | } 114 | else 115 | return '\0'; 116 | } 117 | -------------------------------------------------------------------------------- /compat/jansson/strbuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef STRBUFFER_H 9 | #define STRBUFFER_H 10 | 11 | typedef struct { 12 | char *value; 13 | size_t length; /* bytes used */ 14 | size_t size; /* bytes allocated */ 15 | } strbuffer_t; 16 | 17 | int strbuffer_init(strbuffer_t *strbuff); 18 | void strbuffer_close(strbuffer_t *strbuff); 19 | 20 | void strbuffer_clear(strbuffer_t *strbuff); 21 | 22 | const char *strbuffer_value(const strbuffer_t *strbuff); 23 | 24 | /* Steal the value and close the strbuffer */ 25 | char *strbuffer_steal_value(strbuffer_t *strbuff); 26 | 27 | int strbuffer_append(strbuffer_t *strbuff, const char *string); 28 | int strbuffer_append_byte(strbuffer_t *strbuff, char byte); 29 | int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size); 30 | 31 | char strbuffer_pop(strbuffer_t *strbuff); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /compat/jansson/strconv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "jansson_private.h" 6 | #include "strbuffer.h" 7 | 8 | /* need jansson_private_config.h to get the correct snprintf */ 9 | #ifdef HAVE_CONFIG_H 10 | #include "jansson_private_config.h" 11 | #endif 12 | 13 | #if JSON_HAVE_LOCALECONV 14 | #include 15 | 16 | /* 17 | - This code assumes that the decimal separator is exactly one 18 | character. 19 | 20 | - If setlocale() is called by another thread between the call to 21 | localeconv() and the call to sprintf() or strtod(), the result may 22 | be wrong. setlocale() is not thread-safe and should not be used 23 | this way. Multi-threaded programs should use uselocale() instead. 24 | */ 25 | 26 | static void to_locale(strbuffer_t *strbuffer) 27 | { 28 | const char *point; 29 | char *pos; 30 | 31 | point = localeconv()->decimal_point; 32 | if(*point == '.') { 33 | /* No conversion needed */ 34 | return; 35 | } 36 | 37 | pos = strchr(strbuffer->value, '.'); 38 | if(pos) 39 | *pos = *point; 40 | } 41 | 42 | static void from_locale(char *buffer) 43 | { 44 | const char *point; 45 | char *pos; 46 | 47 | point = localeconv()->decimal_point; 48 | if(*point == '.') { 49 | /* No conversion needed */ 50 | return; 51 | } 52 | 53 | pos = strchr(buffer, *point); 54 | if(pos) 55 | *pos = '.'; 56 | } 57 | #endif 58 | 59 | int jsonp_strtod(strbuffer_t *strbuffer, double *out) 60 | { 61 | double value; 62 | char *end; 63 | 64 | #if JSON_HAVE_LOCALECONV 65 | to_locale(strbuffer); 66 | #endif 67 | 68 | errno = 0; 69 | value = strtod(strbuffer->value, &end); 70 | assert(end == strbuffer->value + strbuffer->length); 71 | 72 | if(errno == ERANGE && value != 0) { 73 | /* Overflow */ 74 | return -1; 75 | } 76 | 77 | *out = value; 78 | return 0; 79 | } 80 | 81 | int jsonp_dtostr(char *buffer, size_t size, double value) 82 | { 83 | int ret; 84 | char *start, *end; 85 | size_t length; 86 | 87 | ret = snprintf(buffer, size, "%.17g", value); 88 | if(ret < 0) 89 | return -1; 90 | 91 | length = (size_t)ret; 92 | if(length >= size) 93 | return -1; 94 | 95 | #if JSON_HAVE_LOCALECONV 96 | from_locale(buffer); 97 | #endif 98 | 99 | /* Make sure there's a dot or 'e' in the output. Otherwise 100 | a real is converted to an integer when decoding */ 101 | if(strchr(buffer, '.') == NULL && 102 | strchr(buffer, 'e') == NULL) 103 | { 104 | if(length + 3 >= size) { 105 | /* No space to append ".0" */ 106 | return -1; 107 | } 108 | buffer[length] = '.'; 109 | buffer[length + 1] = '0'; 110 | buffer[length + 2] = '\0'; 111 | length += 2; 112 | } 113 | 114 | /* Remove leading '+' from positive exponent. Also remove leading 115 | zeros from exponents (added by some printf() implementations) */ 116 | start = strchr(buffer, 'e'); 117 | if(start) { 118 | start++; 119 | end = start + 1; 120 | 121 | if(*start == '-') 122 | start++; 123 | 124 | while(*end == '0') 125 | end++; 126 | 127 | if(end != start) { 128 | memmove(start, end, length - (size_t)(end - buffer)); 129 | length -= (size_t)(end - start); 130 | } 131 | } 132 | 133 | return (int)length; 134 | } 135 | -------------------------------------------------------------------------------- /compat/jansson/utf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef UTF_H 9 | #define UTF_H 10 | 11 | #ifdef HAVE_CONFIG_H 12 | #include "jansson_private_config.h" 13 | 14 | #ifdef HAVE_INTTYPES_H 15 | /* inttypes.h includes stdint.h in a standard environment, so there's 16 | no need to include stdint.h separately. If inttypes.h doesn't define 17 | int32_t, it's defined in config.h. */ 18 | #include 19 | #endif /* HAVE_INTTYPES_H */ 20 | 21 | #else /* !HAVE_CONFIG_H */ 22 | #ifdef _WIN32 23 | typedef int int32_t; 24 | #else /* !_WIN32 */ 25 | /* Assume a standard environment */ 26 | #include 27 | #endif /* _WIN32 */ 28 | 29 | #endif /* HAVE_CONFIG_H */ 30 | 31 | int utf8_encode(int codepoint, char *buffer, int *size); 32 | 33 | int utf8_check_first(char byte); 34 | int utf8_check_full(const char *buffer, int size, int32_t *codepoint); 35 | const char *utf8_iterate(const char *buffer, int32_t *codepoint); 36 | 37 | int utf8_check_string(const char *string, int length); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /compat/jansson/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2010 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef UTIL_H 9 | #define UTIL_H 10 | 11 | #ifndef max 12 | #define max(a, b) ((a) > (b) ? (a) : (b)) 13 | #endif 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /compat/nvapi/NVAPI.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=https://developer.nvidia.com/nvapi 3 | -------------------------------------------------------------------------------- /compat/nvapi/amd64/nvapi64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/nvapi/amd64/nvapi64.lib -------------------------------------------------------------------------------- /compat/nvapi/nvShaderExtnEnums.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | ////////////////////////// NVIDIA SHADER EXTENSIONS //////////////////////////// 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | // This file can be included both from HLSL shader code as well as C++ code. 6 | // The app should call NvAPI_D3D_IsNvShaderExtnOpCodeSupported() to 7 | // check for support for every nv shader extension opcode it plans to use 8 | 9 | 10 | 11 | //----------------------------------------------------------------------------// 12 | //---------------------------- NV Shader Extn Version -----------------------// 13 | //----------------------------------------------------------------------------// 14 | #define NV_SHADER_EXTN_VERSION 1 15 | 16 | //----------------------------------------------------------------------------// 17 | //---------------------------- Misc constants --------------------------------// 18 | //----------------------------------------------------------------------------// 19 | #define NV_WARP_SIZE 32 20 | 21 | 22 | //----------------------------------------------------------------------------// 23 | //---------------------------- opCode constants ------------------------------// 24 | //----------------------------------------------------------------------------// 25 | 26 | 27 | #define NV_EXTN_OP_SHFL 1 28 | #define NV_EXTN_OP_SHFL_UP 2 29 | #define NV_EXTN_OP_SHFL_DOWN 3 30 | #define NV_EXTN_OP_SHFL_XOR 4 31 | 32 | #define NV_EXTN_OP_VOTE_ALL 5 33 | #define NV_EXTN_OP_VOTE_ANY 6 34 | #define NV_EXTN_OP_VOTE_BALLOT 7 35 | 36 | #define NV_EXTN_OP_GET_LANE_ID 8 37 | #define NV_EXTN_OP_FP16_ATOMIC 12 38 | #define NV_EXTN_OP_FP32_ATOMIC 13 39 | -------------------------------------------------------------------------------- /compat/nvapi/nvapi_lite_common.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/nvapi/nvapi_lite_common.h -------------------------------------------------------------------------------- /compat/nvapi/nvapi_lite_d3dext.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/nvapi/nvapi_lite_d3dext.h -------------------------------------------------------------------------------- /compat/nvapi/nvapi_lite_salend.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/nvapi/nvapi_lite_salend.h -------------------------------------------------------------------------------- /compat/nvapi/nvapi_lite_salstart.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/nvapi/nvapi_lite_salstart.h -------------------------------------------------------------------------------- /compat/nvapi/nvapi_lite_sli.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/nvapi/nvapi_lite_sli.h -------------------------------------------------------------------------------- /compat/nvapi/nvapi_lite_stereo.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/nvapi/nvapi_lite_stereo.h -------------------------------------------------------------------------------- /compat/nvapi/nvapi_lite_surround.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/nvapi/nvapi_lite_surround.h -------------------------------------------------------------------------------- /compat/nvapi/x86/nvapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/nvapi/x86/nvapi.lib -------------------------------------------------------------------------------- /compat/pthreads/pthread_barrier.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Meant to improve clang 4 / macos compatibility (untested) 3 | */ 4 | 5 | #ifndef PTHREAD_BARRIER_H_ 6 | #define PTHREAD_BARRIER_H_ 7 | 8 | #include 9 | #include 10 | 11 | typedef int pthread_barrierattr_t; 12 | typedef struct 13 | { 14 | pthread_mutex_t mutex; 15 | pthread_cond_t cond; 16 | int count; 17 | int tripCount; 18 | } pthread_barrier_t; 19 | 20 | 21 | int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count) 22 | { 23 | if(count == 0) 24 | { 25 | errno = EINVAL; 26 | return -1; 27 | } 28 | if(pthread_mutex_init(&barrier->mutex, 0) < 0) 29 | { 30 | return -1; 31 | } 32 | if(pthread_cond_init(&barrier->cond, 0) < 0) 33 | { 34 | pthread_mutex_destroy(&barrier->mutex); 35 | return -1; 36 | } 37 | barrier->tripCount = count; 38 | barrier->count = 0; 39 | 40 | return 0; 41 | } 42 | 43 | int pthread_barrier_destroy(pthread_barrier_t *barrier) 44 | { 45 | pthread_cond_destroy(&barrier->cond); 46 | pthread_mutex_destroy(&barrier->mutex); 47 | return 0; 48 | } 49 | 50 | int pthread_barrier_wait(pthread_barrier_t *barrier) 51 | { 52 | pthread_mutex_lock(&barrier->mutex); 53 | ++(barrier->count); 54 | if(barrier->count >= barrier->tripCount) 55 | { 56 | barrier->count = 0; 57 | pthread_cond_broadcast(&barrier->cond); 58 | pthread_mutex_unlock(&barrier->mutex); 59 | return 1; 60 | } 61 | else 62 | { 63 | pthread_cond_wait(&barrier->cond, &(barrier->mutex)); 64 | pthread_mutex_unlock(&barrier->mutex); 65 | return 0; 66 | } 67 | } 68 | 69 | #endif // PTHREAD_BARRIER_H_ 70 | -------------------------------------------------------------------------------- /compat/pthreads/x64/pthreadVC2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/pthreads/x64/pthreadVC2.lib -------------------------------------------------------------------------------- /compat/pthreads/x86/pthreadVC2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/compat/pthreads/x86/pthreadVC2.lib -------------------------------------------------------------------------------- /compat/stdbool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define false 0 4 | #define true 1 5 | 6 | #define bool int 7 | -------------------------------------------------------------------------------- /compat/sys/time.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef __cplusplus 3 | extern "C" 4 | { 5 | #endif 6 | int gettimeofday(struct timeval *tv, struct timezone *tz); 7 | void usleep(__int64 usec); 8 | #ifdef __cplusplus 9 | } 10 | #endif 11 | typedef __int64 useconds_t; 12 | -------------------------------------------------------------------------------- /compat/unistd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "getopt/getopt.h" -------------------------------------------------------------------------------- /compat/winansi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ANSI emulation wrappers 3 | */ 4 | #ifdef WIN32 5 | #include 6 | #include 7 | #include 8 | 9 | #define isatty(fd) _isatty(fd) 10 | #define fileno(fd) _fileno(fd) 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | int winansi_fputs(const char *str, FILE *stream); 16 | int winansi_printf(const char *format, ...); 17 | int winansi_fprintf(FILE *stream, const char *format, ...); 18 | int winansi_vfprintf(FILE *stream, const char *format, va_list list); 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #undef fputs 24 | #undef fprintf 25 | #undef vfprintf 26 | 27 | #define fputs winansi_fputs 28 | #define printf winansi_printf 29 | #define fprintf winansi_fprintf 30 | #define vfprintf winansi_vfprintf 31 | 32 | #endif -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT([ccminer], [2.2], [], [ccminer], [http://github.com/tpruvot/ccminer]) 2 | 3 | AC_PREREQ([2.59c]) 4 | AC_CANONICAL_SYSTEM 5 | AC_CONFIG_SRCDIR([ccminer.cpp]) 6 | AM_INIT_AUTOMAKE([foreign subdir-objects]) 7 | AC_CONFIG_HEADERS([ccminer-config.h]) 8 | 9 | dnl Make sure anyone changing configure.ac/Makefile.am has a clue 10 | AM_MAINTAINER_MODE 11 | 12 | dnl Checks for programs 13 | AC_PROG_CC_C99 14 | AC_PROG_GCC_TRADITIONAL 15 | AM_PROG_CC_C_O 16 | AM_PROG_AS 17 | AC_PROG_RANLIB 18 | AC_PROG_CXX 19 | AC_OPENMP 20 | 21 | dnl Checks for header files 22 | AC_HEADER_STDC 23 | AC_CHECK_HEADERS([sys/endian.h sys/param.h syslog.h]) 24 | # sys/sysctl.h requires sys/types.h on FreeBSD 25 | # sys/sysctl.h requires sys/param.h on OpenBSD 26 | AC_CHECK_HEADERS([sys/sysctl.h], [], [], 27 | [#include 28 | #ifdef HAVE_SYS_PARAM_H 29 | #include 30 | #endif 31 | ]) 32 | 33 | AC_CHECK_DECLS([be32dec, le32dec, be32enc, le32enc], [], [], 34 | [AC_INCLUDES_DEFAULT 35 | #ifdef HAVE_SYS_ENDIAN_H 36 | #include 37 | #endif 38 | ]) 39 | 40 | AC_FUNC_ALLOCA 41 | AC_CHECK_FUNCS([getopt_long]) 42 | 43 | case $target in 44 | i*86-*-*) 45 | have_x86=true 46 | ;; 47 | x86_64-*-*) 48 | have_x86=true 49 | have_x86_64=true 50 | ;; 51 | amd64-*-*) 52 | have_x86=true 53 | have_x86_64=true 54 | ;; 55 | esac 56 | 57 | PTHREAD_FLAGS="-pthread" 58 | WS2_LIBS="" 59 | 60 | case $target in 61 | *-*-mingw*) 62 | have_win32=true 63 | PTHREAD_FLAGS="" 64 | WS2_LIBS="-lws2_32" 65 | ;; 66 | *86*-apple-darwin*) 67 | have_osx=true 68 | PTHREAD_FLAGS="" 69 | ;; 70 | esac 71 | 72 | AC_CHECK_LIB(jansson, json_loads, request_jansson=false, request_jansson=true) 73 | AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS="-lpthread", 74 | AC_CHECK_LIB([pthreadGC2], [pthread_create], PTHREAD_LIBS="-lpthreadGC2", 75 | AC_CHECK_LIB([pthreadGC1], [pthread_create], PTHREAD_LIBS="-lpthreadGC1", 76 | AC_CHECK_LIB([pthreadGC], [pthread_create], PTHREAD_LIBS="-lpthreadGC" 77 | )))) 78 | 79 | AC_CHECK_LIB([z],[gzopen], [], []) 80 | AC_CHECK_LIB([ssl],[SSL_library_init], [], [AC_MSG_ERROR([OpenSSL library required])]) 81 | AC_CHECK_LIB([crypto],[EVP_DigestFinal_ex], [], [AC_MSG_ERROR([OpenSSL library required])]) 82 | 83 | AM_CONDITIONAL([WANT_JANSSON], [test x$request_jansson = xtrue]) 84 | AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue]) 85 | AM_CONDITIONAL([HAVE_OSX], [test x$have_osx = xtrue]) 86 | AM_CONDITIONAL([ARCH_x86], [test x$have_x86 = xtrue]) 87 | AM_CONDITIONAL([ARCH_x86_64], [test x$have_x86_64 = xtrue]) 88 | 89 | if test x$request_jansson = xtrue 90 | then 91 | JANSSON_LIBS="compat/jansson/libjansson.a" 92 | else 93 | JANSSON_LIBS=-ljansson 94 | fi 95 | 96 | LIBCURL_CHECK_CONFIG(, 7.15.2, , 97 | [AC_MSG_ERROR([Missing required libcurl >= 7.15.2])]) 98 | 99 | AC_SUBST(JANSSON_LIBS) 100 | AC_SUBST(PTHREAD_FLAGS) 101 | AC_SUBST(PTHREAD_LIBS) 102 | AC_SUBST(WS2_LIBS) 103 | 104 | AC_CONFIG_FILES([ 105 | Makefile 106 | compat/Makefile 107 | compat/jansson/Makefile 108 | ]) 109 | 110 | dnl find out what version we are running 111 | ARCH=`uname -m` 112 | if [[ $ARCH == "x86_64" ]]; 113 | then 114 | SUFFIX="64" 115 | else 116 | SUFFIX="" 117 | fi 118 | 119 | if test x$have_osx = xtrue 120 | then 121 | SUFFIX="" 122 | fi 123 | 124 | dnl Setup CUDA paths 125 | AC_ARG_WITH([cuda], 126 | [ --with-cuda=PATH prefix where cuda is installed [default=/usr/local/cuda]]) 127 | 128 | AC_ARG_WITH([nvml], 129 | [ --with-nvml=PATH prefix where libnvml is installed [default=/usr/lib]]) 130 | 131 | AM_CONDITIONAL([HAVE_NVML], [test -n "$with_nvml"]) 132 | 133 | NVCC="nvcc" 134 | 135 | if test -n "$with_cuda" ; then 136 | CUDA_INCLUDES="-I$with_cuda/include" 137 | CUDA_LIBS="-lcudart" 138 | CUDA_LDFLAGS="-L$with_cuda/lib$SUFFIX" 139 | if test -x "$with_cuda/bin/nvcc" ; then 140 | NVCC="$with_cuda/bin/nvcc" 141 | fi 142 | else 143 | CUDA_INCLUDES="-I/usr/local/cuda/include" 144 | CUDA_LIBS="-lcudart -static-libstdc++" 145 | CUDA_LDFLAGS="-L/usr/local/cuda/lib$SUFFIX" 146 | fi 147 | 148 | if test -n "$with_nvml" ; then 149 | NVML_LIBPATH=$with_nvml 150 | CUDA_LDFLAGS="$CUDA_LDFLAGS -ldl" 151 | fi 152 | AC_SUBST(NVML_LIBPATH) 153 | 154 | AC_SUBST(CUDA_CFLAGS) 155 | AC_SUBST(CUDA_INCLUDES) 156 | AC_SUBST(CUDA_LIBS) 157 | AC_SUBST(CUDA_LDFLAGS) 158 | AC_SUBST(NVCC) 159 | 160 | AC_SUBST(OPENMP_CFLAGS) 161 | 162 | AC_OUTPUT 163 | -------------------------------------------------------------------------------- /configure.sh: -------------------------------------------------------------------------------- 1 | # To change the cuda arch, edit Makefile.am and run ./build.sh 2 | 3 | extracflags="-march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16" 4 | 5 | CUDA_CFLAGS="-O3 -lineno -Xcompiler -Wall -D_FORCE_INLINES" \ 6 | ./configure CXXFLAGS="-O3 $extracflags" --with-cuda=/usr/local/cuda --with-nvml=libnvidia-ml.so 7 | 8 | -------------------------------------------------------------------------------- /crypto/cpu/c_keccak.c: -------------------------------------------------------------------------------- 1 | // keccak.c 2 | // 19-Nov-11 Markku-Juhani O. Saarinen 3 | // A baseline Keccak (3rd round) implementation. 4 | 5 | #include "c_keccak.h" 6 | 7 | const uint64_t keccakf_rndc[24] = 8 | { 9 | 0x0000000000000001, 0x0000000000008082, 0x800000000000808a, 10 | 0x8000000080008000, 0x000000000000808b, 0x0000000080000001, 11 | 0x8000000080008081, 0x8000000000008009, 0x000000000000008a, 12 | 0x0000000000000088, 0x0000000080008009, 0x000000008000000a, 13 | 0x000000008000808b, 0x800000000000008b, 0x8000000000008089, 14 | 0x8000000000008003, 0x8000000000008002, 0x8000000000000080, 15 | 0x000000000000800a, 0x800000008000000a, 0x8000000080008081, 16 | 0x8000000000008080, 0x0000000080000001, 0x8000000080008008 17 | }; 18 | 19 | const int keccakf_rotc[24] = 20 | { 21 | 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14, 22 | 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44 23 | }; 24 | 25 | const int keccakf_piln[24] = 26 | { 27 | 10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4, 28 | 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1 29 | }; 30 | 31 | // update the state with given number of rounds 32 | 33 | void keccakf(uint64_t st[25], int rounds) 34 | { 35 | int i, j, round; 36 | uint64_t t, bc[5]; 37 | 38 | for (round = 0; round < rounds; ++round) { 39 | 40 | // Theta 41 | bc[0] = st[0] ^ st[5] ^ st[10] ^ st[15] ^ st[20]; 42 | bc[1] = st[1] ^ st[6] ^ st[11] ^ st[16] ^ st[21]; 43 | bc[2] = st[2] ^ st[7] ^ st[12] ^ st[17] ^ st[22]; 44 | bc[3] = st[3] ^ st[8] ^ st[13] ^ st[18] ^ st[23]; 45 | bc[4] = st[4] ^ st[9] ^ st[14] ^ st[19] ^ st[24]; 46 | 47 | for (i = 0; i < 5; ++i) { 48 | t = bc[(i + 4) % 5] ^ ROTL64(bc[(i + 1) % 5], 1); 49 | st[i ] ^= t; 50 | st[i + 5] ^= t; 51 | st[i + 10] ^= t; 52 | st[i + 15] ^= t; 53 | st[i + 20] ^= t; 54 | } 55 | 56 | // Rho Pi 57 | t = st[1]; 58 | for (i = 0; i < 24; ++i) { 59 | bc[0] = st[keccakf_piln[i]]; 60 | st[keccakf_piln[i]] = ROTL64(t, keccakf_rotc[i]); 61 | t = bc[0]; 62 | } 63 | 64 | // Chi 65 | for (j = 0; j < 25; j += 5) { 66 | bc[0] = st[j ]; 67 | bc[1] = st[j + 1]; 68 | bc[2] = st[j + 2]; 69 | bc[3] = st[j + 3]; 70 | bc[4] = st[j + 4]; 71 | st[j ] ^= (~bc[1]) & bc[2]; 72 | st[j + 1] ^= (~bc[2]) & bc[3]; 73 | st[j + 2] ^= (~bc[3]) & bc[4]; 74 | st[j + 3] ^= (~bc[4]) & bc[0]; 75 | st[j + 4] ^= (~bc[0]) & bc[1]; 76 | } 77 | 78 | // Iota 79 | st[0] ^= keccakf_rndc[round]; 80 | } 81 | } 82 | 83 | // compute a keccak hash (md) of given byte length from "in" 84 | typedef uint64_t state_t[25]; 85 | 86 | int keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen) 87 | { 88 | state_t st; 89 | uint8_t temp[144]; 90 | int i, rsiz, rsizw; 91 | 92 | rsiz = sizeof(state_t) == mdlen ? HASH_DATA_AREA : 200 - 2 * mdlen; 93 | rsizw = rsiz / 8; 94 | 95 | memset(st, 0, sizeof(st)); 96 | 97 | for ( ; inlen >= rsiz; inlen -= rsiz, in += rsiz) { 98 | for (i = 0; i < rsizw; i++) 99 | st[i] ^= ((uint64_t *) in)[i]; 100 | keccakf(st, KECCAK_ROUNDS); 101 | } 102 | 103 | // last block and padding 104 | memcpy(temp, in, inlen); 105 | temp[inlen++] = 1; 106 | memset(temp + inlen, 0, rsiz - inlen); 107 | temp[rsiz - 1] |= 0x80; 108 | 109 | for (i = 0; i < rsizw; i++) 110 | st[i] ^= ((uint64_t *) temp)[i]; 111 | 112 | keccakf(st, KECCAK_ROUNDS); 113 | 114 | memcpy(md, st, mdlen); 115 | 116 | return 0; 117 | } 118 | 119 | void keccak1600(const uint8_t *in, int inlen, uint8_t *md) 120 | { 121 | keccak(in, inlen, md, sizeof(state_t)); 122 | } 123 | -------------------------------------------------------------------------------- /crypto/cpu/c_keccak.h: -------------------------------------------------------------------------------- 1 | // keccak.h 2 | // 19-Nov-11 Markku-Juhani O. Saarinen 3 | 4 | #ifndef KECCAK_H 5 | #define KECCAK_H 6 | 7 | #include 8 | #include 9 | 10 | #ifndef KECCAK_ROUNDS 11 | #define KECCAK_ROUNDS 24 12 | #endif 13 | 14 | #ifndef ROTL64 15 | #define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y)))) 16 | #endif 17 | 18 | #ifndef HASH_SIZE 19 | #define HASH_SIZE 32 20 | #endif 21 | 22 | #ifndef HASH_DATA_AREA 23 | #define HASH_DATA_AREA 136 24 | #endif 25 | 26 | // compute a keccak hash (md) of given byte length from "in" 27 | int keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen); 28 | 29 | // update the state 30 | void keccakf(uint64_t st[25], int norounds); 31 | 32 | void keccak1600(const uint8_t *in, int inlen, uint8_t *md); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /crypto/mman.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #include "mman.h" 7 | 8 | #ifndef FILE_MAP_EXECUTE 9 | #define FILE_MAP_EXECUTE 0x0020 10 | #endif /* FILE_MAP_EXECUTE */ 11 | 12 | static int __map_mman_error(const DWORD err, const int deferr) 13 | { 14 | if (err == 0) 15 | return 0; 16 | //TODO: implement 17 | return err; 18 | } 19 | 20 | static DWORD __map_mmap_prot_page(const int prot) 21 | { 22 | DWORD protect = 0; 23 | 24 | if (prot == PROT_NONE) 25 | return protect; 26 | 27 | if ((prot & PROT_EXEC) != 0) 28 | { 29 | protect = ((prot & PROT_WRITE) != 0) ? 30 | PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ; 31 | } 32 | else 33 | { 34 | protect = ((prot & PROT_WRITE) != 0) ? 35 | PAGE_READWRITE : PAGE_READONLY; 36 | } 37 | 38 | return protect; 39 | } 40 | 41 | static DWORD __map_mmap_prot_file(const int prot) 42 | { 43 | DWORD desiredAccess = 0; 44 | 45 | if (prot == PROT_NONE) 46 | return desiredAccess; 47 | 48 | if ((prot & PROT_READ) != 0) 49 | desiredAccess |= FILE_MAP_READ; 50 | if ((prot & PROT_WRITE) != 0) 51 | desiredAccess |= FILE_MAP_WRITE; 52 | if ((prot & PROT_EXEC) != 0) 53 | desiredAccess |= FILE_MAP_EXECUTE; 54 | 55 | return desiredAccess; 56 | } 57 | 58 | void* mmap(void *addr, size_t len, int prot, int flags, int fildes, OffsetType off) 59 | { 60 | HANDLE fm, h; 61 | 62 | void * map = MAP_FAILED; 63 | 64 | #ifdef _MSC_VER 65 | #pragma warning(push) 66 | #pragma warning(disable: 4293) 67 | #endif 68 | 69 | const DWORD dwFileOffsetLow = (sizeof(OffsetType) <= sizeof(DWORD)) ? 70 | (DWORD)off : (DWORD)(off & 0xFFFFFFFFL); 71 | const DWORD dwFileOffsetHigh = (sizeof(OffsetType) <= sizeof(DWORD)) ? 72 | (DWORD)0 : (DWORD)((off >> 32) & 0xFFFFFFFFL); 73 | const DWORD protect = __map_mmap_prot_page(prot); 74 | const DWORD desiredAccess = __map_mmap_prot_file(prot); 75 | 76 | const OffsetType maxSize = off + (OffsetType)len; 77 | 78 | const DWORD dwMaxSizeLow = (sizeof(OffsetType) <= sizeof(DWORD)) ? 79 | (DWORD)maxSize : (DWORD)(maxSize & 0xFFFFFFFFL); 80 | const DWORD dwMaxSizeHigh = (sizeof(OffsetType) <= sizeof(DWORD)) ? 81 | (DWORD)0 : (DWORD)((maxSize >> 32) & 0xFFFFFFFFL); 82 | 83 | #ifdef _MSC_VER 84 | #pragma warning(pop) 85 | #endif 86 | 87 | errno = 0; 88 | 89 | if (len == 0 90 | /* Unsupported flag combinations */ 91 | || (flags & MAP_FIXED) != 0 92 | /* Usupported protection combinations */ 93 | || prot == PROT_EXEC) 94 | { 95 | errno = EINVAL; 96 | return MAP_FAILED; 97 | } 98 | 99 | h = ((flags & MAP_ANONYMOUS) == 0) ? 100 | (HANDLE)_get_osfhandle(fildes) : INVALID_HANDLE_VALUE; 101 | 102 | if ((flags & MAP_ANONYMOUS) == 0 && h == INVALID_HANDLE_VALUE) 103 | { 104 | errno = EBADF; 105 | return MAP_FAILED; 106 | } 107 | 108 | fm = CreateFileMapping(h, NULL, protect, dwMaxSizeHigh, dwMaxSizeLow, NULL); 109 | 110 | if (fm == NULL) 111 | { 112 | errno = __map_mman_error(GetLastError(), EPERM); 113 | return MAP_FAILED; 114 | } 115 | 116 | map = MapViewOfFile(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len); 117 | 118 | CloseHandle(fm); 119 | 120 | if (map == NULL) 121 | { 122 | errno = __map_mman_error(GetLastError(), EPERM); 123 | return MAP_FAILED; 124 | } 125 | 126 | return map; 127 | } 128 | 129 | int munmap(void *addr, size_t len) 130 | { 131 | if (UnmapViewOfFile(addr)) 132 | return 0; 133 | 134 | errno = __map_mman_error(GetLastError(), EPERM); 135 | 136 | return -1; 137 | } 138 | 139 | int _mprotect(void *addr, size_t len, int prot) 140 | { 141 | DWORD newProtect = __map_mmap_prot_page(prot); 142 | DWORD oldProtect = 0; 143 | 144 | if (VirtualProtect(addr, len, newProtect, &oldProtect)) 145 | return 0; 146 | 147 | errno = __map_mman_error(GetLastError(), EPERM); 148 | 149 | return -1; 150 | } 151 | 152 | int msync(void *addr, size_t len, int flags) 153 | { 154 | if (FlushViewOfFile(addr, len)) 155 | return 0; 156 | 157 | errno = __map_mman_error(GetLastError(), EPERM); 158 | 159 | return -1; 160 | } 161 | 162 | int mlock(const void *addr, size_t len) 163 | { 164 | if (VirtualLock((LPVOID)addr, len)) 165 | return 0; 166 | 167 | errno = __map_mman_error(GetLastError(), EPERM); 168 | 169 | return -1; 170 | } 171 | 172 | int munlock(const void *addr, size_t len) 173 | { 174 | if (VirtualUnlock((LPVOID)addr, len)) 175 | return 0; 176 | 177 | errno = __map_mman_error(GetLastError(), EPERM); 178 | 179 | return -1; 180 | } -------------------------------------------------------------------------------- /crypto/mman.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/mman.h 3 | * mman-win32 4 | */ 5 | 6 | #ifndef _SYS_MMAN_H_ 7 | #define _SYS_MMAN_H_ 8 | 9 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 10 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 11 | #endif 12 | 13 | /* All the headers include this file. */ 14 | #ifndef _MSC_VER 15 | #include <_mingw.h> 16 | #endif 17 | 18 | /* Determine offset type */ 19 | #include 20 | #if defined(_WIN64) 21 | typedef int64_t OffsetType; 22 | #else 23 | typedef uint32_t OffsetType; 24 | #endif 25 | 26 | #include 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | #define PROT_NONE 0 33 | #define PROT_READ 1 34 | #define PROT_WRITE 2 35 | #define PROT_EXEC 4 36 | 37 | #define MAP_FILE 0 38 | #define MAP_SHARED 1 39 | #define MAP_PRIVATE 2 40 | #define MAP_TYPE 0xf 41 | #define MAP_FIXED 0x10 42 | #define MAP_ANONYMOUS 0x20 43 | #define MAP_ANON MAP_ANONYMOUS 44 | 45 | #define MAP_FAILED ((void *)-1) 46 | 47 | /* Flags for msync. */ 48 | #define MS_ASYNC 1 49 | #define MS_SYNC 2 50 | #define MS_INVALIDATE 4 51 | 52 | void* mmap(void *addr, size_t len, int prot, int flags, int fildes, OffsetType off); 53 | int munmap(void *addr, size_t len); 54 | int _mprotect(void *addr, size_t len, int prot); 55 | int msync(void *addr, size_t len, int flags); 56 | int mlock(const void *addr, size_t len); 57 | int munlock(const void *addr, size_t len); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif /* _SYS_MMAN_H_ */ 64 | -------------------------------------------------------------------------------- /crypto/oaes_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * --------------------------------------------------------------------------- 3 | * OpenAES License 4 | * --------------------------------------------------------------------------- 5 | * Copyright (c) 2012, Nabil S. Al Ramli, www.nalramli.com 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * - Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * - Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | * POSSIBILITY OF SUCH DAMAGE. 28 | * --------------------------------------------------------------------------- 29 | */ 30 | 31 | #ifndef _OAES_CONFIG_H 32 | #define _OAES_CONFIG_H 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | //#ifndef OAES_HAVE_ISAAC 39 | //#define OAES_HAVE_ISAAC 1 40 | //#endif // OAES_HAVE_ISAAC 41 | 42 | //#ifndef OAES_DEBUG 43 | //#define OAES_DEBUG 0 44 | //#endif // OAES_DEBUG 45 | //#define OAES_DEBUG 1 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif // _OAES_CONFIG_H 52 | -------------------------------------------------------------------------------- /crypto/wildkeccak.h: -------------------------------------------------------------------------------- 1 | 2 | #define WILD_KECCAK_SCRATCHPAD_BUFFSIZE 1ULL << 29 3 | #define WILD_KECCAK_ADDENDUMS_ARRAY_SIZE 10 4 | 5 | extern uint64_t scratchpad_size; 6 | 7 | extern uint32_t WK_CUDABlocks, WK_CUDAThreads; 8 | 9 | void wildkeccak_scratchpad_need_update(uint64_t* pscratchpad_buff); 10 | 11 | -------------------------------------------------------------------------------- /crypto/xmr-rpc.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "wildkeccak.h" 5 | 6 | #ifdef WIN32 7 | #define _PACKED _ALIGN(4) 8 | #else 9 | #define _PACKED __attribute__((__packed__)) 10 | #endif 11 | 12 | struct _PACKED scratchpad_hi { 13 | unsigned char prevhash[32]; 14 | uint64_t height; 15 | }; 16 | 17 | struct _PACKED addendums_array_entry { 18 | struct scratchpad_hi prev_hi; 19 | uint64_t add_size; 20 | }; 21 | 22 | 23 | struct _PACKED scratchpad_file_header { 24 | struct scratchpad_hi current_hi; 25 | struct addendums_array_entry add_arr[WILD_KECCAK_ADDENDUMS_ARRAY_SIZE]; 26 | uint64_t scratchpad_size; 27 | }; 28 | 29 | 30 | bool rpc2_job_decode(const json_t *job, struct work *work); 31 | bool rpc2_stratum_job(struct stratum_ctx *sctx, json_t *id, json_t *params); 32 | bool rpc2_stratum_gen_work(struct stratum_ctx *sctx, struct work *work); 33 | bool rpc2_stratum_submit(struct pool_infos *pool, struct work *work); 34 | 35 | int rpc2_stratum_thread_stuff(struct pool_infos* pool); 36 | 37 | bool rpc2_login_decode(const json_t *val); 38 | 39 | void rpc2_init(); 40 | 41 | void GetScratchpad(); 42 | -------------------------------------------------------------------------------- /cuda_debug.cuh: -------------------------------------------------------------------------------- 1 | /** 2 | * Helper to trace gpu computed data with --cputest 3 | * 4 | * Sample usage in an algo scan cuda unit : 5 | * 6 | * #define _DEBUG 7 | * #define _DEBUG_PREFIX "x11-" 8 | * #include "cuda_debug.cuh" 9 | * 10 | * TRACE64("luffa", d_hash); 11 | * or 12 | * TRACE("luffa") 13 | * 14 | * Dont forget to link the scan function in util.cpp (do_gpu_tests) 15 | * 16 | */ 17 | 18 | #include 19 | //#include "cuda_helper.h" 20 | 21 | #ifndef _DEBUG_PREFIX 22 | #define _DEBUG_PREFIX "" 23 | #endif 24 | 25 | #ifdef _DEBUG 26 | #define TRACE64(algo, d_buf) { \ 27 | if (max_nonce == 1 && pdata[19] <= 1 && !opt_benchmark) { \ 28 | uint32_t oft = 0; \ 29 | uint32_t* debugbuf = NULL; \ 30 | cudaMallocHost(&debugbuf, 16*sizeof(uint32_t)); \ 31 | cudaMemcpy(debugbuf, d_buf[thr_id] + oft, 16*sizeof(uint32_t), cudaMemcpyDeviceToHost); \ 32 | printf(_DEBUG_PREFIX "%s %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x\n", \ 33 | algo, \ 34 | swab32(debugbuf[0]), swab32(debugbuf[1]), swab32(debugbuf[2]), swab32(debugbuf[3]), \ 35 | swab32(debugbuf[4]), swab32(debugbuf[5]), swab32(debugbuf[6]), swab32(debugbuf[7]), \ 36 | swab32(debugbuf[8]), swab32(debugbuf[9]), swab32(debugbuf[10]),swab32(debugbuf[11]), \ 37 | swab32(debugbuf[12]),swab32(debugbuf[13]),swab32(debugbuf[14]),swab32(debugbuf[15])); \ 38 | cudaFreeHost(debugbuf); \ 39 | } \ 40 | } 41 | #else 42 | #define TRACE64(algo, d_buf) {} 43 | #endif 44 | 45 | // simplified default 46 | #define TRACE(algo) TRACE64(algo, d_hash) 47 | 48 | -------------------------------------------------------------------------------- /cuda_fugue256.h: -------------------------------------------------------------------------------- 1 | #ifndef _CUDA_FUGUE256_H 2 | #define _CUDA_FUGUE256_H 3 | 4 | void fugue256_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, void *outputHashes, uint32_t *nounce); 5 | void fugue256_cpu_setBlock(int thr_id, void *data, void *pTargetIn); 6 | void fugue256_cpu_init(int thr_id, uint32_t threads); 7 | void fugue256_cpu_free(int thr_id); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /cuda_groestlcoin.h: -------------------------------------------------------------------------------- 1 | #ifndef _CUDA_GROESTLCOIN_H 2 | #define _CUDA_GROESTLCOIN_H 3 | 4 | void groestlcoin_cpu_init(int thr_id, uint32_t threads); 5 | void groestlcoin_cpu_free(int thr_id); 6 | void groestlcoin_cpu_setBlock(int thr_id, void *data, void *pTargetIn); 7 | void groestlcoin_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *resNonce); 8 | 9 | #endif -------------------------------------------------------------------------------- /cuda_helper.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/cuda_helper.h -------------------------------------------------------------------------------- /cuda_vector_uint2x4.h: -------------------------------------------------------------------------------- 1 | #ifndef CUDA_VECTOR_UINT2x4_H 2 | #define CUDA_VECTOR_UINT2x4_H 3 | 4 | /////////////////////////////////////////////////////////////////////////////////// 5 | #if (defined(_MSC_VER) && defined(_WIN64)) || defined(__LP64__) 6 | #define __LDG_PTR "l" 7 | #else 8 | #define __LDG_PTR "r" 9 | #endif 10 | 11 | #include "cuda_helper.h" 12 | 13 | typedef struct __align__(16) uint2x4 { 14 | uint2 x, y, z, w; 15 | } uint2x4; 16 | 17 | 18 | static __inline__ __device__ uint2x4 make_uint2x4(uint2 s0, uint2 s1, uint2 s2, uint2 s3) 19 | { 20 | uint2x4 t; 21 | t.x = s0; t.y = s1; t.z = s2; t.w = s3; 22 | return t; 23 | } 24 | 25 | static __forceinline__ __device__ uint2x4 operator^ (const uint2x4 &a, const uint2x4 &b) { 26 | return make_uint2x4(a.x ^ b.x, a.y ^ b.y, a.z ^ b.z, a.w ^ b.w); 27 | } 28 | 29 | static __forceinline__ __device__ uint2x4 operator+ (const uint2x4 &a, const uint2x4 &b) { 30 | return make_uint2x4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); 31 | } 32 | 33 | ///////////////////////// 34 | 35 | static __forceinline__ __device__ void operator^= (uint2x4 &a, const uint2x4 &b) { a = a ^ b; } 36 | static __forceinline__ __device__ void operator+= (uint2x4 &a, const uint2x4 &b) { a = a + b; } 37 | 38 | #if __CUDA_ARCH__ >= 320 39 | 40 | static __device__ __inline__ uint2x4 __ldg4(const uint2x4 *ptr) 41 | { 42 | uint2x4 ret; 43 | asm("ld.global.nc.v4.u32 {%0,%1,%2,%3}, [%4];" : "=r"(ret.x.x), "=r"(ret.x.y), "=r"(ret.y.x), "=r"(ret.y.y) : __LDG_PTR(ptr)); 44 | asm("ld.global.nc.v4.u32 {%0,%1,%2,%3}, [%4+16];" : "=r"(ret.z.x), "=r"(ret.z.y), "=r"(ret.w.x), "=r"(ret.w.y) : __LDG_PTR(ptr)); 45 | return ret; 46 | } 47 | 48 | static __device__ __inline__ void ldg4(const uint2x4 *ptr, uint2x4 *ret) 49 | { 50 | asm("ld.global.nc.v4.u32 {%0,%1,%2,%3}, [%4];" : "=r"(ret[0].x.x), "=r"(ret[0].x.y), "=r"(ret[0].y.x), "=r"(ret[0].y.y) : __LDG_PTR(ptr)); 51 | asm("ld.global.nc.v4.u32 {%0,%1,%2,%3}, [%4+16];" : "=r"(ret[0].z.x), "=r"(ret[0].z.y), "=r"(ret[0].w.x), "=r"(ret[0].w.y) : __LDG_PTR(ptr)); 52 | asm("ld.global.nc.v4.u32 {%0,%1,%2,%3}, [%4+32];" : "=r"(ret[1].x.x), "=r"(ret[1].x.y), "=r"(ret[1].y.x), "=r"(ret[1].y.y) : __LDG_PTR(ptr)); 53 | asm("ld.global.nc.v4.u32 {%0,%1,%2,%3}, [%4+48];" : "=r"(ret[1].z.x), "=r"(ret[1].z.y), "=r"(ret[1].w.x), "=r"(ret[1].w.y) : __LDG_PTR(ptr)); 54 | asm("ld.global.nc.v4.u32 {%0,%1,%2,%3}, [%4+64];" : "=r"(ret[2].x.x), "=r"(ret[2].x.y), "=r"(ret[2].y.x), "=r"(ret[2].y.y) : __LDG_PTR(ptr)); 55 | asm("ld.global.nc.v4.u32 {%0,%1,%2,%3}, [%4+80];" : "=r"(ret[2].z.x), "=r"(ret[2].z.y), "=r"(ret[2].w.x), "=r"(ret[2].w.y) : __LDG_PTR(ptr)); 56 | } 57 | #elif !defined(__ldg4) 58 | #define __ldg4(x) (*(x)) 59 | #define ldg4(ptr, ret) { *(ret) = (*(ptr)); } 60 | #endif 61 | 62 | #endif // H 63 | -------------------------------------------------------------------------------- /cuda_vectors.h: -------------------------------------------------------------------------------- 1 | #include "cuda_helper.h" 2 | 3 | /* Macros for uint2 operations (used by skein) */ 4 | 5 | __device__ __forceinline__ 6 | uint2 ROR8(const uint2 a) { 7 | uint2 result; 8 | result.x = __byte_perm(a.x, a.y, 0x4321); 9 | result.y = __byte_perm(a.y, a.x, 0x4321); 10 | return result; 11 | } 12 | 13 | __device__ __forceinline__ 14 | uint2 ROL24(const uint2 a) { 15 | uint2 result; 16 | result.x = __byte_perm(a.x, a.y, 0x0765); 17 | result.y = __byte_perm(a.y, a.x, 0x0765); 18 | return result; 19 | } 20 | 21 | static __device__ __forceinline__ uint2 operator+ (const uint2 a, const uint32_t b) 22 | { 23 | #if 0 && defined(__CUDA_ARCH__) && CUDA_VERSION < 7000 24 | uint2 result; 25 | asm( 26 | "add.cc.u32 %0,%2,%4; \n\t" 27 | "addc.u32 %1,%3,%5; \n\t" 28 | : "=r"(result.x), "=r"(result.y) : "r"(a.x), "r"(a.y), "r"(b), "r"(0)); 29 | return result; 30 | #else 31 | return vectorize(devectorize(a) + b); 32 | #endif 33 | } 34 | 35 | /* whirlpool ones */ 36 | #ifdef __CUDA_ARCH__ 37 | __device__ __forceinline__ 38 | uint2 ROL16(const uint2 a) { 39 | uint2 result; 40 | result.x = __byte_perm(a.x, a.y, 0x1076); 41 | result.y = __byte_perm(a.y, a.x, 0x1076); 42 | return result; 43 | } 44 | #else 45 | #define ROL16(a) make_uint2(a.x, a.y) /* bad, just to define it */ 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /equi/blake2/blake2-config.h: -------------------------------------------------------------------------------- 1 | /* 2 | BLAKE2 reference source code package - optimized C implementations 3 | 4 | Written in 2012 by Samuel Neves 5 | 6 | To the extent possible under law, the author(s) have dedicated all copyright 7 | and related and neighboring rights to this software to the public domain 8 | worldwide. This software is distributed without any warranty. 9 | 10 | You should have received a copy of the CC0 Public Domain Dedication along with 11 | this software. If not, see . 12 | */ 13 | #pragma once 14 | #ifndef __BLAKE2_CONFIG_H__ 15 | #define __BLAKE2_CONFIG_H__ 16 | 17 | // These don't work everywhere 18 | #if (defined(__SSE2__) || defined(_M_AMD_64) || defined(_M_X64)) 19 | #define HAVE_SSE2 20 | #endif 21 | 22 | #if defined(__SSSE3__) 23 | #define HAVE_SSSE3 24 | #endif 25 | 26 | #if defined(__SSE4_1__) 27 | #define HAVE_SSE41 28 | #endif 29 | 30 | #if defined(__AVX__) 31 | #define HAVE_AVX 32 | #endif 33 | 34 | #if defined(__XOP__) 35 | #define HAVE_XOP 36 | #endif 37 | 38 | 39 | #ifdef HAVE_AVX2 40 | #ifndef HAVE_AVX 41 | #define HAVE_AVX 42 | #endif 43 | #endif 44 | 45 | #ifdef HAVE_XOP 46 | #ifndef HAVE_AVX 47 | #define HAVE_AVX 48 | #endif 49 | #endif 50 | 51 | #ifdef HAVE_AVX 52 | #ifndef HAVE_SSE41 53 | #define HAVE_SSE41 54 | #endif 55 | #endif 56 | 57 | #ifdef HAVE_SSE41 58 | #ifndef HAVE_SSSE3 59 | #define HAVE_SSSE3 60 | #endif 61 | #endif 62 | 63 | #ifdef HAVE_SSSE3 64 | #define HAVE_SSE2 65 | #endif 66 | 67 | #if !defined(HAVE_SSE2) 68 | 69 | #ifdef _MSC_VER 70 | // enforce required stuff for now 71 | #define HAVE_SSE2 72 | //#define HAVE_SSSE3 73 | #define HAVE_SSE41 74 | #else 75 | # error "This code requires at least SSE 4.1" 76 | #endif 77 | 78 | #endif 79 | 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /equi/blake2/blake2-impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | BLAKE2 reference source code package - optimized C implementations 3 | 4 | Written in 2012 by Samuel Neves 5 | 6 | To the extent possible under law, the author(s) have dedicated all copyright 7 | and related and neighboring rights to this software to the public domain 8 | worldwide. This software is distributed without any warranty. 9 | 10 | You should have received a copy of the CC0 Public Domain Dedication along with 11 | this software. If not, see . 12 | */ 13 | #pragma once 14 | #ifndef __BLAKE2_IMPL_H__ 15 | #define __BLAKE2_IMPL_H__ 16 | 17 | #include 18 | 19 | static inline uint32_t load32( const void *src ) 20 | { 21 | #if defined(NATIVE_LITTLE_ENDIAN) 22 | uint32_t w; 23 | memcpy(&w, src, sizeof w); 24 | return w; 25 | #else 26 | const uint8_t *p = ( const uint8_t * )src; 27 | uint32_t w = *p++; 28 | w |= ( uint32_t )( *p++ ) << 8; 29 | w |= ( uint32_t )( *p++ ) << 16; 30 | w |= ( uint32_t )( *p++ ) << 24; 31 | return w; 32 | #endif 33 | } 34 | 35 | static inline uint64_t load64( const void *src ) 36 | { 37 | #if defined(NATIVE_LITTLE_ENDIAN) 38 | uint64_t w; 39 | memcpy(&w, src, sizeof w); 40 | return w; 41 | #else 42 | const uint8_t *p = ( const uint8_t * )src; 43 | uint64_t w = *p++; 44 | w |= ( uint64_t )( *p++ ) << 8; 45 | w |= ( uint64_t )( *p++ ) << 16; 46 | w |= ( uint64_t )( *p++ ) << 24; 47 | w |= ( uint64_t )( *p++ ) << 32; 48 | w |= ( uint64_t )( *p++ ) << 40; 49 | w |= ( uint64_t )( *p++ ) << 48; 50 | w |= ( uint64_t )( *p++ ) << 56; 51 | return w; 52 | #endif 53 | } 54 | 55 | static inline void store32( void *dst, uint32_t w ) 56 | { 57 | #if defined(NATIVE_LITTLE_ENDIAN) 58 | memcpy(dst, &w, sizeof w); 59 | #else 60 | uint8_t *p = ( uint8_t * )dst; 61 | *p++ = ( uint8_t )w; w >>= 8; 62 | *p++ = ( uint8_t )w; w >>= 8; 63 | *p++ = ( uint8_t )w; w >>= 8; 64 | *p++ = ( uint8_t )w; 65 | #endif 66 | } 67 | 68 | static inline void store64( void *dst, uint64_t w ) 69 | { 70 | #if defined(NATIVE_LITTLE_ENDIAN) 71 | memcpy(dst, &w, sizeof w); 72 | #else 73 | uint8_t *p = ( uint8_t * )dst; 74 | *p++ = ( uint8_t )w; w >>= 8; 75 | *p++ = ( uint8_t )w; w >>= 8; 76 | *p++ = ( uint8_t )w; w >>= 8; 77 | *p++ = ( uint8_t )w; w >>= 8; 78 | *p++ = ( uint8_t )w; w >>= 8; 79 | *p++ = ( uint8_t )w; w >>= 8; 80 | *p++ = ( uint8_t )w; w >>= 8; 81 | *p++ = ( uint8_t )w; 82 | #endif 83 | } 84 | 85 | static inline uint64_t load48( const void *src ) 86 | { 87 | const uint8_t *p = ( const uint8_t * )src; 88 | uint64_t w = *p++; 89 | w |= ( uint64_t )( *p++ ) << 8; 90 | w |= ( uint64_t )( *p++ ) << 16; 91 | w |= ( uint64_t )( *p++ ) << 24; 92 | w |= ( uint64_t )( *p++ ) << 32; 93 | w |= ( uint64_t )( *p++ ) << 40; 94 | return w; 95 | } 96 | 97 | static inline void store48( void *dst, uint64_t w ) 98 | { 99 | uint8_t *p = ( uint8_t * )dst; 100 | *p++ = ( uint8_t )w; w >>= 8; 101 | *p++ = ( uint8_t )w; w >>= 8; 102 | *p++ = ( uint8_t )w; w >>= 8; 103 | *p++ = ( uint8_t )w; w >>= 8; 104 | *p++ = ( uint8_t )w; w >>= 8; 105 | *p++ = ( uint8_t )w; 106 | } 107 | 108 | static inline uint32_t rotl32( const uint32_t w, const unsigned c ) 109 | { 110 | return ( w << c ) | ( w >> ( 32 - c ) ); 111 | } 112 | 113 | static inline uint64_t rotl64( const uint64_t w, const unsigned c ) 114 | { 115 | return ( w << c ) | ( w >> ( 64 - c ) ); 116 | } 117 | 118 | static inline uint32_t rotr32( const uint32_t w, const unsigned c ) 119 | { 120 | return ( w >> c ) | ( w << ( 32 - c ) ); 121 | } 122 | 123 | static inline uint64_t rotr64( const uint64_t w, const unsigned c ) 124 | { 125 | return ( w >> c ) | ( w << ( 64 - c ) ); 126 | } 127 | 128 | /* prevents compiler optimizing out memset() */ 129 | static inline void secure_zero_memory( void *v, size_t n ) 130 | { 131 | volatile uint8_t *p = ( volatile uint8_t * )v; 132 | while( n-- ) *p++ = 0; 133 | } 134 | 135 | #endif 136 | 137 | -------------------------------------------------------------------------------- /equi/blake2/blake2-round.h: -------------------------------------------------------------------------------- 1 | #define _mm_roti_epi64(x, c) \ 2 | (-(c) == 32) ? _mm_shuffle_epi32((x), _MM_SHUFFLE(2,3,0,1)) \ 3 | : (-(c) == 24) ? _mm_shuffle_epi8((x), r24) \ 4 | : (-(c) == 16) ? _mm_shuffle_epi8((x), r16) \ 5 | : (-(c) == 63) ? _mm_xor_si128(_mm_srli_epi64((x), -(c)), _mm_add_epi64((x), (x))) \ 6 | : _mm_xor_si128(_mm_srli_epi64((x), -(c)), _mm_slli_epi64((x), 64-(-(c)))) 7 | 8 | #define G1(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \ 9 | row1l = _mm_add_epi64(row1l, row2l); \ 10 | row1h = _mm_add_epi64(row1h, row2h); \ 11 | \ 12 | row4l = _mm_xor_si128(row4l, row1l); \ 13 | row4h = _mm_xor_si128(row4h, row1h); \ 14 | \ 15 | row4l = _mm_roti_epi64(row4l, -32); \ 16 | row4h = _mm_roti_epi64(row4h, -32); \ 17 | \ 18 | row3l = _mm_add_epi64(row3l, row4l); \ 19 | row3h = _mm_add_epi64(row3h, row4h); \ 20 | \ 21 | row2l = _mm_xor_si128(row2l, row3l); \ 22 | row2h = _mm_xor_si128(row2h, row3h); \ 23 | \ 24 | row2l = _mm_roti_epi64(row2l, -24); \ 25 | row2h = _mm_roti_epi64(row2h, -24); \ 26 | 27 | #define G2(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \ 28 | row1l = _mm_add_epi64(row1l, row2l); \ 29 | row1h = _mm_add_epi64(row1h, row2h); \ 30 | \ 31 | row4l = _mm_xor_si128(row4l, row1l); \ 32 | row4h = _mm_xor_si128(row4h, row1h); \ 33 | \ 34 | row4l = _mm_roti_epi64(row4l, -16); \ 35 | row4h = _mm_roti_epi64(row4h, -16); \ 36 | \ 37 | row3l = _mm_add_epi64(row3l, row4l); \ 38 | row3h = _mm_add_epi64(row3h, row4h); \ 39 | \ 40 | row2l = _mm_xor_si128(row2l, row3l); \ 41 | row2h = _mm_xor_si128(row2h, row3h); \ 42 | \ 43 | row2l = _mm_roti_epi64(row2l, -63); \ 44 | row2h = _mm_roti_epi64(row2h, -63); \ 45 | 46 | #define DIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \ 47 | t0 = _mm_alignr_epi8(row2h, row2l, 8); \ 48 | t1 = _mm_alignr_epi8(row2l, row2h, 8); \ 49 | row2l = t0; \ 50 | row2h = t1; \ 51 | \ 52 | t0 = row3l; \ 53 | row3l = row3h; \ 54 | row3h = t0; \ 55 | \ 56 | t0 = _mm_alignr_epi8(row4h, row4l, 8); \ 57 | t1 = _mm_alignr_epi8(row4l, row4h, 8); \ 58 | row4l = t1; \ 59 | row4h = t0; 60 | 61 | #define UNDIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \ 62 | t0 = _mm_alignr_epi8(row2l, row2h, 8); \ 63 | t1 = _mm_alignr_epi8(row2h, row2l, 8); \ 64 | row2l = t0; \ 65 | row2h = t1; \ 66 | \ 67 | t0 = row3l; \ 68 | row3l = row3h; \ 69 | row3h = t0; \ 70 | \ 71 | t0 = _mm_alignr_epi8(row4l, row4h, 8); \ 72 | t1 = _mm_alignr_epi8(row4h, row4l, 8); \ 73 | row4l = t1; \ 74 | row4h = t0; 75 | 76 | #define BLAKE2_ROUND(row1l,row1h,row2l,row2h,row3l,row3h,row4l,row4h) \ 77 | G1(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h); \ 78 | G2(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h); \ 79 | \ 80 | DIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h); \ 81 | \ 82 | G1(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h); \ 83 | G2(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h); \ 84 | \ 85 | UNDIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h); 86 | -------------------------------------------------------------------------------- /equi/blake2/blake2.h: -------------------------------------------------------------------------------- 1 | /* 2 | BLAKE2 reference source code package - optimized C implementations 3 | 4 | Written in 2012 by Samuel Neves 5 | 6 | To the extent possible under law, the author(s) have dedicated all copyright 7 | and related and neighboring rights to this software to the public domain 8 | worldwide. This software is distributed without any warranty. 9 | 10 | You should have received a copy of the CC0 Public Domain Dedication along with 11 | this software. If not, see . 12 | */ 13 | #pragma once 14 | #ifndef __BLAKE2_H__ 15 | #define __BLAKE2_H__ 16 | 17 | #include 18 | #include 19 | 20 | #if defined(_MSC_VER) 21 | #define ALIGN(x) __declspec(align(x)) 22 | #else 23 | #define ALIGN(x) __attribute__ ((__aligned__(x))) 24 | #endif 25 | 26 | #if defined(__cplusplus) 27 | extern "C" { 28 | #endif 29 | 30 | enum blake2b_constant 31 | { 32 | BLAKE2B_BLOCKBYTES = 128, 33 | BLAKE2B_OUTBYTES = 64, 34 | BLAKE2B_KEYBYTES = 64, 35 | BLAKE2B_SALTBYTES = 16, 36 | BLAKE2B_PERSONALBYTES = 16 37 | }; 38 | 39 | #pragma pack(push, 1) 40 | typedef struct __blake2b_param 41 | { 42 | uint8_t digest_length; // 1 43 | uint8_t key_length; // 2 44 | uint8_t fanout; // 3 45 | uint8_t depth; // 4 46 | uint32_t leaf_length; // 8 47 | uint64_t node_offset; // 16 48 | uint8_t node_depth; // 17 49 | uint8_t inner_length; // 18 50 | uint8_t reserved[14]; // 32 51 | uint8_t salt[BLAKE2B_SALTBYTES]; // 48 52 | uint8_t personal[BLAKE2B_PERSONALBYTES]; // 64 53 | } blake2b_param; 54 | 55 | ALIGN( 64 ) typedef struct __blake2b_state 56 | { 57 | uint64_t h[8]; 58 | uint8_t buf[BLAKE2B_BLOCKBYTES]; 59 | uint16_t counter; 60 | uint8_t buflen; 61 | uint8_t lastblock; 62 | } blake2b_state; 63 | 64 | #pragma pack(pop) 65 | 66 | int eq_blake2b_init( blake2b_state *S, const uint8_t outlen ); 67 | int eq_blake2b_init_key( blake2b_state *S, const uint8_t outlen, const void *key, const uint8_t keylen ); 68 | int eq_blake2b_init_param( blake2b_state *S, const blake2b_param *P ); 69 | int eq_blake2b_update( blake2b_state *S, const uint8_t *in, uint64_t inlen ); 70 | int eq_blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen ); 71 | 72 | // Simple API 73 | int eq_blake2b( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen ); 74 | 75 | static inline int eq_blake2( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen ) 76 | { 77 | return eq_blake2b( out, in, key, outlen, inlen, keylen ); 78 | } 79 | 80 | #if defined(__cplusplus) 81 | } 82 | #endif 83 | 84 | #endif 85 | 86 | -------------------------------------------------------------------------------- /equi/eqcuda.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #ifdef WIN32 17 | #define _SNPRINTF _snprintf 18 | #else 19 | #define _SNPRINTF snprintf 20 | #endif 21 | 22 | #ifndef nullptr 23 | #define nullptr NULL 24 | #endif 25 | 26 | #ifdef WIN32 27 | #define rt_error std::runtime_error 28 | #else 29 | class rt_error : public std::runtime_error 30 | { 31 | public: 32 | explicit rt_error(const std::string& str) : std::runtime_error(str) {} 33 | }; 34 | #endif 35 | 36 | #define checkCudaErrors(call) \ 37 | do { \ 38 | cudaError_t err = call; \ 39 | if (cudaSuccess != err) { \ 40 | char errorBuff[512]; \ 41 | _SNPRINTF(errorBuff, sizeof(errorBuff) - 1, \ 42 | "CUDA error '%s' in func '%s' line %d", \ 43 | cudaGetErrorString(err), __FUNCTION__, __LINE__); \ 44 | throw rt_error(errorBuff); \ 45 | } \ 46 | } while (0) 47 | 48 | #define checkCudaDriverErrors(call) \ 49 | do { \ 50 | CUresult err = call; \ 51 | if (CUDA_SUCCESS != err) { \ 52 | char errorBuff[512]; \ 53 | _SNPRINTF(errorBuff, sizeof(errorBuff) - 1, \ 54 | "CUDA error DRIVER: '%d' in func '%s' line %d", \ 55 | err, __FUNCTION__, __LINE__); \ 56 | throw rt_error(errorBuff); \ 57 | } \ 58 | } while (0) 59 | 60 | typedef uint64_t u64; 61 | typedef uint32_t u32; 62 | typedef uint16_t u16; 63 | typedef uint8_t u8; 64 | typedef unsigned char uchar; 65 | 66 | struct packer_default; 67 | struct packer_cantor; 68 | 69 | #define MAXREALSOLS 9 70 | 71 | struct scontainerreal { 72 | u32 sols[MAXREALSOLS][512]; 73 | u32 nsols; 74 | }; 75 | 76 | #if 0 77 | #include 78 | #define fn_solution std::function&, size_t, const unsigned char*)> 79 | #define fn_hashdone std::function 80 | #define fn_cancel std::function 81 | #else 82 | typedef void (*fn_solution)(int thr_id, const std::vector&, size_t, const unsigned char*); 83 | typedef void (*fn_hashdone)(int thr_id); 84 | typedef bool (*fn_cancel)(int thr_id); 85 | #endif 86 | 87 | template struct equi; 88 | 89 | // --------------------------------------------------------------------------------------------------- 90 | 91 | struct eq_cuda_context_interface 92 | { 93 | virtual ~eq_cuda_context_interface(); 94 | 95 | virtual void solve(const char *tequihash_header, 96 | unsigned int tequihash_header_len, 97 | const char* nonce, 98 | unsigned int nonce_len, 99 | fn_cancel cancelf, 100 | fn_solution solutionf, 101 | fn_hashdone hashdonef); 102 | public: 103 | int thread_id; 104 | int device_id; 105 | int throughput; 106 | int totalblocks; 107 | int threadsperblock; 108 | int threadsperblock_digits; 109 | size_t equi_mem_sz; 110 | }; 111 | 112 | // --------------------------------------------------------------------------------------------------- 113 | 114 | template 115 | class eq_cuda_context : public eq_cuda_context_interface 116 | { 117 | equi* device_eq; 118 | scontainerreal* solutions; 119 | CUcontext pctx; 120 | 121 | void solve(const char *tequihash_header, 122 | unsigned int tequihash_header_len, 123 | const char* nonce, 124 | unsigned int nonce_len, 125 | fn_cancel cancelf, 126 | fn_solution solutionf, 127 | fn_hashdone hashdonef); 128 | 129 | public: 130 | eq_cuda_context(int thr_id, int dev_id); 131 | ~eq_cuda_context(); 132 | }; 133 | 134 | // RB, SM, SSM, TPB, PACKER... but any change only here will fail.. 135 | #define CONFIG_MODE_1 9, 1248, 12, 640, packer_cantor 136 | //#define CONFIG_MODE_2 8, 640, 12, 512, packer_default 137 | -------------------------------------------------------------------------------- /equi/equihash.h: -------------------------------------------------------------------------------- 1 | #ifndef EQUIHASH_H 2 | #define EQUIHASH_H 3 | 4 | #include 5 | 6 | // miner nonce "cursor" unique for each thread 7 | #define EQNONCE_OFFSET 30 /* 27:34 */ 8 | 9 | #define WK 9 10 | #define WN 200 11 | //#define CONFIG_MODE_1 9, 1248, 12, 640, packer_cantor /* eqcuda.hpp */ 12 | 13 | extern "C" { 14 | void equi_hash(const void* input, void* output, int len); 15 | int equi_verify_sol(void* const hdr, void* const soln); 16 | bool equi_verify(uint8_t* const hdr, uint8_t* const soln); 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /fuguecoin.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "sph/sph_fugue.h" 6 | 7 | #include "miner.h" 8 | 9 | #include "cuda_fugue256.h" 10 | 11 | #define SWAP32(x) \ 12 | ((((x) << 24) & 0xff000000u) | (((x) << 8) & 0x00ff0000u) | \ 13 | (((x) >> 8) & 0x0000ff00u) | (((x) >> 24) & 0x000000ffu)) 14 | 15 | void fugue256_hash(unsigned char* output, const unsigned char* input, int len) 16 | { 17 | sph_fugue256_context ctx; 18 | 19 | sph_fugue256_init(&ctx); 20 | sph_fugue256(&ctx, input, len); 21 | sph_fugue256_close(&ctx, (void *)output); 22 | } 23 | 24 | static bool init[MAX_GPUS] = { 0 }; 25 | 26 | int scanhash_fugue256(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) 27 | { 28 | uint32_t _ALIGN(64) endiandata[20]; 29 | uint32_t *pdata = work->data; 30 | uint32_t *ptarget = work->target; 31 | uint32_t start_nonce = pdata[19]++; 32 | int intensity = (device_sm[device_map[thr_id]] > 500) ? 22 : 19; 33 | uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity); 34 | if (init[thr_id]) throughput = min(throughput, max_nonce - start_nonce); 35 | 36 | if (opt_benchmark) 37 | ptarget[7] = 0xf; 38 | 39 | // init 40 | if(!init[thr_id]) 41 | { 42 | cudaSetDevice(device_map[thr_id]); 43 | if (opt_cudaschedule == -1 && gpu_threads == 1) { 44 | cudaDeviceReset(); 45 | // reduce cpu usage 46 | cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync); 47 | CUDA_LOG_ERROR(); 48 | } 49 | gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput); 50 | 51 | fugue256_cpu_init(thr_id, throughput); 52 | init[thr_id] = true; 53 | } 54 | 55 | // Endian 56 | for (int kk=0; kk < 20; kk++) 57 | be32enc(&endiandata[kk], pdata[kk]); 58 | 59 | fugue256_cpu_setBlock(thr_id, endiandata, (void*)ptarget); 60 | 61 | do { 62 | // GPU 63 | uint32_t foundNounce = UINT32_MAX; 64 | fugue256_cpu_hash(thr_id, throughput, pdata[19], NULL, &foundNounce); 65 | 66 | *hashes_done = pdata[19] - start_nonce + throughput; 67 | 68 | if (foundNounce < UINT32_MAX && bench_algo < 0) 69 | { 70 | uint32_t vhash[8]; 71 | sph_fugue256_context ctx_fugue; 72 | endiandata[19] = SWAP32(foundNounce); 73 | 74 | sph_fugue256_init(&ctx_fugue); 75 | sph_fugue256 (&ctx_fugue, endiandata, 80); 76 | sph_fugue256_close(&ctx_fugue, &vhash); 77 | 78 | if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) 79 | { 80 | work_set_target_ratio(work, vhash); 81 | pdata[19] = foundNounce; 82 | return 1; 83 | } else { 84 | gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", foundNounce); 85 | } 86 | } 87 | 88 | if ((uint64_t) throughput + pdata[19] >= max_nonce) { 89 | pdata[19] = max_nonce; 90 | break; 91 | } 92 | 93 | pdata[19] += throughput; 94 | 95 | } while (!work_restart[thr_id].restart); 96 | 97 | *hashes_done = pdata[19] - start_nonce; 98 | return 0; 99 | } 100 | 101 | // cleanup 102 | void free_fugue256(int thr_id) 103 | { 104 | if (!init[thr_id]) 105 | return; 106 | 107 | cudaThreadSynchronize(); 108 | 109 | fugue256_cpu_free(thr_id); 110 | 111 | init[thr_id] = false; 112 | 113 | cudaDeviceSynchronize(); 114 | } 115 | -------------------------------------------------------------------------------- /groestlcoin.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "sph/sph_groestl.h" 7 | #include "cuda_groestlcoin.h" 8 | 9 | #include "miner.h" 10 | 11 | // CPU hash 12 | void groestlhash(void *state, const void *input) 13 | { 14 | uint32_t _ALIGN(64) hash[16]; 15 | sph_groestl512_context ctx_groestl; 16 | 17 | sph_groestl512_init(&ctx_groestl); 18 | sph_groestl512(&ctx_groestl, input, 80); 19 | sph_groestl512_close(&ctx_groestl, hash); 20 | 21 | sph_groestl512_init(&ctx_groestl); 22 | sph_groestl512(&ctx_groestl, hash, 64); 23 | sph_groestl512_close(&ctx_groestl, hash); 24 | 25 | memcpy(state, hash, 32); 26 | } 27 | 28 | static bool init[MAX_GPUS] = { 0 }; 29 | 30 | int scanhash_groestlcoin(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done) 31 | { 32 | uint32_t _ALIGN(64) endiandata[32]; 33 | uint32_t *pdata = work->data; 34 | uint32_t *ptarget = work->target; 35 | uint32_t start_nonce = pdata[19]; 36 | uint32_t throughput = cuda_default_throughput(thr_id, 1 << 19); // 256*256*8 37 | if (init[thr_id]) throughput = min(throughput, max_nonce - start_nonce); 38 | 39 | if (opt_benchmark) 40 | ptarget[7] = 0x001f; 41 | 42 | if (!init[thr_id]) 43 | { 44 | cudaSetDevice(device_map[thr_id]); 45 | if (opt_cudaschedule == -1 && gpu_threads == 1) { 46 | cudaDeviceReset(); 47 | // reduce cpu usage 48 | cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync); 49 | CUDA_LOG_ERROR(); 50 | } 51 | gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput); 52 | 53 | CUDA_LOG_ERROR(); 54 | groestlcoin_cpu_init(thr_id, throughput); 55 | init[thr_id] = true; 56 | } 57 | 58 | for (int k=0; k < 20; k++) 59 | be32enc(&endiandata[k], pdata[k]); 60 | 61 | groestlcoin_cpu_setBlock(thr_id, endiandata, (void*)ptarget); 62 | 63 | do { 64 | memset(work->nonces, 0xff, sizeof(work->nonces)); 65 | 66 | *hashes_done = pdata[19] - start_nonce + throughput; 67 | 68 | // GPU hash 69 | groestlcoin_cpu_hash(thr_id, throughput, pdata[19], &work->nonces[0]); 70 | 71 | if (work->nonces[0] < UINT32_MAX && bench_algo < 0) 72 | { 73 | uint32_t _ALIGN(64) vhash[8]; 74 | endiandata[19] = swab32(work->nonces[0]); 75 | groestlhash(vhash, endiandata); 76 | 77 | if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) { 78 | work->valid_nonces = 1; 79 | work_set_target_ratio(work, vhash); 80 | pdata[19] = work->nonces[0] + 1; // cursor 81 | return work->valid_nonces; 82 | } else if (vhash[7] > ptarget[7]) { 83 | gpu_increment_reject(thr_id); 84 | if (!opt_quiet) 85 | gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]); 86 | } 87 | } 88 | 89 | if ((uint64_t) throughput + pdata[19] >= max_nonce) { 90 | pdata[19] = max_nonce; 91 | break; 92 | } 93 | pdata[19] += throughput; 94 | 95 | } while (!work_restart[thr_id].restart); 96 | 97 | *hashes_done = pdata[19] - start_nonce; 98 | return 0; 99 | } 100 | 101 | // cleanup 102 | void free_groestlcoin(int thr_id) 103 | { 104 | if (!init[thr_id]) 105 | return; 106 | 107 | cudaThreadSynchronize(); 108 | 109 | groestlcoin_cpu_free(thr_id); 110 | init[thr_id] = false; 111 | 112 | cudaDeviceSynchronize(); 113 | } 114 | -------------------------------------------------------------------------------- /heavy/cuda_bastion.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cuda_helper.h" 4 | 5 | static uint32_t *d_offsets1[MAX_GPUS] = { 0 }; 6 | static uint32_t *d_offsets2[MAX_GPUS] = { 0 }; 7 | 8 | static uint32_t *d_brcount1[MAX_GPUS] = { 0 }; 9 | static uint32_t *d_brcount2[MAX_GPUS] = { 0 }; 10 | 11 | __global__ __launch_bounds__(128, 6) 12 | void bastion_filter2_gpu(const uint32_t threads, const uint32_t* d_hash, uint32_t* d_hash1, uint32_t* d_hash2, uint32_t* d_br_ofts1, uint32_t* d_count1, uint32_t* d_br_ofts2, uint32_t* d_count2) 13 | { 14 | const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x); 15 | if (thread < threads) 16 | { 17 | const uint32_t offset = thread * 16U; // 64U / sizeof(uint32_t); 18 | uint4 *psrc = (uint4*) (&d_hash[offset]); 19 | uint4 *pdst; 20 | d_br_ofts1[thread] = 0; 21 | d_br_ofts2[thread] = 0; 22 | if (((uint8_t*)psrc)[0] & 0x8) { 23 | // uint4 = 4x uint32_t = 16 bytes 24 | uint32_t oft = atomicAdd(d_count1, 1U) * 16U; 25 | d_br_ofts1[thread] = oft + 16U; 26 | pdst = (uint4*) (&d_hash1[oft]); 27 | } else { 28 | uint32_t oft = atomicAdd(d_count2, 1U) * 16U; 29 | d_br_ofts2[thread] = oft + 16U; 30 | pdst = (uint4*) (&d_hash2[oft]); 31 | } 32 | pdst[0] = psrc[0]; 33 | pdst[1] = psrc[1]; 34 | pdst[2] = psrc[2]; 35 | pdst[3] = psrc[3]; 36 | } 37 | } 38 | 39 | __global__ __launch_bounds__(128, 6) 40 | void bastion_merge2_gpu(const uint32_t threads, uint32_t* d_hash, uint32_t* d_hash1, uint32_t* d_hash2, uint32_t* d_br_ofts1, uint32_t* d_br_ofts2) 41 | { 42 | const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x); 43 | if (thread < threads) 44 | { 45 | const uint32_t offset = thread * 16U; 46 | uint4 *pdst = (uint4*) (&d_hash[offset]); 47 | uint4 *psrc; 48 | if (d_br_ofts1[thread]) { 49 | const uint32_t oft = d_br_ofts1[thread] - 16U; 50 | psrc = (uint4*) (&d_hash1[oft]); 51 | } else { 52 | const uint32_t oft = d_br_ofts2[thread] - 16U; 53 | psrc = (uint4*) (&d_hash2[oft]); 54 | } 55 | pdst[0] = psrc[0]; 56 | pdst[1] = psrc[1]; 57 | pdst[2] = psrc[2]; 58 | pdst[3] = psrc[3]; 59 | } 60 | } 61 | 62 | 63 | __host__ 64 | void bastion_init(const int thr_id, const uint32_t threads) 65 | { 66 | CUDA_SAFE_CALL(cudaMalloc(&d_offsets1[thr_id], sizeof(uint32_t) * threads)); 67 | CUDA_SAFE_CALL(cudaMalloc(&d_offsets2[thr_id], sizeof(uint32_t) * threads)); 68 | CUDA_SAFE_CALL(cudaMalloc(&d_brcount1[thr_id], sizeof(uint32_t))); 69 | CUDA_SAFE_CALL(cudaMalloc(&d_brcount2[thr_id], sizeof(uint32_t))); 70 | } 71 | 72 | __host__ 73 | void bastion_free(const int thr_id) 74 | { 75 | cudaFree(d_offsets1[thr_id]); 76 | cudaFree(d_offsets2[thr_id]); 77 | cudaFree(d_brcount1[thr_id]); 78 | cudaFree(d_brcount2[thr_id]); 79 | } 80 | 81 | __host__ 82 | uint32_t bastion_filter2(const int thr_id, const uint32_t threads, const uint32_t *inpHashes, uint32_t* d_hash1, uint32_t* d_hash2) 83 | { 84 | uint32_t num = 0; 85 | cudaMemset(d_brcount1[thr_id], 0, 4); 86 | cudaMemset(d_brcount2[thr_id], 0, 4); 87 | const uint32_t threadsperblock = 128; 88 | dim3 grid((threads + threadsperblock - 1) / threadsperblock); 89 | dim3 block(threadsperblock); 90 | bastion_filter2_gpu <<>> (threads, inpHashes, d_hash1, d_hash2, d_offsets1[thr_id], d_brcount1[thr_id], d_offsets2[thr_id], d_brcount2[thr_id]); 91 | cudaMemcpy(&num, d_brcount1[thr_id], 4, cudaMemcpyDeviceToHost); 92 | return num; 93 | } 94 | 95 | __host__ 96 | void bastion_merge2(const int thr_id, const uint32_t threads, uint32_t *outpHashes, uint32_t* d_hash1, uint32_t* d_hash2) 97 | { 98 | const uint32_t threadsperblock = 128; 99 | dim3 grid((threads + threadsperblock - 1) / threadsperblock); 100 | dim3 block(threadsperblock); 101 | // put back branch hashes to the common buffer d_hash 102 | bastion_merge2_gpu <<>> (threads, outpHashes, d_hash1, d_hash2, d_offsets1[thr_id], d_offsets2[thr_id]); 103 | } 104 | -------------------------------------------------------------------------------- /heavy/heavy.h: -------------------------------------------------------------------------------- 1 | #ifndef _CUDA_HEAVY_H 2 | #define _CUDA_HEAVY_H 3 | 4 | void blake512_cpu_init(int thr_id, uint32_t threads); 5 | void blake512_cpu_setBlock(void *pdata, int len); 6 | void blake512_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce); 7 | void blake512_cpu_free(int thr_id); 8 | 9 | void groestl512_cpu_init(int thr_id, uint32_t threads); 10 | void groestl512_cpu_copyHeftyHash(int thr_id, uint32_t threads, void *heftyHashes, int copy); 11 | void groestl512_cpu_setBlock(void *data, int len); 12 | void groestl512_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce); 13 | void groestl512_cpu_free(int thr_id); 14 | 15 | void hefty_cpu_hash(int thr_id, uint32_t threads, int startNounce); 16 | void hefty_cpu_setBlock(int thr_id, uint32_t threads, void *data, int len); 17 | void hefty_cpu_init(int thr_id, uint32_t threads); 18 | void hefty_cpu_free(int thr_id); 19 | 20 | void keccak512_cpu_init(int thr_id, uint32_t threads); 21 | void keccak512_cpu_setBlock(void *data, int len); 22 | void keccak512_cpu_copyHeftyHash(int thr_id, uint32_t threads, void *heftyHashes, int copy); 23 | void keccak512_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce); 24 | void keccak512_cpu_free(int thr_id); 25 | 26 | void sha256_cpu_init(int thr_id, uint32_t threads); 27 | void sha256_cpu_setBlock(void *data, int len); 28 | void sha256_cpu_hash(int thr_id, uint32_t threads, int startNounce); 29 | void sha256_cpu_copyHeftyHash(int thr_id, uint32_t threads, void *heftyHashes, int copy); 30 | void sha256_cpu_free(int thr_id); 31 | 32 | void combine_cpu_init(int thr_id, uint32_t threads); 33 | void combine_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *hash); 34 | void combine_cpu_free(int thr_id); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /hefty1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEFTY1 CPU-only cryptographic hash function 3 | * 4 | * Copyright (c) 2014, dbcc14 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are those 28 | * of the authors and should not be interpreted as representing official policies, 29 | * either expressed or implied, of the FreeBSD Project. 30 | */ 31 | 32 | #ifndef __HEFTY1_H__ 33 | #define __HEFTY1_H__ 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #ifndef WIN32 40 | #include 41 | #endif 42 | 43 | #include 44 | 45 | #define HEFTY1_DIGEST_BYTES 32 46 | #define HEFTY1_BLOCK_BYTES 64 47 | #define HEFTY1_STATE_WORDS 8 48 | #define HEFTY1_SPONGE_WORDS 4 49 | 50 | typedef struct HEFTY1_CTX { 51 | uint32_t h[HEFTY1_STATE_WORDS]; 52 | uint8_t block[HEFTY1_BLOCK_BYTES]; 53 | uint64_t written; 54 | uint32_t sponge[HEFTY1_SPONGE_WORDS]; 55 | } HEFTY1_CTX; 56 | 57 | void HEFTY1_Init(HEFTY1_CTX *cxt); 58 | void HEFTY1_Update(HEFTY1_CTX *cxt, const void *data, size_t len); 59 | void HEFTY1_Final(unsigned char *digest, HEFTY1_CTX *cxt); 60 | unsigned char* HEFTY1(const unsigned char *data, size_t len, unsigned char *digest); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* __HEFTY1_H__ */ 67 | -------------------------------------------------------------------------------- /lyra2/Lyra2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Header file for the Lyra2 Password Hashing Scheme (PHS). 3 | * 4 | * Author: The Lyra PHC team (http://www.lyra-kdf.net/) -- 2014. 5 | * 6 | * This software is hereby placed in the public domain. 7 | * 8 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS 9 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 10 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 11 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 12 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 13 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 14 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 15 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 16 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 17 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 18 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 19 | */ 20 | #ifndef LYRA2_H_ 21 | #define LYRA2_H_ 22 | 23 | #include 24 | 25 | typedef unsigned char byte; 26 | 27 | //Block length required so Blake2's Initialization Vector (IV) is not overwritten (THIS SHOULD NOT BE MODIFIED) 28 | #define BLOCK_LEN_BLAKE2_SAFE_INT64 8 //512 bits (=64 bytes, =8 uint64_t) 29 | #define BLOCK_LEN_BLAKE2_SAFE_BYTES (BLOCK_LEN_BLAKE2_SAFE_INT64 * 8) //same as above, in bytes 30 | 31 | 32 | #ifdef BLOCK_LEN_BITS 33 | #define BLOCK_LEN_INT64 (BLOCK_LEN_BITS/64) //Block length: 768 bits (=96 bytes, =12 uint64_t) 34 | #define BLOCK_LEN_BYTES (BLOCK_LEN_BITS/8) //Block length, in bytes 35 | #else //default block lenght: 768 bits 36 | #define BLOCK_LEN_INT64 12 //Block length: 768 bits (=96 bytes, =12 uint64_t) 37 | #define BLOCK_LEN_BYTES (BLOCK_LEN_INT64 * 8) //Block length, in bytes 38 | #endif 39 | 40 | int LYRA2(void *K, int64_t kLen, const void *pwd, int32_t pwdlen, const void *salt, int32_t saltlen, int64_t timeCost, const int16_t nRows, const int16_t nCols); 41 | 42 | #endif /* LYRA2_H_ */ 43 | -------------------------------------------------------------------------------- /lyra2/Lyra2Z.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Header file for the Lyra2 Password Hashing Scheme (PHS). 3 | * 4 | * Author: The Lyra PHC team (http://www.lyra-kdf.net/) -- 2014. 5 | * 6 | * This software is hereby placed in the public domain. 7 | * 8 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS 9 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 10 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 11 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 12 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 13 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 14 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 15 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 16 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 17 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 18 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 19 | */ 20 | #ifndef LYRA2Z_H_ 21 | #define LYRA2Z_H_ 22 | 23 | #include 24 | 25 | typedef unsigned char byte; 26 | 27 | //Block length required so Blake2's Initialization Vector (IV) is not overwritten (THIS SHOULD NOT BE MODIFIED) 28 | #define BLOCK_LEN_BLAKE2_SAFE_INT64 8 //512 bits (=64 bytes, =8 uint64_t) 29 | #define BLOCK_LEN_BLAKE2_SAFE_BYTES (BLOCK_LEN_BLAKE2_SAFE_INT64 * 8) //same as above, in bytes 30 | 31 | 32 | #ifdef BLOCK_LEN_BITS 33 | #define BLOCK_LEN_INT64 (BLOCK_LEN_BITS/64) //Block length: 768 bits (=96 bytes, =12 uint64_t) 34 | #define BLOCK_LEN_BYTES (BLOCK_LEN_BITS/8) //Block length, in bytes 35 | #else //default block lenght: 768 bits 36 | #define BLOCK_LEN_INT64 12 //Block length: 768 bits (=96 bytes, =12 uint64_t) 37 | #define BLOCK_LEN_BYTES (BLOCK_LEN_INT64 * 8) //Block length, in bytes 38 | #endif 39 | 40 | int LYRA2Z(void *K, int64_t kLen, const void *pwd, int32_t pwdlen, const void *salt, int32_t saltlen, int64_t timeCost, const int16_t nRows, const int16_t nCols); 41 | 42 | #endif /* LYRA2_H_ */ 43 | -------------------------------------------------------------------------------- /lyra2/Sponge.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Header file for Blake2b's internal permutation in the form of a sponge. 3 | * This code is based on the original Blake2b's implementation provided by 4 | * Samuel Neves (https://blake2.net/) 5 | * 6 | * Author: The Lyra PHC team (http://www.lyra-kdf.net/) -- 2014. 7 | * 8 | * This software is hereby placed in the public domain. 9 | * 10 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS 11 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 13 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 14 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 15 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 16 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 17 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 18 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 19 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 20 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | #ifndef SPONGE_H_ 23 | #define SPONGE_H_ 24 | 25 | #include 26 | 27 | /* Blake2b IV Array */ 28 | static const uint64_t blake2b_IV[8] = 29 | { 30 | 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, 31 | 0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL, 32 | 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL, 33 | 0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL 34 | }; 35 | 36 | /* Blake2b's rotation */ 37 | static __inline uint64_t rotr64(const uint64_t w, const unsigned c) { 38 | #ifdef _MSC_VER 39 | return _rotr64(w, c); 40 | #else 41 | return ( w >> c ) | ( w << ( 64 - c ) ); 42 | #endif 43 | } 44 | 45 | /* Blake2b's G function */ 46 | #define G(r,i,a,b,c,d) do { \ 47 | a = a + b; \ 48 | d = rotr64(d ^ a, 32); \ 49 | c = c + d; \ 50 | b = rotr64(b ^ c, 24); \ 51 | a = a + b; \ 52 | d = rotr64(d ^ a, 16); \ 53 | c = c + d; \ 54 | b = rotr64(b ^ c, 63); \ 55 | } while(0) 56 | 57 | 58 | /*One Round of the Blake2b's compression function*/ 59 | #define ROUND_LYRA(r) \ 60 | G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \ 61 | G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \ 62 | G(r,2,v[ 2],v[ 6],v[10],v[14]); \ 63 | G(r,3,v[ 3],v[ 7],v[11],v[15]); \ 64 | G(r,4,v[ 0],v[ 5],v[10],v[15]); \ 65 | G(r,5,v[ 1],v[ 6],v[11],v[12]); \ 66 | G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \ 67 | G(r,7,v[ 3],v[ 4],v[ 9],v[14]); 68 | 69 | //---- Housekeeping 70 | void initState(uint64_t state[/*16*/]); 71 | 72 | //---- Squeezes 73 | void squeeze(uint64_t *state, unsigned char *out, unsigned int len); 74 | void reducedSqueezeRow0(uint64_t* state, uint64_t* row, const uint32_t nCols); 75 | 76 | //---- Absorbs 77 | void absorbBlock(uint64_t *state, const uint64_t *in); 78 | void absorbBlockBlake2Safe(uint64_t *state, const uint64_t *in); 79 | 80 | //---- Duplexes 81 | void reducedDuplexRow1(uint64_t *state, uint64_t *rowIn, uint64_t *rowOut, const uint32_t nCols); 82 | void reducedDuplexRowSetup(uint64_t *state, uint64_t *rowIn, uint64_t *rowInOut, uint64_t *rowOut, const uint32_t nCols); 83 | void reducedDuplexRow(uint64_t *state, uint64_t *rowIn, uint64_t *rowInOut, uint64_t *rowOut, const uint32_t nCols); 84 | 85 | //---- Misc 86 | void printArray(unsigned char *array, unsigned int size, char *name); 87 | 88 | #endif /* SPONGE_H_ */ 89 | -------------------------------------------------------------------------------- /lyra2/cuda_lyra2v2.cu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/lyra2/cuda_lyra2v2.cu -------------------------------------------------------------------------------- /lyra2/lyra2REv2.cu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/lyra2/lyra2REv2.cu -------------------------------------------------------------------------------- /myriadgroestl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "sph/sph_groestl.h" 7 | 8 | #include "miner.h" 9 | 10 | void myriadgroestl_cpu_init(int thr_id, uint32_t threads); 11 | void myriadgroestl_cpu_free(int thr_id); 12 | void myriadgroestl_cpu_setBlock(int thr_id, void *data, uint32_t *target); 13 | void myriadgroestl_cpu_hash(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *resNonces); 14 | 15 | void myriadhash(void *state, const void *input) 16 | { 17 | uint32_t _ALIGN(64) hash[16]; 18 | sph_groestl512_context ctx_groestl; 19 | SHA256_CTX sha256; 20 | 21 | sph_groestl512_init(&ctx_groestl); 22 | sph_groestl512(&ctx_groestl, input, 80); 23 | sph_groestl512_close(&ctx_groestl, hash); 24 | 25 | SHA256_Init(&sha256); 26 | SHA256_Update(&sha256,(unsigned char *)hash, 64); 27 | SHA256_Final((unsigned char *)hash, &sha256); 28 | 29 | memcpy(state, hash, 32); 30 | } 31 | 32 | static bool init[MAX_GPUS] = { 0 }; 33 | 34 | int scanhash_myriad(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done) 35 | { 36 | uint32_t _ALIGN(64) endiandata[32]; 37 | uint32_t *pdata = work->data; 38 | uint32_t *ptarget = work->target; 39 | uint32_t start_nonce = pdata[19]; 40 | int dev_id = device_map[thr_id]; 41 | int intensity = (device_sm[dev_id] >= 600) ? 20 : 18; 42 | uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity); 43 | if (init[thr_id]) throughput = min(throughput, max_nonce - start_nonce); 44 | 45 | if (opt_benchmark) 46 | ptarget[7] = 0x0000ff; 47 | 48 | // init 49 | if(!init[thr_id]) 50 | { 51 | cudaSetDevice(dev_id); 52 | if (opt_cudaschedule == -1 && gpu_threads == 1) { 53 | cudaDeviceReset(); 54 | // reduce cpu usage 55 | cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync); 56 | CUDA_LOG_ERROR(); 57 | } 58 | gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput); 59 | 60 | myriadgroestl_cpu_init(thr_id, throughput); 61 | init[thr_id] = true; 62 | } 63 | 64 | for (int k=0; k < 20; k++) 65 | be32enc(&endiandata[k], pdata[k]); 66 | 67 | myriadgroestl_cpu_setBlock(thr_id, endiandata, ptarget); 68 | 69 | do { 70 | memset(work->nonces, 0xff, sizeof(work->nonces)); 71 | 72 | // GPU 73 | myriadgroestl_cpu_hash(thr_id, throughput, pdata[19], work->nonces); 74 | 75 | *hashes_done = pdata[19] - start_nonce + throughput; 76 | 77 | if (work->nonces[0] < UINT32_MAX && bench_algo < 0) 78 | { 79 | uint32_t _ALIGN(64) vhash[8]; 80 | endiandata[19] = swab32(work->nonces[0]); 81 | myriadhash(vhash, endiandata); 82 | if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) { 83 | work->valid_nonces = 1; 84 | work_set_target_ratio(work, vhash); 85 | if (work->nonces[1] != UINT32_MAX) { 86 | endiandata[19] = swab32(work->nonces[1]); 87 | myriadhash(vhash, endiandata); 88 | bn_set_target_ratio(work, vhash, 1); 89 | work->valid_nonces = 2; 90 | pdata[19] = max(work->nonces[0], work->nonces[1]) + 1; 91 | } else { 92 | pdata[19] = work->nonces[0] + 1; // cursor 93 | } 94 | return work->valid_nonces; 95 | } 96 | else if (vhash[7] > ptarget[7]) { 97 | gpu_increment_reject(thr_id); 98 | if (!opt_quiet) 99 | gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]); 100 | pdata[19] = work->nonces[0] + 1; 101 | continue; 102 | } 103 | } 104 | 105 | if ((uint64_t) throughput + pdata[19] >= max_nonce) { 106 | pdata[19] = max_nonce; 107 | break; 108 | } 109 | pdata[19] += throughput; 110 | 111 | } while (!work_restart[thr_id].restart); 112 | 113 | *hashes_done = max_nonce - start_nonce; 114 | 115 | return 0; 116 | } 117 | 118 | // cleanup 119 | void free_myriad(int thr_id) 120 | { 121 | if (!init[thr_id]) 122 | return; 123 | 124 | cudaThreadSynchronize(); 125 | 126 | myriadgroestl_cpu_free(thr_id); 127 | init[thr_id] = false; 128 | 129 | cudaDeviceSynchronize(); 130 | } 131 | -------------------------------------------------------------------------------- /neoscrypt/neoscrypt.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "neoscrypt.h" 6 | 7 | extern void neoscrypt_setBlockTarget(uint32_t* const data, uint32_t* const ptarget); 8 | 9 | extern void neoscrypt_init(int thr_id, uint32_t threads); 10 | extern void neoscrypt_free(int thr_id); 11 | extern void neoscrypt_hash_k4(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *resNonces, bool stratum); 12 | 13 | static bool init[MAX_GPUS] = { 0 }; 14 | 15 | int scanhash_neoscrypt(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) 16 | { 17 | uint32_t _ALIGN(64) endiandata[20]; 18 | uint32_t *pdata = work->data; 19 | uint32_t *ptarget = work->target; 20 | const uint32_t first_nonce = pdata[19]; 21 | 22 | int dev_id = device_map[thr_id]; 23 | int intensity = is_windows() ? 18 : 19; 24 | if (strstr(device_name[dev_id], "GTX 10")) intensity = 21; // >= 20 need more than 2GB 25 | 26 | uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity); 27 | throughput = throughput / 32; /* set for max intensity ~= 20 */ 28 | api_set_throughput(thr_id, throughput); 29 | 30 | if (opt_benchmark) 31 | ptarget[7] = 0x00ff; 32 | 33 | if (!init[thr_id]) 34 | { 35 | cudaDeviceSynchronize(); 36 | cudaSetDevice(dev_id); 37 | if (opt_cudaschedule == -1 && gpu_threads == 1) { 38 | cudaDeviceReset(); 39 | // reduce cpu usage 40 | cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync); 41 | cudaGetLastError(); // reset errors if device is not "reset" 42 | } 43 | if (device_sm[dev_id] <= 300) { 44 | gpulog(LOG_ERR, thr_id, "Sorry neoscrypt is not supported on SM 3.0 devices"); 45 | proper_exit(EXIT_CODE_CUDA_ERROR); 46 | } 47 | gpulog(LOG_INFO, thr_id, "Intensity set to %g (+5), %u cuda threads", throughput2intensity(throughput), throughput); 48 | 49 | neoscrypt_init(thr_id, throughput); 50 | 51 | init[thr_id] = true; 52 | } 53 | 54 | if (have_stratum) { 55 | for (int k = 0; k < 20; k++) 56 | be32enc(&endiandata[k], pdata[k]); 57 | } else { 58 | for (int k = 0; k < 20; k++) 59 | endiandata[k] = pdata[k]; 60 | } 61 | 62 | neoscrypt_setBlockTarget(endiandata,ptarget); 63 | 64 | do { 65 | memset(work->nonces, 0xff, sizeof(work->nonces)); 66 | neoscrypt_hash_k4(thr_id, throughput, pdata[19], work->nonces, have_stratum); 67 | 68 | *hashes_done = pdata[19] - first_nonce + throughput; 69 | 70 | if (work->nonces[0] != UINT32_MAX) 71 | { 72 | const uint32_t Htarg = ptarget[7]; 73 | uint32_t _ALIGN(64) vhash[8]; 74 | 75 | if (have_stratum) { 76 | be32enc(&endiandata[19], work->nonces[0]); 77 | } else { 78 | endiandata[19] = work->nonces[0]; 79 | } 80 | neoscrypt((uchar*)vhash, (uchar*) endiandata, 0x80000620U); 81 | 82 | if (vhash[7] <= Htarg && fulltest(vhash, ptarget)) { 83 | work->valid_nonces = 1; 84 | work_set_target_ratio(work, vhash); 85 | pdata[19] = work->nonces[0] + 1; // cursor 86 | return work->valid_nonces; 87 | } 88 | else if (vhash[7] > Htarg) { 89 | gpu_increment_reject(thr_id); 90 | if (!opt_quiet) 91 | gpulog(LOG_WARNING, thr_id, "nonce %08x does not validate on CPU!", work->nonces[0]); 92 | } 93 | } 94 | 95 | if ((uint64_t)throughput + pdata[19] >= max_nonce) { 96 | pdata[19] = max_nonce; 97 | break; 98 | } 99 | 100 | pdata[19] += throughput; 101 | 102 | } while (!work_restart[thr_id].restart); 103 | 104 | *hashes_done = pdata[19] - first_nonce; 105 | return 0; 106 | } 107 | 108 | // cleanup 109 | void free_neoscrypt(int thr_id) 110 | { 111 | if (!init[thr_id]) 112 | return; 113 | 114 | cudaThreadSynchronize(); 115 | 116 | neoscrypt_free(thr_id); 117 | init[thr_id] = false; 118 | 119 | cudaDeviceSynchronize(); 120 | } 121 | -------------------------------------------------------------------------------- /neoscrypt/neoscrypt.h: -------------------------------------------------------------------------------- 1 | #if (__cplusplus) 2 | extern "C" { 3 | #endif 4 | 5 | void neoscrypt(unsigned char *output, const unsigned char *input, unsigned int profile); 6 | 7 | #if (__cplusplus) 8 | } 9 | #else 10 | 11 | #define SCRYPT_BLOCK_SIZE 64 12 | #define SCRYPT_HASH_BLOCK_SIZE 64 13 | #define SCRYPT_HASH_DIGEST_SIZE 32 14 | 15 | typedef uint8_t hash_digest[SCRYPT_HASH_DIGEST_SIZE]; 16 | 17 | #define ROTL32(a,b) (((a) << (b)) | ((a) >> (32 - b))) 18 | #define ROTR32(a,b) (((a) >> (b)) | ((a) << (32 - b))) 19 | 20 | #define U8TO32_BE(p) \ 21 | (((uint32_t)((p)[0]) << 24) | ((uint32_t)((p)[1]) << 16) | \ 22 | ((uint32_t)((p)[2]) << 8) | ((uint32_t)((p)[3]))) 23 | 24 | #define U32TO8_BE(p, v) \ 25 | (p)[0] = (uint8_t)((v) >> 24); (p)[1] = (uint8_t)((v) >> 16); \ 26 | (p)[2] = (uint8_t)((v) >> 8); (p)[3] = (uint8_t)((v) ); 27 | 28 | #define U64TO8_BE(p, v) \ 29 | U32TO8_BE((p), (uint32_t)((v) >> 32)); \ 30 | U32TO8_BE((p) + 4, (uint32_t)((v) )); 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /pools.conf: -------------------------------------------------------------------------------- 1 | { 2 | "_note": "Sample rotation of 2 pools", 3 | 4 | "pools":[{ 5 | "name": "Longpoll sample", 6 | "url": "http://ziftr.suprnova.cc:9991", 7 | "user": "tpruvot.win", 8 | "pass": "x", 9 | "max-diff": 0.0, 10 | "scantime": 40, 11 | "time-limit": 180, 12 | "disabled": false 13 | }, 14 | { 15 | "name": "Stratum sample", 16 | "url": "stratum+tcp://zrc-stratum.suprnova.cc:2257", 17 | "user": "tpruvot.elite", 18 | "pass": "x", 19 | "time-limit": 300 20 | }], 21 | 22 | "algo" : "zr5", 23 | 24 | "timeout": 60, 25 | 26 | "api-bind" : "0.0.0.0", 27 | "api-remote" : true, 28 | 29 | "no-gbt": true 30 | } 31 | -------------------------------------------------------------------------------- /quark/cuda_bmw512.cu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/quark/cuda_bmw512.cu -------------------------------------------------------------------------------- /quark/cuda_quark.h: -------------------------------------------------------------------------------- 1 | #include "cuda_helper.h" 2 | 3 | /* commonly used cuda quark kernels prototypes */ 4 | 5 | extern void quark_blake512_cpu_init(int thr_id, uint32_t threads); 6 | extern void quark_blake512_cpu_free(int thr_id); 7 | extern void quark_blake512_cpu_setBlock_80(int thr_id, uint32_t *pdata); 8 | extern void quark_blake512_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_hash); 9 | extern void quark_blake512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order); 10 | 11 | extern void quark_bmw512_cpu_init(int thr_id, uint32_t threads); 12 | extern void quark_bmw512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order); 13 | 14 | extern void quark_groestl512_cpu_init(int thr_id, uint32_t threads); 15 | extern void quark_groestl512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order); 16 | extern void quark_doublegroestl512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order); 17 | extern void quark_groestl512_cpu_free(int thr_id); 18 | 19 | extern void quark_skein512_cpu_init(int thr_id, uint32_t threads); 20 | extern void quark_skein512_cpu_hash_64(int thr_id, const uint32_t threads, const uint32_t startNonce, uint32_t *d_nonceVector, uint32_t *d_hash, int order); 21 | 22 | extern void quark_keccak512_cpu_init(int thr_id, uint32_t threads); 23 | extern void quark_keccak512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order); 24 | 25 | extern void quark_jh512_cpu_init(int thr_id, uint32_t threads); 26 | extern void quark_jh512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order); 27 | 28 | extern void quark_compactTest_cpu_init(int thr_id, uint32_t threads); 29 | extern void quark_compactTest_cpu_free(int thr_id); 30 | extern void quark_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable, 31 | uint32_t *d_nonces1, uint32_t *nrm1, uint32_t *d_nonces2, uint32_t *nrm2, int order); 32 | extern void quark_compactTest_single_false_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable, 33 | uint32_t *d_nonces1, uint32_t *nrm1, int order); 34 | 35 | extern uint32_t cuda_check_hash_branch(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_inputHash, int order); 36 | -------------------------------------------------------------------------------- /quark/groestl_simple.cuh: -------------------------------------------------------------------------------- 1 | /** 2 | * Simplified groestl512 big perm code 3 | * tpruvot - 2017 4 | */ 5 | 6 | #ifdef __INTELLISENSE__ 7 | #define __CUDA_ARCH__ 210 8 | #define __CUDACC__ 9 | #include 10 | #include 11 | #define __byte_perm(a,b,c) (a) 12 | #define tex1Dfetch(t, n) (n) 13 | #endif 14 | 15 | // todo: merge with cuda_quark_groestl512_sm20.cu (used for groestl512-80) 16 | 17 | #if __CUDA_ARCH__ < 300 || defined(_DEBUG) 18 | 19 | #ifndef SPH_C32 20 | #define SPH_C32(x) ((uint32_t)(x ## U)) 21 | #define SPH_T32(x) ((x) & SPH_C32(0xFFFFFFFF)) 22 | #endif 23 | 24 | #ifndef PC32up 25 | #define PC32up(j, r) ((uint32_t)((j) + (r))) 26 | #define PC32dn(j, r) 0 27 | #define QC32up(j, r) 0xFFFFFFFF 28 | #define QC32dn(j, r) (((uint32_t)(r) << 24) ^ SPH_T32(~((uint32_t)(j) << 24))) 29 | #endif 30 | 31 | #define tT0up(x) tex1Dfetch(t0up1, x) 32 | #define tT0dn(x) tex1Dfetch(t0dn1, x) 33 | #define tT1up(x) tex1Dfetch(t1up1, x) 34 | #define tT1dn(x) tex1Dfetch(t1dn1, x) 35 | #define tT2up(x) tex1Dfetch(t2up1, x) 36 | #define tT2dn(x) tex1Dfetch(t2dn1, x) 37 | #define tT3up(x) tex1Dfetch(t3up1, x) 38 | #define tT3dn(x) tex1Dfetch(t3dn1, x) 39 | 40 | #undef B32_0 41 | #define B32_0(x) ((x) & 0xFFu) 42 | 43 | __device__ __forceinline__ 44 | static void tex_groestl512_perm_P(uint32_t *a) 45 | { 46 | #pragma unroll 1 47 | for(int r=0; r<14; r++) 48 | { 49 | uint32_t t[32]; 50 | 51 | #pragma unroll 16 52 | for (int k=0; k<16; k++) 53 | a[(k*2)+0] ^= PC32up(k<< 4, r); 54 | 55 | #pragma unroll 16 56 | for(int k=0; k<32; k+=2) 57 | { 58 | uint32_t t0_0 = B32_0(a[(k ) & 0x1f]), t9_0 = B32_0(a[(k + 9) & 0x1f]); 59 | uint32_t t2_1 = B32_1(a[(k + 2) & 0x1f]), t11_1 = B32_1(a[(k + 11) & 0x1f]); 60 | uint32_t t4_2 = B32_2(a[(k + 4) & 0x1f]), t13_2 = B32_2(a[(k + 13) & 0x1f]); 61 | uint32_t t6_3 = B32_3(a[(k + 6) & 0x1f]), t23_3 = B32_3(a[(k + 23) & 0x1f]); 62 | 63 | t[k + 0] = tT0up( t0_0 ) ^ tT1up( t2_1 ) ^ tT2up( t4_2 ) ^ tT3up( t6_3 ) ^ 64 | tT0dn( t9_0 ) ^ tT1dn( t11_1 ) ^ tT2dn( t13_2 ) ^ tT3dn( t23_3 ); 65 | 66 | t[k + 1] = tT0dn( t0_0 ) ^ tT1dn( t2_1 ) ^ tT2dn( t4_2 ) ^ tT3dn( t6_3 ) ^ 67 | tT0up( t9_0 ) ^ tT1up( t11_1 ) ^ tT2up( t13_2 ) ^ tT3up( t23_3 ); 68 | } 69 | 70 | #pragma unroll 32 71 | for(int k=0; k<32; k++) 72 | a[k] = t[k]; 73 | } 74 | } 75 | 76 | __device__ __forceinline__ 77 | static void tex_groestl512_perm_Q(uint32_t *a) 78 | { 79 | #pragma unroll 1 80 | for(int r=0; r<14; r++) 81 | { 82 | uint32_t t[32]; 83 | 84 | #pragma unroll 16 85 | for (int k=0; k<16; k++) { 86 | a[(k*2)+0] ^= QC32up(k<< 4, r); 87 | a[(k*2)+1] ^= QC32dn(k<< 4, r); 88 | } 89 | 90 | #pragma unroll 16 91 | for(int k=0; k<32; k+=2) 92 | { 93 | uint32_t t2_0 = B32_0(a[(k + 2) & 0x1f]), t1_0 = B32_0(a[(k + 1) & 0x1f]); 94 | uint32_t t6_1 = B32_1(a[(k + 6) & 0x1f]), t5_1 = B32_1(a[(k + 5) & 0x1f]); 95 | uint32_t t10_2 = B32_2(a[(k + 10) & 0x1f]), t9_2 = B32_2(a[(k + 9) & 0x1f]); 96 | uint32_t t22_3 = B32_3(a[(k + 22) & 0x1f]), t13_3 = B32_3(a[(k + 13) & 0x1f]); 97 | 98 | t[k + 0] = tT0up( t2_0 ) ^ tT1up( t6_1 ) ^ tT2up( t10_2 ) ^ tT3up( t22_3 ) ^ 99 | tT0dn( t1_0 ) ^ tT1dn( t5_1 ) ^ tT2dn( t9_2 ) ^ tT3dn( t13_3 ); 100 | 101 | t[k + 1] = tT0dn( t2_0 ) ^ tT1dn( t6_1 ) ^ tT2dn( t10_2 ) ^ tT3dn( t22_3 ) ^ 102 | tT0up( t1_0 ) ^ tT1up( t5_1 ) ^ tT2up( t9_2 ) ^ tT3up( t13_3 ); 103 | } 104 | 105 | #pragma unroll 32 106 | for(int k=0; k<32; k++) 107 | a[k] = t[k]; 108 | } 109 | } 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /quark/groestl_transf_quad.h: -------------------------------------------------------------------------------- 1 | /* File included in quark/groestl (quark/jha,nist5/X11+) and groest/myriad coins for SM 3+ */ 2 | 3 | #define merge8(z,x,y)\ 4 | z=__byte_perm(x, y, 0x5140); \ 5 | 6 | #define SWAP8(x,y)\ 7 | x=__byte_perm(x, y, 0x5410); \ 8 | y=__byte_perm(x, y, 0x7632); 9 | 10 | #define SWAP4(x,y)\ 11 | t = (y<<4); \ 12 | t = (x ^ t); \ 13 | t = 0xf0f0f0f0UL & t; \ 14 | x = (x ^ t); \ 15 | t= t>>4;\ 16 | y= y ^ t; 17 | 18 | #define SWAP2(x,y)\ 19 | t = (y<<2); \ 20 | t = (x ^ t); \ 21 | t = 0xccccccccUL & t; \ 22 | x = (x ^ t); \ 23 | t= t>>2;\ 24 | y= y ^ t; 25 | 26 | #define SWAP1(x,y)\ 27 | t = (y+y); \ 28 | t = (x ^ t); \ 29 | t = 0xaaaaaaaaUL & t; \ 30 | x = (x ^ t); \ 31 | t= t>>1;\ 32 | y= y ^ t; 33 | 34 | 35 | __device__ __forceinline__ 36 | void to_bitslice_quad(uint32_t *const __restrict__ input, uint32_t *const __restrict__ output) 37 | { 38 | uint32_t other[8]; 39 | uint32_t d[8]; 40 | uint32_t t; 41 | const unsigned int n = threadIdx.x & 3; 42 | 43 | #pragma unroll 44 | for (int i = 0; i < 8; i++) { 45 | input[i] = __shfl((int)input[i], n ^ (3*(n >=1 && n <=2)), 4); 46 | other[i] = __shfl((int)input[i], (threadIdx.x + 1) & 3, 4); 47 | input[i] = __shfl((int)input[i], threadIdx.x & 2, 4); 48 | other[i] = __shfl((int)other[i], threadIdx.x & 2, 4); 49 | if (threadIdx.x & 1) { 50 | input[i] = __byte_perm(input[i], 0, 0x1032); 51 | other[i] = __byte_perm(other[i], 0, 0x1032); 52 | } 53 | } 54 | 55 | merge8(d[0], input[0], input[4]); 56 | merge8(d[1], other[0], other[4]); 57 | merge8(d[2], input[1], input[5]); 58 | merge8(d[3], other[1], other[5]); 59 | merge8(d[4], input[2], input[6]); 60 | merge8(d[5], other[2], other[6]); 61 | merge8(d[6], input[3], input[7]); 62 | merge8(d[7], other[3], other[7]); 63 | 64 | SWAP1(d[0], d[1]); 65 | SWAP1(d[2], d[3]); 66 | SWAP1(d[4], d[5]); 67 | SWAP1(d[6], d[7]); 68 | 69 | SWAP2(d[0], d[2]); 70 | SWAP2(d[1], d[3]); 71 | SWAP2(d[4], d[6]); 72 | SWAP2(d[5], d[7]); 73 | 74 | SWAP4(d[0], d[4]); 75 | SWAP4(d[1], d[5]); 76 | SWAP4(d[2], d[6]); 77 | SWAP4(d[3], d[7]); 78 | 79 | output[0] = d[0]; 80 | output[1] = d[1]; 81 | output[2] = d[2]; 82 | output[3] = d[3]; 83 | output[4] = d[4]; 84 | output[5] = d[5]; 85 | output[6] = d[6]; 86 | output[7] = d[7]; 87 | } 88 | 89 | __device__ __forceinline__ 90 | void from_bitslice_quad(const uint32_t *const __restrict__ input, uint32_t *const __restrict__ output) 91 | { 92 | uint32_t d[8]; 93 | uint32_t t; 94 | 95 | d[0] = __byte_perm(input[0], input[4], 0x7531); 96 | d[1] = __byte_perm(input[1], input[5], 0x7531); 97 | d[2] = __byte_perm(input[2], input[6], 0x7531); 98 | d[3] = __byte_perm(input[3], input[7], 0x7531); 99 | 100 | SWAP1(d[0], d[1]); 101 | SWAP1(d[2], d[3]); 102 | 103 | SWAP2(d[0], d[2]); 104 | SWAP2(d[1], d[3]); 105 | 106 | t = __byte_perm(d[0], d[2], 0x5410); 107 | d[2] = __byte_perm(d[0], d[2], 0x7632); 108 | d[0] = t; 109 | 110 | t = __byte_perm(d[1], d[3], 0x5410); 111 | d[3] = __byte_perm(d[1], d[3], 0x7632); 112 | d[1] = t; 113 | 114 | SWAP4(d[0], d[2]); 115 | SWAP4(d[1], d[3]); 116 | 117 | output[0] = d[0]; 118 | output[2] = d[1]; 119 | output[4] = d[0] >> 16; 120 | output[6] = d[1] >> 16; 121 | output[8] = d[2]; 122 | output[10] = d[3]; 123 | output[12] = d[2] >> 16; 124 | output[14] = d[3] >> 16; 125 | 126 | #pragma unroll 8 127 | for (int i = 0; i < 16; i+=2) { 128 | if (threadIdx.x & 1) output[i] = __byte_perm(output[i], 0, 0x1032); 129 | output[i] = __byte_perm(output[i], __shfl((int)output[i], (threadIdx.x+1)&3, 4), 0x7610); 130 | output[i+1] = __shfl((int)output[i], (threadIdx.x+2)&3, 4); 131 | if (threadIdx.x & 3) output[i] = output[i+1] = 0; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /qubit/luffa.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * luffa 80 algo (Introduced by Doomcoin) 3 | */ 4 | extern "C" { 5 | #include "sph/sph_luffa.h" 6 | } 7 | 8 | #include "miner.h" 9 | 10 | #include "cuda_helper.h" 11 | 12 | static uint32_t *d_hash[MAX_GPUS]; 13 | 14 | extern void qubit_luffa512_cpu_init(int thr_id, uint32_t threads); 15 | extern void qubit_luffa512_cpu_setBlock_80(void *pdata); 16 | extern void qubit_luffa512_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_hash, int order); 17 | 18 | extern "C" void luffa_hash(void *state, const void *input) 19 | { 20 | uint8_t _ALIGN(64) hash[64]; 21 | 22 | sph_luffa512_context ctx_luffa; 23 | 24 | sph_luffa512_init(&ctx_luffa); 25 | sph_luffa512 (&ctx_luffa, input, 80); 26 | sph_luffa512_close(&ctx_luffa, (void*) hash); 27 | 28 | memcpy(state, hash, 32); 29 | } 30 | 31 | static bool init[MAX_GPUS] = { 0 }; 32 | 33 | extern "C" int scanhash_luffa(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) 34 | { 35 | uint32_t _ALIGN(64) endiandata[20]; 36 | uint32_t *pdata = work->data; 37 | uint32_t *ptarget = work->target; 38 | const uint32_t first_nonce = pdata[19]; 39 | uint32_t throughput = cuda_default_throughput(thr_id, 1U << 21); 40 | if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce); 41 | 42 | if (opt_benchmark) 43 | ptarget[7] = 0x0000f; 44 | 45 | if (!init[thr_id]) 46 | { 47 | cudaSetDevice(device_map[thr_id]); 48 | if (opt_cudaschedule == -1 && gpu_threads == 1) { 49 | cudaDeviceReset(); 50 | // reduce cpu usage 51 | cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync); 52 | CUDA_LOG_ERROR(); 53 | } 54 | gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput); 55 | 56 | CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], (size_t) 64 * throughput)); 57 | 58 | qubit_luffa512_cpu_init(thr_id, throughput); 59 | cuda_check_cpu_init(thr_id, throughput); 60 | 61 | init[thr_id] = true; 62 | } 63 | 64 | for (int k=0; k < 19; k++) 65 | be32enc(&endiandata[k], pdata[k]); 66 | 67 | qubit_luffa512_cpu_setBlock_80((void*)endiandata); 68 | cuda_check_cpu_setTarget(ptarget); 69 | 70 | do { 71 | qubit_luffa512_cpu_hash_80(thr_id, (int) throughput, pdata[19], d_hash[thr_id], 0); 72 | 73 | *hashes_done = pdata[19] - first_nonce + throughput; 74 | 75 | work->nonces[0] = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]); 76 | if (work->nonces[0] != UINT32_MAX) 77 | { 78 | const uint32_t Htarg = ptarget[7]; 79 | uint32_t _ALIGN(64) vhash[8]; 80 | be32enc(&endiandata[19], work->nonces[0]); 81 | luffa_hash(vhash, endiandata); 82 | 83 | if (vhash[7] <= Htarg && fulltest(vhash, ptarget)) { 84 | work->valid_nonces = 1; 85 | work_set_target_ratio(work, vhash); 86 | work->nonces[1] = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1); 87 | if (work->nonces[1] != 0) { 88 | be32enc(&endiandata[19], work->nonces[1]); 89 | luffa_hash(vhash, endiandata); 90 | bn_set_target_ratio(work, vhash, 1); 91 | work->valid_nonces++; 92 | pdata[19] = max(work->nonces[0], work->nonces[1]) + 1; 93 | } else { 94 | pdata[19] = work->nonces[0] + 1; // cursor 95 | } 96 | return work->valid_nonces; 97 | } 98 | else if (vhash[7] > Htarg) { 99 | gpu_increment_reject(thr_id); 100 | if (!opt_quiet) 101 | gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]); 102 | pdata[19] = work->nonces[0] + 1; 103 | continue; 104 | } 105 | } 106 | 107 | if ((uint64_t)throughput + pdata[19] >= max_nonce) { 108 | pdata[19] = max_nonce; 109 | break; 110 | } 111 | pdata[19] += throughput; 112 | 113 | } while (!work_restart[thr_id].restart); 114 | 115 | *hashes_done = pdata[19] - first_nonce; 116 | return 0; 117 | } 118 | 119 | // cleanup 120 | extern "C" void free_luffa(int thr_id) 121 | { 122 | if (!init[thr_id]) 123 | return; 124 | 125 | cudaThreadSynchronize(); 126 | 127 | cudaFree(d_hash[thr_id]); 128 | 129 | cuda_check_cpu_free(thr_id); 130 | 131 | init[thr_id] = false; 132 | cudaDeviceSynchronize(); 133 | } 134 | -------------------------------------------------------------------------------- /res/ccminer.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/res/ccminer.ico -------------------------------------------------------------------------------- /res/ccminer.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/res/ccminer.rc -------------------------------------------------------------------------------- /res/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nanashi-Meiyo-Meijin/ccminer_v2.2_mod_r2/8affcb9cd09edd917d33c1ed450f23400f571bdb/res/resource.h -------------------------------------------------------------------------------- /scrypt/code/scrypt-conf.h: -------------------------------------------------------------------------------- 1 | /* 2 | pick the best algo at runtime or compile time? 3 | ---------------------------------------------- 4 | SCRYPT_CHOOSE_COMPILETIME (gcc only!) 5 | SCRYPT_CHOOSE_RUNTIME 6 | */ 7 | #define SCRYPT_CHOOSE_RUNTIME 8 | 9 | 10 | /* 11 | hash function to use 12 | ------------------------------- 13 | SCRYPT_BLAKE256 14 | SCRYPT_BLAKE512 15 | SCRYPT_SHA256 16 | SCRYPT_SHA512 17 | SCRYPT_SKEIN512 18 | */ 19 | //#define SCRYPT_SHA256 20 | 21 | 22 | /* 23 | block mixer to use 24 | ----------------------------- 25 | SCRYPT_CHACHA 26 | SCRYPT_SALSA 27 | */ 28 | //#define SCRYPT_SALSA 29 | -------------------------------------------------------------------------------- /scrypt/code/scrypt-jane-chacha.h: -------------------------------------------------------------------------------- 1 | #define SCRYPT_MIX_BASE "ChaCha20/8" 2 | 3 | typedef uint32_t scrypt_mix_word_t; 4 | 5 | #define SCRYPT_WORDTO8_LE U32TO8_LE 6 | #define SCRYPT_WORD_ENDIAN_SWAP U32_SWAP 7 | 8 | #define SCRYPT_P 1 9 | #define SCRYPT_R 1 10 | #define SCRYPT_BLOCK_BYTES 64 11 | #define SCRYPT_BLOCK_WORDS (SCRYPT_BLOCK_BYTES / sizeof(scrypt_mix_word_t)) 12 | 13 | /* must have these here in case block bytes is ever != 64 */ 14 | #include "scrypt-jane-romix-basic.h" 15 | 16 | #include "scrypt-jane-mix_chacha.h" 17 | 18 | /* cpu agnostic */ 19 | #define SCRYPT_ROMIX_FN scrypt_ROMix_basic 20 | #define SCRYPT_MIX_FN chacha_core_basic 21 | #define SCRYPT_ROMIX_TANGLE_FN scrypt_romix_convert_endian 22 | #define SCRYPT_ROMIX_UNTANGLE_FN scrypt_romix_convert_endian 23 | #include "scrypt-jane-romix-template.h" 24 | 25 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) 26 | static scrypt_ROMixfn 27 | scrypt_getROMix() { 28 | size_t cpuflags = detect_cpu(); 29 | 30 | return scrypt_ROMix_basic; 31 | } 32 | #endif 33 | 34 | 35 | #if defined(SCRYPT_TEST_SPEED) 36 | static size_t 37 | available_implementations() { 38 | size_t cpuflags = detect_cpu(); 39 | size_t flags = 0; 40 | 41 | return flags; 42 | } 43 | #endif 44 | 45 | static int 46 | scrypt_test_mix() { 47 | static const uint8_t expected[16] = { 48 | 0x48,0x2b,0x2d,0xb8,0xa1,0x33,0x22,0x73,0xcd,0x16,0xc4,0xb4,0xb0,0x7f,0xb1,0x8a, 49 | }; 50 | 51 | int ret = 1; 52 | size_t cpuflags = detect_cpu(); 53 | 54 | #if defined(SCRYPT_CHACHA_BASIC) 55 | ret &= scrypt_test_mix_instance(scrypt_ChunkMix_basic, scrypt_romix_convert_endian, scrypt_romix_convert_endian, expected); 56 | #endif 57 | 58 | return ret; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /scrypt/code/scrypt-jane-mix_chacha.h: -------------------------------------------------------------------------------- 1 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_CHACHA_INCLUDED) 2 | 3 | #undef SCRYPT_MIX 4 | #define SCRYPT_MIX "ChaCha20/8 Ref" 5 | 6 | #undef SCRYPT_CHACHA_INCLUDED 7 | #define SCRYPT_CHACHA_INCLUDED 8 | #define SCRYPT_CHACHA_BASIC 9 | 10 | static void 11 | chacha_core_basic(uint32_t state[16]) { 12 | size_t rounds = 8; 13 | uint32_t x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,t; 14 | 15 | x0 = state[0]; 16 | x1 = state[1]; 17 | x2 = state[2]; 18 | x3 = state[3]; 19 | x4 = state[4]; 20 | x5 = state[5]; 21 | x6 = state[6]; 22 | x7 = state[7]; 23 | x8 = state[8]; 24 | x9 = state[9]; 25 | x10 = state[10]; 26 | x11 = state[11]; 27 | x12 = state[12]; 28 | x13 = state[13]; 29 | x14 = state[14]; 30 | x15 = state[15]; 31 | 32 | #define quarter(a,b,c,d) \ 33 | a += b; t = d^a; d = ROTL32(t,16); \ 34 | c += d; t = b^c; b = ROTL32(t,12); \ 35 | a += b; t = d^a; d = ROTL32(t, 8); \ 36 | c += d; t = b^c; b = ROTL32(t, 7); 37 | 38 | for (; rounds; rounds -= 2) { 39 | quarter( x0, x4, x8,x12) 40 | quarter( x1, x5, x9,x13) 41 | quarter( x2, x6,x10,x14) 42 | quarter( x3, x7,x11,x15) 43 | quarter( x0, x5,x10,x15) 44 | quarter( x1, x6,x11,x12) 45 | quarter( x2, x7, x8,x13) 46 | quarter( x3, x4, x9,x14) 47 | } 48 | 49 | state[0] += x0; 50 | state[1] += x1; 51 | state[2] += x2; 52 | state[3] += x3; 53 | state[4] += x4; 54 | state[5] += x5; 55 | state[6] += x6; 56 | state[7] += x7; 57 | state[8] += x8; 58 | state[9] += x9; 59 | state[10] += x10; 60 | state[11] += x11; 61 | state[12] += x12; 62 | state[13] += x13; 63 | state[14] += x14; 64 | state[15] += x15; 65 | 66 | #undef quarter 67 | } 68 | 69 | #endif -------------------------------------------------------------------------------- /scrypt/code/scrypt-jane-portable-x86.h: -------------------------------------------------------------------------------- 1 | 2 | typedef enum cpu_flags_x86_t { }cpu_flags_x86; 3 | 4 | typedef enum cpu_vendors_x86_t { 5 | cpu_nobody, 6 | cpu_intel, 7 | cpu_amd 8 | } cpu_vendors_x86; 9 | 10 | typedef struct x86_regs_t { 11 | uint32_t eax, ebx, ecx, edx; 12 | } x86_regs; 13 | 14 | 15 | #if defined(SCRYPT_TEST_SPEED) 16 | size_t cpu_detect_mask = (size_t)-1; 17 | #endif 18 | 19 | static size_t 20 | detect_cpu(void) { 21 | size_t cpu_flags = 0; 22 | return cpu_flags; 23 | } 24 | 25 | #if defined(SCRYPT_TEST_SPEED) 26 | static const char * 27 | get_top_cpuflag_desc(size_t flag) { 28 | return "Basic"; 29 | } 30 | #endif 31 | 32 | #define asm_calling_convention 33 | -------------------------------------------------------------------------------- /scrypt/code/scrypt-jane-romix-basic.h: -------------------------------------------------------------------------------- 1 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) 2 | /* function type returned by scrypt_getROMix, used with cpu detection */ 3 | typedef void (FASTCALL *scrypt_ROMixfn)(scrypt_mix_word_t *X/*[chunkWords]*/, scrypt_mix_word_t *Y/*[chunkWords]*/, scrypt_mix_word_t *V/*[chunkWords * N]*/, uint32_t N, uint32_t r); 4 | #endif 5 | 6 | /* romix pre/post nop function */ 7 | static void asm_calling_convention 8 | scrypt_romix_nop(scrypt_mix_word_t *blocks, size_t nblocks) { 9 | } 10 | 11 | /* romix pre/post endian conversion function */ 12 | static void asm_calling_convention 13 | scrypt_romix_convert_endian(scrypt_mix_word_t *blocks, size_t nblocks) { 14 | #if !defined(CPU_LE) 15 | static const union { uint8_t b[2]; uint16_t w; } endian_test = {{1,0}}; 16 | size_t i; 17 | if (endian_test.w == 0x100) { 18 | nblocks *= SCRYPT_BLOCK_WORDS; 19 | for (i = 0; i < nblocks; i++) { 20 | SCRYPT_WORD_ENDIAN_SWAP(blocks[i]); 21 | } 22 | } 23 | #endif 24 | } 25 | 26 | /* chunkmix test function */ 27 | typedef void (asm_calling_convention *chunkmixfn)(scrypt_mix_word_t *Bout/*[chunkWords]*/, scrypt_mix_word_t *Bin/*[chunkWords]*/, scrypt_mix_word_t *Bxor/*[chunkWords]*/, uint32_t r); 28 | typedef void (asm_calling_convention *blockfixfn)(scrypt_mix_word_t *blocks, size_t nblocks); 29 | 30 | static int 31 | scrypt_test_mix_instance(chunkmixfn mixfn, blockfixfn prefn, blockfixfn postfn, const uint8_t expected[16]) { 32 | /* r = 2, (2 * r) = 4 blocks in a chunk, 4 * SCRYPT_BLOCK_WORDS total */ 33 | const uint32_t r = 2, blocks = 2 * r, words = blocks * SCRYPT_BLOCK_WORDS; 34 | scrypt_mix_word_t MM16 chunk[2][4 * SCRYPT_BLOCK_WORDS], v; 35 | uint8_t final[16]; 36 | size_t i; 37 | 38 | for (i = 0; i < words; i++) { 39 | v = (scrypt_mix_word_t)i; 40 | v = (v << 8) | v; 41 | v = (v << 16) | v; 42 | chunk[0][i] = v; 43 | } 44 | 45 | prefn(chunk[0], blocks); 46 | mixfn(chunk[1], chunk[0], NULL, r); 47 | postfn(chunk[1], blocks); 48 | 49 | /* grab the last 16 bytes of the final block */ 50 | for (i = 0; i < 16; i += sizeof(scrypt_mix_word_t)) { 51 | SCRYPT_WORDTO8_LE(final + i, chunk[1][words - (16 / sizeof(scrypt_mix_word_t)) + (i / sizeof(scrypt_mix_word_t))]); 52 | } 53 | 54 | return scrypt_verify(expected, final, 16); 55 | } 56 | 57 | /* returns a pointer to item i, where item is len scrypt_mix_word_t's long */ 58 | static scrypt_mix_word_t * 59 | scrypt_item(scrypt_mix_word_t *base, scrypt_mix_word_t i, scrypt_mix_word_t len) { 60 | return base + (i * len); 61 | } 62 | 63 | /* returns a pointer to block i */ 64 | static scrypt_mix_word_t * 65 | scrypt_block(scrypt_mix_word_t *base, scrypt_mix_word_t i) { 66 | return base + (i * SCRYPT_BLOCK_WORDS); 67 | } 68 | -------------------------------------------------------------------------------- /scrypt/fermi_kernel.h: -------------------------------------------------------------------------------- 1 | #ifndef FERMI_KERNEL_H 2 | #define FERMI_KERNEL_H 3 | 4 | #include "salsa_kernel.h" 5 | 6 | class FermiKernel : public KernelInterface 7 | { 8 | public: 9 | FermiKernel(); 10 | 11 | virtual void set_scratchbuf_constants(int MAXWARPS, uint32_t** h_V); 12 | virtual bool run_kernel(dim3 grid, dim3 threads, int WARPS_PER_BLOCK, int thr_id, cudaStream_t stream, uint32_t* d_idata, uint32_t* d_odata, unsigned int N, unsigned int LOOKUP_GAP, bool interactive, bool benchmark, int texture_cache); 13 | virtual bool bindtexture_1D(uint32_t *d_V, size_t size); 14 | virtual bool bindtexture_2D(uint32_t *d_V, int width, int height, size_t pitch); 15 | virtual bool unbindtexture_1D(); 16 | virtual bool unbindtexture_2D(); 17 | 18 | virtual char get_identifier() { return 'F'; }; 19 | virtual int get_major_version() { return 1; } 20 | virtual int get_minor_version() { return 0; } 21 | virtual int max_warps_per_block() { return 16; }; 22 | virtual int get_texel_width() { return 4; }; 23 | virtual bool support_lookup_gap() { return true; } 24 | virtual cudaSharedMemConfig shared_mem_config() { return cudaSharedMemBankSizeFourByte; } 25 | virtual cudaFuncCache cache_config() { return cudaFuncCachePreferShared; } 26 | }; 27 | 28 | #endif // #ifndef FERMI_KERNEL_H 29 | -------------------------------------------------------------------------------- /scrypt/keccak.h: -------------------------------------------------------------------------------- 1 | #ifndef KECCAK_H 2 | #define KEKKAC_H 3 | 4 | extern "C" void prepare_keccak512(int thr_id, const uint32_t host_pdata[20]); 5 | extern "C" void pre_keccak512(int thr_id, int stream, uint32_t nonce, int throughput); 6 | extern "C" void post_keccak512(int thr_id, int stream, uint32_t nonce, int throughput); 7 | 8 | #endif // #ifndef KEKKAC_H 9 | -------------------------------------------------------------------------------- /scrypt/kepler_kernel.h: -------------------------------------------------------------------------------- 1 | #ifndef KEPLER_KERNEL_H 2 | #define KEPLER_KERNEL_H 3 | 4 | #include "salsa_kernel.h" 5 | 6 | class KeplerKernel : public KernelInterface 7 | { 8 | public: 9 | KeplerKernel(); 10 | 11 | virtual void set_scratchbuf_constants(int MAXWARPS, uint32_t** h_V); 12 | virtual bool run_kernel(dim3 grid, dim3 threads, int WARPS_PER_BLOCK, int thr_id, cudaStream_t stream, uint32_t* d_idata, uint32_t* d_odata, unsigned int N, unsigned int LOOKUP_GAP, bool interactive, bool benchmark, int texture_cache); 13 | virtual bool bindtexture_1D(uint32_t *d_V, size_t size); 14 | virtual bool bindtexture_2D(uint32_t *d_V, int width, int height, size_t pitch); 15 | virtual bool unbindtexture_1D(); 16 | virtual bool unbindtexture_2D(); 17 | 18 | virtual char get_identifier() { return 'k'; }; 19 | virtual int get_major_version() { return 3; }; 20 | virtual int get_minor_version() { return 0; }; 21 | 22 | virtual int max_warps_per_block() { return 32; }; 23 | virtual int get_texel_width() { return 4; }; 24 | virtual int threads_per_wu() { return 4; } 25 | virtual bool support_lookup_gap() { return true; } 26 | virtual cudaFuncCache cache_config() { return cudaFuncCachePreferL1; } 27 | }; 28 | 29 | #endif // #ifndef KEPLER_KERNEL_H 30 | -------------------------------------------------------------------------------- /scrypt/nv_kernel.h: -------------------------------------------------------------------------------- 1 | #ifndef NV_KERNEL_H 2 | #define NV_KERNEL_H 3 | 4 | #include "salsa_kernel.h" 5 | 6 | class NVKernel : public KernelInterface 7 | { 8 | public: 9 | NVKernel(); 10 | 11 | virtual void set_scratchbuf_constants(int MAXWARPS, uint32_t** h_V); 12 | virtual bool run_kernel(dim3 grid, dim3 threads, int WARPS_PER_BLOCK, int thr_id, cudaStream_t stream, uint32_t* d_idata, uint32_t* d_odata, unsigned int N, unsigned int LOOKUP_GAP, bool interactive, bool benchmark, int texture_cache); 13 | 14 | virtual bool bindtexture_1D(uint32_t *d_V, size_t size); 15 | virtual bool bindtexture_2D(uint32_t *d_V, int width, int height, size_t pitch); 16 | virtual bool unbindtexture_1D(); 17 | virtual bool unbindtexture_2D(); 18 | 19 | virtual char get_identifier() { return 'K'; }; 20 | virtual int get_major_version() { return 3; }; 21 | virtual int get_minor_version() { return 0; }; 22 | 23 | virtual int max_warps_per_block() { return 32; }; 24 | virtual int get_texel_width() { return 4; }; 25 | virtual bool support_lookup_gap() { return true; } 26 | virtual cudaSharedMemConfig shared_mem_config() { return cudaSharedMemBankSizeFourByte; } 27 | virtual cudaFuncCache cache_config() { return cudaFuncCachePreferL1; } 28 | }; 29 | 30 | #endif // #ifndef NV_KERNEL_H 31 | -------------------------------------------------------------------------------- /scrypt/nv_kernel2.h: -------------------------------------------------------------------------------- 1 | #ifndef NV2_KERNEL_H 2 | #define NV2_KERNEL_H 3 | 4 | #include "miner.h" 5 | #include 6 | 7 | #include "salsa_kernel.h" 8 | 9 | class NV2Kernel : public KernelInterface 10 | { 11 | public: 12 | NV2Kernel(); 13 | 14 | virtual void set_scratchbuf_constants(int MAXWARPS, uint32_t** h_V); 15 | virtual bool run_kernel(dim3 grid, dim3 threads, int WARPS_PER_BLOCK, int thr_id, cudaStream_t stream, uint32_t* d_idata, uint32_t* d_odata, unsigned int N, unsigned int LOOKUP_GAP, bool interactive, bool benchmark, int texture_cache); 16 | 17 | virtual char get_identifier() { return 'T'; }; 18 | virtual int get_major_version() { return 3; }; 19 | virtual int get_minor_version() { return 5; }; 20 | 21 | virtual int max_warps_per_block() { return 24; }; 22 | virtual int get_texel_width() { return 4; }; 23 | virtual bool no_textures() { return true; } 24 | virtual bool support_lookup_gap() { return true; } 25 | 26 | virtual cudaSharedMemConfig shared_mem_config() { return cudaSharedMemBankSizeFourByte; } 27 | virtual cudaFuncCache cache_config() { return cudaFuncCachePreferL1; } 28 | }; 29 | 30 | #endif // #ifndef NV2_KERNEL_H 31 | -------------------------------------------------------------------------------- /scrypt/salsa_kernel.h: -------------------------------------------------------------------------------- 1 | #ifndef SALSA_KERNEL_H 2 | #define SALSA_KERNEL_H 3 | 4 | #include 5 | #include 6 | #include 7 | #ifndef __APPLE__ 8 | #include 9 | #endif 10 | #include 11 | #include 12 | 13 | #include "miner.h" 14 | 15 | // from ccminer.cpp 16 | extern short device_map[MAX_GPUS]; 17 | extern int device_batchsize[MAX_GPUS]; // cudaminer -b 18 | extern int device_interactive[MAX_GPUS]; // cudaminer -i 19 | extern int device_texturecache[MAX_GPUS]; // cudaminer -C 20 | extern int device_singlememory[MAX_GPUS]; // cudaminer -m 21 | extern int device_lookup_gap[MAX_GPUS]; // -L 22 | extern int device_backoff[MAX_GPUS]; // WIN32/LINUX var 23 | extern char *device_config[MAX_GPUS]; // -l 24 | extern char *device_name[MAX_GPUS]; 25 | 26 | extern bool opt_autotune; 27 | extern int opt_nfactor; 28 | extern char *jane_params; 29 | extern int parallel; 30 | 31 | extern void get_currentalgo(char* buf, int sz); 32 | 33 | typedef unsigned int uint32_t; // define this as 32 bit type derived from int 34 | 35 | // scrypt variants 36 | #define A_SCRYPT 0 37 | #define A_SCRYPT_JANE 1 38 | static char algo[64] = { 0 }; 39 | static int scrypt_algo = -1; 40 | static __inline int get_scrypt_type() { 41 | if (scrypt_algo != -1) return scrypt_algo; 42 | get_currentalgo(algo, 64); 43 | if (!strncasecmp(algo,"scrypt-jane",11)) scrypt_algo = A_SCRYPT_JANE; 44 | else if (!strncasecmp(algo,"scrypt",6)) scrypt_algo = A_SCRYPT; 45 | return scrypt_algo; 46 | } 47 | static __inline bool IS_SCRYPT() { get_scrypt_type(); return (scrypt_algo == A_SCRYPT); } 48 | static __inline bool IS_SCRYPT_JANE() { get_scrypt_type(); return (scrypt_algo == A_SCRYPT_JANE); } 49 | 50 | // CUDA externals 51 | extern int cuda_throughput(int thr_id); 52 | extern uint32_t *cuda_transferbuffer(int thr_id, int stream); 53 | extern uint32_t *cuda_hashbuffer(int thr_id, int stream); 54 | 55 | extern void cuda_scrypt_HtoD(int thr_id, uint32_t *X, int stream); 56 | extern void cuda_scrypt_serialize(int thr_id, int stream); 57 | extern void cuda_scrypt_core(int thr_id, int stream, unsigned int N); 58 | extern void cuda_scrypt_done(int thr_id, int stream); 59 | extern void cuda_scrypt_DtoH(int thr_id, uint32_t *X, int stream, bool postSHA); 60 | extern bool cuda_scrypt_sync(int thr_id, int stream); 61 | extern void cuda_scrypt_flush(int thr_id, int stream); 62 | 63 | // If we're in C++ mode, we're either compiling .cu files or scrypt.cpp 64 | 65 | #ifdef __NVCC__ 66 | 67 | /** 68 | * An pure virtual interface for a CUDA kernel implementation. 69 | * TODO: encapsulate the kernel launch parameters in some kind of wrapper. 70 | */ 71 | class KernelInterface 72 | { 73 | public: 74 | virtual void set_scratchbuf_constants(int MAXWARPS, uint32_t** h_V) = 0; 75 | virtual bool run_kernel(dim3 grid, dim3 threads, int WARPS_PER_BLOCK, int thr_id, cudaStream_t stream, uint32_t* d_idata, uint32_t* d_odata, unsigned int N, unsigned int LOOKUP_GAP, bool interactive, bool benchmark, int texture_cache) = 0; 76 | virtual bool bindtexture_1D(uint32_t *d_V, size_t size) { return true; } 77 | virtual bool bindtexture_2D(uint32_t *d_V, int width, int height, size_t pitch) { return true; } 78 | virtual bool unbindtexture_1D() { return true; } 79 | virtual bool unbindtexture_2D() { return true; } 80 | 81 | virtual char get_identifier() = 0; 82 | virtual int get_major_version() { return 1; } 83 | virtual int get_minor_version() { return 0; } 84 | virtual int max_warps_per_block() = 0; 85 | virtual int get_texel_width() = 0; 86 | virtual bool no_textures() { return false; }; 87 | virtual bool single_memory() { return false; }; 88 | virtual int threads_per_wu() { return 1; } 89 | virtual bool support_lookup_gap() { return false; } 90 | virtual cudaSharedMemConfig shared_mem_config() { return cudaSharedMemBankSizeDefault; } 91 | virtual cudaFuncCache cache_config() { return cudaFuncCachePreferNone; } 92 | }; 93 | 94 | // Not performing error checking is actually bad, but... 95 | #define checkCudaErrors(x) x 96 | #define getLastCudaError(x) 97 | 98 | #endif // #ifdef __NVCC__ 99 | 100 | // Define work unit size 101 | #define TOTAL_WARP_LIMIT 4096 102 | #define WU_PER_WARP (32 / THREADS_PER_WU) 103 | #define WU_PER_BLOCK (WU_PER_WARP*WARPS_PER_BLOCK) 104 | #define WU_PER_LAUNCH (GRID_BLOCKS*WU_PER_BLOCK) 105 | 106 | // make scratchpad size dependent on N and LOOKUP_GAP 107 | #define SCRATCH (((N+LOOKUP_GAP-1)/LOOKUP_GAP)*32) 108 | 109 | #endif // #ifndef SALSA_KERNEL_H 110 | -------------------------------------------------------------------------------- /scrypt/scrypt-jane.h: -------------------------------------------------------------------------------- 1 | #ifndef SCRYPT_JANE_H 2 | #define SCRYPT_JANE_H 3 | 4 | /* 5 | Nfactor: Increases CPU & Memory Hardness 6 | N = (1 << (Nfactor + 1)): How many times to mix a chunk and how many temporary chunks are used 7 | 8 | rfactor: Increases Memory Hardness 9 | r = (1 << rfactor): How large a chunk is 10 | 11 | pfactor: Increases CPU Hardness 12 | p = (1 << pfactor): Number of times to mix the main chunk 13 | 14 | A block is the basic mixing unit (salsa/chacha block = 64 bytes) 15 | A chunk is (2 * r) blocks 16 | 17 | ~Memory used = (N + 2) * ((2 * r) * block size) 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | typedef void (*scrypt_fatal_errorfn)(const char *msg); 25 | void scrypt_set_fatal_error(scrypt_fatal_errorfn fn); 26 | 27 | void scrypt_N_1_1(const unsigned char *password, size_t password_len, const unsigned char *salt, size_t salt_len, uint32_t N, unsigned char *out, size_t bytes, uint8_t *X, uint8_t *Y, uint8_t *V); 28 | 29 | #endif /* SCRYPT_JANE_H */ 30 | -------------------------------------------------------------------------------- /scrypt/sha256.h: -------------------------------------------------------------------------------- 1 | #ifndef SHA256_H 2 | #define SHA256_H 3 | 4 | #include 5 | 6 | extern "C" void prepare_sha256(int thr_id, uint32_t cpu_pdata[20], uint32_t cpu_midstate[8]); 7 | extern "C" void pre_sha256(int thr_id, int stream, uint32_t nonce, int throughput); 8 | extern "C" void post_sha256(int thr_id, int stream, int throughput); 9 | 10 | #endif // #ifndef SHA256_H 11 | -------------------------------------------------------------------------------- /scrypt/test_kernel.h: -------------------------------------------------------------------------------- 1 | #ifndef TEST_KERNEL_H 2 | #define TEST_KERNEL_H 3 | 4 | #include "salsa_kernel.h" 5 | 6 | class TestKernel : public KernelInterface 7 | { 8 | public: 9 | TestKernel(); 10 | 11 | virtual void set_scratchbuf_constants(int MAXWARPS, uint32_t** h_V); 12 | virtual bool run_kernel(dim3 grid, dim3 threads, int WARPS_PER_BLOCK, int thr_id, cudaStream_t stream, uint32_t* d_idata, uint32_t* d_odata, unsigned int N, unsigned int LOOKUP_GAP, bool interactive, bool benchmark, int texture_cache); 13 | virtual bool bindtexture_1D(uint32_t *d_V, size_t size); 14 | virtual bool bindtexture_2D(uint32_t *d_V, int width, int height, size_t pitch); 15 | virtual bool unbindtexture_1D(); 16 | virtual bool unbindtexture_2D(); 17 | 18 | virtual char get_identifier() { return 'f'; }; 19 | virtual int get_major_version() { return 1; }; 20 | virtual int get_minor_version() { return 0; }; 21 | 22 | virtual int max_warps_per_block() { return 32; }; 23 | virtual int get_texel_width() { return 4; }; 24 | virtual int threads_per_wu() { return 4; } 25 | virtual bool support_lookup_gap() { return true; } 26 | virtual cudaSharedMemConfig shared_mem_config() { return cudaSharedMemBankSizeFourByte; } 27 | virtual cudaFuncCache cache_config() { return cudaFuncCachePreferL1; } 28 | }; 29 | 30 | #endif // #ifndef TEST_KERNEL_H 31 | -------------------------------------------------------------------------------- /scrypt/titan_kernel.h: -------------------------------------------------------------------------------- 1 | #ifndef TITAN_KERNEL_H 2 | #define TITAN_KERNEL_H 3 | 4 | #include "salsa_kernel.h" 5 | 6 | class TitanKernel : public KernelInterface 7 | { 8 | public: 9 | TitanKernel(); 10 | 11 | virtual void set_scratchbuf_constants(int MAXWARPS, uint32_t** h_V); 12 | virtual bool run_kernel(dim3 grid, dim3 threads, int WARPS_PER_BLOCK, int thr_id, cudaStream_t stream, uint32_t* d_idata, uint32_t* d_odata, unsigned int N, unsigned int LOOKUP_GAP, bool interactive, bool benchmark, int texture_cache); 13 | 14 | virtual char get_identifier() { return 't'; } 15 | virtual int get_major_version() { return 3; } 16 | virtual int get_minor_version() { return 5; } 17 | 18 | virtual int max_warps_per_block() { return 32; } 19 | virtual int get_texel_width() { return 4; } 20 | virtual bool no_textures() { return true; } 21 | virtual int threads_per_wu() { return 4; } 22 | virtual bool support_lookup_gap() { return true; } 23 | virtual cudaFuncCache cache_config() { return cudaFuncCachePreferL1; } 24 | }; 25 | 26 | #endif // #ifndef TITAN_KERNEL_H 27 | -------------------------------------------------------------------------------- /sha256/sha256d.cu: -------------------------------------------------------------------------------- 1 | /** 2 | * SHA256d 3 | * by tpruvot@github - 2017 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // CPU Check 11 | extern "C" void sha256d_hash(void *output, const void *input) 12 | { 13 | unsigned char _ALIGN(64) hash[64]; 14 | SHA256_CTX sha256; 15 | 16 | SHA256_Init(&sha256); 17 | SHA256_Update(&sha256, (unsigned char *)input, 80); 18 | SHA256_Final(hash, &sha256); 19 | 20 | SHA256_Init(&sha256); 21 | SHA256_Update(&sha256, hash, 32); 22 | SHA256_Final((unsigned char *)output, &sha256); 23 | } 24 | 25 | static bool init[MAX_GPUS] = { 0 }; 26 | extern void sha256d_init(int thr_id); 27 | extern void sha256d_free(int thr_id); 28 | extern void sha256d_setBlock_80(uint32_t *pdata, uint32_t *ptarget); 29 | extern void sha256d_hash_80(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *resNonces); 30 | 31 | extern "C" int scanhash_sha256d(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) 32 | { 33 | uint32_t _ALIGN(64) endiandata[20]; 34 | uint32_t *pdata = work->data; 35 | uint32_t *ptarget = work->target; 36 | const uint32_t first_nonce = pdata[19]; 37 | uint32_t throughput = cuda_default_throughput(thr_id, 1U << 25); 38 | if (init[thr_id]) throughput = min(throughput, (max_nonce - first_nonce)); 39 | 40 | if (opt_benchmark) 41 | ((uint32_t*)ptarget)[7] = 0x03; 42 | 43 | if (!init[thr_id]) 44 | { 45 | cudaSetDevice(device_map[thr_id]); 46 | if (opt_cudaschedule == -1 && gpu_threads == 1) { 47 | cudaDeviceReset(); 48 | // reduce cpu usage 49 | cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync); 50 | CUDA_LOG_ERROR(); 51 | } 52 | gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput); 53 | 54 | sha256d_init(thr_id); 55 | 56 | init[thr_id] = true; 57 | } 58 | 59 | for (int k=0; k < 19; k++) 60 | be32enc(&endiandata[k], pdata[k]); 61 | 62 | sha256d_setBlock_80(endiandata, ptarget); 63 | 64 | do { 65 | // Hash with CUDA 66 | *hashes_done = pdata[19] - first_nonce + throughput; 67 | 68 | sha256d_hash_80(thr_id, throughput, pdata[19], work->nonces); 69 | if (work->nonces[0] != UINT32_MAX) 70 | { 71 | uint32_t _ALIGN(64) vhash[8]; 72 | 73 | endiandata[19] = swab32(work->nonces[0]); 74 | sha256d_hash(vhash, endiandata); 75 | if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) { 76 | work->valid_nonces = 1; 77 | work_set_target_ratio(work, vhash); 78 | if (work->nonces[1] != UINT32_MAX) { 79 | endiandata[19] = swab32(work->nonces[1]); 80 | sha256d_hash(vhash, endiandata); 81 | if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) { 82 | work->valid_nonces++; 83 | bn_set_target_ratio(work, vhash, 1); 84 | } 85 | pdata[19] = max(work->nonces[0], work->nonces[1]) + 1; 86 | } else { 87 | pdata[19] = work->nonces[0] + 1; 88 | } 89 | return work->valid_nonces; 90 | } 91 | else if (vhash[7] > ptarget[7]) { 92 | gpu_increment_reject(thr_id); 93 | if (!opt_quiet) 94 | gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]); 95 | pdata[19] = work->nonces[0] + 1; 96 | continue; 97 | } 98 | } 99 | 100 | if ((uint64_t) throughput + pdata[19] >= max_nonce) { 101 | pdata[19] = max_nonce; 102 | break; 103 | } 104 | 105 | pdata[19] += throughput; 106 | 107 | } while (!work_restart[thr_id].restart); 108 | 109 | *hashes_done = pdata[19] - first_nonce; 110 | 111 | return 0; 112 | } 113 | 114 | // cleanup 115 | extern "C" void free_sha256d(int thr_id) 116 | { 117 | if (!init[thr_id]) 118 | return; 119 | 120 | cudaThreadSynchronize(); 121 | 122 | sha256d_free(thr_id); 123 | 124 | init[thr_id] = false; 125 | 126 | cudaDeviceSynchronize(); 127 | } 128 | -------------------------------------------------------------------------------- /sha256/sha256t.cu: -------------------------------------------------------------------------------- 1 | /** 2 | * SHA256 3x 3 | * by tpruvot@github - 2017 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // CPU Check 11 | extern "C" void sha256t_hash(void *output, const void *input) 12 | { 13 | unsigned char _ALIGN(64) hash[64]; 14 | SHA256_CTX sha256; 15 | 16 | SHA256_Init(&sha256); 17 | SHA256_Update(&sha256, (unsigned char *)input, 80); 18 | SHA256_Final(hash, &sha256); 19 | 20 | SHA256_Init(&sha256); 21 | SHA256_Update(&sha256, hash, 32); 22 | SHA256_Final(hash, &sha256); 23 | 24 | SHA256_Init(&sha256); 25 | SHA256_Update(&sha256, hash, 32); 26 | SHA256_Final((unsigned char *)output, &sha256); 27 | } 28 | 29 | static bool init[MAX_GPUS] = { 0 }; 30 | extern void sha256t_init(int thr_id); 31 | extern void sha256t_free(int thr_id); 32 | extern void sha256t_setBlock_80(uint32_t *pdata, uint32_t *ptarget); 33 | extern void sha256t_hash_80(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *resNonces); 34 | 35 | extern "C" int scanhash_sha256t(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) 36 | { 37 | uint32_t _ALIGN(64) endiandata[20]; 38 | uint32_t *pdata = work->data; 39 | uint32_t *ptarget = work->target; 40 | const uint32_t first_nonce = pdata[19]; 41 | uint32_t throughput = cuda_default_throughput(thr_id, 1U << 23); 42 | if (init[thr_id]) throughput = min(throughput, (max_nonce - first_nonce)); 43 | 44 | if (opt_benchmark) 45 | ((uint32_t*)ptarget)[7] = 0x03; 46 | 47 | if (!init[thr_id]) 48 | { 49 | cudaSetDevice(device_map[thr_id]); 50 | if (opt_cudaschedule == -1 && gpu_threads == 1) { 51 | cudaDeviceReset(); 52 | // reduce cpu usage 53 | cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync); 54 | CUDA_LOG_ERROR(); 55 | } 56 | gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput); 57 | 58 | sha256t_init(thr_id); 59 | 60 | init[thr_id] = true; 61 | } 62 | 63 | for (int k=0; k < 19; k++) 64 | be32enc(&endiandata[k], pdata[k]); 65 | 66 | sha256t_setBlock_80(endiandata, ptarget); 67 | 68 | do { 69 | // Hash with CUDA 70 | *hashes_done = pdata[19] - first_nonce + throughput; 71 | 72 | sha256t_hash_80(thr_id, throughput, pdata[19], work->nonces); 73 | if (work->nonces[0] != UINT32_MAX) 74 | { 75 | uint32_t _ALIGN(64) vhash[8]; 76 | 77 | endiandata[19] = swab32(work->nonces[0]); 78 | sha256t_hash(vhash, endiandata); 79 | if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) { 80 | work->valid_nonces = 1; 81 | work_set_target_ratio(work, vhash); 82 | if (work->nonces[1] != UINT32_MAX) { 83 | endiandata[19] = swab32(work->nonces[1]); 84 | sha256t_hash(vhash, endiandata); 85 | if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) { 86 | work->valid_nonces++; 87 | bn_set_target_ratio(work, vhash, 1); 88 | } 89 | pdata[19] = max(work->nonces[0], work->nonces[1]) + 1; 90 | } else { 91 | pdata[19] = work->nonces[0] + 1; 92 | } 93 | return work->valid_nonces; 94 | } 95 | else if (vhash[7] > ptarget[7]) { 96 | gpu_increment_reject(thr_id); 97 | if (!opt_quiet) 98 | gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]); 99 | pdata[19] = work->nonces[0] + 1; 100 | continue; 101 | } 102 | } 103 | 104 | if ((uint64_t) throughput + pdata[19] >= max_nonce) { 105 | pdata[19] = max_nonce; 106 | break; 107 | } 108 | 109 | pdata[19] += throughput; 110 | 111 | } while (!work_restart[thr_id].restart); 112 | 113 | *hashes_done = pdata[19] - first_nonce; 114 | 115 | return 0; 116 | } 117 | 118 | // cleanup 119 | extern "C" void free_sha256t(int thr_id) 120 | { 121 | if (!init[thr_id]) 122 | return; 123 | 124 | cudaThreadSynchronize(); 125 | 126 | sha256t_free(thr_id); 127 | 128 | init[thr_id] = false; 129 | 130 | cudaDeviceSynchronize(); 131 | } 132 | -------------------------------------------------------------------------------- /sia/sia-rpc.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char* sia_getheader(CURL *curl, struct pool_infos *pool); 4 | bool sia_work_decode(const char *hexdata, struct work *work); 5 | bool sia_submit(CURL *curl, struct pool_infos *pool, struct work *work); 6 | 7 | -------------------------------------------------------------------------------- /sph/blake2b.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef __BLAKE2B_H__ 3 | #define __BLAKE2B_H__ 4 | 5 | #include 6 | #include 7 | 8 | #if defined(_MSC_VER) 9 | #include 10 | #define inline __inline 11 | #define ALIGN(x) __declspec(align(x)) 12 | #else 13 | #define ALIGN(x) __attribute__((aligned(x))) 14 | #endif 15 | 16 | #if defined(_MSC_VER) || defined(__x86_64__) || defined(__x86__) 17 | #define NATIVE_LITTLE_ENDIAN 18 | #endif 19 | 20 | // state context 21 | ALIGN(64) typedef struct { 22 | uint8_t b[128]; // input buffer 23 | uint64_t h[8]; // chained state 24 | uint64_t t[2]; // total number of bytes 25 | size_t c; // pointer for b[] 26 | size_t outlen; // digest size 27 | } blake2b_ctx; 28 | 29 | #if defined(__cplusplus) 30 | extern "C" { 31 | #endif 32 | 33 | int blake2b_init(blake2b_ctx *ctx, size_t outlen, const void *key, size_t keylen); 34 | void blake2b_update(blake2b_ctx *ctx, const void *in, size_t inlen); 35 | void blake2b_final(blake2b_ctx *ctx, void *out); 36 | 37 | #if defined(__cplusplus) 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /sph/sph_fugue.h: -------------------------------------------------------------------------------- 1 | #ifndef SPH_FUGUE_H__ 2 | #define SPH_FUGUE_H__ 3 | 4 | #include 5 | #include "sph_types.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C"{ 9 | #endif 10 | 11 | #define SPH_SIZE_fugue224 224 12 | 13 | #define SPH_SIZE_fugue256 256 14 | 15 | #define SPH_SIZE_fugue384 384 16 | 17 | #define SPH_SIZE_fugue512 512 18 | 19 | typedef struct { 20 | #ifndef DOXYGEN_IGNORE 21 | sph_u32 partial; 22 | unsigned partial_len; 23 | unsigned round_shift; 24 | sph_u32 S[36]; 25 | #if SPH_64 26 | sph_u64 bit_count; 27 | #else 28 | sph_u32 bit_count_high, bit_count_low; 29 | #endif 30 | #endif 31 | } sph_fugue_context; 32 | 33 | typedef sph_fugue_context sph_fugue224_context; 34 | 35 | typedef sph_fugue_context sph_fugue256_context; 36 | 37 | typedef sph_fugue_context sph_fugue384_context; 38 | 39 | typedef sph_fugue_context sph_fugue512_context; 40 | 41 | void sph_fugue224_init(void *cc); 42 | 43 | void sph_fugue224(void *cc, const void *data, size_t len); 44 | 45 | void sph_fugue224_close(void *cc, void *dst); 46 | 47 | void sph_fugue224_addbits_and_close( 48 | void *cc, unsigned ub, unsigned n, void *dst); 49 | 50 | void sph_fugue256_init(void *cc); 51 | 52 | void sph_fugue256(void *cc, const void *data, size_t len); 53 | 54 | void sph_fugue256_close(void *cc, void *dst); 55 | 56 | void sph_fugue256_addbits_and_close( 57 | void *cc, unsigned ub, unsigned n, void *dst); 58 | 59 | void sph_fugue384_init(void *cc); 60 | 61 | void sph_fugue384(void *cc, const void *data, size_t len); 62 | 63 | void sph_fugue384_close(void *cc, void *dst); 64 | 65 | void sph_fugue384_addbits_and_close( 66 | void *cc, unsigned ub, unsigned n, void *dst); 67 | 68 | void sph_fugue512_init(void *cc); 69 | 70 | void sph_fugue512(void *cc, const void *data, size_t len); 71 | 72 | void sph_fugue512_close(void *cc, void *dst); 73 | 74 | void sph_fugue512_addbits_and_close( 75 | void *cc, unsigned ub, unsigned n, void *dst); 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /sysinfos.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Unit to read cpu informations 3 | * 4 | * TODO: WMI implementation for windows 5 | * 6 | * tpruvot 2014 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "miner.h" 15 | 16 | #ifndef WIN32 17 | 18 | #define HWMON_PATH \ 19 | "/sys/class/hwmon/hwmon1/device/temp1_input" 20 | #define HWMON_ALT \ 21 | "/sys/class/hwmon/hwmon0/temp1_input" 22 | 23 | static double linux_cputemp(int core) 24 | { 25 | double tc = 0.0; 26 | FILE *fd = fopen(HWMON_PATH, "r"); 27 | uint32_t val = 0; 28 | 29 | if (!fd) 30 | fd = fopen(HWMON_ALT, "r"); 31 | 32 | if (!fd) 33 | return tc; 34 | 35 | if (fscanf(fd, "%d", &val)) 36 | tc = (double)val / 1000.0; 37 | 38 | fclose(fd); 39 | return tc; 40 | } 41 | 42 | #define CPUFREQ_PATH \ 43 | "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq" 44 | static uint32_t linux_cpufreq(int core) 45 | { 46 | FILE *fd = fopen(CPUFREQ_PATH, "r"); 47 | uint32_t freq = 0; 48 | 49 | if (!fd) 50 | return freq; 51 | 52 | if (!fscanf(fd, "%d", &freq)) 53 | ; 54 | 55 | fclose(fd); 56 | return freq; 57 | } 58 | 59 | #else /* WIN32 */ 60 | 61 | static float win32_cputemp(int core) 62 | { 63 | // todo 64 | return 0.0; 65 | } 66 | 67 | #endif /* !WIN32 */ 68 | 69 | 70 | /* exports */ 71 | 72 | 73 | float cpu_temp(int core) 74 | { 75 | #ifdef WIN32 76 | return win32_cputemp(core); 77 | #else 78 | return (float) linux_cputemp(core); 79 | #endif 80 | } 81 | 82 | uint32_t cpu_clock(int core) 83 | { 84 | #ifdef WIN32 85 | return 0; 86 | #else 87 | return linux_cpufreq(core); 88 | #endif 89 | } 90 | 91 | int cpu_fanpercent() 92 | { 93 | return 0; 94 | } 95 | 96 | -------------------------------------------------------------------------------- /x11/cuda_x11.h: -------------------------------------------------------------------------------- 1 | #include "quark/cuda_quark.h" 2 | 3 | extern void x11_luffaCubehash512_cpu_init(int thr_id, uint32_t threads); 4 | extern void x11_luffaCubehash512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t *d_hash, int order); 5 | 6 | extern void x11_luffa512_cpu_init(int thr_id, uint32_t threads); 7 | extern void x11_luffa512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order); 8 | 9 | extern void x11_cubehash512_cpu_init(int thr_id, uint32_t threads); 10 | 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); 11 | 12 | extern void x11_shavite512_cpu_init(int thr_id, uint32_t threads); 13 | extern void x11_shavite512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order); 14 | 15 | extern int x11_simd512_cpu_init(int thr_id, uint32_t threads); 16 | extern void x11_simd512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order); 17 | extern void x11_simd512_cpu_free(int thr_id); 18 | 19 | extern void x11_echo512_cpu_init(int thr_id, uint32_t threads); 20 | extern void x11_echo512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order); 21 | 22 | -------------------------------------------------------------------------------- /x15/whirlpoolx.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * whirlpool routine (djm) 3 | * whirlpoolx routine (provos alexis, tpruvot) 4 | */ 5 | extern "C" { 6 | #include "sph/sph_whirlpool.h" 7 | } 8 | 9 | #include "miner.h" 10 | #include "cuda_helper.h" 11 | 12 | static uint32_t *d_hash[MAX_GPUS] = { 0 }; 13 | 14 | extern void whirlpoolx_cpu_init(int thr_id, uint32_t threads); 15 | extern void whirlpoolx_cpu_free(int thr_id); 16 | extern void whirlpoolx_setBlock_80(void *pdata, const void *ptarget); 17 | extern uint32_t whirlpoolx_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce); 18 | extern void whirlpoolx_precompute(int thr_id); 19 | 20 | // CPU Hash function 21 | extern "C" void whirlxHash(void *state, const void *input) 22 | { 23 | sph_whirlpool_context ctx_whirlpool; 24 | 25 | unsigned char hash[64]; 26 | unsigned char hash_xored[32]; 27 | 28 | sph_whirlpool_init(&ctx_whirlpool); 29 | sph_whirlpool(&ctx_whirlpool, input, 80); 30 | sph_whirlpool_close(&ctx_whirlpool, hash); 31 | 32 | // compress the 48 first bytes of the hash to 32 33 | for (int i = 0; i < 32; i++) { 34 | hash_xored[i] = hash[i] ^ hash[i + 16]; 35 | } 36 | memcpy(state, hash_xored, 32); 37 | } 38 | 39 | static bool init[MAX_GPUS] = { 0 }; 40 | 41 | extern "C" int scanhash_whirlx(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) 42 | { 43 | uint32_t *pdata = work->data; 44 | uint32_t *ptarget = work->target; 45 | const uint32_t first_nonce = pdata[19]; 46 | uint32_t endiandata[20]; 47 | int intensity = is_windows() ? 20 : 22; 48 | uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity); 49 | if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce); 50 | 51 | if (opt_benchmark) 52 | ptarget[7] = 0x000f; 53 | 54 | if (!init[thr_id]) { 55 | cudaSetDevice(device_map[thr_id]); 56 | if (opt_cudaschedule == -1 && gpu_threads == 1) { 57 | cudaDeviceReset(); 58 | // reduce cpu usage 59 | cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync); 60 | CUDA_LOG_ERROR(); 61 | } 62 | gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput); 63 | 64 | CUDA_CALL_OR_RET_X(cudaMalloc(&d_hash[thr_id], (size_t) 64 * throughput), -1); 65 | 66 | whirlpoolx_cpu_init(thr_id, throughput); 67 | 68 | init[thr_id] = true; 69 | } 70 | 71 | for (int k=0; k < 20; k++) { 72 | be32enc(&endiandata[k], pdata[k]); 73 | } 74 | 75 | whirlpoolx_setBlock_80((void*)endiandata, ptarget); 76 | whirlpoolx_precompute(thr_id); 77 | 78 | do { 79 | uint32_t foundNonce = whirlpoolx_cpu_hash(thr_id, throughput, pdata[19]); 80 | 81 | *(hashes_done) = pdata[19] - first_nonce + throughput; 82 | 83 | if (foundNonce != UINT32_MAX && bench_algo < 0) 84 | { 85 | const uint32_t Htarg = ptarget[7]; 86 | uint32_t vhash64[8]; 87 | be32enc(&endiandata[19], foundNonce); 88 | whirlxHash(vhash64, endiandata); 89 | 90 | if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) { 91 | work_set_target_ratio(work, vhash64); 92 | pdata[19] = foundNonce; 93 | return 1; 94 | } else { 95 | gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", foundNonce); 96 | } 97 | } 98 | 99 | if ((uint64_t)throughput + pdata[19] >= max_nonce) { 100 | pdata[19] = max_nonce; 101 | break; 102 | } 103 | 104 | pdata[19] += throughput; 105 | 106 | } while (!work_restart[thr_id].restart); 107 | 108 | *(hashes_done) = pdata[19] - first_nonce; 109 | 110 | return 0; 111 | } 112 | 113 | // cleanup 114 | extern "C" void free_whirlx(int thr_id) 115 | { 116 | if (!init[thr_id]) 117 | return; 118 | 119 | cudaThreadSynchronize(); 120 | 121 | cudaFree(d_hash[thr_id]); 122 | 123 | whirlpoolx_cpu_free(thr_id); 124 | init[thr_id] = false; 125 | 126 | cudaDeviceSynchronize(); 127 | } 128 | --------------------------------------------------------------------------------