From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B2F81A0597; Wed, 8 Apr 2020 20:20:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B306A1C217; Wed, 8 Apr 2020 20:20:11 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 632361C205 for ; Wed, 8 Apr 2020 20:20:08 +0200 (CEST) IronPort-SDR: yP45OQlOTvmbpdFUWWE2AmWnegiQzWOpQ0A7uAtSvIxwmrupY5KRGGLdXlIJTnMSxhpfvnIEPx nimJiuAyvw+Q== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2020 11:20:07 -0700 IronPort-SDR: uDITcEuKWujkjkeGa+yeCvRrCYnyj4QBJWzu/Ec5PhQtyC7Ha3Mc8pgkjsh995Z1kWRsWu8y4d x0YV/wwM4pfw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,359,1580803200"; d="scan'208";a="254878147" Received: from silpixa00400072.ir.intel.com ([10.237.222.213]) by orsmga006.jf.intel.com with ESMTP; 08 Apr 2020 11:20:06 -0700 From: Vladimir Medvedkin To: dev@dpdk.org Cc: konstantin.ananyev@intel.com, yipeng1.wang@intel.com, sameh.gobriel@intel.com, bruce.richardson@intel.com Date: Wed, 8 Apr 2020 19:19:57 +0100 Message-Id: <58a648b9e85b5b37f282237501962c6183118cae.1586369591.git.vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 4/4] test: add k32v64 perf tests X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Add performance tests for rte_k32v64_hash Signed-off-by: Vladimir Medvedkin --- app/test/test_hash_perf.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c index a438eae..0a02445 100644 --- a/app/test/test_hash_perf.c +++ b/app/test/test_hash_perf.c @@ -12,8 +12,10 @@ #include #include #include +#include #include #include +#include #include "test.h" @@ -29,6 +31,8 @@ #define NUM_SHUFFLES 10 #define BURST_SIZE 16 +#define CRC_INIT_VAL 0xdeadbeef + enum operations { ADD = 0, LOOKUP, @@ -669,6 +673,82 @@ fbk_hash_perf_test(void) } static int +k32v64_hash_perf_test(void) +{ + struct rte_k32v64_hash_params params = { + .name = "k32v64_hash_test", + .entries = ENTRIES * 2, + .socket_id = rte_socket_id(), + }; + struct rte_k32v64_hash_table *handle = NULL; + uint32_t *keys = NULL; + unsigned int indexes[TEST_SIZE]; + uint64_t tmp_val; + uint64_t lookup_time = 0; + uint64_t begin; + uint64_t end; + unsigned int added = 0; + uint32_t key; + uint16_t val; + unsigned int i, j; + int ret = 0; + + handle = rte_k32v64_hash_create(¶ms); + if (handle == NULL) { + printf("Error creating table\n"); + return -1; + } + + keys = rte_zmalloc(NULL, ENTRIES * sizeof(*keys), 0); + if (keys == NULL) { + printf("fbk hash: memory allocation for key store failed\n"); + return -1; + } + + /* Generate random keys and values. */ + for (i = 0; i < ENTRIES; i++) { + key = (uint32_t)rte_rand(); + val = rte_rand(); + + if (rte_k32v64_hash_add(handle, key, rte_hash_crc_4byte(key, + CRC_INIT_VAL), val) == 0) { + keys[added] = key; + added++; + } + } + + for (i = 0; i < TEST_ITERATIONS; i++) { + + /* Generate random indexes into keys[] array. */ + for (j = 0; j < TEST_SIZE; j++) + indexes[j] = rte_rand() % added; + + begin = rte_rdtsc(); + /* Do lookups */ + + for (j = 0; j < TEST_SIZE; j++) + ret += rte_k32v64_hash_lookup(handle, + keys[indexes[j]], + rte_hash_crc_4byte(keys[indexes[j]], + CRC_INIT_VAL), &tmp_val); + + + end = rte_rdtsc(); + lookup_time += (double)(end - begin); + } + + printf("\n\n *** K32V64 Hash function performance test results ***\n"); + if (ret == 0) + printf("Number of ticks per lookup = %g\n", + (double)lookup_time / + ((double)TEST_ITERATIONS * (double)TEST_SIZE)); + + rte_k32v64_hash_free(handle); + + return 0; +} + +static int test_hash_perf(void) { unsigned int with_pushes, with_locks; @@ -695,6 +775,9 @@ test_hash_perf(void) if (fbk_hash_perf_test() < 0) return -1; + if (k32v64_hash_perf_test() < 0) + return -1; + return 0; } -- 2.7.4