Add a configure option to disable assembly code

This commit is contained in:
pooler 2014-05-16 15:37:41 +02:00
parent ab6d34e043
commit a5430f73e1
12 changed files with 26 additions and 16 deletions

View file

@ -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@

View file

@ -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])

View file

@ -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__) || \

View file

@ -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);

View file

@ -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__) || \

View file

@ -30,7 +30,7 @@
.section .note.GNU-stack,"",%progbits
#endif
#if defined(__x86_64__)
#if defined(USE_ASM) && defined(__x86_64__)
.text
.p2align 6

View file

@ -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

View file

@ -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__)

View file

@ -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

View file

@ -13,7 +13,7 @@
.section .note.GNU-stack,"",%progbits
#endif
#if defined(__x86_64__)
#if defined(USE_ASM) && defined(__x86_64__)
.data
.p2align 7

View file

@ -13,7 +13,7 @@
.section .note.GNU-stack,"",%progbits
#endif
#if defined(__i386__)
#if defined(USE_ASM) && defined(__i386__)
.data
.p2align 7

2
sha2.c
View file

@ -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