From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f50.google.com (mail-oi0-f50.google.com [209.85.218.50]) by dpdk.org (Postfix) with ESMTP id 6B4405A13 for ; Sat, 9 May 2015 00:54:41 +0200 (CEST) Received: by oign205 with SMTP id n205so69519633oig.2 for ; Fri, 08 May 2015 15:54:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=PPtqZWrpMxexV8dxKSq5xkqkBllUzsEuJ+C58bNbllM=; b=L/O/vGD5pJNdLQzW1tEQcfJxXuu0jQF3gb4s+Y+FfWtiPXNpynG0Vnpd+2r8I4+rhz GduSYOF28eLkXifR6flLmwVkTll+At1elzCQ0bSS7suU+jErLqOPc6enquKCGcjeKSkF qLzeD2pUlJCv4f+s3GrFnC3+uhq4KpJ1FeOF2p6Ro+lBHXrr0d8f2Fu3OvGwSd9OSctI xAqaNP8VH+AbgTlfyvcwzrWrYvB4ZwcrVXY8gc+duL/9QUsckSi9qag5a631DZwOmLe2 6/7fvvz9GD6v3mMW2FbuJpMPwO7+ij7RAqWcqbXShQWvYuQ9XuCzcwx+Gnfhr38FxTUC ch9Q== MIME-Version: 1.0 X-Received: by 10.182.24.5 with SMTP id q5mr252700obf.8.1431125680863; Fri, 08 May 2015 15:54:40 -0700 (PDT) Received: by 10.202.179.195 with HTTP; Fri, 8 May 2015 15:54:40 -0700 (PDT) In-Reply-To: References: <1431119946-32078-1-git-send-email-rkerur@gmail.com> <1431119989-32124-1-git-send-email-rkerur@gmail.com> Date: Fri, 8 May 2015 15:54:40 -0700 Message-ID: From: Ravi Kerur To: Matt Laswell Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE instructions. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 May 2015 22:54:41 -0000 On Fri, May 8, 2015 at 3:29 PM, Matt Laswell wrote: > > > On Fri, May 8, 2015 at 4:19 PM, Ravi Kerur wrote: > >> This patch replaces memcmp in librte_hash with rte_memcmp which is >> implemented with AVX/SSE instructions. >> >> +static inline int >> +rte_memcmp(const void *_src_1, const void *_src_2, size_t n) >> +{ >> + const uint8_t *src_1 = (const uint8_t *)_src_1; >> + const uint8_t *src_2 = (const uint8_t *)_src_2; >> + int ret = 0; >> + >> + if (n & 0x80) >> + return rte_cmp128(src_1, src_2); >> + >> + if (n & 0x40) >> + return rte_cmp64(src_1, src_2); >> + >> + if (n & 0x20) { >> + ret = rte_cmp32(src_1, src_2); >> + n -= 0x20; >> + src_1 += 0x20; >> + src_2 += 0x20; >> + } >> >> > Pardon me for butting in, but this seems incorrect for the first two cases > listed above, as the function as written will only compare the first 128 or > 64 bytes of each source and return the result. The pattern expressed in > the 32 byte case appears more correct, as it compares the first 32 bytes > and then lets later pieces of the function handle the smaller remaining > bits of the sources. Also, if this function is to handle arbitrarily large > source data, the 128 byte case needs to be in a loop. > > What am I missing? > Current max hash key length supported is 64 bytes, hence no comparison is done after 64 bytes. 128 bytes comparison is added to measure performance only and there is no use-case as of now. With the current use-cases its not required but if there is a need to handle large arbitrary data upto 128 bytes it can be modified. > > -- > Matt Laswell > infinite io, inc. > laswell@infiniteio.com > >