DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/3] hash: run-time function selection
@ 2017-11-06 18:04 Elza Mathew
  2017-12-11 12:52 ` Bruce Richardson
  0 siblings, 1 reply; 3+ messages in thread
From: Elza Mathew @ 2017-11-06 18:04 UTC (permalink / raw)
  To: bruce.richardson, pablo.de.lara.guarch; +Cc: dev

Compile-time function selection can potentially lead to
lower performance on generic builds done by distros.
Replaced compile time flag checks with run-time function
selection.

Signed-off-by: Elza Mathew <elza.mathew@intel.com>
---
 lib/librte_hash/rte_cuckoo_hash.c | 10 +++++++++-
 lib/librte_hash/rte_cuckoo_hash.h |  6 ------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index e69b911..078d9c8 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -125,6 +125,7 @@ struct rte_hash *
 	unsigned num_key_slots;
 	unsigned hw_trans_mem_support = 0;
 	unsigned i;
+	rte_hash_function default_hash_func = (rte_hash_function)rte_jhash;
 
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
@@ -268,6 +269,13 @@ struct rte_hash *
 				RTE_CACHE_LINE_SIZE, params->socket_id);
 	}
 
+	/* Default hash function */
+#if defined(RTE_ARCH_X86)
+	default_hash_func = (rte_hash_function)rte_hash_crc;
+#elif defined(RTE_ARCH_ARM64)
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
+		default_hash_func = (rte_hash_function)rte_hash_crc;
+#endif
 	/* Setup hash context */
 	snprintf(h->name, sizeof(h->name), "%s", params->name);
 	h->entries = params->entries;
@@ -279,7 +287,7 @@ struct rte_hash *
 	h->bucket_bitmask = h->num_buckets - 1;
 	h->buckets = buckets;
 	h->hash_func = (params->hash_func == NULL) ?
-		DEFAULT_HASH_FUNC : params->hash_func;
+		default_hash_func : params->hash_func;
 	h->key_store = k;
 	h->free_slots = r;
 	h->hw_trans_mem_support = hw_trans_mem_support;
diff --git a/lib/librte_hash/rte_cuckoo_hash.h b/lib/librte_hash/rte_cuckoo_hash.h
index f75392d..b4fd9b1 100644
--- a/lib/librte_hash/rte_cuckoo_hash.h
+++ b/lib/librte_hash/rte_cuckoo_hash.h
@@ -57,14 +57,8 @@
 #define RETURN_IF_TRUE(cond, retval)
 #endif
 
-/* Hash function used if none is specified */
-#if defined(RTE_ARCH_X86) || defined(RTE_MACHINE_CPUFLAG_CRC32)
 #include <rte_hash_crc.h>
-#define DEFAULT_HASH_FUNC       rte_hash_crc
-#else
 #include <rte_jhash.h>
-#define DEFAULT_HASH_FUNC       rte_jhash
-#endif
 
 #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64)
 /*
-- 
1.9.1

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

* Re: [dpdk-dev] [PATCH 1/3] hash: run-time function selection
  2017-11-06 18:04 [dpdk-dev] [PATCH 1/3] hash: run-time function selection Elza Mathew
@ 2017-12-11 12:52 ` Bruce Richardson
  2018-01-20 14:36   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Bruce Richardson @ 2017-12-11 12:52 UTC (permalink / raw)
  To: Elza Mathew; +Cc: pablo.de.lara.guarch, dev

On Mon, Nov 06, 2017 at 10:04:02AM -0800, Elza Mathew wrote:
> Compile-time function selection can potentially lead to
> lower performance on generic builds done by distros.
> Replaced compile time flag checks with run-time function
> selection.
> 
> Signed-off-by: Elza Mathew <elza.mathew@intel.com>
> ---
>  lib/librte_hash/rte_cuckoo_hash.c | 10 +++++++++-
>  lib/librte_hash/rte_cuckoo_hash.h |  6 ------
>  2 files changed, 9 insertions(+), 7 deletions(-)
> 

Looks good to me.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

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

* Re: [dpdk-dev] [PATCH 1/3] hash: run-time function selection
  2017-12-11 12:52 ` Bruce Richardson
@ 2018-01-20 14:36   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2018-01-20 14:36 UTC (permalink / raw)
  To: Elza Mathew; +Cc: dev, Bruce Richardson, pablo.de.lara.guarch

11/12/2017 13:52, Bruce Richardson:
> On Mon, Nov 06, 2017 at 10:04:02AM -0800, Elza Mathew wrote:
> > Compile-time function selection can potentially lead to
> > lower performance on generic builds done by distros.
> > Replaced compile time flag checks with run-time function
> > selection.
> > 
> > Signed-off-by: Elza Mathew <elza.mathew@intel.com>
> > ---
> >  lib/librte_hash/rte_cuckoo_hash.c | 10 +++++++++-
> >  lib/librte_hash/rte_cuckoo_hash.h |  6 ------
> >  2 files changed, 9 insertions(+), 7 deletions(-)
> > 
> 
> Looks good to me.
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks

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

end of thread, other threads:[~2018-01-20 14:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-06 18:04 [dpdk-dev] [PATCH 1/3] hash: run-time function selection Elza Mathew
2017-12-11 12:52 ` Bruce Richardson
2018-01-20 14:36   ` 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).