Permalink
Browse files

Merge pull request #14 from tpruvot/master

Fix for issue #13 + 2 new cpuminer features
  • Loading branch information...
2 parents 9119d7b + 8eb0a06 commit d971882fdb6921c548b9277162a55ab9532c2b2f @lucasjones lucasjones committed Aug 2, 2014
Showing with 46,896 additions and 211 deletions.
  1. +2 −1 .gitignore
  2. +11 −1 Makefile.am
  3. +21 −0 NEWS
  4. +4 −1 README.md
  5. +3 −3 blake.c
  6. +9 −2 configure.ac
  7. +68 −19 cpu-miner.c
  8. +1 −1 cryptonight.c
  9. +1 −1 heavy.c
  10. +1 −1 ink.c
  11. +1 −1 keccak.c
  12. +25 −15 miner.h
  13. +3 −0 minerd.1
  14. +3 −3 quark.c
  15. +50 −37 scrypt-arm.S
  16. +91 −63 scrypt-x64.S
  17. +17 −8 scrypt-x86.S
  18. +41 −43 scrypt.c
  19. +1 −1 sha2-arm.S
  20. +1 −1 sha2-x64.S
  21. +1 −1 sha2-x86.S
  22. +4 −4 sha2.c
  23. +2 −2 sha3/sph_fugue.h
  24. +867 −0 sha3/sph_hamsi.c
  25. +321 −0 sha3/sph_hamsi.h
  26. +39,648 −0 sha3/sph_hamsi_helper.c
  27. +805 −0 sha3/sph_shabal.c
  28. +343 −0 sha3/sph_shabal.h
  29. +3,480 −0 sha3/sph_whirlpool.c
  30. +209 −0 sha3/sph_whirlpool.h
  31. +346 −0 sha3/sph_x15_helper.c
  32. +1 −1 skein.c
  33. +1 −1 x11.c
  34. +164 −0 x13.c
  35. +172 −0 x14.c
  36. +178 −0 x15.c
View
@@ -26,5 +26,6 @@ config.sub
mingw32-config.cache
+*/.dirstamp
-*.iml
+*.iml
View
@@ -30,6 +30,9 @@ minerd_SOURCES = elist.h \
blake.c \
cryptonight.c \
x11.c \
+ x13.c \
+ x14.c \
+ x15.c \
sha3/sph_keccak.c \
sha3/sph_hefty1.c \
sha3/sph_groestl.c \
@@ -42,6 +45,10 @@ minerd_SOURCES = elist.h \
sha3/sph_cubehash.c \
sha3/sph_simd.c \
sha3/sph_echo.c \
+ sha3/sph_hamsi.c \
+ sha3/sph_fugue.c \
+ sha3/sph_shabal.c \
+ sha3/sph_whirlpool.c \
crypto/oaes_lib.c \
crypto/c_keccak.c \
crypto/c_groestl.c \
@@ -50,6 +57,7 @@ minerd_SOURCES = elist.h \
crypto/c_skein.c \
crypto/hash.c \
crypto/aesb.c
+if USE_ASM
if ARCH_x86
minerd_SOURCES += sha2-x86.S scrypt-x86.S aesb-x86.S crypto/aesb-x86-impl.c
endif
@@ -59,11 +67,13 @@ endif
if ARCH_ARM
minerd_SOURCES += sha2-arm.S scrypt-arm.S
endif
+endif
+
minerd_LDFLAGS = $(PTHREAD_FLAGS)
minerd_LDADD = @LIBCURL@ @JANSSON_LIBS@ @PTHREAD_LIBS@ @WS2_LIBS@
minerd_CPPFLAGS = @LIBCURL_CPPFLAGS@
minerd_CFLAGS = -Ofast -flto -fuse-linker-plugin
if HAVE_WINDOWS
minerd_CFLAGS += -Wl,--stack,10485760
-endif
+endif
View
@@ -1,3 +1,24 @@
+Version multi 1.0.4 (Tanguy Pruvot)
+
+- Add x13 x14 and x15 algos (Sherlockcoin, X14Coin, Webcoin..)
+- Add scrypt:N variants (Vertcoin)
+- Fix thread khashes/s value output
+- Add a configure option --disable-assembly
+
+Version multi 1.0.3 (Lucas Jones)
+
+- Add new algos :
+ x11 (Darkcoin [DRK], Hirocoin, Limecoin)
+ cryptonight (Bytecoin [BCN], Monero)
+ keccak (Maxcoin HelixCoin, CryptoMeth, Galleon, 365coin, Slothcoin, BitcointalkCoin)
+ hefty1 (Heavycoin)
+ quark (Quarkcoin)
+ skein (Skeincoin, Myriadcoin)
+ shavite3 (INKcoin)
+ blake (Blakecoin)
+
+- See README.md
+
Version 2.3.3 - Feb 27, 2014
- The --url option is now mandatory
View
@@ -21,8 +21,12 @@ Algorithms
==========
#### Currently supported
*__scrypt__ (Litecoin, Dogecoin, Feathercoin, etc..)
+ *__scrypt:N__ (Vertcoin [VTC])
*__sha256d__ (Bitcoin, Freicoin, Peercoin/PPCoin, Terracoin, etc..)
*__x11__ (Darkcoin [DRK], Hirocoin, Limecoin)
+ *__x13__ (Sherlockcoin, [ACE], [B2B], [GRC], [XHC], etc..)
+ *__x14__ (X14, Webcoin [WEB])
+ *__x14__ (RadianceCoin [RCE])
*__cryptonight__ (Bytecoin [BCN], Monero)
#### Implemented, but untested
@@ -34,7 +38,6 @@ Algorithms
* ? blake (Blakecoin)
#### Planned support for
- * *scrypt-n* (Vertcoin [VTC])
* *scrypt-jane* (YaCoin, CopperBars, Pennies, Tickets, etc..)
* *qubit* (Qubitcoin, Myriadcoin)
* *groestl* (Groestlcoin)
View
@@ -11,7 +11,7 @@ typedef struct {
sph_blake256_context blake1;
} blakehash_context_holder;
-blakehash_context_holder base_contexts;
+static blakehash_context_holder base_contexts;
void init_blakehash_contexts()
{
@@ -35,7 +35,7 @@ static void blakehash(void *state, const void *input)
}
int scanhash_blake(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
- uint32_t max_nonce, unsigned long *hashes_done)
+ uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19];
@@ -143,4 +143,4 @@ int scanhash_blake(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
*hashes_done = n - first_nonce + 1;
pdata[19] = n;
return 0;
-}
+}
View
@@ -1,4 +1,4 @@
-AC_INIT([cpuminer], [1.0.3])
+AC_INIT([cpuminer], [1.0.4])
AC_PREREQ([2.59c])
AC_CANONICAL_SYSTEM
@@ -61,7 +61,13 @@ case $target in
;;
esac
-if test x$have_x86 = xtrue -o x$have_x86_64 = xtrue
+AC_ARG_ENABLE([assembly],
+ AS_HELP_STRING([--disable-assembly], [disable assembly-language routines]))
+if test x$enable_assembly != xno; then
+ AC_DEFINE([USE_ASM], [1], [Define to 1 if assembly routines are wanted.])
+fi
+
+if test x$enable_assembly != xno -a x$have_x86_64 = xtrue
then
AC_MSG_CHECKING(whether we can compile AVX code)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[asm ("vmovdqa %ymm0, %ymm1");])],
@@ -108,6 +114,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([static __uint128_t i = 100;])],
AM_CONDITIONAL([WANT_JANSSON], [test x$request_jansson = xtrue])
AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
+AM_CONDITIONAL([USE_ASM], [test x$enable_assembly != xno])
AM_CONDITIONAL([ARCH_x86], [test x$have_x86 = xtrue])
AM_CONDITIONAL([ARCH_x86_64], [test x$have_x86_64 = xtrue])
AM_CONDITIONAL([ARCH_ARM], [test x$have_arm = xtrue])
View
@@ -99,7 +99,7 @@ struct workio_cmd {
} u;
};
-enum mining_algo {
+enum algos {
ALGO_SCRYPT, /* scrypt(1024,1,1) */
ALGO_SHA256D, /* SHA-256d */
ALGO_KECCAK, /* Keccak */
@@ -109,6 +109,9 @@ enum mining_algo {
ALGO_SHAVITE3, /* Shavite3 */
ALGO_BLAKE, /* Blake */
ALGO_X11, /* X11 */
+ ALGO_X13, /* X13 */
+ ALGO_X14, /* X14 */
+ ALGO_X15, /* X15 Whirlpool */
ALGO_CRYPTONIGHT, /* CryptoNight */
};
@@ -122,6 +125,9 @@ static const char *algo_names[] = {
[ALGO_SHAVITE3] = "shavite3",
[ALGO_BLAKE] = "blake",
[ALGO_X11] = "x11",
+ [ALGO_X13] = "x13",
+ [ALGO_X14] = "x14",
+ [ALGO_X15] = "x15",
[ALGO_CRYPTONIGHT] = "cryptonight",
};
@@ -144,7 +150,8 @@ int opt_timeout = 0;
static int opt_scantime = 5;
static json_t *opt_config;
static const bool opt_time = true;
-static enum mining_algo opt_algo = ALGO_SCRYPT;
+static enum algos opt_algo = ALGO_SCRYPT;
+static int opt_scrypt_n = 1024;
static int opt_n_threads;
static int num_processors;
static char *rpc_url;
@@ -192,6 +199,7 @@ Usage: " PROGRAM_NAME " [OPTIONS]\n\
Options:\n\
-a, --algo=ALGO specify the algorithm to use\n\
scrypt scrypt(1024, 1, 1) (default)\n\
+ scrypt:N scrypt(N, 1, 1)\n\
sha256d SHA-256d\n\
keccak Keccak\n\
quark Quark\n\
@@ -200,6 +208,9 @@ Options:\n\
shavite3 Shavite3\n\
blake Blake\n\
x11 X11\n\
+ x13 X13\n\
+ x14 X14\n\
+ x15 X15\n\
cryptonight CryptoNight\n\
-o, --url=URL URL of mining server\n\
-O, --userpass=U:P username:password pair for mining server\n\
@@ -1047,12 +1058,17 @@ static void *miner_thread(void *userdata) {
}
if (opt_algo == ALGO_SCRYPT) {
- scratchbuf = scrypt_buffer_alloc();
+ scratchbuf = scrypt_buffer_alloc(opt_scrypt_n);
+ if (!scratchbuf) {
+ applog(LOG_ERR, "scrypt buffer allocation failed");
+ pthread_mutex_lock(&applog_lock);
+ exit(1);
+ }
}
uint32_t *nonceptr = (uint32_t*) (((char*)work.data) + (jsonrpc_2 ? 39 : 76));
while (1) {
- unsigned long hashes_done;
+ uint64_t hashes_done;
struct timeval tv_start, tv_end, diff;
int64_t max64;
int rc;
@@ -1106,11 +1122,20 @@ static void *miner_thread(void *userdata) {
if (max64 <= 0) {
switch (opt_algo) {
case ALGO_SCRYPT:
- max64 = 0xfffLL;
+ max64 = opt_scrypt_n < 16 ? 0x3ffff : 0x3fffff / opt_scrypt_n;
break;
case ALGO_CRYPTONIGHT:
max64 = 0x40LL;
break;
+ case ALGO_X13:
+ max64 = 0x1ffff;
+ break;
+ case ALGO_X14:
+ max64 = 0x3ffff;
+ break;
+ case ALGO_X15:
+ max64 = 0x1ffff;
+ break;
default:
max64 = 0x1fffffLL;
break;
@@ -1128,7 +1153,7 @@ static void *miner_thread(void *userdata) {
switch (opt_algo) {
case ALGO_SCRYPT:
rc = scanhash_scrypt(thr_id, work.data, scratchbuf, work.target,
- max_nonce, &hashes_done);
+ max_nonce, &hashes_done, opt_scrypt_n);
break;
case ALGO_SHA256D:
@@ -1167,6 +1192,18 @@ static void *miner_thread(void *userdata) {
rc = scanhash_x11(thr_id, work.data, work.target, max_nonce,
&hashes_done);
break;
+ case ALGO_X13:
+ rc = scanhash_x13(thr_id, work.data, work.target, max_nonce,
+ &hashes_done);
+ break;
+ case ALGO_X14:
+ rc = scanhash_x14(thr_id, work.data, work.target, max_nonce,
+ &hashes_done);
+ break;
+ case ALGO_X15:
+ rc = scanhash_x15(thr_id, work.data, work.target, max_nonce,
+ &hashes_done);
+ break;
case ALGO_CRYPTONIGHT:
rc = scanhash_cryptonight(thr_id, work.data, work.target,
max_nonce, &hashes_done);
@@ -1178,12 +1215,12 @@ static void *miner_thread(void *userdata) {
}
/* record scanhash elapsed time */
- gettimeofday(&tv_end, NULL );
+ gettimeofday(&tv_end, NULL);
timeval_subtract(&diff, &tv_end, &tv_start);
if (diff.tv_usec || diff.tv_sec) {
pthread_mutex_lock(&stats_lock);
- thr_hashrates[thr_id] = hashes_done
- / (diff.tv_sec + 1e-6 * diff.tv_usec);
+ thr_hashrates[thr_id] =
+ hashes_done / (diff.tv_sec + diff.tv_usec * 1e-6);
pthread_mutex_unlock(&stats_lock);
}
if (!opt_quiet) {
@@ -1194,8 +1231,8 @@ static void *miner_thread(void *userdata) {
break;
default:
sprintf(s, thr_hashrates[thr_id] >= 1e6 ? "%.0f" : "%.2f",
- 1e-3 * thr_hashrates[thr_id]);
- applog(LOG_INFO, "thread %d: %lu hashes, %.2f khash/s", thr_id,
+ thr_hashrates[thr_id] / 1e3);
+ applog(LOG_INFO, "thread %d: %llu hashes, %s khash/s", thr_id,
hashes_done, s);
break;
}
@@ -1210,7 +1247,7 @@ static void *miner_thread(void *userdata) {
applog(LOG_INFO, "Total: %s H/s", hashrate);
break;
default:
- sprintf(s, hashrate >= 1e6 ? "%.0f" : "%.2f", 1e-3 * hashrate);
+ sprintf(s, hashrate >= 1e6 ? "%.0f" : "%.2f", hashrate / 1000);
applog(LOG_INFO, "Total: %s khash/s", s);
break;
}
@@ -1459,13 +1496,13 @@ static void *stratum_thread(void *userdata) {
static void show_version_and_exit(void) {
printf(PACKAGE_STRING "\n built on " __DATE__ "\n features:"
-#if defined(__i386__)
+#if defined(USE_ASM) && defined(__i386__)
" i386"
#endif
-#if defined(__x86_64__)
+#if defined(USE_ASM) && defined(__x86_64__)
" x86_64"
#endif
-#if defined(__i386__) || defined(__x86_64__)
+#if defined(USE_ASM) && defined(__i386__) || defined(__x86_64__)
" SSE2"
#endif
#if defined(__x86_64__) && defined(USE_AVX)
@@ -1477,7 +1514,7 @@ static void show_version_and_exit(void) {
#if defined(__x86_64__) && defined(USE_XOP)
" XOP"
#endif
-#if defined(__arm__) && defined(__APCS_32__)
+#if defined(USE_ASM) && defined(__arm__) && defined(__APCS_32__)
" ARM"
#if defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || \
defined(__ARM_ARCH_5TEJ__) || defined(__ARM_ARCH_6__) || \
@@ -1518,9 +1555,21 @@ static void parse_arg(int key, char *arg) {
switch (key) {
case 'a':
for (i = 0; i < ARRAY_SIZE(algo_names); i++) {
- if (algo_names[i] && !strcmp(arg, algo_names[i])) {
- opt_algo = i;
- break;
+ v = strlen(algo_names[i]);
+ if (!strncmp(arg, algo_names[i], v)) {
+ if (arg[v] == '\0') {
+ opt_algo = i;
+ break;
+ }
+ if (arg[v] == ':' && i == ALGO_SCRYPT) {
+ char *ep;
+ v = strtol(arg+v+1, &ep, 10);
+ if (*ep || v & (v-1) || v < 2)
+ continue;
+ opt_algo = i;
+ opt_scrypt_n = v;
+ break;
+ }
}
}
if (i == ARRAY_SIZE(algo_names))
View
@@ -255,7 +255,7 @@ void cryptonight_hash_ctx_aes_ni(void* output, const void* input, size_t len, st
}
int scanhash_cryptonight(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
- uint32_t max_nonce, unsigned long *hashes_done) {
+ uint32_t max_nonce, uint64_t *hashes_done) {
uint32_t *nonceptr = (uint32_t*) (((char*)pdata) + 39);
uint32_t n = *nonceptr - 1;
const uint32_t first_nonce = n + 1;
View
@@ -81,7 +81,7 @@ void heavycoin_hash(unsigned char* output, const unsigned char* input, int len)
}
int scanhash_heavy(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
- uint32_t max_nonce, unsigned long *hashes_done)
+ uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t hash[8];
uint32_t start_nonce = pdata[19];
View
@@ -33,7 +33,7 @@ static void inkhash(void *state, const void *input)
}
int scanhash_ink(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
- uint32_t max_nonce, unsigned long *hashes_done)
+ uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19];
Oops, something went wrong.

0 comments on commit d971882

Please sign in to comment.