From a5430f73e173766f7c2973930e9efc8d8c9cb580 Mon Sep 17 00:00:00 2001 From: pooler Date: Fri, 16 May 2014 15:37:41 +0200 Subject: [PATCH] Add a configure option to disable assembly code --- Makefile.am | 2 ++ configure.ac | 9 ++++++++- cpu-miner.c | 8 ++++---- miner.h | 3 ++- scrypt-arm.S | 2 +- scrypt-x64.S | 2 +- scrypt-x86.S | 2 +- scrypt.c | 6 +++--- sha2-arm.S | 2 +- sha2-x64.S | 2 +- sha2-x86.S | 2 +- sha2.c | 2 +- 12 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9a48b97..ca8f9e5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,6 +18,7 @@ dist_man_MANS = minerd.1 minerd_SOURCES = elist.h miner.h compat.h \ cpu-miner.c util.c \ sha2.c scrypt.c +if USE_ASM if ARCH_x86 minerd_SOURCES += sha2-x86.S scrypt-x86.S endif @@ -27,6 +28,7 @@ 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@ diff --git a/configure.ac b/configure.ac index 719ec8e..218e794 100644 --- a/configure.ac +++ b/configure.ac @@ -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");])], @@ -98,6 +104,7 @@ AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS="-lpthread", 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]) diff --git a/cpu-miner.c b/cpu-miner.c index da50fbd..1823571 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -1395,13 +1395,13 @@ out: 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) @@ -1413,7 +1413,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__) || \ diff --git a/miner.h b/miner.h index 765512e..2ed3653 100644 --- a/miner.h +++ b/miner.h @@ -136,19 +136,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); diff --git a/scrypt-arm.S b/scrypt-arm.S index 5e2e29c..983202a 100644 --- a/scrypt-arm.S +++ b/scrypt-arm.S @@ -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__) || \ diff --git a/scrypt-x64.S b/scrypt-x64.S index c95fa45..b9f3358 100644 --- a/scrypt-x64.S +++ b/scrypt-x64.S @@ -30,7 +30,7 @@ .section .note.GNU-stack,"",%progbits #endif -#if defined(__x86_64__) +#if defined(USE_ASM) && defined(__x86_64__) .text .p2align 6 diff --git a/scrypt-x86.S b/scrypt-x86.S index 4fb2c46..7e12ceb 100644 --- a/scrypt-x86.S +++ b/scrypt-x86.S @@ -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 diff --git a/scrypt.c b/scrypt.c index f113c79..702551b 100644 --- a/scrypt.c +++ b/scrypt.c @@ -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 @@ -392,13 +392,13 @@ void scrypt_core_3way(uint32_t *X, uint32_t *V); void scrypt_core_6way(uint32_t *X, uint32_t *V); #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); -#elif defined(__arm__) && defined(__APCS_32__) +#elif defined(USE_ASM) && defined(__arm__) && defined(__APCS_32__) void scrypt_core(uint32_t *X, uint32_t *V); #if defined(__ARM_NEON__) diff --git a/sha2-arm.S b/sha2-arm.S index 7ea307c..bd7fdc5 100644 --- a/sha2-arm.S +++ b/sha2-arm.S @@ -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 diff --git a/sha2-x64.S b/sha2-x64.S index 909e2fa..0326d9d 100644 --- a/sha2-x64.S +++ b/sha2-x64.S @@ -13,7 +13,7 @@ .section .note.GNU-stack,"",%progbits #endif -#if defined(__x86_64__) +#if defined(USE_ASM) && defined(__x86_64__) .data .p2align 7 diff --git a/sha2-x86.S b/sha2-x86.S index 89bf4a9..e2eb112 100644 --- a/sha2-x86.S +++ b/sha2-x86.S @@ -13,7 +13,7 @@ .section .note.GNU-stack,"",%progbits #endif -#if defined(__i386__) +#if defined(USE_ASM) && defined(__i386__) .data .p2align 7 diff --git a/sha2.c b/sha2.c index d13a495..367efda 100644 --- a/sha2.c +++ b/sha2.c @@ -14,7 +14,7 @@ #include #include -#if defined(__arm__) && defined(__APCS_32__) +#if defined(USE_ASM) && defined(__arm__) && defined(__APCS_32__) #define EXTERN_SHA256 #endif