From 15584e4f05183635f92cce6a32af55860bfec768 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sun, 3 May 2015 14:52:10 +0200 Subject: [PATCH] neoscrypt: adapt for visual studio compat todo: fix SM 3.0 builds --- ccminer.cpp | 2 +- ccminer.vcxproj | 4 ++-- ccminer.vcxproj.filters | 9 +++++++++ miner.h | 2 +- neoscrypt.cu | 11 +++++------ neoscrypt/cuda_neoscrypt.cu | 4 ++-- neoscrypt/neoscrypt.c | 10 +++++----- neoscrypt/neoscrypt.h | 2 +- util.cpp | 2 +- 9 files changed, 27 insertions(+), 19 deletions(-) diff --git a/ccminer.cpp b/ccminer.cpp index 3bebf98..8238456 100644 --- a/ccminer.cpp +++ b/ccminer.cpp @@ -275,7 +275,7 @@ Options:\n\ lyra2 VertCoin\n\ mjollnir Mjollnircoin\n\ myr-gr Myriad-Groestl\n\ - neoscrypt use to mine FeatherCoin\n\ + neoscrypt FeatherCoin, Phoenix, UFO...\n\ nist5 NIST5 (TalkCoin)\n\ penta Pentablake hash (5x Blake 512)\n\ pluck SupCoin\n\ diff --git a/ccminer.vcxproj b/ccminer.vcxproj index 9322821..7218c00 100644 --- a/ccminer.vcxproj +++ b/ccminer.vcxproj @@ -179,7 +179,7 @@ 80 true true - compute_30,sm_30;compute_35,sm_35;compute_50,sm_50;compute_52,sm_52 + compute_35,sm_35;compute_50,sm_50;compute_52,sm_52 --ptxas-options="-O2" %(AdditionalOptions) @@ -536,4 +536,4 @@ - + \ No newline at end of file diff --git a/ccminer.vcxproj.filters b/ccminer.vcxproj.filters index 9f62c54..d89036c 100644 --- a/ccminer.vcxproj.filters +++ b/ccminer.vcxproj.filters @@ -231,6 +231,9 @@ Source Files\CUDA\scrypt + + Source Files + @@ -619,6 +622,12 @@ Source Files\CUDA\scrypt + + Source Files\CUDA + + + Source Files + diff --git a/miner.h b/miner.h index 2c17fec..d0218cf 100644 --- a/miner.h +++ b/miner.h @@ -692,7 +692,7 @@ unsigned int jackpothash(void *state, const void *input); void groestlhash(void *state, const void *input); void lyra2_hash(void *state, const void *input); void myriadhash(void *state, const void *input); -void neoscrypt(const uchar *password, uchar *output, uint profile); +void neoscrypt(uchar *output, const uchar *input, uint32_t profile); void nist5hash(void *state, const void *input); void pentablakehash(void *output, const void *input); void pluckhash(uint32_t *hash, const uint32_t *data, uchar *hashbuffer, const int N); diff --git a/neoscrypt.cu b/neoscrypt.cu index 792812c..c24a7e9 100644 --- a/neoscrypt.cu +++ b/neoscrypt.cu @@ -16,7 +16,6 @@ extern uint32_t neoscrypt_cpu_hash_k4(int stratum, int thr_id, uint32_t threads, int scanhash_neoscrypt(int thr_id, uint32_t *pdata, const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done) { const uint32_t first_nonce = pdata[19]; - const int stratum = have_stratum; if (opt_benchmark) ((uint32_t*)ptarget)[7] = 0x0000ff; @@ -41,7 +40,7 @@ int scanhash_neoscrypt(int thr_id, uint32_t *pdata, const uint32_t *ptarget, uin } uint32_t endiandata[20]; - if (stratum) { + if (have_stratum) { for (int k = 0; k < 20; k++) be32enc(&endiandata[k], ((uint32_t*)pdata)[k]); } else { @@ -52,19 +51,19 @@ int scanhash_neoscrypt(int thr_id, uint32_t *pdata, const uint32_t *ptarget, uin neoscrypt_setBlockTarget(endiandata,ptarget); do { - uint32_t foundNonce = neoscrypt_cpu_hash_k4(stratum, thr_id, throughput, pdata[19], 0); + uint32_t foundNonce = neoscrypt_cpu_hash_k4((int)have_stratum, thr_id, throughput, pdata[19], 0); if (foundNonce != UINT32_MAX) { uint32_t _ALIGN(64) vhash64[8]; *hashes_done = pdata[19] - first_nonce + 1; - if (stratum) { + if (have_stratum) { be32enc(&endiandata[19], foundNonce); } else { endiandata[19] = foundNonce; } - neoscrypt((uchar*) endiandata, (uchar*)vhash64, 0x80000620); + neoscrypt((uchar*)vhash64, (uchar*) endiandata, 0x80000620U); if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) { pdata[19] = foundNonce; @@ -76,7 +75,7 @@ int scanhash_neoscrypt(int thr_id, uint32_t *pdata, const uint32_t *ptarget, uin pdata[19] += throughput; - } while (!work_restart[thr_id].restart && ((uint64_t)max_nonce > ((uint64_t)(pdata[19]) + (uint64_t)throughput))); + } while (!work_restart[thr_id].restart && (max_nonce > ((uint64_t)(pdata[19]) + throughput))); *hashes_done = pdata[19] - first_nonce + 1; return 0; diff --git a/neoscrypt/cuda_neoscrypt.cu b/neoscrypt/cuda_neoscrypt.cu index 652d3ca..b4f6fc3 100644 --- a/neoscrypt/cuda_neoscrypt.cu +++ b/neoscrypt/cuda_neoscrypt.cu @@ -77,8 +77,8 @@ __constant__ uint32_t BLAKE2S_SIGMA[10][16]; } #endif -#define ROTL32(x, n) ((x) << (n)) | ((x) >> (32 - (n))) -#define ROTR32(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) +//#define ROTL32(x, n) ((x) << (n)) | ((x) >> (32 - (n))) +//#define ROTR32(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) #define BLAKE_Ghost(idx0, idx1, a, b, c, d, key) { \ idx = BLAKE2S_SIGMA_host[idx0][idx1]; a += key[idx]; \ diff --git a/neoscrypt/neoscrypt.c b/neoscrypt/neoscrypt.c index 59150ed..75f1abf 100644 --- a/neoscrypt/neoscrypt.c +++ b/neoscrypt/neoscrypt.c @@ -881,7 +881,7 @@ static void neoscrypt_blkmix(uint *X, uint *Y, uint r, uint mixmode) * ..... * 11110 = N of 2147483648; * profile bits 30 to 13 are reserved */ -void neoscrypt(const uchar *password, uchar *output, uint profile) +void neoscrypt(unsigned char *output, const unsigned char *input, unsigned int profile) { uint N = 128, r = 2, dblmix = 1, mixmode = 0x14, stack_align = 0x40; uint kdf, i, j; @@ -916,11 +916,11 @@ void neoscrypt(const uchar *password, uchar *output, uint profile) default: case(0x0): - neoscrypt_fastkdf(password, 80, password, 80, 32, (uchar *) X, r * 2 * SCRYPT_BLOCK_SIZE); + neoscrypt_fastkdf(input, 80, input, 80, 32, (uchar *) X, r * 2 * SCRYPT_BLOCK_SIZE); break; case(0x1): - neoscrypt_pbkdf2_sha256(password, 80, password, 80, 1, (uchar *) X, r * 2 * SCRYPT_BLOCK_SIZE); + neoscrypt_pbkdf2_sha256(input, 80, input, 80, 1, (uchar *) X, r * 2 * SCRYPT_BLOCK_SIZE); break; } @@ -981,11 +981,11 @@ void neoscrypt(const uchar *password, uchar *output, uint profile) default: case(0x0): - neoscrypt_fastkdf(password, 80, (uchar *) X, r * 2 * SCRYPT_BLOCK_SIZE, 32, output, 32); + neoscrypt_fastkdf(input, 80, (uchar *) X, r * 2 * SCRYPT_BLOCK_SIZE, 32, output, 32); break; case(0x1): - neoscrypt_pbkdf2_sha256(password, 80, (uchar *) X, r * 2 * SCRYPT_BLOCK_SIZE, 1, output, 32); + neoscrypt_pbkdf2_sha256(input, 80, (uchar *) X, r * 2 * SCRYPT_BLOCK_SIZE, 1, output, 32); break; } } diff --git a/neoscrypt/neoscrypt.h b/neoscrypt/neoscrypt.h index 5c4d4e4..fc4d7e7 100644 --- a/neoscrypt/neoscrypt.h +++ b/neoscrypt/neoscrypt.h @@ -2,7 +2,7 @@ extern "C" { #endif -void neoscrypt(const unsigned char *input, unsigned char *output, unsigned int profile); +void neoscrypt(unsigned char *output, const unsigned char *input, unsigned int profile); #if (__cplusplus) } diff --git a/util.cpp b/util.cpp index 6c8e298..b0ec0c6 100644 --- a/util.cpp +++ b/util.cpp @@ -1777,7 +1777,7 @@ void print_hash_tests(void) myriadhash(&hash[0], &buf[0]); printpfx("myriad", hash); - neoscrypt(&buf[0], &hash[0], 80000620); + neoscrypt(&hash[0], &buf[0], 80000620); printpfx("neoscrypt", hash); nist5hash(&hash[0], &buf[0]);