Skip to content

Commit 34399cf

Browse files
committed
Re-enable scrypt optimizations.
Update assembler implementations with ones from cpuminer-opt.
1 parent 057aac2 commit 34399cf

File tree

6 files changed

+4437
-1816
lines changed

6 files changed

+4437
-1816
lines changed

configure.ac

+42-20
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ else
4343
CXXFLAGS_overridden=no
4444
fi
4545
AC_PROG_CXX
46+
AM_PROG_AS
4647

4748
dnl By default, libtool for mingw refuses to link static libs into a dll for
4849
dnl fear of mixing pic/non-pic objects, and import/export complications. Since
@@ -179,6 +180,42 @@ if test "x$use_asm" = xyes; then
179180
AC_DEFINE(USE_ASM, 1, [Define this symbol to build in assembly routines])
180181
fi
181182

183+
BUILD_TARGET=`$CC -dumpmachine 2>&1`
184+
case $BUILD_TARGET in
185+
x86_64-*-*|amd64-*-*)
186+
have_x86_64=true
187+
;;
188+
esac
189+
190+
if test x$enable_assembly != xno -a x$have_x86_64 = xtrue
191+
then
192+
AC_MSG_CHECKING(whether we can compile AVX code)
193+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[asm ("vmovdqa %ymm0, %ymm1");])],
194+
AC_DEFINE(ENABLE_AVX, 1, [Define to 1 if AVX assembly is available.])
195+
AC_MSG_RESULT(yes)
196+
AC_MSG_CHECKING(whether we can compile XOP code)
197+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[asm ("vprotd \$7, %xmm0, %xmm1");])],
198+
AC_DEFINE(ENABLE_XOP, 1, [Define to 1 if XOP assembly is available.])
199+
AC_MSG_RESULT(yes)
200+
,
201+
AC_MSG_RESULT(no)
202+
AC_MSG_WARN([The assembler does not support the XOP instruction set.])
203+
)
204+
AC_MSG_CHECKING(whether we can compile AVX2 code)
205+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[asm ("vpaddd %ymm0, %ymm1, %ymm2");])],
206+
enable_avx2=yes;
207+
AC_DEFINE(ENABLE_AVX2, 1, [Define to 1 if AVX2 assembly is available.])
208+
AC_MSG_RESULT(yes)
209+
,
210+
AC_MSG_RESULT(no)
211+
AC_MSG_WARN([The assembler does not support the AVX2 instruction set.])
212+
)
213+
,
214+
AC_MSG_RESULT(no)
215+
AC_MSG_WARN([The assembler does not support the AVX instruction set.])
216+
)
217+
fi
218+
182219
# Enable debug
183220
AC_ARG_ENABLE([debug],
184221
[AS_HELP_STRING([--enable-debug],
@@ -282,25 +319,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
282319
)
283320
CXXFLAGS="$TEMP_CXXFLAGS"
284321

285-
TEMP_CXXFLAGS="$CXXFLAGS"
286-
CXXFLAGS="$CXXFLAGS $AVX2_CXXFLAGS"
287-
AC_MSG_CHECKING(for AVX2 intrinsics)
288-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
289-
#include <stdint.h>
290-
#if defined(_MSC_VER)
291-
#include <immintrin.h>
292-
#elif defined(__GNUC__) && defined(__AVX2__)
293-
#include <x86intrin.h>
294-
#endif
295-
]],[[
296-
__m256i l = _mm256_set1_epi32(0);
297-
return _mm256_extract_epi32(l, 7);
298-
]])],
299-
[ AC_MSG_RESULT(yes); enable_avx2=yes; AC_DEFINE(ENABLE_AVX2, 1, [Define this symbol to build code that uses AVX2 intrinsics]) ],
300-
[ AC_MSG_RESULT(no)]
301-
)
302-
CXXFLAGS="$TEMP_CXXFLAGS"
303-
304322
CPPFLAGS="$CPPFLAGS -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
305323

306324
AC_ARG_WITH([utils],
@@ -1099,7 +1117,6 @@ if test x$build_bitcoin_utils$build_bitcoin_libs$build_gridcoinresearchd$bitcoin
10991117
AC_MSG_ERROR([No targets! Please specify at least one of: --with-utils --with-libs --with-daemon --with-gui --enable-bench or --enable-tests])
11001118
fi
11011119

1102-
11031120
AM_CONDITIONAL([TARGET_DARWIN], [test x$TARGET_OS = xdarwin])
11041121
AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin])
11051122
AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows])
@@ -1116,6 +1133,9 @@ AM_CONDITIONAL([ENABLE_HWCRC32],[test x$enable_hwcrc32 = xyes])
11161133
AM_CONDITIONAL([ENABLE_SSE41],[test x$enable_sse41 = xyes])
11171134
AM_CONDITIONAL([ENABLE_AVX2],[test x$enable_avx2 = xyes])
11181135
AM_CONDITIONAL([USE_ASM],[test x$use_asm = xyes])
1136+
AM_CONDITIONAL([ARCH_x86], [test x$have_x86 = xtrue])
1137+
AM_CONDITIONAL([ARCH_x86_64], [test x$have_x86_64 = xtrue])
1138+
AM_CONDITIONAL([ARCH_ARM], [test x$have_arm = xtrue])
11191139

11201140
AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version])
11211141
AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version])
@@ -1241,4 +1261,6 @@ echo " CPPFLAGS = $CPPFLAGS"
12411261
echo " CXX = $CXX"
12421262
echo " CXXFLAGS = $CXXFLAGS"
12431263
echo " LDFLAGS = $LDFLAGS"
1264+
echo " AS = $CCAS"
1265+
echo " ASFLAGS = $CCASFLAGS"
12441266
echo

src/Makefile.am

+3
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ GRIDCOIN_CORE_CPP = addrman.cpp \
166166
scraper/scraper.cpp \
167167
script.cpp \
168168
scrypt.cpp \
169+
scrypt-arm.S \
170+
scrypt-x86_64.S \
171+
scrypt-x86.S \
169172
sync.cpp \
170173
tally.cpp \
171174
txdb-leveldb.cpp \

0 commit comments

Comments
 (0)