DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH 02/11] test/thash_perf: test gfni thash when platform supports
Date: Tue,  1 Dec 2026 15:16:14 +0000	[thread overview]
Message-ID: <20261201151623.2240031-3-bruce.richardson@intel.com> (raw)
In-Reply-To: <20261201151623.2240031-1-bruce.richardson@intel.com>

The current thash performance tests only test the gfni thash functions
when the max SIMD bitwidth is set to 512. To increase test coverage -
and visibility of the perf benefits the functions provide - increase the
max SIMD bitwidth automatically when the test is run on a supporting
platform, and the build has gfni enabled.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/test/test_thash_perf.c | 39 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/app/test/test_thash_perf.c b/app/test/test_thash_perf.c
index 9dfd5d3c21..9d391fd296 100644
--- a/app/test/test_thash_perf.c
+++ b/app/test/test_thash_perf.c
@@ -7,10 +7,12 @@
 #include <stdlib.h>
 #include <math.h>
 
+#include <rte_cpuflags.h>
 #include <rte_cycles.h>
 #include <rte_malloc.h>
 #include <rte_random.h>
 #include <rte_thash.h>
+#include <rte_vect.h>
 
 #include "test.h"
 
@@ -92,6 +94,10 @@ run_thash_test(unsigned int tuple_len)
 	uint32_t len = RTE_ALIGN_CEIL(tuple_len, sizeof(uint32_t));
 	uint64_t tsc_diff;
 
+	/* with GFNI each length reports four results, so separate the groups */
+	if (rte_thash_gfni_supported())
+		printf("\n--- key len %u ---\n", len);
+
 	for (i = 0; i < BATCH_SZ; i++) {
 		tuples[i] = rte_zmalloc(NULL, len, 0);
 		for (j = 0; j < len / sizeof(uint32_t); j++)
@@ -124,9 +130,42 @@ run_thash_test(unsigned int tuple_len)
 		(double)(tsc_diff) / (double)(ITERATIONS * BATCH_SZ), len);
 }
 
+/*
+ * The GFNI implementation is only used when 512-bit SIMD is permitted, which
+ * is not the default on x86, so opt in to it where the CPU can support it.
+ */
+static void
+enable_gfni_simd_bitwidth(void)
+{
+#ifdef RTE_THASH_GFNI_DEFINED
+	const uint16_t cur = rte_vect_get_max_simd_bitwidth();
+
+	if (cur >= RTE_VECT_SIMD_512)
+		return;
+
+	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_GFNI) ||
+			!rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512VBMI) ||
+			!rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512DQ) ||
+			!rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512VL))
+		return;
+
+	const int ret = rte_vect_set_max_simd_bitwidth(RTE_VECT_SIMD_512);
+	if (ret != 0) {
+		printf("WARNING: CPU supports GFNI, but max SIMD bitwidth is pinned at %u, so GFNI is not benchmarked\n",
+			cur);
+		return;
+	}
+
+	printf("WARNING: CPU supports GFNI, raising max SIMD bitwidth from %u to %u to benchmark it\n",
+		cur, RTE_VECT_SIMD_512);
+#endif
+}
+
 static int
 test_thash_perf(void)
 {
+	enable_gfni_simd_bitwidth();
+
 	run_thash_test(IPV4_2_TUPLE_LEN);
 	run_thash_test(IPV4_4_TUPLE_LEN);
 	run_thash_test(IPV6_2_TUPLE_LEN);
-- 
2.55.0


  parent reply	other threads:[~2026-12-01 15:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 15:16 [PATCH 00/11] Add optimized path selection for thash Bruce Richardson
2026-12-01 15:16 ` [PATCH 01/11] hash: improve build-time instruction set checks " Bruce Richardson
2026-12-01 15:16 ` Bruce Richardson [this message]
2026-12-01 15:16 ` [PATCH 03/11] hash: create library internal header file " Bruce Richardson
2026-12-01 15:16 ` [PATCH 04/11] hash: add functions for GFNI RSS hash calculations Bruce Richardson
2026-12-01 15:16 ` [PATCH 05/11] hash: add fixed-size scalar " Bruce Richardson
2026-12-01 15:16 ` [PATCH 06/11] hash: add thash context struct for runtime path selection Bruce Richardson
2026-12-01 15:16 ` [PATCH 07/11] hash: implement IPv4 and IPv6 RSS hashing in SW Bruce Richardson
2026-12-01 15:16 ` [PATCH 08/11] hash: add explicit handling for RSS with split L3/L4 data Bruce Richardson
2026-12-01 15:16 ` [PATCH 09/11] test/thash: add perf tests for new RSS functions Bruce Richardson
2026-12-01 15:16 ` [PATCH 10/11] hash: remove extra store-load when performing RSS Bruce Richardson
2026-12-01 15:16 ` [PATCH 11/11] hash: add AVX2 RSS hash functions Bruce Richardson

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=20261201151623.2240031-3-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /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