From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AD1404545B; Fri, 14 Jun 2024 15:43:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A97540B95; Fri, 14 Jun 2024 15:43:07 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 023CB40B8F for ; Fri, 14 Jun 2024 15:43:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718372585; 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=VOXMT1oJijjrBmskLpvW9i4UdNZ5+Dd0s4GO6PGf92c=; b=bUg6sDRb/fXD1bAs7NpaRoIBZm5Do3bU43jxlF08gWDigOnr/hVd7DlwTht0ufIV70LMMy 1ybTa2iihz6S4SQ69REE+br32cUAyzpUwHM01UxDFaERLADamb/KpJtxB57pPf7eZxTAWT XQ9f6DbY+2SR0PlwBqGorHk8y3yOYl0= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-356-Ix2MIGShN4yCRwVYDwbWgg-1; Fri, 14 Jun 2024 09:43:01 -0400 X-MC-Unique: Ix2MIGShN4yCRwVYDwbWgg-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-52c9894a547so1772072e87.1 for ; Fri, 14 Jun 2024 06:43:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718372579; x=1718977379; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VOXMT1oJijjrBmskLpvW9i4UdNZ5+Dd0s4GO6PGf92c=; b=kdRBSDp55bT6qyE9K0O2Iv6egRD1ZrAH7xzCkpWfIiQ3gzdw4gho/K7Pbvu26Ku6uD VPviWgE2PaItmVvohzorZW9f+1GvBz0d10EoNqMxIxHfBXU2S6kKkKo6+Kw/iLgsm+MC q0tLfXXQjPuiMbN+iK/u17CSkJXCHQLMcIqjuwth4ctXq11VUKKRO/fHlgCK0UnLke5g JB45K4kqTeC6gYl8cJCJjLgG3R5Y8ENIEIZuvYaAnzqytSMI5RHeWd83lxbNa5omGGGR jg5xFp9+sjF5g6Vkm77VFNUx6iM7c0wmN++5Tfl5+JI9hMzron3tq7a7az73GH4WAuWX 1KSg== X-Forwarded-Encrypted: i=1; AJvYcCWvb/f/wd/xUCHmeKNUaLnMApvcVLsdXOGo42H2WYQyUcpRo73DmrjzMj5u6ACDIrb1TzDX0AH4Kz4Rxqk= X-Gm-Message-State: AOJu0Yw1F2zp4LywcOCw/mk/kiDnlhq8rp30rUkUWOvLffLCOY96B1er n26L5A6dJRTnAeiMS6e8QhpiUNHP/akvaZDob3xYWmc+JuPqXQIciwlfk7lCO2C4y4GPniS4MPX UgSyRHQCbfHIihsuhE5hPdPpXCDcHrcdyYE0oNFFhAfO7QsJ+8Sl4d1QwleoE4Q+gURwMRAJv70 KC1xfssQSN7M+HWak= X-Received: by 2002:ac2:4c36:0:b0:52b:bee3:dcc6 with SMTP id 2adb3069b0e04-52ca6e91150mr1717946e87.51.1718372579685; Fri, 14 Jun 2024 06:42:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHuyRIrz9X11Q+QXEPhdhsNGilEplDh4Mi9R81JtIy5yS3jusmSZrXr4EOkCKlXtQp+7be42tEqpRIaBV4WIaI= X-Received: by 2002:ac2:4c36:0:b0:52b:bee3:dcc6 with SMTP id 2adb3069b0e04-52ca6e91150mr1717934e87.51.1718372579307; Fri, 14 Jun 2024 06:42:59 -0700 (PDT) MIME-Version: 1.0 References: <20231020165159.1649282-1-yoan.picchi@arm.com> <20240430162743.1525484-1-yoan.picchi@arm.com> <20240430162743.1525484-2-yoan.picchi@arm.com> In-Reply-To: <20240430162743.1525484-2-yoan.picchi@arm.com> From: David Marchand Date: Fri, 14 Jun 2024 15:42:47 +0200 Message-ID: Subject: Re: [PATCH v9 1/4] hash: pack the hitmask for hash in bulk lookup To: Yoan Picchi Cc: Thomas Monjalon , Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin , dev@dpdk.org, nd@arm.com, Ruifeng Wang , Nathan Brown , Paul Szczepanek X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Tue, Apr 30, 2024 at 6:28=E2=80=AFPM Yoan Picchi w= rote: > > Current hitmask includes padding due to Intel's SIMD > implementation detail. This patch allows non Intel SIMD > implementations to benefit from a dense hitmask. > In addition, the new dense hitmask interweave the primary > and secondary matches which allow a better cache usage and > enable future improvements for the SIMD implementations > The default non SIMD path now use this dense mask. > > Signed-off-by: Yoan Picchi > Reviewed-by: Ruifeng Wang > Reviewed-by: Nathan Brown > --- > .mailmap | 2 + > lib/hash/arch/arm/compare_signatures.h | 61 +++++++ > lib/hash/arch/common/compare_signatures.h | 37 +++++ > lib/hash/arch/x86/compare_signatures.h | 53 ++++++ > lib/hash/rte_cuckoo_hash.c | 192 ++++++++++++---------- > 5 files changed, 254 insertions(+), 91 deletions(-) > create mode 100644 lib/hash/arch/arm/compare_signatures.h > create mode 100644 lib/hash/arch/common/compare_signatures.h > create mode 100644 lib/hash/arch/x86/compare_signatures.h > > diff --git a/.mailmap b/.mailmap > index 66ebc20666..00b50414d3 100644 > --- a/.mailmap > +++ b/.mailmap > @@ -494,6 +494,7 @@ Hari Kumar Vemula > Harini Ramakrishnan > Hariprasad Govindharajan > Harish Patil > +Harjot Singh This should be in patch 3. > Harman Kalra > Harneet Singh > Harold Huang > @@ -1633,6 +1634,7 @@ Yixue Wang > Yi Yang > Yi Zhang > Yoann Desmouceaux > +Yoan Picchi > Yogesh Jangra > Yogev Chaimovich > Yongjie Gu > diff --git a/lib/hash/arch/arm/compare_signatures.h b/lib/hash/arch/arm/c= ompare_signatures.h > new file mode 100644 > index 0000000000..46d15da89f > --- /dev/null > +++ b/lib/hash/arch/arm/compare_signatures.h Why create a new directory? Simple lib/hash/hash_compare_signature_{arm,x86,generic}.h are enough. > @@ -0,0 +1,61 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2010-2016 Intel Corporation > + * Copyright(c) 2018-2024 Arm Limited > + */ > + > +/* > + * Arm's version uses a densely packed hitmask buffer: > + * Every bit is in use. > + */ > + > +#include > +#include > +#include > +#include "rte_cuckoo_hash.h" Please separate headers by groups, like in https://doc.dpdk.org/guides/contributing/coding_style.html#header-includes > + > +#define DENSE_HASH_BULK_LOOKUP 1 > + > +static inline void > +compare_signatures_dense(uint16_t *hitmask_buffer, > + const uint16_t *prim_bucket_sigs, > + const uint16_t *sec_bucket_sigs, > + uint16_t sig, > + enum rte_hash_sig_compare_function sig_cmp_fn) Strange indent. > +{ > + > + static_assert(sizeof(*hitmask_buffer) >=3D 2 * (RTE_HASH_BUCKET_E= NTRIES / 8), > + "hitmask_buffer must be wide enough to = fit a dense hitmask"); This is similar but less strict than an added check in rte_cuckoo_hash.c later in this patch. So I suspect only one of those checks is necessary. But I don't understand the logic, so for you to figure out :-). > + > + /* For match mask every bits indicates the match */ > + switch (sig_cmp_fn) { > +#if RTE_HASH_BUCKET_ENTRIES <=3D 8 > + case RTE_HASH_COMPARE_NEON: { > + uint16x8_t vmat, vsig, x; > + int16x8_t shift =3D {0, 1, 2, 3, 4, 5, 6, 7}; > + uint16_t low, high; > + > + vsig =3D vld1q_dup_u16((uint16_t const *)&sig); > + /* Compare all signatures in the primary bucket */ > + vmat =3D vceqq_u16(vsig, > + vld1q_u16((uint16_t const *)prim_bucket_sigs)); General comment for this series. When possible, keep on the same line up to 100 chars, the code is hard enough to read with all those vector intrinsics... > + x =3D vshlq_u16(vandq_u16(vmat, vdupq_n_u16(0x0001)), shi= ft); > + low =3D (uint16_t)(vaddvq_u16(x)); > + /* Compare all signatures in the secondary bucket */ > + vmat =3D vceqq_u16(vsig, > + vld1q_u16((uint16_t const *)sec_bucket_sigs)); > + x =3D vshlq_u16(vandq_u16(vmat, vdupq_n_u16(0x0001)), shi= ft); > + high =3D (uint16_t)(vaddvq_u16(x)); > + *hitmask_buffer =3D low | high << RTE_HASH_BUCKET_ENTRIES= ; > + > + } > + break; > +#endif > + default: > + for (unsigned int i =3D 0; i < RTE_HASH_BUCKET_ENTRIES; i= ++) { > + *hitmask_buffer |=3D > + (sig =3D=3D prim_bucket_sigs[i]) << i; > + *hitmask_buffer |=3D > + ((sig =3D=3D sec_bucket_sigs[i]) << i) <<= RTE_HASH_BUCKET_ENTRIES; > + } > + } > +} [snip] --=20 David Marchand