summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@mbnet.fi>2013-01-23 11:55:13 +0200
committerWerner Koch <wk@gnupg.org>2013-02-19 11:21:48 +0100
commit63ac3ba07dba82fde040d31b90b4eff627bd92b9 (patch)
treec103c60a747faff8ebb8e1f7b72a9faa68ed089d /configure.ac
parent4de62d80644228fc5db2a9f9c94a7eb633d8de2e (diff)
downloadlibgcrypt-63ac3ba07dba82fde040d31b90b4eff627bd92b9.tar.gz
Add AES-NI/AVX accelerated Camellia implementation
* configure.ac: Add option --disable-avx-support. (HAVE_GCC_INLINE_ASM_AVX): New. (ENABLE_AVX_SUPPORT): New. (camellia) [ENABLE_AVX_SUPPORT, ENABLE_AESNI_SUPPORT]: Add camellia_aesni_avx_x86-64.lo. * cipher/Makefile.am (AM_CCASFLAGS): Add. (EXTRA_libcipher_la_SOURCES): Add camellia_aesni_avx_x86-64.S * cipher/camellia-glue.c [ENABLE_AESNI_SUPPORT, ENABLE_AVX_SUPPORT] [__x86_64__] (USE_AESNI_AVX): Add macro. (struct Camellia_context) [USE_AESNI_AVX]: Add use_aesni_avx. [USE_AESNI_AVX] (_gcry_camellia_aesni_avx_ctr_enc) (_gcry_camellia_aesni_avx_cbc_dec): New prototypes to assembly functions. (camellia_setkey) [USE_AESNI_AVX]: Enable AES-NI/AVX if hardware support both. (_gcry_camellia_ctr_enc) [USE_AESNI_AVX]: Add AES-NI/AVX code. (_gcry_camellia_cbc_dec) [USE_AESNI_AVX]: Add AES-NI/AVX code. * cipher/camellia_aesni_avx_x86-64.S: New. * src/g10lib.h (HWF_INTEL_AVX): New. * src/global.c (hwflist): Add HWF_INTEL_AVX. * src/hwf-x86.c (detect_x86_gnuc) [ENABLE_AVX_SUPPORT]: Add detection for AVX. -- Before: Running each test 250 times. ECB/Stream CBC CFB OFB CTR --------------- --------------- --------------- --------------- --------------- CAMELLIA128 2210ms 2200ms 2300ms 2050ms 2240ms 2250ms 2290ms 2270ms 2070ms 2070ms CAMELLIA256 2810ms 2800ms 2920ms 2670ms 2840ms 2850ms 2910ms 2890ms 2660ms 2640ms After: Running each test 250 times. ECB/Stream CBC CFB OFB CTR --------------- --------------- --------------- --------------- --------------- CAMELLIA128 2200ms 2220ms 2290ms 470ms 2240ms 2270ms 2270ms 2290ms 480ms 480ms CAMELLIA256 2820ms 2820ms 2900ms 600ms 2860ms 2860ms 2900ms 2920ms 620ms 620ms AES-NI/AVX implementation works by processing 16 parallel blocks (256 bytes). It's bytesliced implementation that uses AES-NI (Subbyte) for Camellia sboxes, with help of prefiltering/postfiltering. For smaller data sets generic C implementation is used. Speed-up for CBC-decryption and CTR-mode (large data): 4.3x Tests were run on: Intel Core i5-2450M Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi> (license boiler plate update by wk)
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac42
1 files changed, 42 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 5e57868e..4a4a2aac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -557,6 +557,14 @@ if test x"$drngsupport" = xyes ; then
[Enable support for Intel DRNG (RDRAND instruction).])
fi
+# Implementation of the --disable-avx-support switch.
+AC_MSG_CHECKING([whether AVX support is requested])
+AC_ARG_ENABLE(avx-support,
+ AC_HELP_STRING([--disable-avx-support],
+ [Disable support for the Intel AVX instructions]),
+ avxsupport=$enableval,avxsupport=yes)
+AC_MSG_RESULT($avxsupport)
+
# Implementation of the --disable-O-flag-munging switch.
AC_MSG_CHECKING([whether a -O flag munging is requested])
AC_ARG_ENABLE([O-flag-munging],
@@ -842,6 +850,32 @@ if test "$gcry_cv_have_asm" = "no" ; then
fi
+#
+# Check whether GCC inline assembler supports AVX instructions
+#
+AC_CACHE_CHECK([whether GCC inline assembler supports AVX instructions],
+ [gcry_cv_gcc_inline_asm_avx],
+ [gcry_cv_gcc_inline_asm_avx=no
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+ [[void a(void) {
+ __asm__("vaesdeclast (%[mem]),%%xmm0,%%xmm7\n\t"::[mem]"r"(0):);
+ }]])],
+ [gcry_cv_gcc_inline_asm_avx=yes])])
+if test "$gcry_cv_gcc_inline_asm_avx" = "yes" ; then
+ AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX,1,
+ [Defined if inline assembler supports AVX instructions])
+
+ if test x"$avxsupport" = xyes ; then
+ AC_DEFINE(ENABLE_AVX_SUPPORT,1,
+ [Enable support for Intel AVX instructions.])
+ fi
+else
+ if test x"$avxsupport" = xyes ; then
+ avxsupport="no (unsupported by compiler)"
+ fi
+fi
+
+
#######################################
#### Checks for library functions. ####
#######################################
@@ -1139,6 +1173,13 @@ LIST_MEMBER(camellia, $enabled_ciphers)
if test "$found" = "1" ; then
GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia.lo camellia-glue.lo"
AC_DEFINE(USE_CAMELLIA, 1, [Defined if this module should be included])
+
+ if test x"$avxsupport" = xyes ; then
+ if test x"$aesnisupport" = xyes ; then
+ # Build with the AES-NI/AVX implementation
+ GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia_aesni_avx_x86-64.lo"
+ fi
+ fi
fi
LIST_MEMBER(idea, $enabled_ciphers)
@@ -1358,6 +1399,7 @@ echo "
Try using Padlock crypto: $padlocksupport
Try using AES-NI crypto: $aesnisupport
Try using DRNG (RDRAND): $drngsupport
+ Try using Intel AVX: $avxsupport
"
if test "$print_egd_notice" = "yes"; then