Skip to content

Commit

Permalink
Add a configure option to disable assembly code
Browse files Browse the repository at this point in the history
Backport from cpuminer 2.4

Require ./autogen.sh to enable this new (default) option

Signed-off-by: Tanguy Pruvot <[email protected]>
  • Loading branch information
pooler authored and tpruvot committed Aug 2, 2014
1 parent c0841fb commit c6427bc
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 17 deletions.
5 changes: 4 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,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
Expand All @@ -59,11 +60,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
9 changes: 8 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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");])],
Expand Down Expand Up @@ -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])
Expand Down
8 changes: 4 additions & 4 deletions cpu-miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -1466,13 +1466,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)
Expand All @@ -1484,7 +1484,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__) || \
Expand Down
3 changes: 2 additions & 1 deletion miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,20 @@ void sha256_init(uint32_t *state);
void sha256_transform(uint32_t *state, const uint32_t *block, int swap);
void sha256d(unsigned char *hash, const unsigned char *data, int len);

#ifdef USE_ASM
#if defined(__ARM_NEON__) || defined(__i386__) || defined(__x86_64__)
#define HAVE_SHA256_4WAY 1
int sha256_use_4way();
void sha256_init_4way(uint32_t *state);
void sha256_transform_4way(uint32_t *state, const uint32_t *block, int swap);
#endif

#if defined(__x86_64__) && defined(USE_AVX2)
#define HAVE_SHA256_8WAY 1
int sha256_use_8way();
void sha256_init_8way(uint32_t *state);
void sha256_transform_8way(uint32_t *state, const uint32_t *block, int swap);
#endif
#endif

extern int scanhash_sha256d(int thr_id, uint32_t *pdata,
const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done);
Expand Down
2 changes: 1 addition & 1 deletion scrypt-arm.S
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "cpuminer-config.h"

#if defined(__arm__) && defined(__APCS_32__)
#if defined(USE_ASM) && defined(__arm__) && defined(__APCS_32__)

#if defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || \
defined(__ARM_ARCH_5TEJ__) || defined(__ARM_ARCH_6__) || \
Expand Down
2 changes: 1 addition & 1 deletion scrypt-x64.S
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
.section .note.GNU-stack,"",%progbits
#endif

#if defined(__x86_64__)
#if defined(USE_ASM) && defined(__x86_64__)

.text
.p2align 6
Expand Down
2 changes: 1 addition & 1 deletion scrypt-x86.S
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
.section .note.GNU-stack,"",%progbits
#endif

#if defined(__i386__)
#if defined(USE_ASM) && defined(__i386__)

.macro scrypt_shuffle src, so, dest, do
movl \so+60(\src), %eax
Expand Down
6 changes: 3 additions & 3 deletions scrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ static inline void PBKDF2_SHA256_128_32_8way(uint32_t *tstate,
#endif /* HAVE_SHA256_8WAY */


#if defined(__x86_64__)
#if defined(USE_ASM) && defined(__x86_64__)

#define SCRYPT_MAX_WAYS 12
#define HAVE_SCRYPT_3WAY 1
Expand All @@ -392,13 +392,13 @@ void scrypt_core_3way(uint32_t *X, uint32_t *V, int N);
void scrypt_core_6way(uint32_t *X, uint32_t *V, int N);
#endif

#elif defined(__i386__)
#elif defined(USE_ASM) && defined(__i386__)

#define SCRYPT_MAX_WAYS 4
#define scrypt_best_throughput() 1
void scrypt_core(uint32_t *X, uint32_t *V, int N);

#elif defined(__arm__) && defined(__APCS_32__)
#elif defined(USE_ASM) && defined(__arm__) && defined(__APCS_32__)

void scrypt_core(uint32_t *X, uint32_t *V, int N);
#if defined(__ARM_NEON__)
Expand Down
2 changes: 1 addition & 1 deletion sha2-arm.S
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "cpuminer-config.h"

#if defined(__arm__) && defined(__APCS_32__)
#if defined(USE_ASM) && defined(__arm__) && defined(__APCS_32__)

.macro sha256_k
.align 2
Expand Down
2 changes: 1 addition & 1 deletion sha2-x64.S
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
.section .note.GNU-stack,"",%progbits
#endif

#if defined(__x86_64__)
#if defined(USE_ASM) && defined(__x86_64__)

.data
.p2align 7
Expand Down
2 changes: 1 addition & 1 deletion sha2-x86.S
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
.section .note.GNU-stack,"",%progbits
#endif

#if defined(__i386__)
#if defined(USE_ASM) && defined(__i386__)

.data
.p2align 7
Expand Down
2 changes: 1 addition & 1 deletion sha2.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <string.h>
#include <inttypes.h>

#if defined(__arm__) && defined(__APCS_32__)
#if defined(USE_ASM) && defined(__arm__) && defined(__APCS_32__)
#define EXTERN_SHA256
#endif

Expand Down

0 comments on commit c6427bc

Please sign in to comment.