Skip to content

Commit b63c99e

Browse files
authored
Merge pull request #7701 from raffenet/avx-5.0.x
[5.0.x] mpl: Improved check for AVX/AVX512F support
2 parents 2be583b + 1ddb5e7 commit b63c99e

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/mpl/configure.ac

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,28 @@ fi
207207

208208
# check if compiler supports avx, avx512f
209209
# also check if the building machine can run them if not force enabled
210-
AC_CACHE_CHECK([whether -mavx2 is supported], pac_cv_found_avx,
211-
[PAC_C_CHECK_COMPILER_OPTION([-mavx2],pac_cv_found_avx=yes,pac_cv_found_avx=no)],
212-
pac_cv_found_avx=no,pac_cv_found_avx=yes)
213-
AC_CACHE_CHECK([whether -mavx512f is supported], pac_cv_found_avx512f,
214-
[PAC_C_CHECK_COMPILER_OPTION([-mavx512f],pac_cv_found_avx512f=yes,pac_cv_found_avx512f=no)],
215-
pac_cv_found_avx512f=no,pac_cv_found_avx512f=yes)
210+
AC_CACHE_CHECK([whether -mavx2 is supported], pac_cv_found_avx, [
211+
PAC_PUSH_FLAG([CFLAGS])
212+
PAC_APPEND_FLAG([-mavx2], [CFLAGS])
213+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <immintrin.h>]],[[
214+
const void *src;
215+
void *dest;
216+
__m256i ymm = _mm256_loadu_si256(src);
217+
_mm256_stream_si256(dest, ymm);
218+
]])],
219+
pac_cv_found_avx=yes,pac_cv_found_avx=no)
220+
PAC_POP_FLAG([CFLAGS])])
221+
AC_CACHE_CHECK([whether -mavx512f is supported], pac_cv_found_avx512f, [
222+
PAC_PUSH_FLAG([CFLAGS])
223+
PAC_APPEND_FLAG([-mavx512f], [CFLAGS])
224+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <immintrin.h>]],[[
225+
const void *src;
226+
void *dest;
227+
__m512i zmm = _mm512_loadu_si512(src);
228+
_mm512_stream_si512(dest, zmm);
229+
]])],
230+
pac_cv_found_avx512f=yes,pac_cv_found_avx512f=no)
231+
PAC_POP_FLAG([CFLAGS])])
216232

217233
AM_CONDITIONAL([MPL_BUILD_AVX], [test "x$pac_cv_found_avx" = "xyes"])
218234
if test "x$pac_cv_found_avx" = "xyes"; then

0 commit comments

Comments
 (0)