provide crc32 functions based on intrinsics for MSVC
PATCH 1/1 provide crc32 functions based on intrinsics for MSVC
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(-)
Signature · 1 line
1.8.3.1
PATCH 1/1 hash: provide crc32 functions based on intrinsics
Provide crc32 inline functions implemented using intrinsics for MSVC.
--- lib/hash/rte_crc_x86.h | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-)
lib/hash/rte_crc_x86.h +36 -10
@@ -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
Signature · 1 line
1.8.3.1
Re: [PATCH] hash: provide crc32 functions based on intrinsics
20/03/2024 22:28, Tyler Retzlaff:
Quoted 1 line
Provide crc32 inline functions implemented using intrinsics for MSVC.
This is replacing asm.
Could we completely replace asm, avoiding the #ifdef?
PATCH v2 1/1 hash: provide crc32 functions based on intrinsics
In reply to Tyler RetzlaffMSVC 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(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/1 hash: provide crc32 functions based on intrinsics
MSVC does not support inline asm so replace crc32 inline function implementations with intrinsics compatible with all toolchains.
--- lib/hash/rte_crc_x86.h | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-)
lib/hash/rte_crc_x86.h +13 -25
@@ -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
Signature · 1 line
1.8.3.1
Re: [PATCH v2] hash: provide crc32 functions based on intrinsics
Quoted 5 lines · On Tue, 21 May 2024 17:02:14 -0700 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 <[email protected]>---
always good to remove asm since in tends not to get optimized.
Morten Brørup
Acked-byRE: [PATCH v2] hash: provide crc32 functions based on intrinsics
Quoted 9 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Wednesday, 22 May 2024 04.21Quoted 3 lines · On Tue, 21 May 2024 17:02:14 -0700 Tyler Retzlaff…
MSVC does not support inline asm so replace crc32 inline function implementations with intrinsics compatible with all toolchains.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Tyler Retzlaff <[email protected]>---
always good to remove asm since in tends not to get optimized.
Thomas Monjalon
AppliedRe: [PATCH v2] hash: provide crc32 functions based on intrinsics
22/05/2024 10:36, Morten Brørup:
Quoted 9 lines
Quoted 9 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Wednesday, 22 May 2024 04.21Quoted 3 lines · On Tue, 21 May 2024 17:02:14 -0700 Tyler Retzlaff…
MSVC does not support inline asm so replace crc32 inline function implementations with intrinsics compatible with all toolchains.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Tyler Retzlaff <[email protected]>always good to remove asm since in tends not to get optimized.
Acked-by Morten Brørup <[email protected]>
Applied, thanks.