From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) by dpdk.org (Postfix) with ESMTP id E113F20BD for ; Tue, 22 Aug 2017 17:57:04 +0200 (CEST) Received: by mail-qk0-f194.google.com with SMTP id 130so9439422qkg.5 for ; Tue, 22 Aug 2017 08:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=1HE4lqWhn1Z6FlZwh5tXLQFMPyHRXUY66T+ZycA/UQo=; b=WIZgAmrfrJCwz4zaYwOTALraJvHo1px/WNYZFYNCD6WvzUpR1Z2JRrQFx0jFUNX6j8 oa0UVqWKK04hwBFSfxFV2uakIKoHy2jz6xg9woVuwSa9GKGSppXjsmHIKlojR0KIunEf jSy/jWGloqeU80c9DN8AKlUuUdpjPr8FKmpzAD79UfEt0etUJq6bmWgm31J+/4RpuLV6 hya6khmFXvQCBFz0Qwy5U9l2eDV98QegT+uJC89wUOlenP5pKndsqBjP790H/nvCt+Fs 9yE2BeAAfbRf9QTBmXuctgIjEHI6LgX03qUXpYHGd8UKwWYuCJuzUlpw/lr+xeaMC67h Qm5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=1HE4lqWhn1Z6FlZwh5tXLQFMPyHRXUY66T+ZycA/UQo=; b=g3Py9jkvvuSIlv1U8L3klVoWbwcVrPmj0ncV/iZxZx0GECSPZICtQFgd38d7OmuT1B 8v2wxr+mco2C8+lMPJbeZs3SOvZx41he6AAtt4nPxcqHjvn5OVYZato8UBpaM21lgx8Z TtgC4nL2HyFdbpPV+NWCr+rmic2LMEBn2J850jtTr0TNJSDYt9GrArdI31G3nf1vl883 ZRTqOdqCTP7w3o/OAEoEauAzIl5UVOWAOKM1YsKt6Aei6aJG3URZCv+0gKmPAUXzVLX4 T+I6l5CzWngFNghyQyg3KAiq+GxHR85khVUyDKp2D5fA9/NpdpRaw51917bL88frs3ho gRfA== X-Gm-Message-State: AHYfb5g86uBsDI1CHPHNNWJfK3oKrJgX44dtYu/ukkUUF0/GvZcWcg/u oyK+yDMU2zWwp/qemcAKE+bh2AIB4Z/7 X-Received: by 10.55.27.85 with SMTP id b82mr1721124qkb.309.1503417424295; Tue, 22 Aug 2017 08:57:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.3.68 with HTTP; Tue, 22 Aug 2017 08:57:03 -0700 (PDT) In-Reply-To: <1503403355-4917-1-git-send-email-zhouyates@gmail.com> References: <1503403355-4917-1-git-send-email-zhouyates@gmail.com> From: Vladimir Medvedkin Date: Tue, 22 Aug 2017 18:57:03 +0300 Message-ID: To: Yangchao Zhou Cc: "dev@dpdk.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH] hash: optimize the softrss computation 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: , X-List-Received-Date: Tue, 22 Aug 2017 15:57:05 -0000 Hi, 2017-08-22 15:02 GMT+03:00 Yangchao Zhou : > Use rte_bsf32 and fast bit unset operation to optimize the softrss > computation. > The following measurements shows improvement over the default > softrss computation function. > > tuple lens old(cycles) new(cycles) > 3 1225 337 > 9 3743 992 > > Signed-off-by: Yangchao Zhou > --- > lib/librte_hash/rte_thash.h | 22 ++++++++++------------ > 1 file changed, 10 insertions(+), 12 deletions(-) > > diff --git a/lib/librte_hash/rte_thash.h b/lib/librte_hash/rte_thash.h > index 2fffd61..4fa5e07 100644 > --- a/lib/librte_hash/rte_thash.h > +++ b/lib/librte_hash/rte_thash.h > @@ -207,15 +207,14 @@ static inline uint32_t > rte_softrss(uint32_t *input_tuple, uint32_t input_len, > const uint8_t *rss_key) > { > - uint32_t i, j, ret = 0; > + uint32_t i, j, map, ret = 0; > > for (j = 0; j < input_len; j++) { > - for (i = 0; i < 32; i++) { > - if (input_tuple[j] & (1 << (31 - i))) { > - ret ^= rte_cpu_to_be_32(((const uint32_t > *)rss_key)[j]) << i | > + for (map = input_tuple[j]; map; map &= (map - 1)) { > + i = rte_bsf32(map); > + ret ^= rte_cpu_to_be_32(((const uint32_t > *)rss_key)[j]) << (31 - i) | > (uint32_t)((uint64_t)(rte_cpu_to_be_32(((const > uint32_t *)rss_key)[j + 1])) >> > - (32 - i)); > - } > + (i + 1)); > } > } > return ret; > @@ -238,14 +237,13 @@ static inline uint32_t > rte_softrss_be(uint32_t *input_tuple, uint32_t input_len, > const uint8_t *rss_key) > { > - uint32_t i, j, ret = 0; > + uint32_t i, j, map, ret = 0; > > for (j = 0; j < input_len; j++) { > - for (i = 0; i < 32; i++) { > - if (input_tuple[j] & (1 << (31 - i))) { > - ret ^= ((const uint32_t *)rss_key)[j] << i > | > - (uint32_t)((uint64_t)(((const > uint32_t *)rss_key)[j + 1]) >> (32 - i)); > - } > + for (map = input_tuple[j]; map; map &= (map - 1)) { > + i = rte_bsf32(map); > + ret ^= ((const uint32_t *)rss_key)[j] << (31 - i) | > + (uint32_t)((uint64_t)(((const uint32_t > *)rss_key)[j + 1]) >> (i + 1)); > } > } > return ret; > -- > 2.7.4 > > Looks good for me. Thanks! Reviewed-by: Medvedkin Vladimir -- Regards, Vladimir