configure: check AVX support
authorMaryam Tahhan <maryam.tahhan@intel.com>
Tue, 7 Jun 2016 11:31:44 +0000 (12:31 +0100)
committerKim Jones <kim-marie.jones@intel.com>
Thu, 28 Jul 2016 12:23:38 +0000 (13:23 +0100)
Check AVX support before adding -mavx flag.

Change-Id: I2de2a12704126590ef991de89880ad5bd5c3805e
Signed-off-by: Maryam Tahhan <maryam.tahhan@intel.com>
configure.ac

index 0988299..5b7a950 100644 (file)
@@ -2457,7 +2457,25 @@ then
         then
            AC_MSG_ERROR([cannot link with dpdk in $DPDK_LIB_DIR])
        fi
-       BUILD_WITH_DPDK_CFLAGS="-mavx -fPIC -I$DPDK_INCLUDE"
+       BUILD_WITH_DPDK_CFLAGS=""
+       AC_MSG_NOTICE([Checking for avx instructions])
+       AC_RUN_IFELSE(
+               [AC_LANG_PROGRAM(
+[[
+#include <immintrin.h>
+]],
+[[
+__m128i zero = _mm_setzero_si128();
+]]
+       )],
+               [HAVE_AVX=true], [HAVE_AVX=false])
+       if test "x$HAVE_AVX" = "xtrue"
+       then
+               BUILD_WITH_DPDK_CFLAGS="-mavx "
+               AC_MSG_NOTICE([avx instructions supported])
+       fi
+
+       BUILD_WITH_DPDK_CFLAGS+="-fPIC -I$DPDK_INCLUDE"
        if test "x$LOCAL_DPDK_INSTALL" != "xtrue"
         then
                BUILD_WITH_DPDK_LDFLAGS="-Wl,--no-as-needed"