Blob Blame History Raw
diff -up mpich/configure.ac.simd mpich/configure.ac
--- mpich/configure.ac.simd	2017-06-12 15:45:53.001455666 +0200
+++ mpich/configure.ac	2017-06-12 15:46:18.131946972 +0200
@@ -196,6 +196,10 @@ AC_MSG_RESULT([${can_compile_sse}])
 
 dnl check whether one can compile with avx - gcc intrinsics
 
+save_CFLAGS="$CFLAGS"
+save_CXXFLAGS="$CXXFLAGS"
+CFLAGS="$CFLAGS -mavx"
+
 dnl first pass: try with specified CFLAGS and CXXFLAGS
 AC_MSG_CHECKING([whether we can compile AVX intrinsics in C])
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
@@ -211,6 +215,8 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
 )
 AC_MSG_RESULT([${can_compile_avx}])
 if test "${can_compile_avx}" = "yes" ; then
+  AVXCFLAGS="-mavx"
+  CXXFLAGS="$CXXFLAGS -mavx"
   AC_MSG_CHECKING([whether we can compile AVX intrinsics in C++])
   AC_LANG_PUSH([C++])
   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
@@ -228,9 +234,15 @@ if test "${can_compile_avx}" = "yes" ; t
   AC_MSG_RESULT([${can_compile_avx}])
   if test "${can_compile_avx}" = "no" ; then
     AC_MSG_WARN([Cannot compile C++ with AVX: disabling AVX alltogether])
+  else
+    AVXCXXFLAGS="-mavx"
   fi
 fi
 
+CFLAGS=$save_CFLAGS
+CXXFLAGS=$save_CXXFLAGS
+CFLAGS="$CFLAGS -mavx2 -mfma"
+
 AC_MSG_CHECKING([whether we can compile AVX2 intrinsics in C])
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  #include <x86intrin.h>
@@ -246,6 +258,8 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
 )
 AC_MSG_RESULT([${can_compile_avx2}])
 if test "${can_compile_avx2}" = "yes" ; then
+  AVX2CFLAGS="-mavx2 -mfma"
+  CXXFLAGS="$CXXFLAGS -mavx2 -mfma"
   AC_MSG_CHECKING([whether we can compile AVX2 intrinsics in C++])
   AC_LANG_PUSH([C++])
   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
@@ -264,9 +278,13 @@ if test "${can_compile_avx2}" = "yes" ;
   AC_MSG_RESULT([${can_compile_avx2}])
   if test "${can_compile_avx2}" = "no" ; then
     AC_MSG_WARN([Cannot compile C++ with AVX2!])
+  else
+    AVX2CXXFLAGS="-mavx2 -mfma"
   fi
 fi
 
+CFLAGS=$save_CFLAGS
+CXXFLAGS=$save_CXXFLAGS
 
 if test "${can_compile_avx}" = "yes" ; then
   install_real_avx_block2=yes
@@ -669,6 +687,10 @@ AC_SUBST([OPENMP_CFLAGS])
 AC_SUBST([OPENMP_FCFLAGS])
 AC_SUBST([OPENMP_LDFLAGS])
 #AC_SUBST(OPT_FCFLAGS)
+AC_SUBST([AVXCFLAGS])
+AC_SUBST([AVXCXXFLAGS])
+AC_SUBST([AVX2CFLAGS])
+AC_SUBST([AVX2CXXFLAGS])
 
 rm -rf modules/ .fortran_dependencies/
 mkdir modules
diff -up mpich/Makefile.am.simd mpich/Makefile.am
--- mpich/Makefile.am.simd	2015-11-22 20:05:49.000000000 +0100
+++ mpich/Makefile.am	2017-06-12 15:45:53.002455686 +0200
@@ -8,6 +8,8 @@ AM_LDFLAGS = $(SCALAPACK_LDFLAGS)
 # libelpa
 lib_LTLIBRARIES = libelpa@SUFFIX@.la
 libelpa@SUFFIX@_la_LINK = $(FCLINK) $(AM_LDFLAGS) -version-info $(ELPA_SO_VERSION) -lstdc++
+libelpa@SUFFIX@_la_CFLAGS = $(AVXCFLAGS) $(AVX2CFLAGS) $(AM_CFLAGS)
+libelpa@SUFFIX@_la_CXXFLAGS = $(AVXCXXFLAGS) $(AVX2CXXFLAGS) $(AM_CFLAGS)
 
 libelpa@SUFFIX@_la_SOURCES = src/elpa_utilities.F90 \
 	                     src/elpa1.F90 \