DPDK patches and discussions
 help / color / mirror / Atom feed
From: Elza Mathew <elza.mathew@intel.com>
To: jasvinder.singh@intel.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 3/3] net: run-time function selection
Date: Mon,  6 Nov 2017 10:05:43 -0800	[thread overview]
Message-ID: <1509991543-26521-1-git-send-email-elza.mathew@intel.com> (raw)

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_net/rte_net_crc.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/lib/librte_net/rte_net_crc.c b/lib/librte_net/rte_net_crc.c
index 661fe32..8f6a0e7 100644
--- a/lib/librte_net/rte_net_crc.c
+++ b/lib/librte_net/rte_net_crc.c
@@ -39,8 +39,8 @@
 #include <rte_common.h>
 #include <rte_net_crc.h>
 
-#if defined(RTE_ARCH_X86_64) && defined(RTE_MACHINE_CPUFLAG_PCLMULQDQ)
-#define X86_64_SSE42_PCLMULQDQ     1
+#ifdef RTE_ARCH_X86_64
+#include <net_crc_sse.h>
 #elif defined(RTE_ARCH_ARM64) && defined(RTE_MACHINE_CPUFLAG_PMULL)
 #define ARM64_NEON_PMULL           1
 #endif
@@ -71,7 +71,7 @@
 	[RTE_NET_CRC32_ETH] = rte_crc32_eth_handler,
 };
 
-#ifdef X86_64_SSE42_PCLMULQDQ
+#ifdef RTE_ARCH_X86_64
 static rte_net_crc_handler handlers_sse42[] = {
 	[RTE_NET_CRC16_CCITT] = rte_crc16_ccitt_sse42_handler,
 	[RTE_NET_CRC32_ETH] = rte_crc32_eth_sse42_handler,
@@ -169,10 +169,12 @@
 rte_net_crc_set_alg(enum rte_net_crc_alg alg)
 {
 	switch (alg) {
-#ifdef X86_64_SSE42_PCLMULQDQ
+#ifdef RTE_ARCH_X86_64
 	case RTE_NET_CRC_SSE42:
-		handlers = handlers_sse42;
-		break;
+		if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_PCLMULQDQ)) {
+			handlers = handlers_sse42;
+			break;
+		}
 #elif defined ARM64_NEON_PMULL
 		/* fall-through */
 	case RTE_NET_CRC_NEON:
@@ -212,9 +214,11 @@ static inline void __attribute__((constructor))
 
 	rte_net_crc_scalar_init();
 
-#ifdef X86_64_SSE42_PCLMULQDQ
-	alg = RTE_NET_CRC_SSE42;
-	rte_net_crc_sse42_init();
+#ifdef RTE_ARCH_X86_64
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_PCLMULQDQ)) {
+		alg = RTE_NET_CRC_SSE42;
+		rte_net_crc_sse42_init();
+	}
 #elif defined ARM64_NEON_PMULL
 	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_PMULL)) {
 		alg = RTE_NET_CRC_NEON;
-- 
1.9.1

             reply	other threads:[~2017-11-07  0:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-06 18:05 Elza Mathew [this message]
2017-12-11 15:31 ` Bruce Richardson
2018-01-18 23:43   ` Thomas Monjalon
2018-01-19  9:20     ` Bruce Richardson
2018-01-22 17:36   ` Bruce Richardson

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=1509991543-26521-1-git-send-email-elza.mathew@intel.com \
    --to=elza.mathew@intel.com \
    --cc=dev@dpdk.org \
    --cc=jasvinder.singh@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).