[ovs-dev] [PATCH v1] configure: Allow opt-in to CPU ISA opts at compile time

Kumar Amber kumar.amber at intel.com
Fri Sep 3 13:53: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.

If an 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,
the DPIF AVX512, MFEX AVX512 ISA optimized implementation 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: Kumar Amber <kumar.amber at intel.com>
Signed-off-by: Harry van Haaren <harry.van.haaren at intel.com>
Co-authored-by: Harry van Haaren <harry.van.haaren at intel.com>
---
 Documentation/topics/dpdk/bridge.rst |  9 +++++++++
 NEWS                                 |  2 ++
 acinclude.m4                         | 17 +++++++++++++++++
 configure.ac                         |  1 +
 lib/dpif-netdev-lookup.c             |  8 +++++++-
 lib/dpif-netdev-private-dpif.c       |  2 +-
 lib/dpif-netdev-private-extract.c    |  2 ++
 7 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/Documentation/topics/dpdk/bridge.rst b/Documentation/topics/dpdk/bridge.rst
index f645b9ade..8568ec365 100644
--- a/Documentation/topics/dpdk/bridge.rst
+++ b/Documentation/topics/dpdk/bridge.rst
@@ -436,3 +436,12 @@ the following test-case in tests/system-dpdk.at ::
 
     make check-dpdk TESTSUITEFLAGS='-k MFEX'
     OVS-DPDK - MFEX Autovalidator Fuzzy
+
+Enabling all AVX512 options
+---------------------------
+
+A user can enable all the three DPIF, Miniflow Extract and DPLCS optimized
+AVX512 options at build time, if the CPU supports the required AVX512 ISA
+by using the following command ::
+
+    ./configure --enable-cpu-isa
diff --git a/NEWS b/NEWS
index 1f2adf718..8d700595b 100644
--- a/NEWS
+++ b/NEWS
@@ -68,6 +68,8 @@ v2.16.0 - 16 Aug 2021
      * Add new 'pmd-rxq-isolate' option that can be set to 'false' in order
        that pmd cores which are pinned with rxqs using 'pmd-rxq-affinity'
        are available for assigning other non-pinned rxqs.
+     * Add command and documentation to enable all AVX512 optimized options
+       by default at build time.
    - ovs-ctl:
      * New option '--no-record-hostname' to disable hostname configuration
        in ovsdb on startup.
diff --git a/acinclude.m4 b/acinclude.m4
index dba365ea1..75098f980 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -33,6 +33,23 @@ AC_DEFUN([OVS_CHECK_MFEX_AUTOVALIDATOR], [
   fi
 ])
 
+dnl Set OVS DPCLS DPIF and MFEX to AVX512 opt at compile time?
+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
+    AC_DEFINE([CPU_ISA_OPT_IN], [1],
+              [DPIF AVX512, DPCLS AVX512, MFEX AVX512 is a
+               default implementation.])
+    AC_MSG_RESULT([yes])
+  fi
+])
+
 dnl Set OVS DPCLS Autovalidator as default subtable search at compile time?
 dnl This enables automatically running all unit tests with all DPCLS
 dnl implementations.
diff --git a/configure.ac b/configure.ac
index eaa9bf7ee..47e64a98c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -182,6 +182,7 @@ OVS_CONDITIONAL_CC_OPTION([-Wno-unused-parameter], [HAVE_WNO_UNUSED_PARAMETER])
 OVS_ENABLE_WERROR
 OVS_ENABLE_SPARSE
 OVS_CTAGS_IDENTIFIERS
+OVS_CHECK_CPU_ISA_OPT_IN
 OVS_CHECK_DPCLS_AUTOVALIDATOR
 OVS_CHECK_DPIF_AVX512_DEFAULT
 OVS_CHECK_MFEX_AUTOVALIDATOR
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
diff --git a/lib/dpif-netdev-private-dpif.c b/lib/dpif-netdev-private-dpif.c
index 84d4ec156..22761c10e 100644
--- a/lib/dpif-netdev-private-dpif.c
+++ b/lib/dpif-netdev-private-dpif.c
@@ -60,7 +60,7 @@ dp_netdev_impl_get_default(void)
 
 /* Configure-time overriding to run test suite on all implementations. */
 #if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__)
-#ifdef DPIF_AVX512_DEFAULT
+#if defined(DPIF_AVX512_DEFAULT) || defined(CPU_ISA_OPT_IN)
         dp_netdev_input_func_probe probe;
 
         /* Check if the compiled default is compatible. */
diff --git a/lib/dpif-netdev-private-extract.c b/lib/dpif-netdev-private-extract.c
index 7a06dbf6f..482aa1f37 100644
--- a/lib/dpif-netdev-private-extract.c
+++ b/lib/dpif-netdev-private-extract.c
@@ -105,6 +105,8 @@ dpif_miniflow_extract_init(void)
     atomic_uintptr_t *mfex_func = (void *)&default_mfex_func;
 #ifdef MFEX_AUTOVALIDATOR_DEFAULT
     int mfex_idx = MFEX_IMPL_AUTOVALIDATOR;
+#elif CPU_ISA_OPT_IN
+    int mfex_idx = MFEX_IMPL_STUDY;
 #else
     int mfex_idx = MFEX_IMPL_SCALAR;
 #endif
-- 
2.25.1



More information about the dev mailing list