From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6989BA0C4B; Fri, 15 Oct 2021 11:30:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0826841209; Fri, 15 Oct 2021 11:30:23 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 8B08A411E6 for ; Fri, 15 Oct 2021 11:30:21 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10137"; a="251328309" X-IronPort-AV: E=Sophos;i="5.85,375,1624345200"; d="scan'208";a="251328309" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 02:30:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,375,1624345200"; d="scan'208";a="461517067" Received: from silpixa00400072.ir.intel.com ([10.237.222.213]) by orsmga002.jf.intel.com with ESMTP; 15 Oct 2021 02:30:19 -0700 From: Vladimir Medvedkin To: dev@dpdk.org Cc: yipeng1.wang@intel.com, sameh.gobriel@intel.com, bruce.richardson@intel.com, konstantin.ananyev@intel.com, stephen@networkplumber.org Date: Fri, 15 Oct 2021 10:30:06 +0100 Message-Id: <1634290206-251913-6-git-send-email-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1634290206-251913-1-git-send-email-vladimir.medvedkin@intel.com> References: <1634290206-251913-1-git-send-email-vladimir.medvedkin@intel.com> In-Reply-To: <1630944239-363648-1-git-send-email-vladimir.medvedkin@intel.com> References: <1630944239-363648-1-git-send-email-vladimir.medvedkin@intel.com> Subject: [dpdk-dev] [PATCH v2 5/5] test/thash: add performance tests for the Toeplitz hash X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch adds performance tests for different implementations of the Toeplitz hash function. Signed-off-by: Vladimir Medvedkin --- app/test/meson.build | 2 + app/test/test_thash_perf.c | 125 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 app/test/test_thash_perf.c diff --git a/app/test/meson.build b/app/test/meson.build index f144d8b..b9c4e78 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -141,6 +141,7 @@ test_sources = files( 'test_table_tables.c', 'test_tailq.c', 'test_thash.c', + 'test_thash_perf.c', 'test_timer.c', 'test_timer_perf.c', 'test_timer_racecond.c', @@ -315,6 +316,7 @@ perf_test_names = [ 'hash_readwrite_lf_perf_autotest', 'trace_perf_autotest', 'ipsec_perf_autotest', + 'thash_perf_autotest', ] driver_test_names = [ diff --git a/app/test/test_thash_perf.c b/app/test/test_thash_perf.c new file mode 100644 index 0000000..ccc4710 --- /dev/null +++ b/app/test/test_thash_perf.c @@ -0,0 +1,125 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Intel Corporation + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "test.h" + +#define ITERATIONS (1 << 15) +#define BATCH_SZ (1 << 10) + +#define IPV4_2_TUPLE_LEN (8) +#define IPV4_4_TUPLE_LEN (12) +#define IPV6_2_TUPLE_LEN (32) +#define IPV6_4_TUPLE_LEN (36) + + +static uint8_t default_rss_key[] = { + 0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2, + 0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0, + 0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4, + 0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c, + 0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa, +}; + +static void +run_thash_test(unsigned int tuple_len) +{ + uint32_t *tuples[BATCH_SZ]; + unsigned int i, j; + uint64_t start_tsc, end_tsc; + uint32_t len = RTE_ALIGN_CEIL(tuple_len, sizeof(uint32_t)); + volatile uint32_t hash = 0; + uint32_t hash_1 = 0; + uint32_t hash_2 = 0; + + for (i = 0; i < BATCH_SZ; i++) { + tuples[i] = rte_zmalloc(NULL, len, 0); + for (j = 0; j < len / sizeof(uint32_t); j++) + tuples[i][j] = rte_rand(); + } + + start_tsc = rte_rdtsc_precise(); + for (i = 0; i < ITERATIONS; i++) { + for (j = 0; j < BATCH_SZ; j++) { + hash ^= rte_softrss(tuples[j], len / sizeof(uint32_t), + default_rss_key); + } + } + end_tsc = rte_rdtsc_precise(); + + printf("Average rte_softrss() takes \t\t%.1f cycles for key len %d\n", + (double)(end_tsc - start_tsc) / (double)(ITERATIONS * + BATCH_SZ), len); + + start_tsc = rte_rdtsc_precise(); + for (i = 0; i < ITERATIONS; i++) { + for (j = 0; j < BATCH_SZ; j++) { + hash ^= rte_softrss_be(tuples[j], len / + sizeof(uint32_t), default_rss_key); + } + } + end_tsc = rte_rdtsc_precise(); + + printf("Average rte_softrss_be() takes \t\t%.1f cycles for key len %d\n", + (double)(end_tsc - start_tsc) / (double)(ITERATIONS * + BATCH_SZ), len); + + if (!rte_thash_gfni_supported) + return; + + uint64_t rss_key_matrixes[RTE_DIM(default_rss_key)]; + + rte_thash_complete_matrix(rss_key_matrixes, default_rss_key, + RTE_DIM(default_rss_key)); + + start_tsc = rte_rdtsc_precise(); + for (i = 0; i < ITERATIONS; i++) { + for (j = 0; j < BATCH_SZ; j++) + hash ^= rte_thash_gfni(rss_key_matrixes, + (uint8_t *)tuples[j], len); + } + end_tsc = rte_rdtsc_precise(); + + printf("Average rte_thash_gfni takes \t\t%.1f cycles for key len %d\n", + (double)(end_tsc - start_tsc) / (double)(ITERATIONS * + BATCH_SZ), len); + + start_tsc = rte_rdtsc_precise(); + for (i = 0; i < ITERATIONS; i++) { + for (j = 0; j < BATCH_SZ; j += 2) { + rte_thash_gfni_x2(rss_key_matrixes, + (uint8_t *)tuples[j], (uint8_t *)tuples[j + 1], + len, &hash_1, &hash_2); + + hash ^= hash_1 ^ hash_2; + } + } + end_tsc = rte_rdtsc_precise(); + + printf("Average rte_thash_gfni_x2 takes \t%.1f cycles for key len %d\n", + (double)(end_tsc - start_tsc) / (double)(ITERATIONS * + BATCH_SZ), len); +} + +static int +test_thash_perf(void) +{ + run_thash_test(IPV4_2_TUPLE_LEN); + run_thash_test(IPV4_4_TUPLE_LEN); + run_thash_test(IPV6_2_TUPLE_LEN); + run_thash_test(IPV6_4_TUPLE_LEN); + + return 0; +} + +REGISTER_TEST_COMMAND(thash_perf_autotest, test_thash_perf); -- 2.7.4