From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ie0-f178.google.com (mail-ie0-f178.google.com [209.85.223.178]) by dpdk.org (Postfix) with ESMTP id C75AB9AD8 for ; Sat, 9 May 2015 00:29:43 +0200 (CEST) Received: by iedfl3 with SMTP id fl3so82885830ied.1 for ; Fri, 08 May 2015 15:29:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=k/8sE5iJWq0MLhMmcT+MG/WnKbHH6vr6ezsELBHdzWQ=; b=G3SejxIDnlpNWhEfsb5BVCgXFHajPL//UQL1Eb9nj/qtoQ8jij95REKQySGqbLNlE7 YS/38CJtjluzsiiTxa+BR007LOM5+U0794qFJuaRTSJHxJ6roAJD4KVLxu94+jhL9zhO nqDFSLAKoOMmm6D30of+iTnCPA9/ZJto6VGAHc5O8YGkQCR8Hz6rqkxxy8BlLBKCvck2 RPETS3TPqlrjFymDTHByQu/BPlZ2lOy+HrjCvJ3qyu3F/vOBs6spS8SAQBZ+8vfzmikD H3roVzLMbRAEIuOeoIvb0Ugm2O9WkK79h5m/C1fiVgFiULhHu9KDDyuYF8M6OFCnwsUQ /xsA== X-Gm-Message-State: ALoCoQmP7FUqqC/Q/kk317JvpyrCGP7R5sM6KEzoq3itdvKCR8Z7r4WN5gXbstHqUc8iUjERqRGh MIME-Version: 1.0 X-Received: by 10.107.153.8 with SMTP id b8mr292932ioe.3.1431124183214; Fri, 08 May 2015 15:29:43 -0700 (PDT) Received: by 10.36.159.68 with HTTP; Fri, 8 May 2015 15:29:43 -0700 (PDT) In-Reply-To: <1431119989-32124-1-git-send-email-rkerur@gmail.com> References: <1431119946-32078-1-git-send-email-rkerur@gmail.com> <1431119989-32124-1-git-send-email-rkerur@gmail.com> Date: Fri, 8 May 2015 17:29:43 -0500 Message-ID: From: Matt Laswell To: Ravi Kerur Content-Type: text/plain; charset=UTF-8 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:29:44 -0000 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? -- Matt Laswell infinite io, inc. laswell@infiniteio.com