From patchwork Wed Jan 5 16:53:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Finn, Emma" X-Patchwork-Id: 1575770 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=lC4yRHDB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JTbDm4bCrz9sXM for ; Thu, 6 Jan 2022 03:54:32 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 024214295F; Wed, 5 Jan 2022 16:54:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uTX21RqqFFiw; Wed, 5 Jan 2022 16:54:28 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 0575442925; Wed, 5 Jan 2022 16:54:23 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BC84EC002F; Wed, 5 Jan 2022 16:54:22 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 18DE3C002F for ; Wed, 5 Jan 2022 16:54:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 48A4982D57 for ; Wed, 5 Jan 2022 16:54:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=intel.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dz4HzwKRhyXm for ; Wed, 5 Jan 2022 16:54:12 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by smtp1.osuosl.org (Postfix) with ESMTPS id B0BC982F03 for ; Wed, 5 Jan 2022 16:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641401652; x=1672937652; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4xUM0sRPELjLtpb4HnsacMymnBlRn51Cra8AH/6FJcg=; b=lC4yRHDBJcwyDua65cPV0G8IbezuSAjDg1+lfsh23RRSNIBxAWvoY3Lr WghB/5DUqhLSrjgJFHBjSWamrjtvsjkDKioUSo3qjEIBd81iLlnfXBo3+ ZH4v2uXydmVtmLRUv+69ruCtitJ1lXOXIVjkQHG9Ur3rAEcj0aEYp3C2D BgmsNHXfv8QjgiO7jfjZVLtS6zIdqAtdyh56WcnIcCfyrEBHuAugOuA6h 5HKnTwMBTcJM+EBBNmFBoCxfDfDgLc+mXrNsDyo+jKf8QIR5hhCPlDAdC X+wwIqIK5fH9iraUy8gQC7VoY1e32Vo06Frf/Lg1oR8Mu0OyQWB6Jp8Gs w==; X-IronPort-AV: E=McAfee;i="6200,9189,10217"; a="242688540" X-IronPort-AV: E=Sophos;i="5.88,264,1635231600"; d="scan'208";a="242688540" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2022 08:54:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,264,1635231600"; d="scan'208";a="611525886" Received: from silpixa00400899.ir.intel.com ([10.243.23.110]) by FMSMGA003.fm.intel.com with ESMTP; 05 Jan 2022 08:54:11 -0800 From: Emma Finn To: dev@openvswitch.org, harry.van.haaren@intel.com, kumar.amber@intel.com Date: Wed, 5 Jan 2022 16:53:47 +0000 Message-Id: <20220105165349.3447695-8-emma.finn@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220105165349.3447695-1-emma.finn@intel.com> References: <20211203153301.37692-1-emma.finn@intel.com> <20220105165349.3447695-1-emma.finn@intel.com> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH v4 7/9] odp-execute: Add ISA implementation of actions. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" This commit adds the AVX512 implementation of the action functionality. Usage: $ ovs-appctl dpif-netdev/action-impl-set avx512 Signed-off-by: Emma Finn Acked-by: Harry van Haaren --- Documentation/topics/dpdk/bridge.rst | 25 ++++++++++ Documentation/topics/testing.rst | 20 +++++--- NEWS | 1 + lib/automake.mk | 4 +- lib/cpu.c | 1 + lib/cpu.h | 1 + lib/odp-execute-avx512.c | 69 ++++++++++++++++++++++++++++ lib/odp-execute-private.c | 9 ++++ lib/odp-execute-private.h | 9 ++++ 9 files changed, 131 insertions(+), 8 deletions(-) create mode 100644 lib/odp-execute-avx512.c diff --git a/Documentation/topics/dpdk/bridge.rst b/Documentation/topics/dpdk/bridge.rst index b79d9871b..8bc85cd0a 100644 --- a/Documentation/topics/dpdk/bridge.rst +++ b/Documentation/topics/dpdk/bridge.rst @@ -297,3 +297,28 @@ following command:: ``scalar`` can be selected on core ``3`` by the following command:: $ ovs-appctl dpif-netdev/miniflow-parser-set -pmd 3 scalar + +Actions Performance +------------------- + +Actions are used in OpenFlow flows to describe what to do when the flow +matches a packet. Just like with the datapath interface, SIMD instructions +can be applied to the action implementation to improve performance. + +OVS provides multiple implementations of the actions. +Available implementations can be listed with the following command:: + + $ ovs-appctl dpif-netdev/action-impl-get + Available Actions implementations: + scalar (available: True, active: True) + autovalidator (available: True, active: False) + avx512 (available: True, active: False) + +By default, ``scalar`` is used. Implementations can be selected by +name:: + + $ ovs-appctl dpif-netdev/action-impl-set avx512 + action implementation set to avx512. + + $ ovs-appctl dpif-netdev/action-impl-set scalar + action implementation set to scalar. diff --git a/Documentation/topics/testing.rst b/Documentation/topics/testing.rst index c15d5b38f..10d0ecc48 100644 --- a/Documentation/topics/testing.rst +++ b/Documentation/topics/testing.rst @@ -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,24 @@ 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 dpif-netdev/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:: - $ ./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 diff --git a/NEWS b/NEWS index 2e7dc1acb..f13722ab7 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,7 @@ Post-v2.16.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. - Python: * For SSL support, the use of the pyOpenSSL library has been replaced with the native 'ssl' module. diff --git a/lib/automake.mk b/lib/automake.mk index 1bc855a6b..e332c3327 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -32,6 +32,7 @@ lib_libopenvswitch_la_LIBADD += lib/libopenvswitchavx512.la lib_libopenvswitchavx512_la_CFLAGS = \ -mavx512f \ -mavx512bw \ + -mavx512vl \ -mavx512dq \ -mbmi \ -mbmi2 \ @@ -42,7 +43,8 @@ lib_libopenvswitchavx512_la_SOURCES = \ lib/cpu.h \ lib/dpif-netdev-lookup-avx512-gather.c \ lib/dpif-netdev-extract-avx512.c \ - lib/dpif-netdev-avx512.c + lib/dpif-netdev-avx512.c \ + lib/odp-execute-avx512.c lib_libopenvswitchavx512_la_LDFLAGS = \ -static endif diff --git a/lib/cpu.c b/lib/cpu.c index 2df003c51..0292f715e 100644 --- a/lib/cpu.c +++ b/lib/cpu.c @@ -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 diff --git a/lib/cpu.h b/lib/cpu.h index 92897bb71..3215229bc 100644 --- a/lib/cpu.h +++ b/lib/cpu.h @@ -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, }; diff --git a/lib/odp-execute-avx512.c b/lib/odp-execute-avx512.c new file mode 100644 index 000000000..aa71faa1c --- /dev/null +++ b/lib/odp-execute-avx512.c @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021 Intel. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "cpu.h" +#include "odp-execute-private.h" +#include "odp-netlink.h" +#include "dp-packet.h" +#include "openvswitch/vlog.h" + +#include "immintrin.h" + + +/* Probe functions to check ISA requirements. */ +static int32_t +avx512_isa_probe(uint32_t needs_vbmi) +{ + static enum ovs_cpu_isa isa_required[] = { + OVS_CPU_ISA_X86_AVX512F, + OVS_CPU_ISA_X86_AVX512BW, + OVS_CPU_ISA_X86_BMI2, + OVS_CPU_ISA_X86_AVX512VL + }; + + int32_t ret = 0; + for (uint32_t i = 0; i < ARRAY_SIZE(isa_required); i++) { + if (!cpu_has_isa(isa_required[i])) { + ret = -ENOTSUP; + } + } + + if (needs_vbmi) { + if (!cpu_has_isa(OVS_CPU_ISA_X86_AVX512VBMI)) { + ret = -ENOTSUP; + } + } + + return ret; +} + +int32_t +action_avx512_probe(void) +{ + const uint32_t needs_vbmi = 0; + return avx512_isa_probe(needs_vbmi); +} + + +int32_t +action_avx512_init(void) +{ + avx512_isa_probe(0); + return 0; +} diff --git a/lib/odp-execute-private.c b/lib/odp-execute-private.c index 2301194a0..19a04f518 100644 --- a/lib/odp-execute-private.c +++ b/lib/odp-execute-private.c @@ -46,6 +46,15 @@ static struct odp_execute_action_impl action_impls[] = { .probe = NULL, .init_func = action_autoval_init, }, + + #if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__) + [ACTION_IMPL_AVX512] = { + .available = 1, + .name = "avx512", + .probe = action_avx512_probe, + .init_func = NULL, + }, + #endif }; static void diff --git a/lib/odp-execute-private.h b/lib/odp-execute-private.h index d49714bd2..4c09bee63 100644 --- a/lib/odp-execute-private.h +++ b/lib/odp-execute-private.h @@ -73,6 +73,9 @@ enum odp_execute_action_impl_idx { * Do not change the autovalidator position in this list without updating * the define below. */ + #if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__) + ACTION_IMPL_AVX512, + #endif ACTION_IMPL_MAX, }; @@ -98,4 +101,10 @@ int32_t odp_execute_action_set(const char *name, */ int32_t odp_action_scalar_init(struct odp_execute_action_impl *self); +/* Init function for the optimized with AVX512 actions. */ +int32_t action_avx512_init(void); + +/* Probe function to check ISA requirements. */ +int32_t action_avx512_probe(void); + #endif /* ODP_EXTRACT_PRIVATE */