[PATCH] Add check for avx support.

Tomáš Chvátal tomas.chvatal at gmail.com
Wed Aug 3 04:52:13 PDT 2011


Signed-off-by: Tomáš Chvátal <tomas.chvatal at gmail.com>
---
 configure.in |   31 +++++++++++++++++++++++++++++++
 set_soenv.in |    1 +
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/configure.in b/configure.in
index cf308dc..3317d42 100755
--- a/configure.in
+++ b/configure.in
@@ -1885,6 +1885,37 @@ fi
 AC_SUBST(HAVE_LD_BSYMBOLIC_FUNCTIONS)
 
 dnl ===================================================================
+dnl Check for AVX
+dnl ===================================================================
+AS_IF([test "x$AVX_CFLAGS" = "x"], [
+  AS_IF([test "x$SUNCC" = "xyes" && test "x$AMD64_ABI" = "xno"], [
+       AVX_CFLAGS="-xarch=avx"
+  ])
+], [
+  AVX_CFLAGS="-mavx -Winline"
+])
+
+have_avx_intrinsics=no
+AC_MSG_CHECKING(whether to use AVX intrinsics)
+avx_save_CFLAGS=$CFLAGS
+CFLAGS="$AVX_CFLAGS $CFLAGS"
+AC_COMPILE_IFELSE([
+#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5))
+#   if !defined(__amd64__) && !defined(__x86_64__)
+#      error "Need GCC >= 4.5 for AVX intrinsics on x86"
+#   endif
+#endif
+#include <immintrin.h>
+int main () {
+    __m256i a = _mm256_set1_epi32 (0), b = _mm256_set1_epi32 (0), c;
+        c = _mm256_permute2f128_si256 (a, b, 0);
+    return 0;
+}], have_avx_intrinsics=yes)
+CFLAGS=$avx_save_CFLAGS
+AC_MSG_RESULT([$have_avx_intrinsics])
+AM_CONDITIONAL(HAVE_GCC_AVX, [test "x$have_avx_intrinsics" = "xyes"])
+
+dnl ===================================================================
 dnl Set up a different compiler to produce tools to run on the build
 dnl machine when doing cross-compilation
 dnl ===================================================================
diff --git a/set_soenv.in b/set_soenv.in
index 4994709..729241c 100755
--- a/set_soenv.in
+++ b/set_soenv.in
@@ -1825,6 +1825,7 @@ ToFile( "ALIGNOF_INT",          "@ALIGNOF_INT@", "e" );
 ToFile( "ALIGNOF_LONG",         "@ALIGNOF_LONG@", "e" );
 ToFile( "ALIGNOF_DOUBLE",       "@ALIGNOF_DOUBLE@", "e" );
 ToFile( "HAVE_GCC_NO_LONG_DOUBLE", "@HAVE_GCC_NO_LONG_DOUBLE@", "e" );
+ToFile( "HAVE_GCC_AVX", "@HAVE_GCC_AVX@", "e" );
 ToFile( "HAVE_GCC_VISIBILITY_FEATURE",
 		"@HAVE_GCC_VISIBILITY_FEATURE@", "e" );
 ToFile( "HAVE_GCC_VISIBILITY_BROKEN",
-- 
1.7.3.4


--------------000508000308030305090601
Content-Type: text/x-patch;
 name="0001-Fix-segmentation-fault-when-linking-mavx-on-new-CPUs.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0001-Fix-segmentation-fault-when-linking-mavx-on-new-CPUs.pa";
 filename*1="tch"



More information about the LibreOffice mailing list