From patchwork Wed Mar 20 21:24:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 138645 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8240643D0A; Wed, 20 Mar 2024 22:24:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A78C942E4B; Wed, 20 Mar 2024 22:24:45 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9621A42E0C for ; Wed, 20 Mar 2024 22:24:41 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id B157E20B74C1; Wed, 20 Mar 2024 14:24:40 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B157E20B74C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1710969880; bh=8+c4mZe23i78eRD9C5VoIkXBqGXu4Aa5Ft/zqy3y/Ag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cJhopcYFe2qQb3fIEmwLDN1QONSfO/h6/gJPpVduPo3qV/3ld/uZP3kKtpC0I7+hs Fbo3qNIqDkzw/zUm+2139gX3HtWIFwHB5n3Dym/CuzTXCtjxNQq8F01yGNabBWChQI SYOWKrZevTqZ2ykudU7rraXOQjZhJAqTMqQll+uY= From: Tyler Retzlaff To: dev@dpdk.org Cc: Bruce Richardson , Joyce Kong , Konstantin Ananyev , Tyler Retzlaff Subject: [PATCH 1/2] eal: provide movdiri for MSVC Date: Wed, 20 Mar 2024 14:24:38 -0700 Message-Id: <1710969879-23701-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1710969879-23701-1-git-send-email-roretzla@linux.microsoft.com> References: <1710969879-23701-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org MSVC does not support inline assembly instead it provides compiler intrinsics. Provide conditional compile for MSVC for movdiri using the _directstoreu_u32 intrinsic. Signed-off-by: Tyler Retzlaff --- lib/eal/x86/include/rte_io.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/eal/x86/include/rte_io.h b/lib/eal/x86/include/rte_io.h index 0e1fefd..2c72601 100644 --- a/lib/eal/x86/include/rte_io.h +++ b/lib/eal/x86/include/rte_io.h @@ -22,11 +22,15 @@ static __rte_always_inline void __rte_x86_movdiri(uint32_t value, volatile void *addr) { +#ifdef RTE_TOOLCHAIN_MSVC + _directstoreu_u32((void *)(uintptr_t)addr, value); +#else asm volatile( /* MOVDIRI */ ".byte 0x40, 0x0f, 0x38, 0xf9, 0x02" : : "a" (value), "d" (addr)); +#endif } __rte_experimental From patchwork Wed Mar 20 21:24:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 138644 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D34DE43D0A; Wed, 20 Mar 2024 22:24:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B2C142E37; Wed, 20 Mar 2024 22:24:44 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 7D97942DF0 for ; Wed, 20 Mar 2024 22:24:41 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id BD85720B74C2; Wed, 20 Mar 2024 14:24:40 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com BD85720B74C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1710969880; bh=dtBOzkA46rM1KI0WTIFF6Ulwp8sGxQQaFhWC+ev3QXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TrR80MjLOd3fVD3sRw1uCuzPSe6znphP85lBfxzFwJySNI0Na2iaEYVdPfGz6vCGb pYOpdL0sqcxuqciH0TDxCBnzIXHkgAvj7MbHzqORbnSLDRVxdEhRy4SbyFvxRUBpR7 HMFAcQnhqGkbmWYpvbBOzPH8IKcrj5VDH0GjVwao= From: Tyler Retzlaff To: dev@dpdk.org Cc: Bruce Richardson , Joyce Kong , Konstantin Ananyev , Tyler Retzlaff Subject: [PATCH 2/2] eal: add rte ffs32 and rte ffs64 inline functions Date: Wed, 20 Mar 2024 14:24:39 -0700 Message-Id: <1710969879-23701-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1710969879-23701-1-git-send-email-roretzla@linux.microsoft.com> References: <1710969879-23701-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org provide toolchain abstraction for __builtin_ffs{,l,ll} gcc built-in intrinsics. Signed-off-by: Tyler Retzlaff --- lib/eal/include/rte_bitops.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/eal/include/rte_bitops.h b/lib/eal/include/rte_bitops.h index 449565e..e157a45 100644 --- a/lib/eal/include/rte_bitops.h +++ b/lib/eal/include/rte_bitops.h @@ -405,6 +405,28 @@ return (unsigned int)__popcnt64(v); } +static inline unsigned int +rte_ffs32(uint32_t v) +{ + unsigned long rv; + + if (0 == _BitScanForward(&rv, v)) + return 0; + + return (unsigned int)rv + 1; +} + +static inline unsigned int +rte_ffs64(uint64_t v) +{ + unsigned long rv; + + if (0 == _BitScanForward64(&rv, v)) + return 0; + + return (unsigned int)rv + 1; +} + #else /** @@ -491,6 +513,18 @@ return (unsigned int)__builtin_popcountll(v); } +static inline unsigned int +rte_ffs32(uint32_t v) +{ + return (unsigned int)__builtin_ffs(v); +} + +static inline unsigned int +rte_ffs64(uint64_t v) +{ + return (unsigned int)__builtin_ffsll(v); +} + #endif /** From patchwork Fri Jan 24 16:14:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Muezerie X-Patchwork-Id: 150453 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E4D1F4612D; Fri, 24 Jan 2025 17:14:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A8590402CC; Fri, 24 Jan 2025 17:14:14 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 12E6B4279A for ; Fri, 24 Jan 2025 17:14:13 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 7DFB8210D0C6; Fri, 24 Jan 2025 08:14:12 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7DFB8210D0C6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1737735252; bh=VwS46Q+IqRv1oR1h0n4t7Eb1Y9wkqljnsK44aEHxo44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H3/xwhLyAVxcHoHvbADPpyhRRuVlMO7RgF2vHc/J4Z90f60b+PhsgBKwbCd5SzHzZ oAzUJhDebErHwPqvG/+/8gH8eI2z6GDfm3w2MAICDwMuKHNriAi+2ODSgDgbr5/ECx Mppe4BOaAXFfAGupEdv4ZVJ0/riJbsHbodah2EgQ= From: Andre Muezerie To: dev@dpdk.org Cc: Andre Muezerie Subject: [PATCH v3 3/3] app/test: add test for rte_ffs32 and rte_ffs64 functions. Date: Fri, 24 Jan 2025 08:14:04 -0800 Message-Id: <1737735244-23234-4-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1737735244-23234-1-git-send-email-andremue@linux.microsoft.com> References: <1710969879-23701-1-git-send-email-roretzla@linux.microsoft.com> <1737735244-23234-1-git-send-email-andremue@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add tests for new rte_ffs32 and rte_ffs64 functions. Signed-off-by: Andre Muezerie --- app/test/test_bitcount.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/app/test/test_bitcount.c b/app/test/test_bitcount.c index 83c68feb7b..8eb4a460f2 100644 --- a/app/test/test_bitcount.c +++ b/app/test/test_bitcount.c @@ -12,6 +12,42 @@ RTE_LOG_REGISTER(bitcount_logtype_test, test.bitcount, INFO); +static int +test_bit_scan_forward(void) +{ + unsigned int bit_nr; + + TEST_ASSERT((bit_nr = rte_ffs32(0)) == 0, + "rte_ffs32 returned unexpected %d", bit_nr); + + for (int i = 0; i < 32; ++i) { + uint32_t n = RTE_BIT32(i); + + TEST_ASSERT((bit_nr = rte_ffs32(n)) == (unsigned int)(i+1), + "rte_ffs32 returned unexpected %d", bit_nr); + } + + return TEST_SUCCESS; +} + +static int +test_bit_scan_forward64(void) +{ + unsigned int bit_nr; + + TEST_ASSERT((bit_nr = rte_ffs64(0)) == 0, + "rte_ffs64 returned unexpected %d", bit_nr); + + for (int i = 0; i < 64; ++i) { + uint64_t n = RTE_BIT64(i); + + TEST_ASSERT((bit_nr = rte_ffs64(n)) == (unsigned int)(i+1), + "rte_ffs64 returned unexpected %d", bit_nr); + } + + return TEST_SUCCESS; +} + static int test_clz32(void) { @@ -117,6 +153,8 @@ static struct unit_test_suite bitcount_test_suite = { .setup = NULL, .teardown = NULL, .unit_test_cases = { + TEST_CASE(test_bit_scan_forward), + TEST_CASE(test_bit_scan_forward64), TEST_CASE(test_clz32), TEST_CASE(test_clz64), TEST_CASE(test_ctz32),