From 4c935e2eee456ff66cdfb908b0edffdd1e8a6c04 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sun, 24 Jun 2018 10:50:40 -0700 Subject: Add SHA256 implementation using using Intel SHA intrinsics --- configure.ac | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index ff7f1b39c8..2826f29ed8 100644 --- a/configure.ac +++ b/configure.ac @@ -319,6 +319,7 @@ fi AX_CHECK_COMPILE_FLAG([-msse4.2],[[SSE42_CXXFLAGS="-msse4.2"]],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-msse4.1],[[SSE41_CXXFLAGS="-msse4.1"]],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-mavx -mavx2],[[AVX2_CXXFLAGS="-mavx -mavx2"]],,[[$CXXFLAG_WERROR]]) +AX_CHECK_COMPILE_FLAG([-msse4 -msha],[[SHANI_CXXFLAGS="-msse4 -msha"]],,[[$CXXFLAG_WERROR]]) TEMP_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS $SSE42_CXXFLAGS" @@ -380,6 +381,27 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ) CXXFLAGS="$TEMP_CXXFLAGS" +TEMP_CXXFLAGS="$CXXFLAGS" +CXXFLAGS="$CXXFLAGS $SHANI_CXXFLAGS" +AC_MSG_CHECKING(for SHA-NI intrinsics) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #if defined(_MSC_VER) + #include + #elif defined(__GNUC__) + #include + #endif + ]],[[ + __m128i i = _mm_set1_epi32(0); + __m128i j = _mm_set1_epi32(1); + __m128i k = _mm_set1_epi32(2); + return _mm_extract_epi32(_mm_sha256rnds2_epu32(i, i, k), 0); + ]])], + [ AC_MSG_RESULT(yes); enable_shani=yes; AC_DEFINE(ENABLE_SHANI, 1, [Define this symbol to build code that uses SHA-NI intrinsics]) ], + [ AC_MSG_RESULT(no)] +) +CXXFLAGS="$TEMP_CXXFLAGS" + CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS" AC_ARG_WITH([utils], @@ -1300,6 +1322,7 @@ AM_CONDITIONAL([HARDEN],[test x$use_hardening = xyes]) AM_CONDITIONAL([ENABLE_HWCRC32],[test x$enable_hwcrc32 = xyes]) AM_CONDITIONAL([ENABLE_SSE41],[test x$enable_sse41 = xyes]) AM_CONDITIONAL([ENABLE_AVX2],[test x$enable_avx2 = xyes]) +AM_CONDITIONAL([ENABLE_SHANI],[test x$enable_shani = xyes]) AM_CONDITIONAL([USE_ASM],[test x$use_asm = xyes]) AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version]) @@ -1344,6 +1367,7 @@ AC_SUBST(SANITIZER_LDFLAGS) AC_SUBST(SSE42_CXXFLAGS) AC_SUBST(SSE41_CXXFLAGS) AC_SUBST(AVX2_CXXFLAGS) +AC_SUBST(SHANI_CXXFLAGS) AC_SUBST(LIBTOOL_APP_LDFLAGS) AC_SUBST(USE_UPNP) AC_SUBST(USE_QRCODE) -- cgit v1.2.3 From 66b2cf1ccfad545a8ec3f2a854e23f647322bf30 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 11 Jun 2018 09:59:20 -0700 Subject: Use immintrin.h everywhere for intrinsics --- configure.ac | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 2826f29ed8..9e635994ef 100644 --- a/configure.ac +++ b/configure.ac @@ -348,11 +348,7 @@ CXXFLAGS="$CXXFLAGS $SSE41_CXXFLAGS" AC_MSG_CHECKING(for SSE4.1 intrinsics) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - #if defined(_MSC_VER) #include - #elif defined(__GNUC__) - #include - #endif ]],[[ __m128i l = _mm_set1_epi32(0); return _mm_extract_epi32(l, 3); @@ -367,11 +363,7 @@ CXXFLAGS="$CXXFLAGS $AVX2_CXXFLAGS" AC_MSG_CHECKING(for AVX2 intrinsics) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - #if defined(_MSC_VER) #include - #elif defined(__GNUC__) && defined(__AVX2__) - #include - #endif ]],[[ __m256i l = _mm256_set1_epi32(0); return _mm256_extract_epi32(l, 7); @@ -386,11 +378,7 @@ CXXFLAGS="$CXXFLAGS $SHANI_CXXFLAGS" AC_MSG_CHECKING(for SHA-NI intrinsics) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - #if defined(_MSC_VER) #include - #elif defined(__GNUC__) - #include - #endif ]],[[ __m128i i = _mm_set1_epi32(0); __m128i j = _mm_set1_epi32(1); -- cgit v1.2.3