Checking for AVX512BW and AVX512DQ separately will allow the compiler to
generate some AVX512 code where it is supported. For example, in GCC 4.9
where there is just support for AVX512F, this patch will allow the
AVX512 DPIF to be built.

This partial support change will be effective when the -mavx512vpopcntdq
check is removed from OVS_CHECK_AVX512. That is done in a later patch.

Signed-off-by: Cian Ferriter <cian.ferri...@intel.com>
---
 acinclude.m4                      | 15 +++++++++++++++
 configure.ac                      |  1 +
 lib/automake.mk                   | 12 ++++++++----
 lib/dpif-netdev-lookup.c          |  3 ++-
 lib/dpif-netdev-private-extract.c |  3 ++-
 lib/dpif-netdev-private-extract.h |  6 ++++--
 6 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index 0c360fd1e..932ff4693 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -85,6 +85,21 @@ AC_DEFUN([OVS_CHECK_AVX512], [
   fi
 ])
 
+dnl OVS_CHECK_AVX512BW_DQ
+dnl
+dnl Checks if compiler and binutils supports AVX512BW and AVX512DQ
+dnl instructions.
+AC_DEFUN([OVS_CHECK_AVX512BW_DQ], [
+  OVS_CHECK_CC_OPTION(
+    [-mavx512bw -mavx512dq], [ovs_have_cc_mavx512bw_dq=yes],
+    [ovs_have_cc_mavx512bw_dq=no])
+  AM_CONDITIONAL([HAVE_AVX512BW_DQ], [test $ovs_have_cc_mavx512bw_dq = yes])
+  if test "$ovs_have_cc_mavx512bw_dq" = yes; then
+    AC_DEFINE([HAVE_AVX512BW_DQ], [1],
+              [Define to 1 if compiler supports AVX512.])
+  fi
+])
+
 dnl OVS_ENABLE_WERROR
 AC_DEFUN([OVS_ENABLE_WERROR],
   [AC_ARG_ENABLE(
diff --git a/configure.ac b/configure.ac
index 298ea85ab..f849837e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -187,6 +187,7 @@ OVS_CHECK_DPCLS_AUTOVALIDATOR
 OVS_CHECK_DPIF_AVX512_DEFAULT
 OVS_CHECK_MFEX_AUTOVALIDATOR
 OVS_CHECK_AVX512
+OVS_CHECK_AVX512BW_DQ
 
 AC_ARG_VAR(KARCH, [Kernel Architecture String])
 AC_SUBST(KARCH)
diff --git a/lib/automake.mk b/lib/automake.mk
index a23cdc4ad..43f9df985 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -31,8 +31,6 @@ lib_LTLIBRARIES += lib/libopenvswitchavx512.la
 lib_libopenvswitch_la_LIBADD += lib/libopenvswitchavx512.la
 lib_libopenvswitchavx512_la_CFLAGS = \
        -mavx512f \
-       -mavx512bw \
-       -mavx512dq \
        -mbmi \
        -mbmi2 \
        -fPIC \
@@ -40,9 +38,15 @@ lib_libopenvswitchavx512_la_CFLAGS = \
 lib_libopenvswitchavx512_la_SOURCES = \
        lib/cpu.c \
        lib/cpu.h \
-       lib/dpif-netdev-lookup-avx512-gather.c \
-       lib/dpif-netdev-extract-avx512.c \
        lib/dpif-netdev-avx512.c
+if HAVE_AVX512BW_DQ
+lib_libopenvswitchavx512_la_CFLAGS += \
+       -mavx512bw \
+       -mavx512dq
+lib_libopenvswitchavx512_la_SOURCES += \
+       lib/dpif-netdev-extract-avx512.c \
+       lib/dpif-netdev-lookup-avx512-gather.c
+endif
 lib_libopenvswitchavx512_la_LDFLAGS = \
        -static
 endif
diff --git a/lib/dpif-netdev-lookup.c b/lib/dpif-netdev-lookup.c
index bd0a99abe..35d0bafb4 100644
--- a/lib/dpif-netdev-lookup.c
+++ b/lib/dpif-netdev-lookup.c
@@ -43,7 +43,8 @@ static struct dpcls_subtable_lookup_info_t subtable_lookups[] 
= {
       .probe = dpcls_subtable_generic_probe,
       .name = "generic", },
 
-#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__)
+#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW_DQ \
+     && __SSE4_2__)
     /* Only available on x86_64 bit builds with SSE 4.2 used for OVS core. */
     { .prio = 0,
       .probe = dpcls_subtable_avx512_gather_probe,
diff --git a/lib/dpif-netdev-private-extract.c 
b/lib/dpif-netdev-private-extract.c
index a29bdcfa7..fee779317 100644
--- a/lib/dpif-netdev-private-extract.c
+++ b/lib/dpif-netdev-private-extract.c
@@ -54,7 +54,8 @@ static struct dpif_miniflow_extract_impl mfex_impls[] = {
         .name = "study", },
 
 /* Compile in implementations only if the compiler ISA checks pass. */
-#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__)
+#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW_DQ \
+     && __SSE4_2__)
     [MFEX_IMPL_VMBI_IPv4_UDP] = {
         .probe = mfex_avx512_vbmi_probe,
         .extract_func = mfex_avx512_vbmi_ip_udp,
diff --git a/lib/dpif-netdev-private-extract.h 
b/lib/dpif-netdev-private-extract.h
index f9a757ba4..0b6c62cde 100644
--- a/lib/dpif-netdev-private-extract.h
+++ b/lib/dpif-netdev-private-extract.h
@@ -81,7 +81,8 @@ enum dpif_miniflow_extract_impl_idx {
     MFEX_IMPL_AUTOVALIDATOR,
     MFEX_IMPL_SCALAR,
     MFEX_IMPL_STUDY,
-#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__)
+#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW_DQ \
+     && __SSE4_2__)
     MFEX_IMPL_VMBI_IPv4_UDP,
     MFEX_IMPL_IPv4_UDP,
     MFEX_IMPL_VMBI_IPv4_TCP,
@@ -99,7 +100,8 @@ extern struct ovs_mutex dp_netdev_mutex;
 /* Define a index which points to the first traffic optimized MFEX
  * option from the enum list else holds max value.
  */
-#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__)
+#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW_DQ \
+     && __SSE4_2__)
 
 #define MFEX_IMPL_START_IDX MFEX_IMPL_VMBI_IPv4_UDP
 #else
-- 
2.25.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to