DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] hash: reverse the operand order to crc32 in rte_hash_crc.h
@ 2014-02-25 10:07 H. Peter Anvin
  2014-02-25 10:57 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: H. Peter Anvin @ 2014-02-25 10:07 UTC (permalink / raw)
  To: dev; +Cc: H. Peter Anvin

From: "H. Peter Anvin" <hpa@linux.intel.com>

Checkin

a132a9cf2bcd440a974b9d3f5c44ba30b2c895a1 hash: use intrinsic

changed the rte_hash_crc.h from using the crc32 instruction via inline
assembly to using an intrinsic.  The intrinsic should allow for better
compiler performance, but the change did not account for the fact that
the inline assembly being in AT&T syntax used the opposite operand
order of the intrinsic.

This turns out to not matter for correctness, because the CRC32
operation is commutative.  However, it could potentially matter for
performance, because the loop is more efficient with the moving
pointer in the source operand and the accumulation in the destination
operand.

This was discovered by Jan Beulich when looking at the equivalent code
in the Linux kernel.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 lib/librte_hash/rte_hash_crc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_hash/rte_hash_crc.h b/lib/librte_hash/rte_hash_crc.h
index f10f139..1b9481e 100644
--- a/lib/librte_hash/rte_hash_crc.h
+++ b/lib/librte_hash/rte_hash_crc.h
@@ -60,7 +60,7 @@ extern "C" {
 static inline uint32_t
 rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 {
-	return _mm_crc32_u32(data, init_val);
+	return _mm_crc32_u32(init_val, data);
 }
 
 /**
-- 
1.8.5.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] hash: reverse the operand order to crc32 in rte_hash_crc.h
  2014-02-25 10:07 [dpdk-dev] [PATCH] hash: reverse the operand order to crc32 in rte_hash_crc.h H. Peter Anvin
@ 2014-02-25 10:57 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2014-02-25 10:57 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: dev

25/02/2014 11:07, H. Peter Anvin:
> From: "H. Peter Anvin" <hpa@linux.intel.com>
> 
> Checkin
> 
> a132a9cf2bcd440a974b9d3f5c44ba30b2c895a1 hash: use intrinsic
> 
> changed the rte_hash_crc.h from using the crc32 instruction via inline
> assembly to using an intrinsic.  The intrinsic should allow for better
> compiler performance, but the change did not account for the fact that
> the inline assembly being in AT&T syntax used the opposite operand
> order of the intrinsic.
> 
> This turns out to not matter for correctness, because the CRC32
> operation is commutative.  However, it could potentially matter for
> performance, because the loop is more efficient with the moving
> pointer in the source operand and the accumulation in the destination
> operand.
> 
> This was discovered by Jan Beulich when looking at the equivalent code
> in the Linux kernel.
> 
> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>

It was also reported by Pashupati Kumar <kumarp@brocade.com>.

Acked and applied.
Thanks
-- 
Thomas

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-25 10:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-25 10:07 [dpdk-dev] [PATCH] hash: reverse the operand order to crc32 in rte_hash_crc.h H. Peter Anvin
2014-02-25 10:57 ` 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).