2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 01:51:26 +00:00

odp-execute: Add ISA implementation of actions.

This commit adds the AVX512 implementation of the action functionality.

Usage:
  $ ovs-appctl odp-execute/action-impl-set avx512

Signed-off-by: Emma Finn <emma.finn@intel.com>
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Co-authored-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
This commit is contained in:
Emma Finn 2022-07-15 10:16:19 +00:00 committed by Ian Stokes
parent b52e0b396e
commit 529af67146
9 changed files with 99 additions and 8 deletions

View File

@ -321,3 +321,33 @@ following command::
``scalar`` can be selected on core ``3`` by the following command::
$ ovs-appctl dpif-netdev/miniflow-parser-set -pmd 3 scalar
Actions Implementations (Experimental)
--------------------------------------
Actions describe what processing or modification should be performed on a
packet when it matches a given flow. Similar to the datapath interface,
DPCLS and MFEX (see above), the implementation of these actions can be
accelerated using SIMD instructions, resulting in improved performance.
OVS provides multiple implementations of the actions, however some
implementations requiring a CPU capable of executing the required SIMD
instructions.
Available implementations can be listed with the following command::
$ ovs-appctl odp-execute/action-impl-show
Available Actions implementations:
scalar (available: Yes, active: Yes)
autovalidator (available: Yes, active: No)
avx512 (available: Yes, active: No)
By default, ``scalar`` is used. Implementations can be selected by
name::
$ ovs-appctl odp-execute/action-impl-set avx512
Action implementation set to avx512.
$ ovs-appctl odp-execute/action-impl-set scalar
Action implementation set to scalar.

View File

@ -361,12 +361,12 @@ testsuite.
Userspace datapath: Testing and Validation of CPU-specific Optimizations
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
As multiple versions of the datapath classifier and packet parsing functions
can co-exist, each with different CPU ISA optimizations, it is important to
validate that they all give the exact same results. To easily test all the
implementations, an ``autovalidator`` implementation of them exists. This
implementation runs all other available implementations, and verifies that the
results are identical.
As multiple versions of the datapath classifier, packet parsing functions and
actions can co-exist, each with different CPU ISA optimizations, it is
important to validate that they all give the exact same results. To easily
test all the implementations, an ``autovalidator`` implementation of them
exists. This implementation runs all other available implementations, and
verifies that the results are identical.
Running the OVS unit tests with the autovalidator enabled ensures all
implementations provide the same results. Note that the performance of the
@ -382,18 +382,26 @@ To set the autovalidator for the packet parser, use this command::
$ ovs-appctl dpif-netdev/miniflow-parser-set autovalidator
To set the autovalidator for actions, use this command::
$ ovs-appctl odp-execute/action-impl-set autovalidator
To run the OVS unit test suite with the autovalidator as the default
implementation, it is required to recompile OVS. During the recompilation,
the default priority of the `autovalidator` implementation is set to the
maximum priority, ensuring every test will be run with every implementation::
maximum priority, ensuring every test will be run with every implementation.
Priority is only related to mfex autovalidator and not the actions
autovalidator.::
$ ./configure --enable-autovalidator --enable-mfex-default-autovalidator
$ ./configure --enable-autovalidator --enable-mfex-default-autovalidator \
--enable-actions-default-autovalidator
The following line should be seen in the configuration log when the above
options are used::
checking whether DPCLS Autovalidator is default implementation... yes
checking whether MFEX Autovalidator is default implementation... yes
checking whether actions Autovalidator is default implementation... yes
Compile OVS in debug mode to have `ovs_assert` statements error out if
there is a mis-match in the datapath classifier lookup or packet parser

1
NEWS
View File

@ -61,6 +61,7 @@ Post-v2.17.0
implementations available at run time.
* Add build time configure command to enable auto-validator as default
actions implementation at build time.
* Add AVX512 implementation of actions.
- Linux datapath:
* Add offloading meter tc police.
* Add support for offloading the check_pkt_len action.

View File

@ -96,6 +96,7 @@ dnl
dnl Checks if compiler and binutils supports various AVX512 ISA.
AC_DEFUN([OVS_CHECK_AVX512], [
OVS_CHECK_BINUTILS_AVX512
OVS_CHECK_GCC_AVX512VL
OVS_CONDITIONAL_CC_OPTION_DEFINE([-mavx512f], [HAVE_AVX512F])
OVS_CONDITIONAL_CC_OPTION_DEFINE([-mavx512bw], [HAVE_AVX512BW])
OVS_CONDITIONAL_CC_OPTION_DEFINE([-mavx512vl], [HAVE_AVX512VL])

View File

@ -53,6 +53,7 @@ X86_ISA(X86_EXT_FEATURES_LEAF, EBX, 16, OVS_CPU_ISA_X86_AVX512F)
X86_ISA(X86_EXT_FEATURES_LEAF, EBX, 30, OVS_CPU_ISA_X86_AVX512BW)
X86_ISA(X86_EXT_FEATURES_LEAF, ECX, 1, OVS_CPU_ISA_X86_AVX512VBMI)
X86_ISA(X86_EXT_FEATURES_LEAF, ECX, 14, OVS_CPU_ISA_X86_VPOPCNTDQ)
X86_ISA(X86_EXT_FEATURES_LEAF, EBX, 31, OVS_CPU_ISA_X86_AVX512VL)
#endif
bool

View File

@ -25,6 +25,7 @@ enum ovs_cpu_isa {
OVS_CPU_ISA_X86_AVX512F,
OVS_CPU_ISA_X86_AVX512BW,
OVS_CPU_ISA_X86_AVX512VBMI,
OVS_CPU_ISA_X86_AVX512VL,
OVS_CPU_ISA_X86_VPOPCNTDQ,
OVS_CPU_ISA_X86_LAST = OVS_CPU_ISA_X86_VPOPCNTDQ,
};

View File

@ -41,6 +41,14 @@ static struct odp_execute_action_impl action_impls[] = {
.name = "scalar",
.init_func = odp_action_scalar_init,
},
#if ACTION_IMPL_AVX512_CHECK
[ACTION_IMPL_AVX512] = {
.available = false,
.name = "avx512",
.init_func = NULL,
},
#endif
};
static void

View File

@ -22,6 +22,14 @@
#include "odp-netlink.h"
#include "ovs-atomic.h"
/* Combine all required ISA and Linker checks into a single #define
* for readability and simplicity where the checks are needed. Note
* that it is always #defined, so code must use the #if preprocesor
* directive (not #ifdef). */
#define ACTION_IMPL_AVX512_CHECK (__x86_64__ && HAVE_AVX512F \
&& HAVE_LD_AVX512_GOOD && __SSE4_2__ && HAVE_AVX512BW && HAVE_AVX512VL \
&& HAVE_GCC_AVX512VL_GOOD)
/* Forward declaration for typedef. */
struct odp_execute_action_impl;
@ -56,6 +64,10 @@ enum odp_execute_action_impl_idx {
* Do not change the autovalidator position in this list without updating
* the define below. */
#if ACTION_IMPL_AVX512_CHECK
ACTION_IMPL_AVX512,
#endif
ACTION_IMPL_MAX,
};

View File

@ -421,6 +421,35 @@ AC_DEFUN([OVS_CHECK_SPHINX],
AC_ARG_VAR([SPHINXBUILD])
AM_CONDITIONAL([HAVE_SPHINX], [test "$SPHINXBUILD" != none])])
dnl Checks for compiler correctly emitting AVX512-VL vpermd instruction.
dnl GCC5 says it exports AVX512-VL, but it doesn't implement "vpermd" instruction
dnl resulting in compilation failures. To workaround this "reported vs actual"
dnl mismatch, we compile a small snippet, and conditionally enable AVX512-VL.
AC_DEFUN([OVS_CHECK_GCC_AVX512VL], [
AC_MSG_CHECKING([whether compiler correctly emits AVX512-VL])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([#include <immintrin.h>
static void __attribute__((__target__("avx512vl")))
check_permutexvar(void)
{
__m256i v_swap32a = _mm256_setr_epi32(0x0, 0x4, 0xF,
0xF, 0xF, 0xF,
0xF, 0xF);
v_swap32a = _mm256_permutexvar_epi32(v_swap32a,
v_swap32a);
}],[])],
[AC_MSG_RESULT([yes])
ovs_cv_gcc_avx512vl_good=yes],
[AC_MSG_RESULT([no])
ovs_cv_gcc_avx512vl_good=no])
if test "$ovs_cv_gcc_avx512vl_good" = yes; then
AC_DEFINE([HAVE_GCC_AVX512VL_GOOD], [1],
[Define to 1 if gcc implements the vpermd instruction.])
fi
AM_CONDITIONAL([HAVE_GCC_AVX512VL_GOOD],
[test "$ovs_cv_gcc_avx512vl_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: