* [dpdk-dev] [PATCH 2/3] hash: run-time function selection
@ 2017-11-06 18:04 Elza Mathew
2017-12-11 13:26 ` 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_fbk_hash.c | 11 ++++++++++-
lib/librte_hash/rte_fbk_hash.h | 8 --------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c
index 55c9f35..7c4e194 100644
--- a/lib/librte_hash/rte_fbk_hash.c
+++ b/lib/librte_hash/rte_fbk_hash.c
@@ -114,6 +114,7 @@ struct rte_fbk_hash_table *
sizeof(*ht) + (sizeof(ht->t[0]) * params->entries);
uint32_t i;
struct rte_fbk_hash_list *fbk_hash_list;
+ rte_fbk_hash_fn default_hash_func = (rte_fbk_hash_fn)rte_jhash_1word;
fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
rte_fbk_hash_list);
@@ -161,6 +162,14 @@ struct rte_fbk_hash_table *
goto exit;
}
+ /* Default hash function */
+#if defined(RTE_ARCH_X86)
+ default_hash_func = (rte_fbk_hash_fn)rte_hash_crc_4byte;
+#elif defined(RTE_ARCH_ARM64)
+ if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
+ default_hash_func = (rte_fbk_hash_fn)rte_hash_crc_4byte;
+#endif
+
/* Set up hash table context. */
snprintf(ht->name, sizeof(ht->name), "%s", params->name);
ht->entries = params->entries;
@@ -177,7 +186,7 @@ struct rte_fbk_hash_table *
ht->init_val = params->init_val;
}
else {
- ht->hash_func = RTE_FBK_HASH_FUNC_DEFAULT;
+ ht->hash_func = default_hash_func;
ht->init_val = RTE_FBK_HASH_INIT_VAL_DEFAULT;
}
diff --git a/lib/librte_hash/rte_fbk_hash.h b/lib/librte_hash/rte_fbk_hash.h
index c39c097..1b1b7df 100644
--- a/lib/librte_hash/rte_fbk_hash.h
+++ b/lib/librte_hash/rte_fbk_hash.h
@@ -54,16 +54,8 @@
#include <string.h>
-#ifndef RTE_FBK_HASH_FUNC_DEFAULT
-#if defined(RTE_ARCH_X86) || defined(RTE_MACHINE_CPUFLAG_CRC32)
#include <rte_hash_crc.h>
-/** Default four-byte key hash function if none is specified. */
-#define RTE_FBK_HASH_FUNC_DEFAULT rte_hash_crc_4byte
-#else
#include <rte_jhash.h>
-#define RTE_FBK_HASH_FUNC_DEFAULT rte_jhash_1word
-#endif
-#endif
#ifndef RTE_FBK_HASH_INIT_VAL_DEFAULT
/** Initialising value used when calculating hash. */
--
1.9.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] hash: run-time function selection
2017-11-06 18:04 [dpdk-dev] [PATCH 2/3] hash: run-time function selection Elza Mathew
@ 2017-12-11 13:26 ` Bruce Richardson
2018-01-20 14:36 ` Thomas Monjalon
0 siblings, 1 reply; 3+ messages in thread
From: Bruce Richardson @ 2017-12-11 13:26 UTC (permalink / raw)
To: Elza Mathew; +Cc: pablo.de.lara.guarch, dev
On Mon, Nov 06, 2017 at 10:04:49AM -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_fbk_hash.c | 11 ++++++++++-
> lib/librte_hash/rte_fbk_hash.h | 8 --------
> 2 files changed, 10 insertions(+), 9 deletions(-)
>
Title needs an update to indicate this change is for fbk-hash. I suspect
that can be fixed on apply.
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] hash: run-time function selection
2017-12-11 13:26 ` 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 14:26, Bruce Richardson:
> On Mon, Nov 06, 2017 at 10:04:49AM -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_fbk_hash.c | 11 ++++++++++-
> > lib/librte_hash/rte_fbk_hash.h | 8 --------
> > 2 files changed, 10 insertions(+), 9 deletions(-)
> >
> Title needs an update to indicate this change is for fbk-hash. I suspect
> that can be fixed on apply.
>
> 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:37 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 2/3] hash: run-time function selection Elza Mathew
2017-12-11 13:26 ` 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).