Skip to content

Commit 6dcdc45

Browse files
authored
Merge pull request #1450 from denravonska/scrypt-asm
[WIP] Re-enable scrypt optimizations.
2 parents ce304ce + d18bd66 commit 6dcdc45

File tree

6 files changed

+4436
-1816
lines changed

6 files changed

+4436
-1816
lines changed

configure.ac

+41-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,41 @@ 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+
AC_DEFINE(enable_avx2=yes; ENABLE_AVX2, 1, [Define to 1 if AVX2 assembly is available.])
207+
AC_MSG_RESULT(yes)
208+
,
209+
AC_MSG_RESULT(no)
210+
AC_MSG_WARN([The assembler does not support the AVX2 instruction set.])
211+
)
212+
,
213+
AC_MSG_RESULT(no)
214+
AC_MSG_WARN([The assembler does not support the AVX instruction set.])
215+
)
216+
fi
217+
182218
# Enable debug
183219
AC_ARG_ENABLE([debug],
184220
[AS_HELP_STRING([--enable-debug],
@@ -290,25 +326,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
290326
)
291327
CXXFLAGS="$TEMP_CXXFLAGS"
292328

293-
TEMP_CXXFLAGS="$CXXFLAGS"
294-
CXXFLAGS="$CXXFLAGS $AVX2_CXXFLAGS"
295-
AC_MSG_CHECKING(for AVX2 intrinsics)
296-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
297-
#include <stdint.h>
298-
#if defined(_MSC_VER)
299-
#include <immintrin.h>
300-
#elif defined(__GNUC__) && defined(__AVX2__)
301-
#include <x86intrin.h>
302-
#endif
303-
]],[[
304-
__m256i l = _mm256_set1_epi32(0);
305-
return _mm256_extract_epi32(l, 7);
306-
]])],
307-
[ AC_MSG_RESULT(yes); enable_avx2=yes; AC_DEFINE(ENABLE_AVX2, 1, [Define this symbol to build code that uses AVX2 intrinsics]) ],
308-
[ AC_MSG_RESULT(no)]
309-
)
310-
CXXFLAGS="$TEMP_CXXFLAGS"
311-
312329
TEMP_CXXFLAGS="$CXXFLAGS"
313330
CXXFLAGS="$CXXFLAGS $SHANI_CXXFLAGS"
314331
AC_MSG_CHECKING(for SHA-NI intrinsics)
@@ -1141,7 +1158,6 @@ if test x$build_bitcoin_utils$build_bitcoin_libs$build_gridcoinresearchd$bitcoin
11411158
AC_MSG_ERROR([No targets! Please specify at least one of: --with-utils --with-libs --with-daemon --with-gui --enable-bench or --enable-tests])
11421159
fi
11431160

1144-
11451161
AM_CONDITIONAL([TARGET_DARWIN], [test x$TARGET_OS = xdarwin])
11461162
AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin])
11471163
AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows])
@@ -1159,6 +1175,9 @@ AM_CONDITIONAL([ENABLE_SSE41],[test x$enable_sse41 = xyes])
11591175
AM_CONDITIONAL([ENABLE_AVX2],[test x$enable_avx2 = xyes])
11601176
AM_CONDITIONAL([ENABLE_SHANI],[test x$enable_shani = xyes])
11611177
AM_CONDITIONAL([USE_ASM],[test x$use_asm = xyes])
1178+
AM_CONDITIONAL([ARCH_x86], [test x$have_x86 = xtrue])
1179+
AM_CONDITIONAL([ARCH_x86_64], [test x$have_x86_64 = xtrue])
1180+
AM_CONDITIONAL([ARCH_ARM], [test x$have_arm = xtrue])
11621181

11631182
AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version])
11641183
AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version])
@@ -1285,4 +1304,6 @@ echo " CPPFLAGS = $CPPFLAGS"
12851304
echo " CXX = $CXX"
12861305
echo " CXXFLAGS = $CXXFLAGS"
12871306
echo " LDFLAGS = $LDFLAGS"
1307+
echo " AS = $CCAS"
1308+
echo " ASFLAGS = $CCASFLAGS"
12881309
echo

src/Makefile.am

+3
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ GRIDCOIN_CORE_CPP = addrdb.cpp \
186186
scraper/scraper.cpp \
187187
script.cpp \
188188
scrypt.cpp \
189+
scrypt-arm.S \
190+
scrypt-x86_64.S \
191+
scrypt-x86.S \
189192
scheduler.cpp \
190193
support/cleanse.cpp \
191194
support/lockedpool.cpp \

0 commit comments

Comments
 (0)