From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Vipin.Varghese@amd.com, Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH v2] build: reduce use of AVX compiler flags
Date: Tue, 27 May 2025 17:24:56 +0100 [thread overview]
Message-ID: <20250527162716.319713-1-bruce.richardson@intel.com> (raw)
In-Reply-To: <20250325172215.3360590-1-bruce.richardson@intel.com>
When doing a build for a target that already has the instruction sets
for AVX2/AVX512 enabled, skip emitting the AVX compiler flags, or the
skylake-avx512 '-march' flags, as they are unnecessary. Instead, when
the default flags produce the desired output, just use them unmodified,
and don't bother adding in extra enabling flags for AVX2 or AVX-512.
Depends-on: series-35006 ("doc/linux_gsg: update recommended compiler versions")
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
V2: dropped the doc update for the minimum meson version. Based on
discussion, that version bump is larger than proposed in RFC and
is now a separate patch/series [series 35006 referenced above]
---
config/x86/meson.build | 31 ++++++++++++++++++++-----------
drivers/meson.build | 9 +--------
lib/meson.build | 9 +--------
3 files changed, 22 insertions(+), 27 deletions(-)
diff --git a/config/x86/meson.build b/config/x86/meson.build
index c3564b0011..97f790b0d4 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -4,11 +4,13 @@
if is_ms_compiler
cc_avx2_flags = ['/arch:AVX2']
else
- cc_avx2_flags = ['-mavx2']
+ cc_avx2_flags = []
+ if cc.get_define('__AVX2__', args: machine_args) == ''
+ cc_avx2_flags = ['-mavx2']
+ endif
endif
cc_has_avx512 = false
-target_has_avx512 = false
dpdk_conf.set('RTE_ARCH_X86', 1)
if dpdk_conf.get('RTE_ARCH_64')
@@ -65,26 +67,33 @@ if is_linux or cc.get_id() == 'gcc'
endif
endif
-cc_avx512_flags = ['-mavx512f', '-mavx512vl', '-mavx512dq', '-mavx512bw', '-mavx512cd']
-if (binutils_ok and cc.has_multi_arguments(cc_avx512_flags)
+avx512_march_flag = '-march=skylake-avx512'
+cc_avx512_flags = []
+if (binutils_ok and cc.has_argument(avx512_march_flag)
and '-mno-avx512f' not in get_option('c_args'))
# check if compiler is working with _mm512_extracti64x4_epi64
# Ref: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82887
code = '''#include <immintrin.h>
void test(__m512i zmm){
__m256i ymm = _mm512_extracti64x4_epi64(zmm, 0);}'''
- result = cc.compiles(code, args : cc_avx512_flags, name : 'AVX512 checking')
+ result = cc.compiles(code, args : [avx512_march_flag], name : 'AVX512 checking')
if result == false
machine_args += '-mno-avx512f'
warning('Broken _mm512_extracti64x4_epi64, disabling AVX512 support')
else
cc_has_avx512 = true
- target_has_avx512 = (
- cc.get_define('__AVX512F__', args: machine_args) != '' and
- cc.get_define('__AVX512BW__', args: machine_args) != '' and
- cc.get_define('__AVX512DQ__', args: machine_args) != '' and
- cc.get_define('__AVX512VL__', args: machine_args) != ''
- )
+ if cc.get_define('__AVX512F__', args: machine_args) == ''
+ cc_avx512_flags = [avx512_march_flag]
+ if cc.has_argument('-Wno-overriding-option')
+ cc_avx512_args += '-Wno-overriding-option'
+ endif
+ endif
+ endif
+endif
+if developer_mode
+ message('Extra C flags needed for AVX2 output: @0@'.format(cc_avx2_flags))
+ if cc_has_avx512
+ message('Extra C flags needed for AVX512 output: @0@'.format(cc_avx512_flags))
endif
endif
diff --git a/drivers/meson.build b/drivers/meson.build
index b0850bbb24..51c824ea40 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -267,18 +267,11 @@ foreach subpath:subdirs
endif
if sources_avx512.length() > 0 and cc_has_avx512
cflags += '-DCC_AVX512_SUPPORT'
- avx512_args = [cflags, cc_avx512_flags]
- if not target_has_avx512 and cc.has_argument('-march=skylake-avx512')
- avx512_args += '-march=skylake-avx512'
- if cc.has_argument('-Wno-overriding-option')
- avx512_args += '-Wno-overriding-option'
- endif
- endif
avx512_lib = static_library(lib_name + '_avx512_lib',
sources_avx512,
dependencies: static_deps,
include_directories: includes,
- c_args: avx512_args)
+ c_args: [cflags, cc_avx512_flags])
objs += avx512_lib.extract_objects(sources_avx512)
endif
endif
diff --git a/lib/meson.build b/lib/meson.build
index 41fd98f4e9..16389b9c34 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -260,18 +260,11 @@ foreach l:libraries
endif
if sources_avx512.length() > 0 and cc_has_avx512
cflags += '-DCC_AVX512_SUPPORT'
- avx512_args = [cflags, cflags_avx512, cc_avx512_flags]
- if not target_has_avx512 and cc.has_argument('-march=skylake-avx512')
- avx512_args += '-march=skylake-avx512'
- if cc.has_argument('-Wno-overriding-option')
- avx512_args += '-Wno-overriding-option'
- endif
- endif
avx512_lib = static_library(libname + '_avx512_lib',
sources_avx512,
dependencies: static_deps,
include_directories: includes,
- c_args: avx512_args)
+ c_args: [cflags, cflags_avx512, cc_avx512_flags])
objs += avx512_lib.extract_objects(sources_avx512)
endif
endif
--
2.48.1
next prev parent reply other threads:[~2025-05-27 16:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-25 17:22 [RFC PATCH] " Bruce Richardson
2025-03-26 16:21 ` Bruce Richardson
2025-03-26 18:06 ` Morten Brørup
2025-03-26 19:20 ` Stephen Hemminger
2025-03-27 7:55 ` DPDK compilers and RHEL 7 support Morten Brørup
2025-03-27 11:11 ` Kevin Traynor
2025-04-09 9:53 ` [RFC PATCH] build: reduce use of AVX compiler flags Varghese, Vipin
2025-04-09 11:31 ` Bruce Richardson
2025-04-10 3:49 ` Varghese, Vipin
2025-05-27 16:24 ` Bruce Richardson [this message]
2025-05-29 10:01 ` [PATCH v2] " Bruce Richardson
2025-05-29 10:33 ` Bruce Richardson
2025-05-29 10:31 ` [PATCH v3] " Bruce Richardson
2025-05-29 15:42 ` [PATCH v4] " Bruce Richardson
2025-05-30 9:30 ` 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=20250527162716.319713-1-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=Vipin.Varghese@amd.com \
--cc=dev@dpdk.org \
/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).