All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>,
	Sameh Gobriel <sameh.gobriel@intel.com>,
	Vladimir Medvedkin <vladimir.medvedkin@intel.com>,
	Yipeng Wang <yipeng1.wang@intel.com>,
	Tyler Retzlaff <roretzla@linux.microsoft.com>
Subject: [PATCH] hash: provide crc32 functions based on intrinsics
Date: Wed, 20 Mar 2024 14:28:47 -0700	[thread overview]
Message-ID: <1710970127-25938-2-git-send-email-roretzla@linux.microsoft.com> (raw)
In-Reply-To: <1710970127-25938-1-git-send-email-roretzla@linux.microsoft.com>

Provide crc32 inline functions implemented using intrinsics for MSVC.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/hash/rte_crc_x86.h | 46 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 36 insertions(+), 10 deletions(-)

diff --git a/lib/hash/rte_crc_x86.h b/lib/hash/rte_crc_x86.h
index 3b865e2..b2ac07f 100644
--- a/lib/hash/rte_crc_x86.h
+++ b/lib/hash/rte_crc_x86.h
@@ -5,6 +5,31 @@
 #ifndef _RTE_CRC_X86_H_
 #define _RTE_CRC_X86_H_
 
+#ifdef RTE_TOOLCHAIN_MSVC
+static inline uint32_t
+crc32c_sse42_u8(uint8_t data, uint32_t init_val)
+{
+	return _mm_crc32_u8(init_val, data);
+}
+
+static inline uint32_t
+crc32c_sse42_u16(uint16_t data, uint32_t init_val)
+{
+	return _mm_crc32_u16(init_val, data);
+}
+
+static inline uint32_t
+crc32c_sse42_u32(uint32_t data, uint32_t init_val)
+{
+	return _mm_crc32_u32(init_val, data);
+}
+
+static inline uint32_t
+crc32c_sse42_u64(uint64_t data, uint64_t init_val)
+{
+	return _mm_crc32_u64(init_val, data);
+}
+#else
 static inline uint32_t
 crc32c_sse42_u8(uint8_t data, uint32_t init_val)
 {
@@ -36,6 +61,17 @@
 }
 
 static inline uint32_t
+crc32c_sse42_u64(uint64_t data, uint64_t init_val)
+{
+	__asm__ volatile(
+			"crc32q %[data], %[init_val];"
+			: [init_val] "+r" (init_val)
+			: [data] "rm" (data));
+	return (uint32_t)init_val;
+}
+#endif
+
+static inline uint32_t
 crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val)
 {
 	union {
@@ -49,16 +85,6 @@
 	return (uint32_t)init_val;
 }
 
-static inline uint32_t
-crc32c_sse42_u64(uint64_t data, uint64_t init_val)
-{
-	__asm__ volatile(
-			"crc32q %[data], %[init_val];"
-			: [init_val] "+r" (init_val)
-			: [data] "rm" (data));
-	return (uint32_t)init_val;
-}
-
 /*
  * Use single crc32 instruction to perform a hash on a byte value.
  * Fall back to software crc32 implementation in case SSE4.2 is
-- 
1.8.3.1


  reply	other threads:[~2024-03-20 21:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20 21:28 [PATCH] provide crc32 functions based on intrinsics for MSVC Tyler Retzlaff
2024-03-20 21:28 ` Tyler Retzlaff [this message]
2024-05-16 17:04   ` [PATCH] hash: provide crc32 functions based on intrinsics Thomas Monjalon
2024-05-22  0:02   ` [PATCH v2] " Tyler Retzlaff
2024-05-22  0:02     ` Tyler Retzlaff
2024-05-22  2:21       ` Stephen Hemminger
2024-05-22  8:36         ` Morten Brørup
2024-05-26 15:07           ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1710970127-25938-2-git-send-email-roretzla@linux.microsoft.com \
    --to=roretzla@linux.microsoft.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=sameh.gobriel@intel.com \
    --cc=vladimir.medvedkin@intel.com \
    --cc=yipeng1.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.