Check whether AVX-512 instructions can be compiled

- configure can test for AVX-512 intrinsics
parent 2fa023fa
......@@ -155,6 +155,7 @@ install_complex_generic_simple=yes
#want_avx=yes
#want_avx2=yes
#want_sse=yes
#want_avx512=yes
AC_LANG([C])
......@@ -277,7 +278,7 @@ fi
dnl check whether one can compile with avx - gcc intrinsics
dnl first pass: try with specified CFLAGS and CXXFLAGS
AC_MSG_CHECKING([whether we can compile AVX intrinsics in C])
AC_MSG_CHECKING([whether we can compile AVX gcc intrinsics in C])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <x86intrin.h>
int main(int argc, char **argv){
......@@ -292,7 +293,7 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
AC_MSG_RESULT([${can_compile_avx}])
#if test "${can_compile_avx}" = "yes" ; then
# AC_MSG_CHECKING([whether we can compile AVX intrinsics in C++])
# AC_MSG_CHECKING([whether we can compile AVX gcc intrinsics in C++])
# AC_LANG_PUSH([C++])
# AC_COMPILE_IFELSE([AC_LANG_SOURCE([
# #include <x86intrin.h>
......@@ -312,7 +313,7 @@ AC_MSG_RESULT([${can_compile_avx}])
# fi
#fi
AC_MSG_CHECKING([whether we can compile AVX2 intrinsics in C])
AC_MSG_CHECKING([whether we can compile AVX2 gcc intrinsics in C])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <x86intrin.h>
int main(int argc, char **argv){
......@@ -327,7 +328,7 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
)
AC_MSG_RESULT([${can_compile_avx2}])
#if test "${can_compile_avx2}" = "yes" ; then
# AC_MSG_CHECKING([whether we can compile AVX2 intrinsics in C++])
# AC_MSG_CHECKING([whether we can compile AVX2 gcc intrinsics in C++])
# AC_LANG_PUSH([C++])
# AC_COMPILE_IFELSE([AC_LANG_SOURCE([
# #include <x86intrin.h>
......@@ -348,6 +349,43 @@ AC_MSG_RESULT([${can_compile_avx2}])
# fi
#fi
AC_MSG_CHECKING([whether we can compile AVX512 gcc intrinsics in C])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <x86intrin.h>
int main(int argc, char **argv){
double* q;
__m512d q1 = _mm512_load_pd(q);
__m512d y1 = _mm512_fmadd_pd(q1, q1, q1);
return 0;
}
])],
[can_compile_avx512=yes],
[can_compile_avx512=no]
)
AC_MSG_RESULT([${can_compile_avx512}])
#if test "${can_compile_avx512}" = "yes" ; then
# AC_MSG_CHECKING([whether we can compile AVX512 gcc intrinsics in C++])
# AC_LANG_PUSH([C++])
# AC_COMPILE_IFELSE([AC_LANG_SOURCE([
# #include <x86intrin.h>
# int main(int argc, char **argv){
# double* q;
# __m512d q1 = _mm512_load_pd(q);
# __m512d y1 = _mm512_fmadd_pd(q1, q1, q1);
# return 0;
# }
# ])],
# [can_compile_avx512=yes],
# [can_compile_avx512=no]
# )
# AC_LANG_POP([C++])
# AC_MSG_RESULT([${can_compile_avx512}])
# if test "${can_compile_avx512}" = "no" ; then
# AC_MSG_WARN([Cannot compile C++ with AVX512!])
# fi
#fi
if test "${can_compile_avx}" = "yes" ; then
install_real_avx_block2=yes
install_real_avx_block4=yes
......@@ -380,6 +418,23 @@ else
install_complex_avx2_block2=no
fi
if test "${can_compile_avx512}" = "yes" ; then
install_real_avx512_block2=yes
install_real_avx512_block4=yes
install_real_avx512_block6=yes
install_complex_avx512_block1=yes
install_complex_avx512_block2=yes
else
install_real_avx512_block2=no
install_real_avx512_block4=no
install_real_avx512_block6=no
install_complex_avx512_block1=no
install_complex_avx512_block2=no
fi
AM_CONDITIONAL([HAVE_SSE_ASSEMBLY],[test x"$can_compile_sse_assembly" = x"yes"])
if test x"${can_compile_sse_assembly}" = x"yes" ; then
AC_DEFINE([HAVE_SSE_ASSEMBLY],[1],[assembly SSE is supported on this CPU])
......@@ -397,6 +452,10 @@ AM_CONDITIONAL([HAVE_AVX2],[test x"$can_compile_avx2" = x"yes"])
if test x"${can_compile_avx2}" = x"yes" ; then
AC_DEFINE([HAVE_AVX2],[1],[AVX2 is supported on this CPU])
fi
AM_CONDITIONAL([HAVE_AVX512],[test x"$can_compile_avx512" = x"yes"])
if test x"${can_compile_avx512}" = x"yes" ; then
AC_DEFINE([HAVE_AVX512],[1],[AVX512 is supported on this CPU])
fi
dnl set the AVX optimization flags if this option is specified
AC_MSG_CHECKING(whether AVX optimization flags should be set automatically)
......@@ -741,6 +800,16 @@ DEFINE_OPTION_SPECIFIC_REAL_KERNEL([real-avx2-block4-kernel]-only,[real-avx2-blo
dnl real-avx2-block6 kernel
DEFINE_OPTION_SPECIFIC_REAL_KERNEL([real-avx2-block6-kernel-only],[real-avx2-block6-kernel],[install_real_avx2_block6])
dnl real-avx512-block2 kernel
DEFINE_OPTION_SPECIFIC_REAL_KERNEL([real-avx512-block2-kernel-only],[real-avx512-block2-kernel],[install_real_avx512_block2])
dnl real-avx512-block4 kernel
DEFINE_OPTION_SPECIFIC_REAL_KERNEL([real-avx512-block4-kernel]-only,[real-avx512-block4-kernel],[install_real_avx512_block4])
dnl real-avx512-block6 kernel
DEFINE_OPTION_SPECIFIC_REAL_KERNEL([real-avx512-block6-kernel-only],[real-avx512-block6-kernel],[install_real_avx512_block6])
dnl complex kernels
dnl generic kernel
......@@ -776,6 +845,13 @@ DEFINE_OPTION_SPECIFIC_COMPLEX_KERNEL([complex-avx2-block1-kernel-only],[complex
dnl complex-avx2-block2 kernel
DEFINE_OPTION_SPECIFIC_COMPLEX_KERNEL([complex-avx2-block2-kernel-only],[complex-avx2-block2-kernel],[install_complex_avx2_block2])
dnl complex-avx512-block1 kernel
DEFINE_OPTION_SPECIFIC_COMPLEX_KERNEL([complex-avx512-block1-kernel-only],[complex-avx512-block1-kernel],[install_complex_avx512_block1])
dnl complex-avx512-block2 kernel
DEFINE_OPTION_SPECIFIC_COMPLEX_KERNEL([complex-avx512-block2-kernel-only],[complex-avx512-block2-kernel],[install_complex_avx512_block2])
dnl set the conditionals according to the previous tests
......@@ -1035,6 +1111,12 @@ if test "${can_compile_avx2}" = "no" ; then
AC_MSG_WARN([Could not compile AVX2 instructions])
# fi
fi
if test "${can_compile_avx512}" = "no" ; then
# if test x"${want_avx512}" = x"yes" ; then
AC_MSG_WARN([Could not compile AVX512 instructions])
# fi
fi
if test "${can_compile_sse}" = "no" ; then
AC_MSG_WARN([Could not compile SSE instructions])
......
......@@ -25,9 +25,17 @@ AC_DEFUN([DEFINE_OPTION_SPECIFIC_REAL_KERNEL],[
install_real_avx_block2=no
install_real_avx_block4=no
install_real_avx_block6=no
install_real_avx2_block2=no
install_real_avx2_block4=no
install_real_avx2_block6=no
install_real_avx512_block2=no
install_real_avx512_block4=no
install_real_avx512_block6=no
want_sse=no
want_avx=no
want_avx2=no
want_avx512=no
install_gpu=no
use_specific_real_kernel=yes
......@@ -42,6 +50,15 @@ AC_DEFUN([DEFINE_OPTION_SPECIFIC_REAL_KERNEL],[
AC_MSG_NOTICE([$1 set. Also avx_block2 is needed])
install_real_avx_block2=yes
fi
if test x"${install_real_avx2_block4}" = x"yes" ; then
AC_MSG_NOTICE([$1 set. Also avx2_block2 is needed])
install_real_avx2_block2=yes
fi
if test x"${install_real_avx512_block4}" = x"yes" ; then
AC_MSG_NOTICE([$1 set. Also avx512_block2 is needed])
install_real_avx512_block2=yes
fi
if test x"${install_real_sse_block6}" = x"yes" ; then
AC_MSG_NOTICE([$1 set. Also sse_block2 is needed])
AC_MSG_NOTICE([$1 set. Also sse_block4 is needed])
......@@ -54,6 +71,19 @@ AC_DEFUN([DEFINE_OPTION_SPECIFIC_REAL_KERNEL],[
install_real_avx_block4=yes
install_real_avx_block2=yes
fi
if test x"${install_real_avx2_block6}" = x"yes" ; then
AC_MSG_NOTICE([$1 set. Also avx2_block2 is needed])
AC_MSG_NOTICE([$1 set. Also avx2_block4 is needed])
install_real_avx2_block4=yes
install_real_avx2_block2=yes
fi
if test x"${install_real_avx512_block6}" = x"yes" ; then
AC_MSG_NOTICE([$1 set. Also avx512_block2 is needed])
AC_MSG_NOTICE([$1 set. Also avx512_block4 is needed])
install_real_avx512_block4=yes
install_real_avx512_block2=yes
fi
dnl in case of SSE or AVX make sure that we can compile the choosen kernel
if test x"${install_real_sse_assembly}" = x"yes" ; then
......@@ -118,6 +148,22 @@ AC_DEFUN([DEFINE_OPTION_SPECIFIC_REAL_KERNEL],[
fi
fi
if test x"${install_real_avx2_block2}" = x"yes" ; then
if test x"${can_compile_avx2}" = x"no" ; then
AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
else
want_avx2=yes
fi
fi
if test x"${install_real_avx512_block2}" = x"yes" ; then
if test x"${can_compile_avx512}" = x"no" ; then
AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
else
want_avx512=yes
fi
fi
if test x"${install_real_avx_block4}" = x"yes" ; then
if test x"${can_compile_avx}" = x"no" ; then
AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
......@@ -126,6 +172,22 @@ AC_DEFUN([DEFINE_OPTION_SPECIFIC_REAL_KERNEL],[
fi
fi
if test x"${install_real_avx2_block4}" = x"yes" ; then
if test x"${can_compile_avx2}" = x"no" ; then
AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
else
want_avx2=yes
fi
fi
if test x"${install_real_avx512_block4}" = x"yes" ; then
if test x"${can_compile_avx512}" = x"no" ; then
AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
else
want_avx512=yes
fi
fi
if test x"${install_real_avx_block6}" = x"yes" ; then
if test x"${can_compile_avx}" = x"no" ; then
AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
......@@ -134,6 +196,22 @@ AC_DEFUN([DEFINE_OPTION_SPECIFIC_REAL_KERNEL],[
fi
fi
if test x"${install_real_avx2_block6}" = x"yes" ; then
if test x"${can_compile_avx2}" = x"no" ; then
AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
else
want_avx2=yes
fi
fi
if test x"${install_real_avx512_block6}" = x"yes" ; then
if test x"${can_compile_avx512}" = x"no" ; then
AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
else
want_avx512=yes
fi
fi
AC_MSG_NOTICE([$1 will be the only compiled kernel for real case])
# if test x"${want_gpu}" = x"yes" ; then
# AC_MSG_WARN([At the moment this disables GPU support!])
......@@ -165,9 +243,15 @@ AC_DEFUN([DEFINE_OPTION_SPECIFIC_COMPLEX_KERNEL],[
install_complex_sse_block2=no
install_complex_avx_block1=no
install_complex_avx_block2=no
install_complex_avx2_block1=no
install_complex_avx2_block2=no
install_complex_avx512_block1=no
install_complex_avx512_block2=no
want_sse=no
want_avx=no
want_avx2=no
want_avx512=no
# install_gpu=no
use_specific_complex_kernel=yes
......@@ -180,6 +264,12 @@ AC_DEFUN([DEFINE_OPTION_SPECIFIC_COMPLEX_KERNEL],[
if test x"${install_complex_avx_block2}" = x"yes" ; then
install_complex_avx_block1=yes
fi
if test x"${install_complex_avx2_block2}" = x"yes" ; then
install_complex_avx2_block1=yes
fi
if test x"${install_complex_avx512_block2}" = x"yes" ; then
install_complex_avx512_block1=yes
fi
dnl in case of SSE or AVX make sure that we can compile the choosen kernel
if test x"${install_complex_sse_assembly}" = x"yes" ; then
......@@ -212,6 +302,20 @@ AC_DEFUN([DEFINE_OPTION_SPECIFIC_COMPLEX_KERNEL],[
want_avx=yes
fi
fi
if test x"${install_complex_avx2_block1}" = x"yes" ; then
if test x"${can_compile_avx2}" = x"no" ; then
AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
else
want_avx2=yes
fi
fi
if test x"${install_complex_avx512_block1}" = x"yes" ; then
if test x"${can_compile_avx512}" = x"no" ; then
AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
else
want_avx512=yes
fi
fi
if test x"${install_complex_avx_block2}" = x"yes" ; then
if test x"${can_compile_avx}" = x"no" ; then
......@@ -221,6 +325,22 @@ AC_DEFUN([DEFINE_OPTION_SPECIFIC_COMPLEX_KERNEL],[
fi
fi
if test x"${install_complex_avx2_block2}" = x"yes" ; then
if test x"${can_compile_avx2}" = x"no" ; then
AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
else
want_avx2=yes
fi
fi
if test x"${install_complex_avx512_block2}" = x"yes" ; then
if test x"${can_compile_avx512}" = x"no" ; then
AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
else
want_avx512=yes
fi
fi
AC_MSG_NOTICE([$1 will be the only compiled kernel for complex case])
if test x"${want_gpu}" = x"yes" ; then
AC_MSG_WARN([At the moment this disables GPU support!])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment