From patchwork Thu Oct 25 17:20:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 10656293 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B85B213B5 for ; Thu, 25 Oct 2018 17:49:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A81A22BED9 for ; Thu, 25 Oct 2018 17:49:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A8F92C2A3; Thu, 25 Oct 2018 17:49:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 351552BED9 for ; Thu, 25 Oct 2018 17:49:39 +0000 (UTC) Received: from localhost ([::1]:56153 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFjlK-0000q0-72 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Oct 2018 13:49:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFjKm-0006hj-D5 for qemu-devel@nongnu.org; Thu, 25 Oct 2018 13:22:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFjKJ-00007y-24 for qemu-devel@nongnu.org; Thu, 25 Oct 2018 13:21:44 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:58607) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gFjKH-0008QE-5R for qemu-devel@nongnu.org; Thu, 25 Oct 2018 13:21:41 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 1255E2217B; Thu, 25 Oct 2018 13:21:10 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 25 Oct 2018 13:21:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=2UHt0Q44vKeSkx7tBqripzHNqohH5jICgeUlXxutG3s=; b=Vt6su JWNsQyxopkC/4V0UiqSJb0vjkHmxLip7RQH/u04rBBA+Z1NeaXIu3I6aYPCNtQ1r eSUOSHjhXGJwcQSf5HSHHHjArT5YNAWLvTztZR5iBqvVLOSdI+UKNiYbmXhAdOAZ YxnzyKX6X3ziv+nmYx3yaU6zv7dHmyXwpC1s3U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=2UHt0Q44vKeSkx7tBqripzHNqohH5 jICgeUlXxutG3s=; b=mDSQBXMWp+hZrwHUqTh2JDHUz7Qi2O/7l0Z8cpphmTGRq aDphaZyzIE8PGtVb8zO1d87eDTPMyq1NrRsrSIKodNQQZemXBxrcLLKf5J6B5D1v 6p4Z7es3Du3qS8n82+/Wy45R8YKGckL3wu1Oa+eiCoIRJCliuK9jXGEhy6QQbwbb FMKoKjZ5UhcqyUz70GiuVhrQW4EphkeP70F7OWVbzoAPXYB01qlmk5Ef7dDqZwun sdmKgZe89cay+Srpyh2FNm7dD0k1fQldTNR1FrahSOc1o7kqmYjNag9ypMwnU32A +zuOOyeMEHKNnU6SEsPk+9mgmivsI+lx2r0WGr+Tw== X-ME-Sender: X-ME-Proxy: Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id A72FDE455F; Thu, 25 Oct 2018 13:21:09 -0400 (EDT) From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Thu, 25 Oct 2018 13:20:22 -0400 Message-Id: <20181025172057.20414-14-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025172057.20414-1-cota@braap.org> References: <20181025172057.20414-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 Subject: [Qemu-devel] [RFC 13/48] xxhash: add qemu_xxhash8 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Llu=C3=ADs?= =?utf-8?q?_Vilanova?= , Pavel Dovgalyuk , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP It will be used for TB hashing soon. Signed-off-by: Emilio G. Cota --- include/qemu/xxhash.h | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/include/qemu/xxhash.h b/include/qemu/xxhash.h index fe35dde328..450427eeaa 100644 --- a/include/qemu/xxhash.h +++ b/include/qemu/xxhash.h @@ -49,7 +49,8 @@ * contiguous in memory. */ static inline uint32_t -qemu_xxhash7(uint64_t ab, uint64_t cd, uint32_t e, uint32_t f, uint32_t g) +qemu_xxhash8(uint64_t ab, uint64_t cd, uint32_t e, uint32_t f, uint32_t g, + uint32_t h) { uint32_t v1 = QEMU_XXHASH_SEED + PRIME32_1 + PRIME32_2; uint32_t v2 = QEMU_XXHASH_SEED + PRIME32_2; @@ -77,17 +78,24 @@ qemu_xxhash7(uint64_t ab, uint64_t cd, uint32_t e, uint32_t f, uint32_t g) v4 = rol32(v4, 13); v4 *= PRIME32_1; - h32 = rol32(v1, 1) + rol32(v2, 7) + rol32(v3, 12) + rol32(v4, 18); - h32 += 28; + v1 += e * PRIME32_2; + v1 = rol32(v1, 13); + v1 *= PRIME32_1; - h32 += e * PRIME32_3; - h32 = rol32(h32, 17) * PRIME32_4; + v2 += f * PRIME32_2; + v2 = rol32(v2, 13); + v2 *= PRIME32_1; + + v3 += g * PRIME32_2; + v3 = rol32(v3, 13); + v3 *= PRIME32_1; - h32 += f * PRIME32_3; - h32 = rol32(h32, 17) * PRIME32_4; + v4 += h * PRIME32_2; + v4 = rol32(v4, 13); + v4 *= PRIME32_1; - h32 += g * PRIME32_3; - h32 = rol32(h32, 17) * PRIME32_4; + h32 = rol32(v1, 1) + rol32(v2, 7) + rol32(v3, 12) + rol32(v4, 18); + h32 += 32; h32 ^= h32 >> 15; h32 *= PRIME32_2; @@ -100,23 +108,29 @@ qemu_xxhash7(uint64_t ab, uint64_t cd, uint32_t e, uint32_t f, uint32_t g) static inline uint32_t qemu_xxhash2(uint64_t ab) { - return qemu_xxhash7(ab, 0, 0, 0, 0); + return qemu_xxhash8(ab, 0, 0, 0, 0, 0); } static inline uint32_t qemu_xxhash4(uint64_t ab, uint64_t cd) { - return qemu_xxhash7(ab, cd, 0, 0, 0); + return qemu_xxhash8(ab, cd, 0, 0, 0, 0); } static inline uint32_t qemu_xxhash5(uint64_t ab, uint64_t cd, uint32_t e) { - return qemu_xxhash7(ab, cd, e, 0, 0); + return qemu_xxhash8(ab, cd, e, 0, 0, 0); } static inline uint32_t qemu_xxhash6(uint64_t ab, uint64_t cd, uint32_t e, uint32_t f) { - return qemu_xxhash7(ab, cd, e, f, 0); + return qemu_xxhash8(ab, cd, e, f, 0, 0); +} + +static inline uint32_t qemu_xxhash7(uint64_t ab, uint64_t cd, uint32_t e, + uint32_t f, uint32_t g) +{ + return qemu_xxhash8(ab, cd, e, f, g, 0); } #endif /* QEMU_XXHASH_H */