diff -up mpich/configure.ac.avx mpich/configure.ac --- mpich/configure.ac.avx 2016-04-03 16:02:10.334634259 +0200 +++ mpich/configure.ac 2016-04-03 16:03:45.419882924 +0200 @@ -196,8 +196,12 @@ AC_MSG_RESULT([${can_compile_sse}]) dnl check whether one can compile with avx - gcc intrinsics +save_CFLAGS="$CFLAGS" +save_CXXFLAGS="$CXXFLAGS" + dnl first pass: try with specified CFLAGS and CXXFLAGS AC_MSG_CHECKING([whether we can compile AVX intrinsics in C]) +CFLAGS="$CFLAGS -mavx" AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include int main(int argc, char **argv){ @@ -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,10 +234,16 @@ 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 + AC_MSG_CHECKING([whether we can compile AVX2 intrinsics in C]) +CFLAGS="$CFLAGS -mavx2 -mfma" AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include int main(int argc, char **argv){ @@ -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,8 @@ AC_SUBST([OPENMP_CFLAGS]) AC_SUBST([OPENMP_FCFLAGS]) AC_SUBST([OPENMP_LDFLAGS]) #AC_SUBST(OPT_FCFLAGS) +AC_SUBST([AVXCFLAGS]) +AC_SUBST([AVXCXXFLAGS]) rm -rf modules/ .fortran_dependencies/ mkdir modules diff -up mpich/Makefile.am.avx mpich/Makefile.am --- mpich/Makefile.am.avx 2015-11-22 20:05:49.000000000 +0100 +++ mpich/Makefile.am 2016-04-03 16:02:10.336634243 +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 \