Message ID | 1698887132-5347-1-git-send-email-roretzla@linux.microsoft.com (mailing list archive) |
---|---|
Headers |
Return-Path: <dev-bounces@dpdk.org> 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 D027443267; Thu, 2 Nov 2023 02:05:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A923C42DD4; Thu, 2 Nov 2023 02:05:38 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 0130B42DC4 for <dev@dpdk.org>; Thu, 2 Nov 2023 02:05:34 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 1993620B74C0; Wed, 1 Nov 2023 18:05:34 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1993620B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1698887134; bh=O4UMyxWQNYqqfw4PigFYM7tyyUQdO9xQHxFOKjjrbyI=; h=From:To:Cc:Subject:Date:From; b=HBRtgs81vUvhg3g6EFwhvBiwQK50QI+jTIJp20Z2/5ihYCwnQUfdbq6YXRKjvqK1f qR0JPLs8ufNYB28HzJVhOYWdDd+dVxPzMzD/tCrnxBFke0wbMWvnjFoWMxRFAHoalY E34YfUBBQ9I9D1yDlD3YUpXXuKgWGEhO01hd1BCM= From: Tyler Retzlaff <roretzla@linux.microsoft.com> To: dev@dpdk.org Cc: Bruce Richardson <bruce.richardson@intel.com>, Cristian Dumitrescu <cristian.dumitrescu@intel.com>, David Hunt <david.hunt@intel.com>, Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>, Ruifeng Wang <ruifeng.wang@arm.com>, Sameh Gobriel <sameh.gobriel@intel.com>, Tyler Retzlaff <roretzla@linux.microsoft.com>, Vladimir Medvedkin <vladimir.medvedkin@intel.com>, Yipeng Wang <yipeng1.wang@intel.com> Subject: [PATCH 0/5] use abstracted bit count functions Date: Wed, 1 Nov 2023 18:05:27 -0700 Message-Id: <1698887132-5347-1-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions <dev.dpdk.org> List-Unsubscribe: <https://mails.dpdk.org/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://mails.dpdk.org/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <https://mails.dpdk.org/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org |
Series | use abstracted bit count functions | |
Message
Tyler Retzlaff
Nov. 2, 2023, 1:05 a.m. UTC
The first set of conversions missed the long 'l' versions of the builtins that were being used. This series completes the conversion of remaining libraries from __builtin_ctzl and __builtin_clzl. Tyler Retzlaff (5): table: use abstracted bit count functions distributor: use abstracted bit count functions hash: use abstracted bit count functions member: use abstracted bit count functions rcu: use abstracted bit count functions lib/distributor/rte_distributor_single.c | 2 +- lib/hash/rte_cuckoo_hash.c | 16 ++++++++-------- lib/member/rte_member_vbf.c | 12 ++++++------ lib/member/rte_member_x86.h | 6 +++--- lib/rcu/rte_rcu_qsbr.c | 4 ++-- lib/rcu/rte_rcu_qsbr.h | 2 +- lib/table/rte_lru_arm64.h | 2 +- lib/table/rte_swx_table_em.c | 4 ++-- lib/table/rte_table_hash_ext.c | 4 ++-- lib/table/rte_table_hash_lru.c | 4 ++-- 10 files changed, 28 insertions(+), 28 deletions(-)
Comments
> From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com] > Sent: Thursday, 2 November 2023 02.05 > > The first set of conversions missed the long 'l' versions of the > builtins that were being used. This series completes the conversion > of remaining libraries from __builtin_ctzl and __builtin_clzl. NAK to blind search/replace of __builtin_clzl()/clzl(). Although the size of long is 64 bit on 64 bit architectures, it only 32 bit on 32 bit architectures. You need to look at the types these builtins operate on: - E.g. in the hash library (patch 3/5) prim_hitmask[i]/sec_hitmask[i] are uint32_t, so rte_ctz32() would be the correct replacement. (I am now asking myself why they were using __builtin_ctzl() instead of __builtin_ctz() here... Probably by mistake.) - And if the type is "long", you need conditional compiling (or a wrapper macro) to choose between the 32 bit or 64 bit variants. NB: You can blindly replace __builtin_ctzll()/clzll(), if any, by 64 bit functions.
On Thu, Nov 02, 2023 at 08:39:04AM +0100, Morten Brørup wrote: > > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com] > > Sent: Thursday, 2 November 2023 02.05 > > > > The first set of conversions missed the long 'l' versions of the > > builtins that were being used. This series completes the conversion > > of remaining libraries from __builtin_ctzl and __builtin_clzl. > > NAK to blind search/replace of __builtin_clzl()/clzl(). > > Although the size of long is 64 bit on 64 bit architectures, it only 32 bit on 32 bit architectures. > > You need to look at the types these builtins operate on: > - E.g. in the hash library (patch 3/5) prim_hitmask[i]/sec_hitmask[i] are uint32_t, so rte_ctz32() would be the correct replacement. (I am now asking myself why they were using __builtin_ctzl() instead of __builtin_ctz() here... Probably by mistake.) > - And if the type is "long", you need conditional compiling (or a wrapper macro) to choose between the 32 bit or 64 bit variants. > > NB: You can blindly replace __builtin_ctzll()/clzll(), if any, by 64 bit functions. they haven't been blindly replaced. but i would like you to validate my thinking. in the case of counting trailing 0s it seems fine if the type is promoted to 64-bits, in the case of leading i checked the type to make sure it was already operating on a 64-bit type. too naive?
> From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com] > Sent: Thursday, 2 November 2023 16.28 > > On Thu, Nov 02, 2023 at 08:39:04AM +0100, Morten Brørup wrote: > > > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com] > > > Sent: Thursday, 2 November 2023 02.05 > > > > > > The first set of conversions missed the long 'l' versions of the > > > builtins that were being used. This series completes the conversion > > > of remaining libraries from __builtin_ctzl and __builtin_clzl. > > > > NAK to blind search/replace of __builtin_clzl()/clzl(). > > > > Although the size of long is 64 bit on 64 bit architectures, it only > 32 bit on 32 bit architectures. > > > > You need to look at the types these builtins operate on: > > - E.g. in the hash library (patch 3/5) prim_hitmask[i]/sec_hitmask[i] > are uint32_t, so rte_ctz32() would be the correct replacement. (I am > now asking myself why they were using __builtin_ctzl() instead of > __builtin_ctz() here... Probably by mistake.) > > - And if the type is "long", you need conditional compiling (or a > wrapper macro) to choose between the 32 bit or 64 bit variants. > > > > NB: You can blindly replace __builtin_ctzll()/clzll(), if any, by 64 > bit functions. > > they haven't been blindly replaced. but i would like you to validate my > thinking. > > in the case of counting trailing 0s it seems fine if the type is > promoted to 64-bits, This will give the correct result, yes. However the 64-bit operation might have a higher performance cost than the 32-bit operation, especially on 32-bit architectures. > in the case of leading i checked the type to make > sure it was already operating on a 64-bit type. If already operating on a 64-bit type, using the 64-bit function is obviously correct. > > too naive?
On Thu, Nov 02, 2023 at 04:33:57PM +0100, Morten Brørup wrote: > > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com] > > Sent: Thursday, 2 November 2023 16.28 > > > > On Thu, Nov 02, 2023 at 08:39:04AM +0100, Morten Brørup wrote: > > > > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com] > > > > Sent: Thursday, 2 November 2023 02.05 > > > > > > > > The first set of conversions missed the long 'l' versions of the > > > > builtins that were being used. This series completes the conversion > > > > of remaining libraries from __builtin_ctzl and __builtin_clzl. > > > > > > NAK to blind search/replace of __builtin_clzl()/clzl(). > > > > > > Although the size of long is 64 bit on 64 bit architectures, it only > > 32 bit on 32 bit architectures. > > > > > > You need to look at the types these builtins operate on: > > > - E.g. in the hash library (patch 3/5) prim_hitmask[i]/sec_hitmask[i] > > are uint32_t, so rte_ctz32() would be the correct replacement. (I am > > now asking myself why they were using __builtin_ctzl() instead of > > __builtin_ctz() here... Probably by mistake.) > > > - And if the type is "long", you need conditional compiling (or a > > wrapper macro) to choose between the 32 bit or 64 bit variants. > > > > > > NB: You can blindly replace __builtin_ctzll()/clzll(), if any, by 64 > > bit functions. > > > > they haven't been blindly replaced. but i would like you to validate my > > thinking. > > > > in the case of counting trailing 0s it seems fine if the type is > > promoted to 64-bits, > > This will give the correct result, yes. However the 64-bit operation might have a higher performance cost than the 32-bit operation, especially on 32-bit architectures. true. okay let me clean this up. thanks for the feedback. > > > in the case of leading i checked the type to make > > sure it was already operating on a 64-bit type. > > If already operating on a 64-bit type, using the 64-bit function is obviously correct. > > > > > too naive?