build: allow disabling avx512 support via compiler flag

Message ID 20250121164114.2311086-1-bruce.richardson@intel.com (mailing list archive)
State Accepted
Delegated to: Thomas Monjalon
Headers
Series build: allow disabling avx512 support via compiler flag |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS

Commit Message

Bruce Richardson Jan. 21, 2025, 4:41 p.m. UTC
DPDK build checks for build support for various instruction sets by
checking both the target machine and the compiler for support. However,
any disabling of instruction sets via compiler flags was not taken into
account in many cases. For AVX512 support, check for a user-specified
"no-avx512f" flag in the c_args parameter before checking if the
compiler can actually build AVX512 code.

As well as providing an option for the user, this can be used to test
builds without AVX512 without having to use an older compiler.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 config/x86/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Stokes, Ian Feb. 11, 2025, 5:02 p.m. UTC | #1
> DPDK build checks for build support for various instruction sets by
> checking both the target machine and the compiler for support. However,
> any disabling of instruction sets via compiler flags was not taken into
> account in many cases. For AVX512 support, check for a user-specified
> "no-avx512f" flag in the c_args parameter before checking if the
> compiler can actually build AVX512 code.
> 
> As well as providing an option for the user, this can be used to test
> builds without AVX512 without having to use an older compiler.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  config/x86/meson.build | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/config/x86/meson.build b/config/x86/meson.build
> index 5455bb0210..47a5b0c04a 100644
> --- a/config/x86/meson.build
> +++ b/config/x86/meson.build
> @@ -17,7 +17,8 @@ endif
>  cc_avx512_flags = ['-mavx512f', '-mavx512vl', '-mavx512dq', '-mavx512bw']
>  cc_has_avx512 = false
>  target_has_avx512 = false
> -if binutils_ok and cc.has_multi_arguments(cc_avx512_flags)
> +if (binutils_ok and cc.has_multi_arguments(cc_avx512_flags)
> +        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>
> --
> 2.43.0

Thanks Bruce,

tested ok for me, LGTM.

Acked-by: Ian Stokes <ian.stokes@intel.com>
  
Thomas Monjalon Feb. 12, 2025, 3:35 p.m. UTC | #2
11/02/2025 18:02, Stokes, Ian:
> > DPDK build checks for build support for various instruction sets by
> > checking both the target machine and the compiler for support. However,
> > any disabling of instruction sets via compiler flags was not taken into
> > account in many cases. For AVX512 support, check for a user-specified
> > "no-avx512f" flag in the c_args parameter before checking if the
> > compiler can actually build AVX512 code.
> > 
> > As well as providing an option for the user, this can be used to test
> > builds without AVX512 without having to use an older compiler.
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> Thanks Bruce,
> 
> tested ok for me, LGTM.
> 
> Acked-by: Ian Stokes <ian.stokes@intel.com>

Applied, thanks.
  

Patch

diff --git a/config/x86/meson.build b/config/x86/meson.build
index 5455bb0210..47a5b0c04a 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -17,7 +17,8 @@  endif
 cc_avx512_flags = ['-mavx512f', '-mavx512vl', '-mavx512dq', '-mavx512bw']
 cc_has_avx512 = false
 target_has_avx512 = false
-if binutils_ok and cc.has_multi_arguments(cc_avx512_flags)
+if (binutils_ok and cc.has_multi_arguments(cc_avx512_flags)
+        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>