From patchwork Mon Jul 4 12:27:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pai G, Sunil" X-Patchwork-Id: 1651979 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=nT8sJ7uY; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lc4nS6BjNz9sFr for ; Mon, 4 Jul 2022 22:27:24 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id A0A4E60E68; Mon, 4 Jul 2022 12:27:22 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A0A4E60E68 Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=nT8sJ7uY X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YjTOr-v7NAWD; Mon, 4 Jul 2022 12:27:21 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id B49E5606E7; Mon, 4 Jul 2022 12:27:20 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org B49E5606E7 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7D936C0032; Mon, 4 Jul 2022 12:27:20 +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 1E287C002D for ; Mon, 4 Jul 2022 12:27:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 011B2813F7 for ; Mon, 4 Jul 2022 12:27:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 011B2813F7 Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=nT8sJ7uY X-Virus-Scanned: amavisd-new at osuosl.org 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 pBYlDyHi91QB for ; Mon, 4 Jul 2022 12:27:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 8E64D81376 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by smtp1.osuosl.org (Postfix) with ESMTPS id 8E64D81376 for ; Mon, 4 Jul 2022 12:27:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656937637; x=1688473637; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Hqn0BieBTVLekuyRSeGP63TEa/qy2ORdloUGHbGRtuA=; b=nT8sJ7uY8ejUa4P4HpzEarwmbj8J7PFBp1WAzzmfUbahXprHdzd3vwKp PlXAMipSLAu+C8q0xzD+ZRqNFWIqUNFyt3S8exGU69xhIpeBMeld1T34B 0eyuptgfyBv1rW1kTdBeu3m/0nsOOje9bcp1bEHfD25cOklV6txiOlqlz vtgNFDKMomIY004i369SmbPm7Tf4sA55ZthbJjrmdnc0KJBk4JQS0FrEC 4aV2flCMl1pl5TBweLzr1h4Gpq6MOUKhyi0b8EexwpBW7EWnqnlBSaE70 yw19EA8Ht2yezlul1AsCkqoNuawEpb45AYWaE+WmLBbgK5NJuDaBDjkqy g==; X-IronPort-AV: E=McAfee;i="6400,9594,10397"; a="262909482" X-IronPort-AV: E=Sophos;i="5.92,243,1650956400"; d="scan'208";a="262909482" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2022 05:27:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,243,1650956400"; d="scan'208";a="542573766" Received: from silpixa00400896.ir.intel.com ([10.243.22.62]) by orsmga003.jf.intel.com with ESMTP; 04 Jul 2022 05:27:14 -0700 From: Sunil Pai G To: dev@openvswitch.org Date: Mon, 4 Jul 2022 12:27:00 +0000 Message-Id: <20220704122700.54825-1-sunil.pai.g@intel.com> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220623070119.989558-1-sunil.pai.g@intel.com> References: <20220623070119.989558-1-sunil.pai.g@intel.com> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH v2] dpif-netdev: Simplify AVX512 build time checks to enhance readability. 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" The preprocessor comparison string to check AVX512 capabilities are lengthy and effecting user readability. Simpify this by aliasing the checks. Suggested-by: Eelco Chaudron Signed-off-by: Sunil Pai G Acked-by: Cian Ferriter --- v2: rebase on master, added alias for DPCLS. Remove the acks since there are changes introduced because of rebase. --- lib/dpif-netdev-lookup.c | 8 ++++---- lib/dpif-netdev-private-dpif.c | 8 +++++--- lib/dpif-netdev-private-extract.c | 6 ++---- lib/dpif-netdev-private-extract.h | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/dpif-netdev-lookup.c b/lib/dpif-netdev-lookup.c index 6bcfb8ba8..4c1379aa5 100644 --- a/lib/dpif-netdev-lookup.c +++ b/lib/dpif-netdev-lookup.c @@ -22,9 +22,10 @@ #include "openvswitch/vlog.h" VLOG_DEFINE_THIS_MODULE(dpif_netdev_lookup); +#define DPCLS_IMPL_AVX512_CHECK (__x86_64__ && HAVE_AVX512F \ + && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW && __SSE4_2__) -#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW \ - && __SSE4_2__) +#if DPCLS_IMPL_AVX512_CHECK static dpcls_subtable_lookup_func dpcls_subtable_avx512_gather_probe(uint32_t u0_bits, uint32_t u1_bits) { @@ -61,8 +62,7 @@ static struct dpcls_subtable_lookup_info_t subtable_lookups[] = { .name = "generic", .usage_cnt = ATOMIC_COUNT_INIT(0), }, -#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW \ - && __SSE4_2__) +#if DPCLS_IMPL_AVX512_CHECK /* Only available on x86_64 bit builds with SSE 4.2 used for OVS core. */ { .prio = 0, .probe = dpcls_subtable_avx512_gather_probe, diff --git a/lib/dpif-netdev-private-dpif.c b/lib/dpif-netdev-private-dpif.c index 5ae119a30..ef4cee2ba 100644 --- a/lib/dpif-netdev-private-dpif.c +++ b/lib/dpif-netdev-private-dpif.c @@ -28,13 +28,15 @@ #include "util.h" VLOG_DEFINE_THIS_MODULE(dpif_netdev_impl); +#define DPIF_NETDEV_IMPL_AVX512_CHECK (__x86_64__ && HAVE_AVX512F \ + && HAVE_LD_AVX512_GOOD && __SSE4_2__) enum dpif_netdev_impl_info_idx { DPIF_NETDEV_IMPL_SCALAR, DPIF_NETDEV_IMPL_AVX512 }; -#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__) +#if DPIF_NETDEV_IMPL_AVX512_CHECK static int32_t dp_netdev_input_outer_avx512_probe(void) { @@ -54,7 +56,7 @@ static struct dpif_netdev_impl_info_t dpif_impls[] = { .probe = NULL, .name = "dpif_scalar", }, -#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__) +#if DPIF_NETDEV_IMPL_AVX512_CHECK /* Only available on x86_64 bit builds with SSE 4.2 used for OVS core. */ [DPIF_NETDEV_IMPL_AVX512] = { .input_func = dp_netdev_input_outer_avx512, .probe = dp_netdev_input_outer_avx512_probe, @@ -73,7 +75,7 @@ dp_netdev_impl_get_default(void) int dpif_idx = DPIF_NETDEV_IMPL_SCALAR; /* Configure-time overriding to run test suite on all implementations. */ -#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__) +#if DPIF_NETDEV_IMPL_AVX512_CHECK #ifdef DPIF_AVX512_DEFAULT dp_netdev_input_func_probe probe; diff --git a/lib/dpif-netdev-private-extract.c b/lib/dpif-netdev-private-extract.c index bd6bb8d94..61258a7ac 100644 --- a/lib/dpif-netdev-private-extract.c +++ b/lib/dpif-netdev-private-extract.c @@ -34,8 +34,7 @@ VLOG_DEFINE_THIS_MODULE(dpif_netdev_extract); /* Variable to hold the default MFEX implementation. */ static ATOMIC(miniflow_extract_func) default_mfex_func; -#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW \ - && __SSE4_2__) +#if MFEX_IMPL_AVX512_CHECK static int32_t avx512_isa_probe(bool needs_vbmi) { @@ -95,8 +94,7 @@ static struct dpif_miniflow_extract_impl mfex_impls[] = { .name = "study", }, /* Compile in implementations only if the compiler ISA checks pass. */ -#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW \ - && __SSE4_2__) +#if MFEX_IMPL_AVX512_CHECK #if HAVE_AVX512VBMI [MFEX_IMPL_VBMI_IPv4_UDP] = { .probe = mfex_avx512_vbmi_probe, diff --git a/lib/dpif-netdev-private-extract.h b/lib/dpif-netdev-private-extract.h index 0b526e199..2a3a91744 100644 --- a/lib/dpif-netdev-private-extract.h +++ b/lib/dpif-netdev-private-extract.h @@ -19,6 +19,9 @@ #include +#define MFEX_IMPL_AVX512_CHECK (__x86_64__ && HAVE_AVX512F \ + && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW && __SSE4_2__) + /* Forward declarations. */ struct dp_packet; struct miniflow; @@ -81,8 +84,7 @@ enum dpif_miniflow_extract_impl_idx { MFEX_IMPL_AUTOVALIDATOR, MFEX_IMPL_SCALAR, MFEX_IMPL_STUDY, -#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW \ - && __SSE4_2__) +#if MFEX_IMPL_AVX512_CHECK #if HAVE_AVX512VBMI MFEX_IMPL_VBMI_IPv4_UDP, #endif @@ -108,9 +110,7 @@ extern struct ovs_mutex dp_netdev_mutex; /* Define a index which points to the first traffic optimized MFEX * option from the enum list else holds max value. */ -#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW \ - && __SSE4_2__) - +#if MFEX_IMPL_AVX512_CHECK #if HAVE_AVX512VBMI #define MFEX_IMPL_START_IDX MFEX_IMPL_VBMI_IPv4_UDP #else