Skip to content

Commit 579cec9

Browse files
author
Erik Lindahl
committed
Enable SSE2 automatically with AVX,AVX2, or AVX512.
256-bit AVX can be significantly slower than 128-bit SIMD. Despite recommendations many distributions appear to only enable AVX, but not SSE. This fixes the problem by also enabling SSE when we use the wider SIMD instructions.
1 parent dd80210 commit 579cec9

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

configure.ac

+23-17
Original file line numberDiff line numberDiff line change
@@ -107,23 +107,6 @@ AM_CONDITIONAL(QUAD, test "$ok" = "yes")
107107
AC_SUBST(PRECISION)
108108
AC_SUBST(CHECK_PL_OPTS)
109109

110-
AC_ARG_ENABLE(sse, [AC_HELP_STRING([--enable-sse],[enable SSE optimizations])], have_sse=$enableval, have_sse=no)
111-
if test "$have_sse" = "yes"; then
112-
if test "$PRECISION" != "s"; then
113-
AC_MSG_ERROR([SSE requires single precision])
114-
fi
115-
fi
116-
117-
AC_ARG_ENABLE(sse2, [AC_HELP_STRING([--enable-sse2],[enable SSE/SSE2 optimizations])], have_sse2=$enableval, have_sse2=no)
118-
if test "$have_sse" = "yes"; then have_sse2=yes; fi
119-
if test "$have_sse2" = "yes"; then
120-
AC_DEFINE(HAVE_SSE2,1,[Define to enable SSE/SSE2 optimizations.])
121-
if test "$PRECISION" != "d" -a "$PRECISION" != "s"; then
122-
AC_MSG_ERROR([SSE2 requires single or double precision])
123-
fi
124-
fi
125-
AM_CONDITIONAL(HAVE_SSE2, test "$have_sse2" = "yes")
126-
127110
AC_ARG_ENABLE(avx, [AC_HELP_STRING([--enable-avx],[enable AVX optimizations])], have_avx=$enableval, have_avx=no)
128111
if test "$have_avx" = "yes"; then
129112
AC_DEFINE(HAVE_AVX,1,[Define to enable AVX optimizations.])
@@ -153,6 +136,29 @@ if test "$have_avx512" = "yes"; then
153136
fi
154137
AM_CONDITIONAL(HAVE_AVX512, test "$have_avx512" = "yes")
155138

139+
dnl Process SSE/SSE2 after AVX, so we can enable the shorter-length vectors too.
140+
dnl All AVX-capable platforms, including AVX-512, support the old SSE instructions.
141+
AC_ARG_ENABLE(sse, [AC_HELP_STRING([--enable-sse],[enable SSE optimizations])], have_sse=$enableval, have_sse=no)
142+
if test "$have_sse" = "yes"; then
143+
if test "$PRECISION" != "s"; then
144+
AC_MSG_ERROR([SSE requires single precision])
145+
fi
146+
fi
147+
148+
AC_ARG_ENABLE(sse2, [AC_HELP_STRING([--enable-sse2],[enable SSE/SSE2 optimizations])], have_sse2=$enableval, have_sse2=no)
149+
if test "$have_sse" = "yes"; then have_sse2=yes; fi
150+
if test "$have_avx" = "yes"; then have_sse2=yes; fi
151+
if test "$have_avx2" = "yes"; then have_sse2=yes; fi
152+
if test "$have_avx512" = "yes"; then have_sse2=yes; fi
153+
if test "$have_sse2" = "yes"; then
154+
AC_DEFINE(HAVE_SSE2,1,[Define to enable SSE/SSE2 optimizations.])
155+
if test "$PRECISION" != "d" -a "$PRECISION" != "s"; then
156+
AC_MSG_ERROR([SSE2 requires single or double precision])
157+
fi
158+
fi
159+
AM_CONDITIONAL(HAVE_SSE2, test "$have_sse2" = "yes")
160+
161+
156162
AC_ARG_ENABLE(kcvi, [AC_HELP_STRING([--enable-kcvi],[enable Knights Corner vector instructions optimizations])], have_kcvi=$enableval, have_kcvi=no)
157163
if test "$have_kcvi" = "yes"; then
158164
AC_DEFINE(HAVE_KCVI,1,[Define to enable KCVI optimizations.])

0 commit comments

Comments
 (0)