This commit is contained in:
Jay D Dee
2016-11-28 12:59:56 -05:00
parent c551fb4a25
commit 06f82c5b97
10 changed files with 58 additions and 1297 deletions

View File

@@ -1,4 +1,4 @@
cpuminer-opt now supports 38 algorithms on CPUs with at least SSE2 cpuminer-opt now supports over 40 algorithms on CPUs with at least SSE2
capabilities including Intel Core2, Nehalem and AMD equivalent. See the capabilities including Intel Core2, Nehalem and AMD equivalent. See the
performance chart below for details. performance chart below for details.
@@ -7,10 +7,10 @@ CPUs with AES_NI for even greater performance, including the Intel
Westbridge and newer and AMD equivalent. See the performance Westbridge and newer and AMD equivalent. See the performance
comparison below. comparison below.
New in 3.4.11 New in 3.4.12
- groestl algo AES optimized +200% - lyra2z (zcoin) modified for blocks after 8192
- myr-gr algo AES optimized +100% - fixed scryptjane to support various N factors
Users with non-SSE2 CPUs or who want to mine algos not supported by Users with non-SSE2 CPUs or who want to mine algos not supported by
cpuminer-opt may find cpuminer-multi by TPruvot useful. cpuminer-opt may find cpuminer-multi by TPruvot useful.

View File

@@ -259,6 +259,7 @@ const char* const algo_alias_map[][2] =
{ "blake256r8", "blakecoin" }, { "blake256r8", "blakecoin" },
{ "blake256r8vnl", "vanilla" }, { "blake256r8vnl", "vanilla" },
{ "blake256r14", "blake" }, { "blake256r14", "blake" },
{ "cryptonote", "cryptonight" },
{ "cryptonight-light", "cryptolight" }, { "cryptonight-light", "cryptolight" },
{ "dmd-gr", "groestl" }, { "dmd-gr", "groestl" },
{ "droplp", "drop" }, { "droplp", "drop" },

View File

@@ -8,7 +8,8 @@ void zcoin_hash(void *state, const void *input, uint32_t height)
uint32_t _ALIGN(256) hash[16]; uint32_t _ALIGN(256) hash[16];
LYRA2Z(hash, 32, input, 80, input, 80, 2, height, 256); // LYRA2Z(hash, 32, input, 80, input, 80, 2, height, 256);
LYRA2Z(hash, 32, input, 80, input, 80, 2, 8192, 256);
memcpy(state, hash, 32); memcpy(state, hash, 32);
} }

View File

@@ -1056,7 +1056,6 @@ int scanhash_neoscrypt( int thr_id, struct work *work,
while (pdata[19] < max_nonce && !work_restart[thr_id].restart) while (pdata[19] < max_nonce && !work_restart[thr_id].restart)
{ {
neoscrypt((uint8_t *) hash, (uint8_t *) pdata ); neoscrypt((uint8_t *) hash, (uint8_t *) pdata );
// , 0x80000020 | (opt_nfactor << 8) );
/* Quick hash check */ /* Quick hash check */
if (hash[7] <= Htarg && fulltest_le(hash, ptarget)) { if (hash[7] <= Htarg && fulltest_le(hash, ptarget)) {
@@ -1071,15 +1070,7 @@ int scanhash_neoscrypt( int thr_id, struct work *work,
return 0; return 0;
} }
int64_t get_neoscrypt_max64() int64_t get_neoscrypt_max64() { return 0x3ffff; }
{
int64_t max64 = opt_scrypt_n < 16 ? 0x3ffff : 0x3fffff / opt_scrypt_n;
if ( opt_nfactor > 3)
max64 >>= ( opt_nfactor - 3);
else if ( opt_nfactor > 16)
max64 = 0xF;
return max64;
}
void neoscrypt_wait_for_diff( struct stratum_ctx *stratum ) void neoscrypt_wait_for_diff( struct stratum_ctx *stratum )
{ {

File diff suppressed because it is too large Load Diff

View File

@@ -48,6 +48,7 @@ static const uint32_t finalblk[16] = {
}; };
static __thread char *scratchbuf; static __thread char *scratchbuf;
int scratchbuf_size = 0;
static inline void HMAC_SHA256_80_init(const uint32_t *key, static inline void HMAC_SHA256_80_init(const uint32_t *key,
uint32_t *tstate, uint32_t *ostate) uint32_t *tstate, uint32_t *ostate)
@@ -726,29 +727,29 @@ extern int scanhash_scrypt( int thr_id, struct work *work, uint32_t max_nonce,
#if defined(HAVE_SHA256_4WAY) #if defined(HAVE_SHA256_4WAY)
if (throughput == 4) if (throughput == 4)
scrypt_1024_1_1_256_4way(data, hash, midstate, scrypt_1024_1_1_256_4way(data, hash, midstate,
scratchbuf, opt_scrypt_n); scratchbuf, scratchbuf_size );
else else
#endif #endif
#if defined(HAVE_SCRYPT_3WAY) && defined(HAVE_SHA256_4WAY) #if defined(HAVE_SCRYPT_3WAY) && defined(HAVE_SHA256_4WAY)
if (throughput == 12) if (throughput == 12)
scrypt_1024_1_1_256_12way(data, hash, midstate, scrypt_1024_1_1_256_12way(data, hash, midstate,
scratchbuf, opt_scrypt_n); scratchbuf, scratchbuf_size );
else else
#endif #endif
#if defined(HAVE_SCRYPT_6WAY) #if defined(HAVE_SCRYPT_6WAY)
if (throughput == 24) if (throughput == 24)
scrypt_1024_1_1_256_24way(data, hash, midstate, scrypt_1024_1_1_256_24way(data, hash, midstate,
scratchbuf, opt_scrypt_n); scratchbuf, scratchbuf_size );
else else
#endif #endif
#if defined(HAVE_SCRYPT_3WAY) #if defined(HAVE_SCRYPT_3WAY)
if (throughput == 3) if (throughput == 3)
scrypt_1024_1_1_256_3way(data, hash, midstate, scrypt_1024_1_1_256_3way(data, hash, midstate,
scratchbuf, opt_scrypt_n); scratchbuf, scratchbuf_size );
else else
#endif #endif
scrypt_1024_1_1_256(data, hash, midstate, scratchbuf, scrypt_1024_1_1_256(data, hash, midstate, scratchbuf,
opt_scrypt_n); scratchbuf_size );
for (i = 0; i < throughput; i++) { for (i = 0; i < throughput; i++) {
if (unlikely(hash[i * 8 + 7] <= Htarg && fulltest(hash + i * 8, ptarget))) { if (unlikely(hash[i * 8 + 7] <= Htarg && fulltest(hash + i * 8, ptarget))) {
@@ -764,19 +765,11 @@ extern int scanhash_scrypt( int thr_id, struct work *work, uint32_t max_nonce,
return 0; return 0;
} }
int64_t scrypt_get_max64() int64_t scrypt_get_max64() { return 0xfff; }
{
int64_t max64 = opt_scrypt_n < 16 ? 0x3ffff : 0x3fffff / opt_scrypt_n;
if ( opt_nfactor > 3)
max64 >>= ( opt_nfactor - 3);
else if ( opt_nfactor > 16)
max64 = 0xF;
return max64;
}
bool scrypt_miner_thread_init( int thr_id ) bool scrypt_miner_thread_init( int thr_id )
{ {
scratchbuf = scrypt_buffer_alloc( opt_scrypt_n ); scratchbuf = scrypt_buffer_alloc( scratchbuf_size );
if ( scratchbuf ) if ( scratchbuf )
return true; return true;
applog( LOG_ERR, "Thread %u: Scrypt buffer allocation failed", thr_id ); applog( LOG_ERR, "Thread %u: Scrypt buffer allocation failed", thr_id );
@@ -791,8 +784,10 @@ bool register_scrypt_algo( algo_gate_t* gate )
gate->hash_alt = (void*)&scrypt_1024_1_1_256_24way; gate->hash_alt = (void*)&scrypt_1024_1_1_256_24way;
gate->set_target = (void*)&scrypt_set_target; gate->set_target = (void*)&scrypt_set_target;
gate->get_max64 = (void*)&scrypt_get_max64; gate->get_max64 = (void*)&scrypt_get_max64;
if ( opt_nfactor == 0 )
opt_nfactor = 6; if ( !opt_scrypt_n )
return true; scratchbuf_size = 1024;
else
scratchbuf_size = opt_scrypt_n;
}; };

View File

@@ -45,6 +45,8 @@
#define scrypt_maxr scrypt_r_32kb /* 32kb */ #define scrypt_maxr scrypt_r_32kb /* 32kb */
#define scrypt_maxp 25 /* (1 << 25) = ~33 million */ #define scrypt_maxp 25 /* (1 << 25) = ~33 million */
uint64_t sj_N;
typedef struct scrypt_aligned_alloc_t { typedef struct scrypt_aligned_alloc_t {
uint8_t *mem, *ptr; uint8_t *mem, *ptr;
} scrypt_aligned_alloc; } scrypt_aligned_alloc;
@@ -140,7 +142,8 @@ int scanhash_scryptjane( int thr_id, struct work *work, uint32_t max_nonce,
{ {
scrypt_aligned_alloc YX, V; scrypt_aligned_alloc YX, V;
uint8_t *X, *Y; uint8_t *X, *Y;
uint32_t N, chunk_bytes; // uint32_t N, chunk_bytes;
uint32_t chunk_bytes;
const uint32_t r = SCRYPT_R; const uint32_t r = SCRYPT_R;
const uint32_t p = SCRYPT_P; const uint32_t p = SCRYPT_P;
@@ -162,10 +165,14 @@ int scanhash_scryptjane( int thr_id, struct work *work, uint32_t max_nonce,
// //scrypt_fatal_error("scrypt: N out of range"); // //scrypt_fatal_error("scrypt: N out of range");
//} //}
N = (1 << ( opt_scrypt_n + 1)); // opt_scrypt_n default is 1024 which makes no sense in this context
// and results in N = 2, but it seems to work on Nicehash scryptjanenf16
// (leocoin). Need to test with proper NF 16 for functionality and performance.
// Also test yacoin (NF 18).
// N = (1 << ( opt_scrypt_n + 1));
chunk_bytes = SCRYPT_BLOCK_BYTES * r * 2; chunk_bytes = SCRYPT_BLOCK_BYTES * r * 2;
if (!scrypt_alloc((uint64_t)N * chunk_bytes, &V)) return 1; if (!scrypt_alloc( sj_N * chunk_bytes, &V ) ) return 1;
if (!scrypt_alloc((p + 1) * chunk_bytes, &YX)) { if (!scrypt_alloc((p + 1) * chunk_bytes, &YX)) {
scrypt_free(&V); scrypt_free(&V);
return 1; return 1;
@@ -181,7 +188,7 @@ int scanhash_scryptjane( int thr_id, struct work *work, uint32_t max_nonce,
scrypt_N_1_1((unsigned char *)endiandata, 80, scrypt_N_1_1((unsigned char *)endiandata, 80,
(unsigned char *)endiandata, 80, (unsigned char *)endiandata, 80,
N, (unsigned char *)hash, 32, X, Y, V.ptr); sj_N, (unsigned char *)hash, 32, X, Y, V.ptr);
if (hash[7] <= Htarg && fulltest(hash, ptarget)) { if (hash[7] <= Htarg && fulltest(hash, ptarget)) {
pdata[19] = nonce; pdata[19] = nonce;
@@ -208,14 +215,13 @@ void scryptjanehash(void *output, const void *input )
scrypt_aligned_alloc YX, V; scrypt_aligned_alloc YX, V;
uint8_t *X, *Y; uint8_t *X, *Y;
uint32_t chunk_bytes; uint32_t chunk_bytes;
uint32_t N = (1 << ( opt_scrypt_n + 1));
const uint32_t r = SCRYPT_R; const uint32_t r = SCRYPT_R;
const uint32_t p = SCRYPT_P; const uint32_t p = SCRYPT_P;
memset(output, 0, 32); memset(output, 0, 32);
chunk_bytes = SCRYPT_BLOCK_BYTES * r * 2; chunk_bytes = SCRYPT_BLOCK_BYTES * r * 2;
if (!scrypt_alloc((uint64_t)N * chunk_bytes, &V)) return; if (!scrypt_alloc( sj_N * chunk_bytes, &V ) ) return;
if (!scrypt_alloc((p + 1) * chunk_bytes, &YX)) { if (!scrypt_alloc((p + 1) * chunk_bytes, &YX)) {
scrypt_free(&V); scrypt_free(&V);
return; return;
@@ -225,7 +231,7 @@ void scryptjanehash(void *output, const void *input )
X = Y + chunk_bytes; X = Y + chunk_bytes;
scrypt_N_1_1((unsigned char*)input, 80, (unsigned char*)input, 80, scrypt_N_1_1((unsigned char*)input, 80, (unsigned char*)input, 80,
N, (unsigned char*)output, 32, X, Y, V.ptr); sj_N, (unsigned char*)output, 32, X, Y, V.ptr);
scrypt_free(&V); scrypt_free(&V);
scrypt_free(&YX); scrypt_free(&YX);
@@ -238,8 +244,23 @@ bool register_scryptjane_algo( algo_gate_t* gate )
gate->hash_alt = (void*)&scryptjanehash; gate->hash_alt = (void*)&scryptjanehash;
gate->set_target = (void*)&scrypt_set_target; gate->set_target = (void*)&scrypt_set_target;
gate->get_max64 = (void*)&get_max64_0x40LL; gate->get_max64 = (void*)&get_max64_0x40LL;
if ( opt_nfactor == 0 )
opt_nfactor = 16; // figure out if arg in N or Nfactor
if ( !opt_scrypt_n )
{
applog( LOG_ERR, "The N factor must be specified in the form algo:nf");
return false;
}
else if ( opt_scrypt_n < 32 )
{
// arg is Nfactor, calculate N
sj_N = 1 << ( opt_scrypt_n + 1 );
}
else
{
// arg is N
sj_N = opt_scrypt_n;
}
return true; return true;
} }

View File

@@ -1,4 +1,4 @@
AC_INIT([cpuminer-opt], [3.4.11]) AC_INIT([cpuminer-opt], [3.4.12])
AC_PREREQ([2.59c]) AC_PREREQ([2.59c])
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM

View File

@@ -100,9 +100,8 @@ int opt_timeout = 300;
static int opt_scantime = 5; static int opt_scantime = 5;
static const bool opt_time = true; static const bool opt_time = true;
enum algos opt_algo = ALGO_NULL; enum algos opt_algo = ALGO_NULL;
int opt_scrypt_n = 1024; int opt_scrypt_n = 0;
int opt_pluck_n = 128; int opt_pluck_n = 128;
unsigned int opt_nfactor = 0;
int opt_n_threads = 0; int opt_n_threads = 0;
int64_t opt_affinity = -1L; int64_t opt_affinity = -1L;
int opt_priority = 0; int opt_priority = 0;
@@ -2321,7 +2320,7 @@ void parse_arg(int key, char *arg )
{ {
char *ep; char *ep;
v = strtol(arg+v+1, &ep, 10); v = strtol(arg+v+1, &ep, 10);
if (*ep || v & (v-1) || v < 2) if (*ep || v < 2)
continue; continue;
opt_algo = (enum algos) i; opt_algo = (enum algos) i;
opt_scrypt_n = v; opt_scrypt_n = v;
@@ -2360,8 +2359,6 @@ void parse_arg(int key, char *arg )
case 1030: /* --api-remote */ case 1030: /* --api-remote */
opt_api_remote = 1; opt_api_remote = 1;
break; break;
case 'n':
break;
case 'B': case 'B':
opt_background = true; opt_background = true;
use_colors = false; use_colors = false;
@@ -2386,8 +2383,6 @@ void parse_arg(int key, char *arg )
} }
break; break;
} }
case 'C':
break;
case 'q': case 'q':
opt_quiet = true; opt_quiet = true;
break; break;

12
miner.h
View File

@@ -620,7 +620,6 @@ extern double net_hashrate;
extern int opt_pluck_n; extern int opt_pluck_n;
extern int opt_scrypt_n; extern int opt_scrypt_n;
extern double opt_diff_factor; extern double opt_diff_factor;
extern unsigned int opt_nfactor;
extern bool opt_randomize; extern bool opt_randomize;
extern bool allow_mininginfo; extern bool allow_mininginfo;
extern time_t g_work_time; extern time_t g_work_time;
@@ -645,16 +644,16 @@ Options:\n\
blakecoin blake256r8\n\ blakecoin blake256r8\n\
blake2s Blake-2 S\n\ blake2s Blake-2 S\n\
bmw BMW 256\n\ bmw BMW 256\n\
c11 flax\n\ c11 Flax\n\
cryptolight Cryptonight-light\n\ cryptolight Cryptonight-light\n\
cryptonight Monero (XMR)\n\ cryptonight cryptonote, Monero (XMR)\n\
decred\n\ decred\n\
drop Dropcoin\n\ drop Dropcoin\n\
fresh Fresh\n\ fresh Fresh\n\
groestl groestl\n\ groestl groestl\n\
heavy Heavy\n\ heavy Heavy\n\
hmq1725 Espers\n\ hmq1725 Espers\n\
hodl hodlcoin\n\ hodl Hodlcoin\n\
keccak Keccak\n\ keccak Keccak\n\
lbry LBC, LBRY Credits\n\ lbry LBC, LBRY Credits\n\
luffa Luffa\n\ luffa Luffa\n\
@@ -671,13 +670,12 @@ Options:\n\
quark Quark\n\ quark Quark\n\
qubit Qubit\n\ qubit Qubit\n\
scrypt scrypt(1024, 1, 1) (default)\n\ scrypt scrypt(1024, 1, 1) (default)\n\
scryptjane\n\
scrypt:N scrypt(N, 1, 1)\n\ scrypt:N scrypt(N, 1, 1)\n\
scryptjane:nf\n\
sha256d SHA-256d\n\ sha256d SHA-256d\n\
shavite3 Shavite3\n\ shavite3 Shavite3\n\
skein Skein+Sha (Skeincoin)\n\ skein Skein+Sha (Skeincoin)\n\
skein2 Double Skein (Woodcoin)\n\ skein2 Double Skein (Woodcoin)\n\
s3 S3\n\
vanilla blake256r8vnl (VCash)\n\ vanilla blake256r8vnl (VCash)\n\
veltor\n\ veltor\n\
whirlpool\n\ whirlpool\n\
@@ -710,7 +708,6 @@ Options:\n\
-f, --diff-factor Divide req. difficulty by this factor (std is 1.0)\n\ -f, --diff-factor Divide req. difficulty by this factor (std is 1.0)\n\
-m, --diff-multiplier Multiply difficulty by this factor (std is 1.0)\n\ -m, --diff-multiplier Multiply difficulty by this factor (std is 1.0)\n\
--hide-diff Do not display changes in difficulty\n\ --hide-diff Do not display changes in difficulty\n\
-n, --nfactor neoscrypt N-Factor\n\
--coinbase-addr=ADDR payout address for solo mining\n\ --coinbase-addr=ADDR payout address for solo mining\n\
--coinbase-sig=TEXT data to insert in the coinbase when possible\n\ --coinbase-sig=TEXT data to insert in the coinbase when possible\n\
--no-longpoll disable long polling support\n\ --no-longpoll disable long polling support\n\
@@ -775,7 +772,6 @@ static struct option const options[] = {
{ "diff-multiplier", 1, NULL, 'm' }, { "diff-multiplier", 1, NULL, 'm' },
{ "hide-diff", 0, NULL, 1013 }, { "hide-diff", 0, NULL, 1013 },
{ "help", 0, NULL, 'h' }, { "help", 0, NULL, 'h' },
{ "nfactor", 1, NULL, 'n' },
{ "no-gbt", 0, NULL, 1011 }, { "no-gbt", 0, NULL, 1011 },
{ "no-getwork", 0, NULL, 1010 }, { "no-getwork", 0, NULL, 1010 },
{ "no-longpoll", 0, NULL, 1003 }, { "no-longpoll", 0, NULL, 1003 },