DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>,
	Zhihong Wang <zhihong.wang@intel.com>,
	Xiaolong Ye <xiaolong.ye@intel.com>,
	Marvin Liu <yong.liu@intel.com>
Cc: dev@dpdk.org, Ferruh Yigit <ferruh.yigit@intel.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	David Marchand <david.marchand@redhat.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Radu Nicolau <radu.nicolau@intel.com>,
	Luca Boccassi <bluca@debian.org>
Subject: [dpdk-dev] [PATCH v2] net/virtio: fix AVX512 datapath selection
Date: Mon, 11 May 2020 19:48:57 +0100	[thread overview]
Message-ID: <20200511184857.614820-1-ferruh.yigit@intel.com> (raw)
In-Reply-To: <20200511144720.241224-1-maxime.coquelin@redhat.com>

From: Maxime Coquelin <maxime.coquelin@redhat.com>

The AVX512 packed ring datapath selection was only done
at build time, but it should also be checked at runtime
that the CPU supports it.

This patch add a CPU flags check so that non-vectorized
path is selected at runtime if AVX512 is not supported.

Also in meson build enable vectorization only for relevant file, not for
all driver.

Fixes: ccb10995c2ad ("net/virtio: add election for vectorized path")

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
Cc: Bruce Richardson <bruce.richardson@intel.com>
Cc: Radu Nicolau <radu.nicolau@intel.com>
Cc: Luca Boccassi <bluca@debian.org>

For meson I mainly adapted implementation from other driver, not able to
test or verify myself.
---
 drivers/net/virtio/meson.build     | 9 +++++++--
 drivers/net/virtio/virtio_ethdev.c | 6 ++++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio/meson.build b/drivers/net/virtio/meson.build
index 5cc529f6aa..3fd6051f4b 100644
--- a/drivers/net/virtio/meson.build
+++ b/drivers/net/virtio/meson.build
@@ -11,8 +11,14 @@ deps += ['kvargs', 'bus_pci']
 if arch_subdir == 'x86'
 	if not machine_args.contains('-mno-avx512f')
 		if cc.has_argument('-mavx512f') and cc.has_argument('-mavx512vl') and cc.has_argument('-mavx512bw')
-			cflags += ['-mavx512f', '-mavx512bw', '-mavx512vl']
 			cflags += ['-DCC_AVX512_SUPPORT']
+			virtio_avx512_lib = static_library('virtio_avx512_lib',
+					      'virtio_rxtx_packed_avx.c',
+					      dependencies: [static_rte_ethdev,
+						static_rte_kvargs, static_rte_bus_pci],
+					      include_directories: includes,
+					      c_args: [cflags, '-mavx512f', '-mavx512bw', '-mavx512vl'])
+			objs += virtio_avx512_lib.extract_objects('virtio_rxtx_packed_avx.c')
 			if (toolchain == 'gcc' and cc.version().version_compare('>=8.3.0'))
 				cflags += '-DVHOST_GCC_UNROLL_PRAGMA'
 			elif (toolchain == 'clang' and cc.version().version_compare('>=3.7.0'))
@@ -20,7 +26,6 @@ if arch_subdir == 'x86'
 			elif (toolchain == 'icc' and cc.version().version_compare('>=16.0.0'))
 				cflags += '-DVHOST_ICC_UNROLL_PRAGMA'
 			endif
-			sources += files('virtio_rxtx_packed_avx.c')
 		endif
 	endif
 	sources += files('virtio_rxtx_simple_sse.c')
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 312871cb48..49ccef12c7 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1965,8 +1965,10 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 			PMD_DRV_LOG(INFO,
 				"building environment do not support packed ring vectorized");
 #else
-			hw->use_vec_rx = 1;
-			hw->use_vec_tx = 1;
+			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F)) {
+				hw->use_vec_rx = 1;
+				hw->use_vec_tx = 1;
+			}
 #endif
 		}
 	}
-- 
2.25.4


  parent reply	other threads:[~2020-05-11 18:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11 14:47 [dpdk-dev] [PATCH] " Maxime Coquelin
2020-05-11 15:11 ` Ferruh Yigit
2020-05-11 18:48 ` Ferruh Yigit [this message]
2020-05-11 19:49   ` [dpdk-dev] [PATCH v2] " Maxime Coquelin
2020-05-11 22:21     ` Ferruh Yigit
2020-05-12  3:29     ` Liu, Yong
2020-05-12  8:36       ` Maxime Coquelin
2020-05-12  8:46         ` Liu, Yong
2020-05-12 10:04           ` Maxime Coquelin
2020-05-12 13:19             ` Liu, Yong
2020-05-12  2:27 ` [dpdk-dev] [PATCH] " Liu, Yong
2020-05-12  8:35   ` Maxime Coquelin

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=20200511184857.614820-1-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=bluca@debian.org \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=radu.nicolau@intel.com \
    --cc=thomas@monjalon.net \
    --cc=xiaolong.ye@intel.com \
    --cc=yong.liu@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).