From: Xiaoyun Li <xiaoyun.li@intel.com>
To: bruce.richardson@intel.com
Cc: dev@dpdk.org, zhihong.wang@intel.com, qi.z.zhang@intel.com,
wenzhuo.lu@intel.com, Xiaoyun Li <xiaoyun.li@intel.com>
Subject: [dpdk-dev] [PATCH v2 3/3] efd: run-time dispatch over x86 EFD functions
Date: Fri, 1 Sep 2017 16:57:02 +0800 [thread overview]
Message-ID: <1504256222-32969-4-git-send-email-xiaoyun.li@intel.com> (raw)
In-Reply-To: <1504256222-32969-1-git-send-email-xiaoyun.li@intel.com>
This patch dynamically selects x86 EFD functions at run-time.
This patch uses function pointer and binds it to the relative
function based on CPU flags at constructor time.
Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
---
lib/librte_efd/rte_efd_x86.h | 41 ++++++++++++++++++++++++++++++++++++++---
1 file changed, 38 insertions(+), 3 deletions(-)
diff --git a/lib/librte_efd/rte_efd_x86.h b/lib/librte_efd/rte_efd_x86.h
index 34f37d7..93b6743 100644
--- a/lib/librte_efd/rte_efd_x86.h
+++ b/lib/librte_efd/rte_efd_x86.h
@@ -43,12 +43,29 @@
#define EFD_LOAD_SI128(val) _mm_lddqu_si128(val)
#endif
+typedef efd_value_t
+(*efd_lookup_internal_avx2_t)(const efd_hashfunc_t *group_hash_idx,
+ const efd_lookuptbl_t *group_lookup_table,
+ const uint32_t hash_val_a, const uint32_t hash_val_b);
+
+static efd_lookup_internal_avx2_t efd_lookup_internal_avx2_ptr;
+
static inline efd_value_t
efd_lookup_internal_avx2(const efd_hashfunc_t *group_hash_idx,
const efd_lookuptbl_t *group_lookup_table,
const uint32_t hash_val_a, const uint32_t hash_val_b)
{
-#ifdef RTE_MACHINE_CPUFLAG_AVX2
+ return (*efd_lookup_internal_avx2_ptr)(group_hash_idx,
+ group_lookup_table,
+ hash_val_a, hash_val_b);
+}
+
+#ifdef CC_SUPPORT_AVX2
+static inline efd_value_t
+efd_lookup_internal_avx2_AVX2(const efd_hashfunc_t *group_hash_idx,
+ const efd_lookuptbl_t *group_lookup_table,
+ const uint32_t hash_val_a, const uint32_t hash_val_b)
+{
efd_value_t value = 0;
uint32_t i = 0;
__m256i vhash_val_a = _mm256_set1_epi32(hash_val_a);
@@ -74,13 +91,31 @@ efd_lookup_internal_avx2(const efd_hashfunc_t *group_hash_idx,
}
return value;
-#else
+}
+#endif
+
+static inline efd_value_t
+efd_lookup_internal_avx2_DEFAULT(const efd_hashfunc_t *group_hash_idx,
+ const efd_lookuptbl_t *group_lookup_table,
+ const uint32_t hash_val_a, const uint32_t hash_val_b)
+{
RTE_SET_USED(group_hash_idx);
RTE_SET_USED(group_lookup_table);
RTE_SET_USED(hash_val_a);
RTE_SET_USED(hash_val_b);
/* Return dummy value, only to avoid compilation breakage */
return 0;
-#endif
+}
+static void __attribute__((constructor))
+rte_efd_x86_init(void)
+{
+#ifdef CC_SUPPORT_AVX2
+ if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2))
+ efd_lookup_internal_avx2_ptr = efd_lookup_internal_avx2_AVX2;
+ else
+ efd_lookup_internal_avx2_ptr = efd_lookup_internal_avx2_DEFAULT;
+#else
+ efd_lookup_internal_avx2_ptr = efd_lookup_internal_avx2_DEFAULT;
+#endif
}
--
2.7.4
prev parent reply other threads:[~2017-09-01 8:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-25 2:06 [dpdk-dev] [PATCH 0/3] dynamic linking support Xiaoyun Li
2017-08-25 2:06 ` [dpdk-dev] [PATCH 1/3] eal/x86: run-time dispatch over memcpy Xiaoyun Li
2017-08-30 14:56 ` Ananyev, Konstantin
2017-08-30 17:51 ` Bruce Richardson
2017-08-31 1:21 ` Lu, Wenzhuo
2017-08-30 18:00 ` Stephen Hemminger
2017-08-31 1:23 ` Lu, Wenzhuo
2017-08-31 5:05 ` Stephen Hemminger
2017-08-31 5:24 ` Li, Xiaoyun
2017-08-25 2:06 ` [dpdk-dev] [PATCH 2/3] app/test: run-time dispatch over memcpy perf test Xiaoyun Li
2017-08-25 2:06 ` [dpdk-dev] [PATCH 3/3] efd: run-time dispatch over x86 EFD functions Xiaoyun Li
2017-09-01 8:56 ` [dpdk-dev] [PATCH v2 0/3] dynamic linking support Xiaoyun Li
2017-09-01 8:57 ` [dpdk-dev] [PATCH v2 1/3] eal/x86: run-time dispatch over memcpy Xiaoyun Li
2017-09-01 9:16 ` Ananyev, Konstantin
2017-09-01 9:28 ` Li, Xiaoyun
2017-09-01 10:38 ` Ananyev, Konstantin
2017-09-04 1:41 ` Li, Xiaoyun
[not found] ` <B9E724F4CB7543449049E7AE7669D82F44216E@SHSMSX101.ccr.corp.intel.com>
[not found] ` <B9E724F4CB7543449049E7AE7669D82F442FE6@SHSMSX101.ccr.corp.intel.com>
2017-09-12 2:27 ` Li, Xiaoyun
2017-09-20 6:57 ` Li, Xiaoyun
2017-09-01 15:34 ` Stephen Hemminger
2017-09-01 8:57 ` [dpdk-dev] [PATCH v2 2/3] app/test: run-time dispatch over memcpy perf test Xiaoyun Li
2017-09-01 8:57 ` Xiaoyun Li [this message]
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=1504256222-32969-4-git-send-email-xiaoyun.li@intel.com \
--to=xiaoyun.li@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=qi.z.zhang@intel.com \
--cc=wenzhuo.lu@intel.com \
--cc=zhihong.wang@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).