[ovs-dev] [PATCH] configure/dpcls: allow opt-in to CPU ISA opts at compile time

Harry van Haaren harry.van.haaren at intel.com
Thu Mar 18 14:01:16 UTC 2021


This commit allows "opt-in" to CPU ISA optimized implementations of
OVS SW datapath components at compile time. This can be useful in some
deployments where the CPU ISA optimized implementation is to be chosen
by default.

Note that only the default priority order of valid subtable
implementations is being modified. If a subtable implementation is
not available due to ISA not being available, it will not be selected.

With --enable-cpu-isa on an AVX512 capable CPU, the dpcls_avx512_gather
ISA optimized implementation of DPCLS is automatically enabled.

The default is off, so unless ./configure --enable-cpu-isa is passed,
the behaviour of the default OVS compile is not changed.

Signed-off-by: Harry van Haaren <harry.van.haaren at intel.com>
---
 acinclude.m4             | 14 ++++++++++++++
 configure.ac             |  1 +
 lib/dpif-netdev-lookup.c |  8 +++++++-
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/acinclude.m4 b/acinclude.m4
index 15a54d636..c8ab8cb89 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -30,6 +30,20 @@ AC_DEFUN([OVS_CHECK_DPCLS_AUTOVALIDATOR], [
   fi
 ])
 
+
+AC_DEFUN([OVS_CHECK_CPU_ISA_OPT_IN], [
+  AC_ARG_ENABLE([cpu-isa],
+                [AC_HELP_STRING([--enable-cpu-isa], [Enable CPU ISA default enable.])],
+                [isa=yes],[isa=no])
+  AC_MSG_CHECKING([whether CPU ISA should be enabled by default])
+  if test "$isa" != yes; then
+    AC_MSG_RESULT([no])
+  else
+    OVS_CFLAGS="$OVS_CFLAGS -DCPU_ISA_OPT_IN"
+    AC_MSG_RESULT([yes])
+  fi
+])
+
 dnl OVS_ENABLE_WERROR
 AC_DEFUN([OVS_ENABLE_WERROR],
   [AC_ARG_ENABLE(
diff --git a/configure.ac b/configure.ac
index c077034d4..eb472a6b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -184,6 +184,7 @@ OVS_CHECK_CC_OPTION([-mavx512f], [CFLAGS="$CFLAGS -DHAVE_AVX512F"])
 OVS_ENABLE_WERROR
 OVS_ENABLE_SPARSE
 OVS_CTAGS_IDENTIFIERS
+OVS_CHECK_CPU_ISA_OPT_IN
 OVS_CHECK_DPCLS_AUTOVALIDATOR
 OVS_CHECK_BINUTILS_AVX512
 
diff --git a/lib/dpif-netdev-lookup.c b/lib/dpif-netdev-lookup.c
index bd0a99abe..0989c6a5f 100644
--- a/lib/dpif-netdev-lookup.c
+++ b/lib/dpif-netdev-lookup.c
@@ -45,7 +45,13 @@ static struct dpcls_subtable_lookup_info_t subtable_lookups[] = {
 
 #if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__)
     /* Only available on x86_64 bit builds with SSE 4.2 used for OVS core. */
-    { .prio = 0,
+    {
+#ifdef CPU_ISA_OPT_IN
+      /* Allow Autovalidator to override, but higher than default scalar. */
+      .prio = 100,
+#else
+      .prio = 0,
+#endif
       .probe = dpcls_subtable_avx512_gather_probe,
       .name = "avx512_gather", },
 #else
-- 
2.25.1



More information about the dev mailing list