[Mesa-dev] [PATCH v2] swr: fix -march flag for AVX

Tim Rowley timothy.o.rowley at intel.com
Fri Jun 10 23:49:13 UTC 2016


Previously used core-avx-i was for ivybridge;
corei7-avx allows sandybridge.

v2: move flag check up to configure.ac; attempt to use gcc 4.9+
documented flags instead of the older architecture naming.
---
 configure.ac                        | 33 +++++++++++++++++++++++++--------
 src/gallium/drivers/swr/Makefile.am |  4 ++--
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/configure.ac b/configure.ac
index 33d1fef..6e54c1d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2397,10 +2397,9 @@ if test -n "$with_gallium_drivers"; then
             swr_llvm_check "swr"
 
             AC_MSG_CHECKING([whether $CXX supports c++11/AVX/AVX2])
-            AVX_CXXFLAGS="-march=core-avx-i"
-            AVX2_CXXFLAGS="-march=core-avx2"
 
             AC_LANG_PUSH([C++])
+
             save_CXXFLAGS="$CXXFLAGS"
             CXXFLAGS="-std=c++11 $CXXFLAGS"
             AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[],
@@ -2408,16 +2407,31 @@ if test -n "$with_gallium_drivers"; then
             CXXFLAGS="$save_CXXFLAGS"
 
             save_CXXFLAGS="$CXXFLAGS"
-            CXXFLAGS="$AVX_CXXFLAGS $CXXFLAGS"
-            AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[],
-                              [AC_MSG_ERROR([AVX compiler support not detected])])
+            CXXFLAGS="-march=sandybridge $CXXFLAGS"
+            AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[AVX_CXXFLAGS="-march=sandybridge"],[])
             CXXFLAGS="$save_CXXFLAGS"
 
+            if test "x$AVX_CXXFLAGS" = x; then
+               save_CXXFLAGS="$CXXFLAGS"
+               CXXFLAGS="-march=corei7-avx $CXXFLAGS"
+               AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[AVX_CXXFLAGS="-march=corei7-avx"],
+                                 [AC_MSG_ERROR([AVX compiler support not detected])])
+               CXXFLAGS="$save_CXXFLAGS"
+            fi
+
             save_CFLAGS="$CXXFLAGS"
-            CXXFLAGS="$AVX2_CXXFLAGS $CXXFLAGS"
-            AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[],
-                              [AC_MSG_ERROR([AVX2 compiler support not detected])])
+            CXXFLAGS="-march=haswell $CXXFLAGS"
+            AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[AVX2_CXXFLAGS="-march=haswell"],[])
             CXXFLAGS="$save_CXXFLAGS"
+
+            if test "x$AVX2_CXXFLAGS" = x; then
+               save_CXXFLAGS="$CXXFLAGS"
+               CXXFLAGS="-march=core-avx2 $CXXFLAGS"
+               AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[AVX2_CXXFLAGS="-march=core-avx2"],
+                                 [AC_MSG_ERROR([AVX2 compiler support not detected])])
+               CXXFLAGS="$save_CXXFLAGS"
+            fi
+
             AC_LANG_POP([C++])
 
             HAVE_GALLIUM_SWR=yes
@@ -2445,6 +2459,9 @@ if test -n "$with_gallium_drivers"; then
     done
 fi
 
+AC_SUBST([AVX_CXXFLAGS])
+AC_SUBST([AVX2_CXXFLAGS])
+
 dnl Set LLVM_LIBS - This is done after the driver configuration so
 dnl that drivers can add additional components to LLVM_COMPONENTS.
 dnl Previously, gallium drivers were updating LLVM_LIBS directly
diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am
index d211f2e..9e21dc9 100644
--- a/src/gallium/drivers/swr/Makefile.am
+++ b/src/gallium/drivers/swr/Makefile.am
@@ -124,7 +124,7 @@ COMMON_LDFLAGS = \
 lib_LTLIBRARIES = libswrAVX.la libswrAVX2.la
 
 libswrAVX_la_CXXFLAGS = \
-	-march=core-avx-i \
+	$(AVX_CXXFLAGS) \
 	-DKNOB_ARCH=KNOB_ARCH_AVX \
 	$(COMMON_CXXFLAGS)
 
@@ -138,7 +138,7 @@ libswrAVX_la_LDFLAGS = \
 	$(COMMON_LDFLAGS)
 
 libswrAVX2_la_CXXFLAGS = \
-	-march=core-avx2 \
+	$(AVX2_CXXFLAGS) \
 	-DKNOB_ARCH=KNOB_ARCH_AVX2 \
 	$(COMMON_CXXFLAGS)
 
-- 
1.9.1



More information about the mesa-dev mailing list