[dpdk-dev,1/3] librte_hash: Fix unsupported instruction `crc32' in i686 platform

Message ID 1425561339-13300-2-git-send-email-michael.qiu@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Michael Qiu March 5, 2015, 1:15 p.m. UTC
  CC rte_hash.o
Error: unsupported instruction `crc32'

The root cause is that i686 platform does not support 'crc32q'
Need make it only available in x86_64 platform

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
---
 lib/librte_hash/rte_hash_crc.h | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Yerden Zhumabekov March 5, 2015, 4:10 p.m. UTC | #1
Hi Michael,

Thanks for this patch, in fact I didn't try to compile it on i686 when
developing original software fallback for CRC32.

I think if we want to make code compilable as wide as possible, we
should compile out all SSE4.2 instructions. As to the patch, we may
compile out 'crc32l' instruction emitting code if the arch is not x86.
This concerns two functions: crc32c_sse42_u32() and
crc32c_sse42_u64_mimic().

The compile check might be something like this:

#if defined(RTE_ARCH_I686) || defined(RTE_ARCH_X86_64)
#endif

Otherwise, the patch looks good.

05.03.2015 19:15, Michael Qiu пишет:
> CC rte_hash.o
> Error: unsupported instruction `crc32'
>
> The root cause is that i686 platform does not support 'crc32q'
> Need make it only available in x86_64 platform
>
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
>  lib/librte_hash/rte_hash_crc.h | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/lib/librte_hash/rte_hash_crc.h b/lib/librte_hash/rte_hash_crc.h
> index d28bb2a..4e9546f 100644
> --- a/lib/librte_hash/rte_hash_crc.h
> +++ b/lib/librte_hash/rte_hash_crc.h
> @@ -374,6 +374,7 @@ crc32c_sse42_u32(uint32_t data, uint32_t init_val)
>  	return init_val;
>  }
>  
> +#ifdef RTE_ARCH_X86_64
>  static inline uint32_t
>  crc32c_sse42_u64(uint64_t data, uint64_t init_val)
>  {
> @@ -383,6 +384,7 @@ crc32c_sse42_u64(uint64_t data, uint64_t init_val)
>  			: [data] "rm" (data));
>  	return init_val;
>  }
> +#endif
>  
>  static inline uint32_t
>  crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val)
> @@ -476,8 +478,10 @@ rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
>  static inline uint32_t
>  rte_hash_crc_8byte(uint64_t data, uint32_t init_val)
>  {
> +#ifdef RTE_ARCH_X86_64
>  	if (likely(crc32_alg == CRC32_SSE42_x64))
>  		return crc32c_sse42_u64(data, init_val);
> +#endif
>  
>  	if (likely(crc32_alg & CRC32_SSE42))
>  		return crc32c_sse42_u64_mimic(data, init_val);
  
Michael Qiu March 5, 2015, 4:34 p.m. UTC | #2
On 2015/3/6 0:12, Yerden Zhumabekov wrote:
> Hi Michael,
>
> Thanks for this patch, in fact I didn't try to compile it on i686 when
> developing original software fallback for CRC32.
>
> I think if we want to make code compilable as wide as possible, we
> should compile out all SSE4.2 instructions. As to the patch, we may
> compile out 'crc32l' instruction emitting code if the arch is not x86.
> This concerns two functions: crc32c_sse42_u32() and
> crc32c_sse42_u64_mimic().

OK, I will add the check for crc32l, make it only works for x86

Thanks,
Michael
> The compile check might be something like this:
>
> #if defined(RTE_ARCH_I686) || defined(RTE_ARCH_X86_64)
> #endif
>
> Otherwise, the patch looks good.
>
> 05.03.2015 19:15, Michael Qiu пишет:
>> CC rte_hash.o
>> Error: unsupported instruction `crc32'
>>
>> The root cause is that i686 platform does not support 'crc32q'
>> Need make it only available in x86_64 platform
>>
>> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
>> ---
>>  lib/librte_hash/rte_hash_crc.h | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/lib/librte_hash/rte_hash_crc.h b/lib/librte_hash/rte_hash_crc.h
>> index d28bb2a..4e9546f 100644
>> --- a/lib/librte_hash/rte_hash_crc.h
>> +++ b/lib/librte_hash/rte_hash_crc.h
>> @@ -374,6 +374,7 @@ crc32c_sse42_u32(uint32_t data, uint32_t init_val)
>>  	return init_val;
>>  }
>>  
>> +#ifdef RTE_ARCH_X86_64
>>  static inline uint32_t
>>  crc32c_sse42_u64(uint64_t data, uint64_t init_val)
>>  {
>> @@ -383,6 +384,7 @@ crc32c_sse42_u64(uint64_t data, uint64_t init_val)
>>  			: [data] "rm" (data));
>>  	return init_val;
>>  }
>> +#endif
>>  
>>  static inline uint32_t
>>  crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val)
>> @@ -476,8 +478,10 @@ rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
>>  static inline uint32_t
>>  rte_hash_crc_8byte(uint64_t data, uint32_t init_val)
>>  {
>> +#ifdef RTE_ARCH_X86_64
>>  	if (likely(crc32_alg == CRC32_SSE42_x64))
>>  		return crc32c_sse42_u64(data, init_val);
>> +#endif
>>  
>>  	if (likely(crc32_alg & CRC32_SSE42))
>>  		return crc32c_sse42_u64_mimic(data, init_val);
  

Patch

diff --git a/lib/librte_hash/rte_hash_crc.h b/lib/librte_hash/rte_hash_crc.h
index d28bb2a..4e9546f 100644
--- a/lib/librte_hash/rte_hash_crc.h
+++ b/lib/librte_hash/rte_hash_crc.h
@@ -374,6 +374,7 @@  crc32c_sse42_u32(uint32_t data, uint32_t init_val)
 	return init_val;
 }
 
+#ifdef RTE_ARCH_X86_64
 static inline uint32_t
 crc32c_sse42_u64(uint64_t data, uint64_t init_val)
 {
@@ -383,6 +384,7 @@  crc32c_sse42_u64(uint64_t data, uint64_t init_val)
 			: [data] "rm" (data));
 	return init_val;
 }
+#endif
 
 static inline uint32_t
 crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val)
@@ -476,8 +478,10 @@  rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_8byte(uint64_t data, uint32_t init_val)
 {
+#ifdef RTE_ARCH_X86_64
 	if (likely(crc32_alg == CRC32_SSE42_x64))
 		return crc32c_sse42_u64(data, init_val);
+#endif
 
 	if (likely(crc32_alg & CRC32_SSE42))
 		return crc32c_sse42_u64_mimic(data, init_val);