summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorCian Ferriter <cian.ferriter@intel.com>2022-08-11 10:36:38 +0000
committerIan Stokes <ian.stokes@intel.com>2022-08-12 09:52:20 +0100
commitac1332216eb3a1857b942457e1b44a22512b092d (patch)
tree5e98605fdc92d139bf0c406127cde10259d1d4cb /m4
parent39364e11dd2cf722a037de25705b352272173f21 (diff)
downloadopenvswitch-ac1332216eb3a1857b942457e1b44a22512b092d.tar.gz
acinclude: Improve vpopcntdq build check.
Support for vpopcntdq instruction generation by the compiler was already checked in the OVS_CHECK_AVX512 AC function by checking if the compiler accepted the -mavx512vpopcntdq option. However, there can be situations where the compiler supports vpopcntdq generation but the assembler doesn't support the instruction. The below OVS_CHECK_AVX512VPOPCNTDQ AC function will check for both compiler and assembler support for the vpopcntdq instruction. Fixes: cb1c64007734 ("acinclude: Add seperate checks for AVX512 ISA.") Reported-by: Ian Stokes <ian.stokes@intel.com> Signed-off-by: Cian Ferriter <cian.ferriter@intel.com> Acked-by: Sunil Pai G <sunil.pai.g@intel.com> Signed-off-by: Ian Stokes <ian.stokes@intel.com>
Diffstat (limited to 'm4')
-rw-r--r--m4/openvswitch.m429
1 files changed, 29 insertions, 0 deletions
diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index 6eef1fb35..b5be5842e 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -450,6 +450,35 @@ AC_DEFUN([OVS_CHECK_GCC_AVX512VL], [
AM_CONDITIONAL([HAVE_GCC_AVX512VL_GOOD],
[test "$ovs_cv_gcc_avx512vl_good" = yes])])
+dnl Checks whether the build system implements the vpopcntdq instruction. The
+dnl compiler and assembler each separately need to support vpopcntdq. In order
+dnl to test the assembler with the below code snippet, set the optimization
+dnl level of the function to "O0" so it won't be optimized away by the
+dnl compiler.
+AC_DEFUN([OVS_CHECK_AVX512VPOPCNTDQ], [
+ AC_MSG_CHECKING([whether compiler correctly emits AVX512-VPOPCNTDQ])
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([#include <immintrin.h>
+ void
+ __attribute__((__target__("avx512vpopcntdq")))
+ __attribute__((optimize("O0")))
+ check_vpopcntdq(void)
+ {
+ __m512i v_test;
+ v_test = _mm512_popcnt_epi64(v_test);
+ }],[])],
+ [AC_MSG_RESULT([yes])
+ ovs_cv_avx512vpopcntdq_good=yes],
+ [AC_MSG_RESULT([no])
+ ovs_cv_avx512vpopcntdq_good=no])
+ if test "$ovs_cv_avx512vpopcntdq_good" = yes; then
+ AC_DEFINE([HAVE_AVX512VPOPCNTDQ], [1],
+ [Define to 1 if the build system implements the vpopcntdq
+ instruction.])
+ fi
+ AM_CONDITIONAL([HAVE_AVX512VPOPCNTDQ],
+ [test "$ovs_cv_avx512vpopcntdq_good" = yes])])
+
dnl Checks for binutils/assembler known issue with AVX512.
dnl Due to backports, we probe assembling a reproducer instead of checking
dnl binutils version string. More details, including ASM dumps and debug here: