From: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, david.marchand@redhat.com,
konstantin.ananyev@intel.com, lance.richardson@broadcom.com,
vladimir.medvedkin@intel.com, Ji@dpdk.org, Kai <kai.ji@intel.com>,
Yipeng Wang <yipeng1.wang@intel.com>,
Sameh Gobriel <sameh.gobriel@intel.com>,
Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH v2] hash: fix thash gfni implementation
Date: Fri, 12 Nov 2021 14:17:19 +0000 [thread overview]
Message-ID: <20211112141719.232932-1-vladimir.medvedkin@intel.com> (raw)
In-Reply-To: <20211109172456.147140-1-vladimir.medvedkin@intel.com>
1. This patch replaces _mm512_set_epi8 with _mm512_set_epi32
due to the lack of support by some compilers.
2. This patch checks if AVX512F is supported along with GFNI.
This is done if the code is built on a platform that supports GFNI,
but does not support AVX512.
3. Also this patch fixes compilation problems on 32bit arch due to
lack of support for _mm_extract_epi64() by implementing XOR folding
with _mm_extract_epi32() on 32-bit arch.
Fixes: 4fd8c4cb0de1 ("hash: add new Toeplitz hash implementation")
Cc: vladimir.medvedkin@intel.com
Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Acked-by: Lance Richardson <lance.richardson@broadcom.com>
Acked-by: Ji, Kai <kai.ji@intel.com>
---
lib/hash/rte_thash_x86_gfni.h | 44 ++++++++++++++++++++---------------
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/lib/hash/rte_thash_x86_gfni.h b/lib/hash/rte_thash_x86_gfni.h
index c2889c3734..987dec4988 100644
--- a/lib/hash/rte_thash_x86_gfni.h
+++ b/lib/hash/rte_thash_x86_gfni.h
@@ -18,7 +18,7 @@
extern "C" {
#endif
-#ifdef __GFNI__
+#if defined(__GFNI__) && defined(__AVX512F__)
#define RTE_THASH_GFNI_DEFINED
#define RTE_THASH_FIRST_ITER_MSK 0x0f0f0f0f0f0e0c08
@@ -33,7 +33,6 @@ __rte_thash_xor_reduce(__m512i xor_acc, uint32_t *val_1, uint32_t *val_2)
{
__m256i tmp_256_1, tmp_256_2;
__m128i tmp128_1, tmp128_2;
- uint64_t tmp_1, tmp_2;
tmp_256_1 = _mm512_castsi512_si256(xor_acc);
tmp_256_2 = _mm512_extracti32x8_epi32(xor_acc, 1);
@@ -43,12 +42,24 @@ __rte_thash_xor_reduce(__m512i xor_acc, uint32_t *val_1, uint32_t *val_2)
tmp128_2 = _mm256_extracti32x4_epi32(tmp_256_1, 1);
tmp128_1 = _mm_xor_si128(tmp128_1, tmp128_2);
+#ifdef RTE_ARCH_X86_64
+ uint64_t tmp_1, tmp_2;
tmp_1 = _mm_extract_epi64(tmp128_1, 0);
tmp_2 = _mm_extract_epi64(tmp128_1, 1);
tmp_1 ^= tmp_2;
*val_1 = (uint32_t)tmp_1;
*val_2 = (uint32_t)(tmp_1 >> 32);
+#else
+ uint32_t tmp_1, tmp_2;
+ tmp_1 = _mm_extract_epi32(tmp128_1, 0);
+ tmp_2 = _mm_extract_epi32(tmp128_1, 1);
+ tmp_1 ^= _mm_extract_epi32(tmp128_1, 2);
+ tmp_2 ^= _mm_extract_epi32(tmp128_1, 3);
+
+ *val_1 = tmp_1;
+ *val_2 = tmp_2;
+#endif
}
__rte_internal
@@ -56,23 +67,18 @@ static inline __m512i
__rte_thash_gfni(const uint64_t *mtrx, const uint8_t *tuple,
const uint8_t *secondary_tuple, int len)
{
- __m512i permute_idx = _mm512_set_epi8(7, 6, 5, 4, 7, 6, 5, 4,
- 6, 5, 4, 3, 6, 5, 4, 3,
- 5, 4, 3, 2, 5, 4, 3, 2,
- 4, 3, 2, 1, 4, 3, 2, 1,
- 3, 2, 1, 0, 3, 2, 1, 0,
- 2, 1, 0, -1, 2, 1, 0, -1,
- 1, 0, -1, -2, 1, 0, -1, -2,
- 0, -1, -2, -3, 0, -1, -2, -3);
-
- const __m512i rewind_idx = _mm512_set_epi8(0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 59, 0, 0, 0, 59,
- 0, 0, 59, 58, 0, 0, 59, 58,
- 0, 59, 58, 57, 0, 59, 58, 57);
+ __m512i permute_idx = _mm512_set_epi32(0x7060504, 0x7060504,
+ 0x6050403, 0x6050403,
+ 0x5040302, 0x5040302,
+ 0x4030201, 0x4030201,
+ 0x3020100, 0x3020100,
+ 0x20100FF, 0x20100FF,
+ 0x100FFFE, 0x100FFFE,
+ 0xFFFEFD, 0xFFFEFD);
+ const __m512i rewind_idx = _mm512_set_epi32(0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3B, 0x3B,
+ 0x3B3A, 0x3B3A,
+ 0x3B3A39, 0x3B3A39);
const __mmask64 rewind_mask = RTE_THASH_REWIND_MSK;
const __m512i shift_8 = _mm512_set1_epi8(8);
__m512i xor_acc = _mm512_setzero_si512();
--
2.25.1
next prev parent reply other threads:[~2021-11-12 14:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-09 17:24 [dpdk-dev] [PATCH] " Vladimir Medvedkin
2021-11-09 17:34 ` Lance Richardson
2021-11-09 18:08 ` Ji, Kai
2021-11-12 14:17 ` Vladimir Medvedkin [this message]
2021-11-16 13:53 ` [PATCH v2] " David Marchand
2021-11-16 14:08 ` Walsh, Conor
2021-11-16 14:10 ` Bruce Richardson
2021-11-16 14:17 ` David Marchand
2021-11-16 14:18 ` Medvedkin, Vladimir
2021-11-16 14:33 ` [PATCH v3] " Vladimir Medvedkin
2021-11-17 9:20 ` David Marchand
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=20211112141719.232932-1-vladimir.medvedkin@intel.com \
--to=vladimir.medvedkin@intel.com \
--cc=Ji@dpdk.org \
--cc=bruce.richardson@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=kai.ji@intel.com \
--cc=konstantin.ananyev@intel.com \
--cc=lance.richardson@broadcom.com \
--cc=sameh.gobriel@intel.com \
--cc=thomas@monjalon.net \
--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 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).