Skip to contentSkip to conversation

drivers: add generic build of SVE files

RFC PATCH In review Bruce Richardson 3 participants 5 messages Apr 7, 2025 – Apr 8, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 drivers: add generic build of SVE files

For SVE, as for AVX2 and AVX-512, support building files for these ISAs from the top-level drivers/meson.build file, rather than having each driver re-implement it.

This removes the remaining build task for drivers in DPDK which is being done by a driver itself, rather than in the generic drivers' build rules.

---
 drivers/meson.build          | 27 +++++++++++++++++++++++++++
 drivers/net/hns3/meson.build | 22 +---------------------
 2 files changed, 28 insertions(+), 21 deletions(-)
drivers/meson.build +27 -0
index b2d2537dc8..a6f0670a2f 100644
@@ -128,6 +128,7 @@ foreach subpath:subdirs
         sources = []
         sources_avx2 = []
         sources_avx512 = []
+        sources_sve = []
         headers = []
         driver_sdk_headers = [] # public headers included by drivers
         objs = []
@@ -285,6 +286,32 @@ foreach subpath:subdirs
             endif
         endif
 
+        if (arch_subdir == 'arm' and sources_sve.length() > 0
+                and cc.has_argument('-march=armv8.2-a+sve')
+                and cc.check_header('arm_sve.h'))
+
+            if dpdk_conf.has('RTE_HAS_SVE_ACLE')
+                sources += sources_sve
+            else
+                cflags += ['-DRTE_HAS_SVE_ACLE=1']
+                sve_cflags = ['-march=armv8.2-a+sve']
+                foreach flag: cflags
+                    if (flag.startswith('-march=')
+                            or flag.startswith('-mcpu=')
+                            or flag.startswith('-mtune='))
+                        continue
+                    endif
+                    sve_cflags += flag
+                endforeach
+                sve_lib = static_library(libname + '_sve_lib',
+                        sources_sve,
+                        dependencies: static_deps,
+                        include_directories: includes,
+                        c_args: sve_cflags)
+                objs += sve_lib.extract_objects(sources_sve)
+            endif
+        endif
+
         # generate pmdinfo sources by building a temporary
         # lib and then running pmdinfogen on the contents of
         # that lib. The final lib reuses the object files and
drivers/net/hns3/meson.build +1 -21
index 53a9dd6f39..87f04aa440 100644
@@ -43,25 +43,5 @@ cflags += no_wvla_cflag
 
 if arch_subdir == 'arm' and dpdk_conf.get('RTE_ARCH_64')
     sources += files('hns3_rxtx_vec.c')
-
-    # compile SVE when:
-    # a. support SVE in minimum instruction set baseline
-    # b. it's not minimum instruction set, but compiler support
-    if dpdk_conf.has('RTE_HAS_SVE_ACLE')
-        sources += files('hns3_rxtx_vec_sve.c')
-    elif cc.has_argument('-march=armv8.2-a+sve') and cc.check_header('arm_sve.h')
-        cflags += ['-DRTE_HAS_SVE_ACLE=1']
-        sve_cflags = []
-        foreach flag: cflags
-            if not (flag.startswith('-march=') or flag.startswith('-mcpu=') or flag.startswith('-mtune='))
-                sve_cflags += flag
-            endif
-        endforeach
-        hns3_sve_lib = static_library('hns3_sve_lib',
-                        'hns3_rxtx_vec_sve.c',
-                        dependencies: [static_rte_ethdev],
-                        include_directories: includes,
-                        c_args: [sve_cflags, '-march=armv8.2-a+sve'])
-        objs += hns3_sve_lib.extract_objects('hns3_rxtx_vec_sve.c')
-    endif
+    sources_sve += files('hns3_rxtx_vec_sve.c')
 endif

--
2.45.2

#1 lore raw
Quoted 8 lines · Bruce Richardson

For SVE, as for AVX2 and AVX-512, support building files for these ISAs from the top-level drivers/meson.build file, rather than having each driver re-implement it.

This removes the remaining build task for drivers in DPDK which is being done by a driver itself, rather than in the generic drivers' build rules.

Quoted 6 lines
---
 drivers/meson.build          | 27 +++++++++++++++++++++++++++
 drivers/net/hns3/meson.build | 22 +---------------------
 2 files changed, 28 insertions(+), 21 deletions(-)

As noted in my email in the other thread [1], this code has not been tested, and is being sent out here as a start point to hopefully enable someone more familiar with SVE to improve on it as-necessary. This support of SVE in hns3 driver is the last remaining instance of a driver doing a separate build of source code itself. All other drivers now simply pass all code files back to the top level meson.build file to have them built appropriately there.

/Bruce

[1] https://inbox.dpdk.org/dev/[email protected]/T/#m6614ca2fdef698e0448311f7255bf3be2438f101

#2 lore raw
In reply to Bruce Richardson
Quoted 10 lines · Bruce Richardson

For SVE, as for AVX2 and AVX-512, support building files for these ISAs from the top-level drivers/meson.build file, rather than having each driver re-implement it.

This removes the remaining build task for drivers in DPDK which is being done by a driver itself, rather than in the generic drivers' build rules.

Thanks for working on this additional cleanup.

Quoted 18 lines
---
 drivers/meson.build          | 27 +++++++++++++++++++++++++++
 drivers/net/hns3/meson.build | 22 +---------------------
 2 files changed, 28 insertions(+), 21 deletions(-)
drivers/meson.build +1 -0
index b2d2537dc8..a6f0670a2f 100644
@@ -128,6 +128,7 @@ foreach subpath:subdirs
         sources = []
         sources_avx2 = []
         sources_avx512 = []
+        sources_sve = []
         headers = []
         driver_sdk_headers = [] # public headers included by drivers
         objs = []

drivers/meson.build foreach subpath:subdirs · line 294

Quoted 9 lines
drivers/meson.build +6 -0
@@ -285,6 +286,32 @@ foreach subpath:subdirs
             endif
         endif
 
+        if (arch_subdir == 'arm' and sources_sve.length() > 0
+                and cc.has_argument('-march=armv8.2-a+sve')
+                and cc.check_header('arm_sve.h'))
+
+            if dpdk_conf.has('RTE_HAS_SVE_ACLE')
+                sources += sources_sve

Do we need this special case?

Quoted 13 lines
drivers/meson.build +13 -0
+            else
+                cflags += ['-DRTE_HAS_SVE_ACLE=1']
+                sve_cflags = ['-march=armv8.2-a+sve']
+                foreach flag: cflags
+                    if (flag.startswith('-march=')
+                            or flag.startswith('-mcpu=')
+                            or flag.startswith('-mtune='))
+                        continue
+                    endif
+                    sve_cflags += flag
+                endforeach
+                sve_lib = static_library(libname + '_sve_lib',
+                        sources_sve,

drivers/meson.build foreach subpath:subdirs · line 317

Quoted 10 lines
drivers/meson.build +7 -0
+                        dependencies: static_deps,
+                        include_directories: includes,
+                        c_args: sve_cflags)
+                objs += sve_lib.extract_objects(sources_sve)
+            endif
+        endif
+
         # generate pmdinfo sources by building a temporary
         # lib and then running pmdinfogen on the contents of
         # that lib. The final lib reuses the object files and

On the principle, sources_sve must be passed to gen_version_map like other sources_XXX.

Signature · 1 line
David Marchand
#3 lore raw
Quoted 37 lines · David Marchand
Quoted 10 lines · Bruce Richardson

For SVE, as for AVX2 and AVX-512, support building files for these ISAs from the top-level drivers/meson.build file, rather than having each driver re-implement it.

This removes the remaining build task for drivers in DPDK which is being done by a driver itself, rather than in the generic drivers' build rules.

Thanks for working on this additional cleanup.

Quoted 21 lines
---
 drivers/meson.build          | 27 +++++++++++++++++++++++++++
 drivers/net/hns3/meson.build | 22 +---------------------
 2 files changed, 28 insertions(+), 21 deletions(-)
drivers/meson.build +1 -0
index b2d2537dc8..a6f0670a2f 100644
@@ -128,6 +128,7 @@ foreach subpath:subdirs
         sources = []
         sources_avx2 = []
         sources_avx512 = []
+        sources_sve = []
         headers = []
         driver_sdk_headers = [] # public headers included by drivers
         objs = []
@@ -285,6 +286,32 @@ foreach subpath:subdirs
             endif
         endif
 
Quoted 9 lines

drivers/meson.build foreach subpath:subdirs · line 294

Quoted 6 lines
drivers/meson.build +6 -0
+        if (arch_subdir == 'arm' and sources_sve.length() > 0
+                and cc.has_argument('-march=armv8.2-a+sve')
+                and cc.check_header('arm_sve.h'))
+
+            if dpdk_conf.has('RTE_HAS_SVE_ACLE')
+                sources += sources_sve

Do we need this special case?

I put it there because it was in the original code. The handling of the march/mcpu flags below are also different to what is done on x86, and being unfamiliar with SVE compilation, I was very conservative in changing things. Again, hopefully an SVE expert (or hns3 driver expert), can rework this as necessary.

Quoted 25 lines
Quoted 14 lines
drivers/meson.build +13 -0
+            else
+                cflags += ['-DRTE_HAS_SVE_ACLE=1']
+                sve_cflags = ['-march=armv8.2-a+sve']
+                foreach flag: cflags
+                    if (flag.startswith('-march=')
+                            or flag.startswith('-mcpu=')
+                            or flag.startswith('-mtune='))
+                        continue
+                    endif
+                    sve_cflags += flag
+                endforeach
+                sve_lib = static_library(libname + '_sve_lib',
+                        sources_sve,

drivers/meson.build foreach subpath:subdirs · line 317

Quoted 10 lines
drivers/meson.build +7 -0
+                        dependencies: static_deps,
+                        include_directories: includes,
+                        c_args: sve_cflags)
+                objs += sve_lib.extract_objects(sources_sve)
+            endif
+        endif
+
         # generate pmdinfo sources by building a temporary
         # lib and then running pmdinfogen on the contents of
         # that lib. The final lib reuses the object files and
Quoted 3 lines

On the principle, sources_sve must be passed to gen_version_map like other sources_XXX.

Yep, missed that as I neglected to update from main the branch I was working on. :(

#4 lore raw
In reply to David Marchand
Quoted 46 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Monday, April 7, 2025 10:50 AM
To: Bruce Richardson <[email protected]>
Cc: [email protected]; Jie Hai <[email protected]>
Subject: Re: [RFC PATCH] drivers: add generic build of SVE files

Quoted 10 lines · Bruce Richardson

For SVE, as for AVX2 and AVX-512, support building files for these ISAs from the top-level drivers/meson.build file, rather than having each driver re-implement it.

This removes the remaining build task for drivers in DPDK which is being done by a driver itself, rather than in the generic drivers' build rules.

Thanks for working on this additional cleanup.

Quoted 21 lines
---
 drivers/meson.build          | 27 +++++++++++++++++++++++++++
 drivers/net/hns3/meson.build | 22 +---------------------
 2 files changed, 28 insertions(+), 21 deletions(-)
drivers/meson.build index renamed from drivers/meson.build +0 -0

b2d2537dc8..a6f0670a2f 100644

drivers/meson.build +1 -0
@@ -128,6 +128,7 @@ foreach subpath:subdirs
         sources = []
         sources_avx2 = []
         sources_avx512 = []
+        sources_sve = []
         headers = []
         driver_sdk_headers = [] # public headers included by drivers
         objs = []
@@ -285,6 +286,32 @@ foreach subpath:subdirs
             endif
         endif
 
Quoted 9 lines

drivers/meson.build foreach subpath:subdirs · line 294

Quoted 6 lines
drivers/meson.build +6 -0
+        if (arch_subdir == 'arm' and sources_sve.length() > 0
+                and cc.has_argument('-march=armv8.2-a+sve')
+                and cc.check_header('arm_sve.h'))
+
+            if dpdk_conf.has('RTE_HAS_SVE_ACLE')
+                sources += sources_sve

Do we need this special case?

config/meson.build sets 'RTE_CPUFLAG_SVE for all SoCs with SVE support. For such SoCs RTE_HAS_SVE_ACLE is set to true if SVE ACLE is available. However, for some reason soc_cn10k sets RTE_HAS_SVE_ACLE to false even though SVE is available on that cnxk SoC.

--wathsala