From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B9A0BA04DC; Mon, 19 Oct 2020 15:56:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8BC5AE2C1; Mon, 19 Oct 2020 15:51:09 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by dpdk.org (Postfix) with ESMTP id EDFD9E2C8 for ; Mon, 19 Oct 2020 15:51:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603115464; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ieCmNvJ9rrrhKkGhP0oUzSZK0lbI8+6MBDu2PascNxc=; b=gDn8uEoXRSZgRivsafQpRLp/pGJaNqEUga9g4rRdqaSRjYIzID55jqV2EBBh/9pQKcfDuN 69PzauiQepGUQJgBqyCNxdG0SImc5CJXI4MNmUu3CjIsND1MrJrqk5YuEzgPs5Ij6mmX0q yjORgYfWCCGl8MV7hO8WxN0wwlKfuR0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-562-5WgfbR7_POW4rezzkOJ0mg-1; Mon, 19 Oct 2020 09:51:00 -0400 X-MC-Unique: 5WgfbR7_POW4rezzkOJ0mg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24B8C640AE; Mon, 19 Oct 2020 13:50:04 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.195.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AF5155798; Mon, 19 Oct 2020 13:50:01 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: viktorin@rehivetech.com, ruifeng.wang@arm.com, jerinj@marvell.com, drc@linux.vnet.ibm.com, bruce.richardson@intel.com, konstantin.ananyev@intel.com, ciara.power@intel.com Date: Mon, 19 Oct 2020 15:48:58 +0200 Message-Id: <20201019134858.32507-19-david.marchand@redhat.com> In-Reply-To: <20201019134858.32507-1-david.marchand@redhat.com> References: <20201019134858.32507-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-dev] [PATCH v10 18/18] acl: check max SIMD bitwidth X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ciara Power When choosing a vector path to take, an extra condition must be satisfied to ensure the max SIMD bitwidth allows for the CPU enabled path. These checks are added in the check alg helper functions. Signed-off-by: Ciara Power Acked-by: Konstantin Ananyev Tested-by: Konstantin Ananyev --- v10: - updated #ifdef magic for arm and ppc checks, v8: - Added AVX512X32 into default options for get best alg function. - Updated doc to reflect the above change. v7: - Removed global variable for max SIMD bitwidth. - Added helper function for checking AVX512 cpu flags. - Separated condition checking for the AVX512 algorithms to allow for checking 256/512 max SIMD bitwidth, respectively. - Added to docs to reflect the added changes in algorithm selection. --- .../prog_guide/packet_classif_access_ctrl.rst | 16 +++--- lib/librte_acl/rte_acl.c | 53 +++++++++++++------ lib/librte_acl/rte_acl.h | 1 + 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/doc/guides/prog_guide/packet_classif_access_ctrl.rst b/doc/guides/prog_guide/packet_classif_access_ctrl.rst index 7659af8eb5..1811db4618 100644 --- a/doc/guides/prog_guide/packet_classif_access_ctrl.rst +++ b/doc/guides/prog_guide/packet_classif_access_ctrl.rst @@ -368,24 +368,27 @@ After rte_acl_build() over given AC context has finished successfully, it can be There are several implementations of classify algorithm: * **RTE_ACL_CLASSIFY_SCALAR**: generic implementation, doesn't require any specific HW support. + Requires max SIMD bitwidth to be at least 64. * **RTE_ACL_CLASSIFY_SSE**: vector implementation, can process up to 8 flows in parallel. Requires SSE 4.1 support. + Requires max SIMD bitwidth to be at least 128. * **RTE_ACL_CLASSIFY_AVX2**: vector implementation, can process up to 16 flows in parallel. Requires AVX2 support. + Requires max SIMD bitwidth to be at least 256. * **RTE_ACL_CLASSIFY_NEON**: vector implementation, can process up to 8 flows - in parallel. Requires NEON support. + in parallel. Requires NEON support. Requires max SIMD bitwidth to be at least 128. * **RTE_ACL_CLASSIFY_ALTIVEC**: vector implementation, can process up to 8 - flows in parallel. Requires ALTIVEC support. + flows in parallel. Requires ALTIVEC support. Requires max SIMD bitwidth to be at least 128. * **RTE_ACL_CLASSIFY_AVX512X16**: vector implementation, can process up to 16 flows in parallel. Uses 256-bit width SIMD registers. - Requires AVX512 support. + Requires AVX512 support. Requires max SIMD bitwidth to be at least 256. * **RTE_ACL_CLASSIFY_AVX512X32**: vector implementation, can process up to 32 flows in parallel. Uses 512-bit width SIMD registers. - Requires AVX512 support. + Requires AVX512 support. Requires max SIMD bitwidth to be at least 512. It is purely a runtime decision which method to choose, there is no build-time difference. All implementations operates over the same internal RT structures and use similar principles. The main difference is that vector implementations can manually exploit IA SIMD instructions and process several input data flows in parallel. @@ -393,9 +396,8 @@ At startup ACL library determines the highest available classify method for the .. note:: - Right now ``RTE_ACL_CLASSIFY_AVX512X32`` is not selected by default - (due to possible frequency level change), but it can be selected at - runtime by apps through the use of ACL API: ``rte_acl_set_ctx_classify``. + Runtime algorithm selection obeys EAL max SIMD bitwidth parameter. + For more details about expected behaviour please see :ref:`max_simd_bitwidth` Application Programming Interface (API) Usage --------------------------------------------- diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c index 7c2f60b2d6..4e693b2488 100644 --- a/lib/librte_acl/rte_acl.c +++ b/lib/librte_acl/rte_acl.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "acl.h" @@ -114,14 +115,14 @@ acl_check_alg_arm(enum rte_acl_classify_alg alg) { if (alg == RTE_ACL_CLASSIFY_NEON) { #if defined(RTE_ARCH_ARM64) - return 0; + if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) + return 0; #elif defined(RTE_ARCH_ARM) - if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_NEON)) + if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_NEON) && + rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) return 0; - return -ENOTSUP; -#else - return -ENOTSUP; #endif + return -ENOTSUP; } return -EINVAL; @@ -136,15 +137,26 @@ acl_check_alg_ppc(enum rte_acl_classify_alg alg) { if (alg == RTE_ACL_CLASSIFY_ALTIVEC) { #if defined(RTE_ARCH_PPC_64) - return 0; -#else - return -ENOTSUP; + if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) + return 0; #endif + return -ENOTSUP; } return -EINVAL; } +#ifdef CC_AVX512_SUPPORT +static int +acl_check_avx512_cpu_flags(void) +{ + return (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) && + rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512VL) && + rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512CD) && + rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW)); +} +#endif + /* * Helper function for acl_check_alg. * Check support for x86 specific classify methods. @@ -152,13 +164,19 @@ acl_check_alg_ppc(enum rte_acl_classify_alg alg) static int acl_check_alg_x86(enum rte_acl_classify_alg alg) { - if (alg == RTE_ACL_CLASSIFY_AVX512X16 || - alg == RTE_ACL_CLASSIFY_AVX512X32) { + if (alg == RTE_ACL_CLASSIFY_AVX512X32) { #ifdef CC_AVX512_SUPPORT - if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) && - rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512VL) && - rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512CD) && - rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW)) + if (acl_check_avx512_cpu_flags() != 0 && + rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512) + return 0; +#endif + return -ENOTSUP; + } + + if (alg == RTE_ACL_CLASSIFY_AVX512X16) { +#ifdef CC_AVX512_SUPPORT + if (acl_check_avx512_cpu_flags() != 0 && + rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256) return 0; #endif return -ENOTSUP; @@ -166,7 +184,8 @@ acl_check_alg_x86(enum rte_acl_classify_alg alg) if (alg == RTE_ACL_CLASSIFY_AVX2) { #ifdef CC_AVX2_SUPPORT - if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2)) + if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) && + rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256) return 0; #endif return -ENOTSUP; @@ -174,7 +193,8 @@ acl_check_alg_x86(enum rte_acl_classify_alg alg) if (alg == RTE_ACL_CLASSIFY_SSE) { #ifdef RTE_ARCH_X86 - if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_1)) + if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_1) && + rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) return 0; #endif return -ENOTSUP; @@ -226,6 +246,7 @@ acl_get_best_alg(void) #elif defined(RTE_ARCH_PPC_64) RTE_ACL_CLASSIFY_ALTIVEC, #elif defined(RTE_ARCH_X86) + RTE_ACL_CLASSIFY_AVX512X32, RTE_ACL_CLASSIFY_AVX512X16, RTE_ACL_CLASSIFY_AVX2, RTE_ACL_CLASSIFY_SSE, diff --git a/lib/librte_acl/rte_acl.h b/lib/librte_acl/rte_acl.h index 1bfed00743..f7f5f08701 100644 --- a/lib/librte_acl/rte_acl.h +++ b/lib/librte_acl/rte_acl.h @@ -329,6 +329,7 @@ rte_acl_classify_alg(const struct rte_acl_ctx *ctx, * New default classify algorithm for given ACL context. * It is the caller responsibility to ensure that the value refers to the * existing algorithm, and that it could be run on the given CPU. + * The max SIMD bitwidth value in EAL must also allow for the chosen algorithm. * @return * - -EINVAL if the parameters are invalid. * - -ENOTSUP requested algorithm is not supported by given platform. -- 2.23.0