* [PATCH] provide crc32 functions based on intrinsics for MSVC
@ 2024-03-20 21:28 Tyler Retzlaff
2024-03-20 21:28 ` [PATCH] hash: provide crc32 functions based on intrinsics Tyler Retzlaff
0 siblings, 1 reply; 8+ messages in thread
From: Tyler Retzlaff @ 2024-03-20 21:28 UTC (permalink / raw)
To: dev
Cc: Bruce Richardson, Sameh Gobriel, Vladimir Medvedkin, Yipeng Wang,
Tyler Retzlaff
MSVC does not support inline assembly so provide crc32 functions
using intrinsics.
Tyler Retzlaff (1):
hash: provide crc32 functions based on intrinsics
lib/hash/rte_crc_x86.h | 46 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 36 insertions(+), 10 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] hash: provide crc32 functions based on intrinsics
2024-03-20 21:28 [PATCH] provide crc32 functions based on intrinsics for MSVC Tyler Retzlaff
@ 2024-03-20 21:28 ` Tyler Retzlaff
2024-05-16 17:04 ` Thomas Monjalon
2024-05-22 0:02 ` [PATCH v2] " Tyler Retzlaff
0 siblings, 2 replies; 8+ messages in thread
From: Tyler Retzlaff @ 2024-03-20 21:28 UTC (permalink / raw)
To: dev
Cc: Bruce Richardson, Sameh Gobriel, Vladimir Medvedkin, Yipeng Wang,
Tyler Retzlaff
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] hash: provide crc32 functions based on intrinsics
2024-03-20 21:28 ` [PATCH] hash: provide crc32 functions based on intrinsics Tyler Retzlaff
@ 2024-05-16 17:04 ` Thomas Monjalon
2024-05-22 0:02 ` [PATCH v2] " Tyler Retzlaff
1 sibling, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2024-05-16 17:04 UTC (permalink / raw)
To: Tyler Retzlaff
Cc: dev, Bruce Richardson, Sameh Gobriel, Vladimir Medvedkin, Yipeng Wang
20/03/2024 22:28, Tyler Retzlaff:
> Provide crc32 inline functions implemented using intrinsics for MSVC.
This is replacing asm.
Could we completely replace asm, avoiding the #ifdef?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] hash: provide crc32 functions based on intrinsics
2024-03-20 21:28 ` [PATCH] hash: provide crc32 functions based on intrinsics Tyler Retzlaff
2024-05-16 17:04 ` Thomas Monjalon
@ 2024-05-22 0:02 ` Tyler Retzlaff
2024-05-22 0:02 ` Tyler Retzlaff
1 sibling, 1 reply; 8+ messages in thread
From: Tyler Retzlaff @ 2024-05-22 0:02 UTC (permalink / raw)
To: dev
Cc: Bruce Richardson, Sameh Gobriel, Vladimir Medvedkin, Yipeng Wang,
Tyler Retzlaff
MSVC does not support inline asm so replace crc32 inline function
implementations with intrinsics compatible with all toolchains.
v2:
* just provide inline functions based on intrinsics and remove
inline asm versions.
Tyler Retzlaff (1):
hash: provide crc32 functions based on intrinsics
lib/hash/rte_crc_x86.h | 38 +++++++++++++-------------------------
1 file changed, 13 insertions(+), 25 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] hash: provide crc32 functions based on intrinsics
2024-05-22 0:02 ` [PATCH v2] " Tyler Retzlaff
@ 2024-05-22 0:02 ` Tyler Retzlaff
2024-05-22 2:21 ` Stephen Hemminger
0 siblings, 1 reply; 8+ messages in thread
From: Tyler Retzlaff @ 2024-05-22 0:02 UTC (permalink / raw)
To: dev
Cc: Bruce Richardson, Sameh Gobriel, Vladimir Medvedkin, Yipeng Wang,
Tyler Retzlaff
MSVC does not support inline asm so replace crc32 inline function
implementations with intrinsics compatible with all toolchains.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
lib/hash/rte_crc_x86.h | 38 +++++++++++++-------------------------
1 file changed, 13 insertions(+), 25 deletions(-)
diff --git a/lib/hash/rte_crc_x86.h b/lib/hash/rte_crc_x86.h
index 3b865e2..eadfe42 100644
--- a/lib/hash/rte_crc_x86.h
+++ b/lib/hash/rte_crc_x86.h
@@ -5,35 +5,33 @@
#ifndef _RTE_CRC_X86_H_
#define _RTE_CRC_X86_H_
+#include <rte_vect.h>
+
static inline uint32_t
crc32c_sse42_u8(uint8_t data, uint32_t init_val)
{
- __asm__ volatile(
- "crc32b %[data], %[init_val];"
- : [init_val] "+r" (init_val)
- : [data] "rm" (data));
- return init_val;
+ return _mm_crc32_u8(init_val, data);
}
static inline uint32_t
crc32c_sse42_u16(uint16_t data, uint32_t init_val)
{
- __asm__ volatile(
- "crc32w %[data], %[init_val];"
- : [init_val] "+r" (init_val)
- : [data] "rm" (data));
- return init_val;
+ return _mm_crc32_u16(init_val, data);
}
static inline uint32_t
crc32c_sse42_u32(uint32_t data, uint32_t init_val)
{
- __asm__ volatile(
- "crc32l %[data], %[init_val];"
- : [init_val] "+r" (init_val)
- : [data] "rm" (data));
- return init_val;
+ return _mm_crc32_u32(init_val, data);
+}
+
+#ifdef RTE_ARCH_X86_64
+static inline uint32_t
+crc32c_sse42_u64(uint64_t data, uint64_t init_val)
+{
+ return _mm_crc32_u64(init_val, data);
}
+#endif
static inline uint32_t
crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val)
@@ -49,16 +47,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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] hash: provide crc32 functions based on intrinsics
2024-05-22 0:02 ` Tyler Retzlaff
@ 2024-05-22 2:21 ` Stephen Hemminger
2024-05-22 8:36 ` Morten Brørup
0 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2024-05-22 2:21 UTC (permalink / raw)
To: Tyler Retzlaff
Cc: dev, Bruce Richardson, Sameh Gobriel, Vladimir Medvedkin, Yipeng Wang
On Tue, 21 May 2024 17:02:14 -0700
Tyler Retzlaff <roretzla@linux.microsoft.com> wrote:
> MSVC does not support inline asm so replace crc32 inline function
> implementations with intrinsics compatible with all toolchains.
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
always good to remove asm since in tends not to get optimized.
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH v2] hash: provide crc32 functions based on intrinsics
2024-05-22 2:21 ` Stephen Hemminger
@ 2024-05-22 8:36 ` Morten Brørup
2024-05-26 15:07 ` Thomas Monjalon
0 siblings, 1 reply; 8+ messages in thread
From: Morten Brørup @ 2024-05-22 8:36 UTC (permalink / raw)
To: Stephen Hemminger, Tyler Retzlaff
Cc: dev, Bruce Richardson, Sameh Gobriel, Vladimir Medvedkin, Yipeng Wang
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Wednesday, 22 May 2024 04.21
>
> On Tue, 21 May 2024 17:02:14 -0700
> Tyler Retzlaff <roretzla@linux.microsoft.com> wrote:
>
> > MSVC does not support inline asm so replace crc32 inline function
> > implementations with intrinsics compatible with all toolchains.
> >
> > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > ---
>
> always good to remove asm since in tends not to get optimized.
>
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] hash: provide crc32 functions based on intrinsics
2024-05-22 8:36 ` Morten Brørup
@ 2024-05-26 15:07 ` Thomas Monjalon
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2024-05-26 15:07 UTC (permalink / raw)
To: Tyler Retzlaff
Cc: Stephen Hemminger, dev, Bruce Richardson, Sameh Gobriel,
Vladimir Medvedkin, Yipeng Wang, Morten Brørup
22/05/2024 10:36, Morten Brørup:
> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > Sent: Wednesday, 22 May 2024 04.21
> >
> > On Tue, 21 May 2024 17:02:14 -0700
> > Tyler Retzlaff <roretzla@linux.microsoft.com> wrote:
> >
> > > MSVC does not support inline asm so replace crc32 inline function
> > > implementations with intrinsics compatible with all toolchains.
> > >
> > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> >
> > always good to remove asm since in tends not to get optimized.
> >
> > Acked-by: Stephen Hemminger <stephen@networkplumber.org>
>
> Acked-by: Morten Brørup <mb@smartsharesystems.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-05-26 15:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-20 21:28 [PATCH] provide crc32 functions based on intrinsics for MSVC Tyler Retzlaff
2024-03-20 21:28 ` [PATCH] hash: provide crc32 functions based on intrinsics Tyler Retzlaff
2024-05-16 17:04 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).