DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1 0/8] centralize AVX-512 feature detection
@ 2024-09-30 17:50 Bruce Richardson
  2024-09-30 17:50 ` [PATCH v1 1/8] config/x86: add global defines for checking AVX-512 Bruce Richardson
                   ` (9 more replies)
  0 siblings, 10 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-09-30 17:50 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson

The meson code to detect CPU and compiler support for AVX512 was duplicated
across multiple drivers. Do all detection in just a single place to simplify
the code.

Bruce Richardson (8):
  config/x86: add global defines for checking AVX-512
  event/dlb2: use global AVX-512 variables
  common/idpf: use global AVX-512 variables
  net/cpfl: use global AVX-512 variables
  net/i40e: use global AVX-512 variables
  net/iavf: use global AVX-512 variables
  net/ice: use global AVX-512 variables
  net/idpf: use global AVX-512 variables

 config/x86/meson.build          | 12 +++++++++-
 drivers/common/idpf/meson.build | 17 ++-----------
 drivers/event/dlb2/meson.build  | 42 +++++++--------------------------
 drivers/net/cpfl/meson.build    | 19 ++-------------
 drivers/net/i40e/meson.build    | 13 ++--------
 drivers/net/iavf/meson.build    | 13 ++--------
 drivers/net/ice/meson.build     | 15 ++----------
 drivers/net/idpf/meson.build    | 19 ++-------------
 8 files changed, 32 insertions(+), 118 deletions(-)

--
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v1 1/8] config/x86: add global defines for checking AVX-512
  2024-09-30 17:50 [PATCH v1 0/8] centralize AVX-512 feature detection Bruce Richardson
@ 2024-09-30 17:50 ` Bruce Richardson
  2024-09-30 17:50 ` [PATCH v1 2/8] event/dlb2: use global AVX-512 variables Bruce Richardson
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-09-30 17:50 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Konstantin Ananyev

Rather than having each driver do its own checking for AVX-512 support,
let's do it once in config/x86/meson.build and let all drivers re-use
that result.

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

diff --git a/config/x86/meson.build b/config/x86/meson.build
index 8087b9ae91..f973878371 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -16,7 +16,8 @@ endif
 
 # check if compiler is working with _mm512_extracti64x4_epi64
 # Ref: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82887
-if cc.has_argument('-mavx512f')
+cc_has_avx512 = false
+if binutils_ok and cc.has_argument('-mavx512f')
     code = '''#include <immintrin.h>
     void test(__m512i zmm){
         __m256i ymm = _mm512_extracti64x4_epi64(zmm, 0);}'''
@@ -24,6 +25,15 @@ if cc.has_argument('-mavx512f')
     if result == false
         machine_args += '-mno-avx512f'
         warning('Broken _mm512_extracti64x4_epi64, disabling AVX512 support')
+    else
+        cc_avx512_flags = ['-mavx512f', '-mavx512vl', '-mavx512dq', '-mavx512bw']
+        cc_has_avx512 = cc.has_multi_arguments(cc_avx512_flags)
+        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) != ''
+            )
     endif
 endif
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v1 2/8] event/dlb2: use global AVX-512 variables
  2024-09-30 17:50 [PATCH v1 0/8] centralize AVX-512 feature detection Bruce Richardson
  2024-09-30 17:50 ` [PATCH v1 1/8] config/x86: add global defines for checking AVX-512 Bruce Richardson
@ 2024-09-30 17:50 ` Bruce Richardson
  2024-09-30 17:50 ` [PATCH v1 3/8] common/idpf: " Bruce Richardson
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-09-30 17:50 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Abdullah Sevincer

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/event/dlb2/meson.build | 42 ++++++++--------------------------
 1 file changed, 9 insertions(+), 33 deletions(-)

diff --git a/drivers/event/dlb2/meson.build b/drivers/event/dlb2/meson.build
index 515d1795fe..34131fd18b 100644
--- a/drivers/event/dlb2/meson.build
+++ b/drivers/event/dlb2/meson.build
@@ -26,43 +26,19 @@ sources = files(
 # we are building 64-bit binary (checked above) AND binutils
 # can generate proper code
 
-if binutils_ok
+if target_has_avx512
+    sources += files('dlb2_avx512.c')
+    cflags += '-DCC_AVX512_SUPPORT'
 
-    # compile AVX512 version if either:
-    # a. we have AVX512VL supported in minimum instruction set
-    #    baseline
-    # b. it's not minimum instruction set, but supported by
-    #    compiler
-    #
-    # in former case, just add avx512 C file to files list
-    # in latter case, compile c file to static lib, using correct
-    # compiler flags, and then have the .o file from static lib
-    # linked into main lib.
-
-    # check if all required flags already enabled (variant a).
-    dlb2_avx512_on = false
-    if cc.get_define('__AVX512VL__', args: machine_args) != ''
-        dlb2_avx512_on = true
-    endif
-
-    if dlb2_avx512_on == true
-
-        sources += files('dlb2_avx512.c')
-        cflags += '-DCC_AVX512_SUPPORT'
-
-    elif cc.has_multi_arguments('-mavx512vl')
-
-        cflags += '-DCC_AVX512_SUPPORT'
-        avx512_tmplib = static_library('avx512_tmp',
+elif cc_has_avx512
+    cflags += '-DCC_AVX512_SUPPORT'
+    avx512_tmplib = static_library('avx512_tmp',
                                'dlb2_avx512.c',
                                dependencies: [static_rte_eal, static_rte_eventdev],
-                               c_args: cflags + ['-mavx512vl'])
-        objs += avx512_tmplib.extract_objects('dlb2_avx512.c')
-    else
-        sources += files('dlb2_sse.c')
-    endif
+                               c_args: cflags + cc_avx512_flags)
+    objs += avx512_tmplib.extract_objects('dlb2_avx512.c')
 else
-        sources += files('dlb2_sse.c')
+    sources += files('dlb2_sse.c')
 endif
 
 headers = files('rte_pmd_dlb2.h')
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v1 3/8] common/idpf: use global AVX-512 variables
  2024-09-30 17:50 [PATCH v1 0/8] centralize AVX-512 feature detection Bruce Richardson
  2024-09-30 17:50 ` [PATCH v1 1/8] config/x86: add global defines for checking AVX-512 Bruce Richardson
  2024-09-30 17:50 ` [PATCH v1 2/8] event/dlb2: use global AVX-512 variables Bruce Richardson
@ 2024-09-30 17:50 ` Bruce Richardson
  2024-09-30 17:50 ` [PATCH v1 4/8] net/cpfl: " Bruce Richardson
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-09-30 17:50 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Jingjing Wu

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/common/idpf/meson.build | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/common/idpf/meson.build b/drivers/common/idpf/meson.build
index 80c8906f80..1cf215186c 100644
--- a/drivers/common/idpf/meson.build
+++ b/drivers/common/idpf/meson.build
@@ -16,22 +16,9 @@ sources = files(
 )
 
 if arch_subdir == 'x86'
-    idpf_avx512_cpu_support = (
-        cc.get_define('__AVX512F__', args: machine_args) != '' and
-        cc.get_define('__AVX512BW__', args: machine_args) != '' and
-        cc.get_define('__AVX512DQ__', args: machine_args) != ''
-    )
-
-    idpf_avx512_cc_support = (
-        not machine_args.contains('-mno-avx512f') and
-        cc.has_argument('-mavx512f') and
-        cc.has_argument('-mavx512bw') and
-        cc.has_argument('-mavx512dq')
-    )
-
-    if idpf_avx512_cpu_support == true or idpf_avx512_cc_support == true
+    if target_has_avx512 or cc_has_avx512
         cflags += ['-DCC_AVX512_SUPPORT']
-        avx512_args = [cflags, '-mavx512f', '-mavx512bw', '-mavx512dq']
+        avx512_args = [cflags] + cc_avx512_flags
         if cc.has_argument('-march=skylake-avx512')
             avx512_args += '-march=skylake-avx512'
         endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v1 4/8] net/cpfl: use global AVX-512 variables
  2024-09-30 17:50 [PATCH v1 0/8] centralize AVX-512 feature detection Bruce Richardson
                   ` (2 preceding siblings ...)
  2024-09-30 17:50 ` [PATCH v1 3/8] common/idpf: " Bruce Richardson
@ 2024-09-30 17:50 ` Bruce Richardson
  2024-09-30 17:50 ` [PATCH v1 5/8] net/i40e: " Bruce Richardson
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-09-30 17:50 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/cpfl/meson.build | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/net/cpfl/meson.build b/drivers/net/cpfl/meson.build
index e4e0e269bd..87fcfe0bb1 100644
--- a/drivers/net/cpfl/meson.build
+++ b/drivers/net/cpfl/meson.build
@@ -22,23 +22,8 @@ sources = files(
         'cpfl_rules.c',
 )
 
-if arch_subdir == 'x86'
-    cpfl_avx512_cpu_support = (
-        cc.get_define('__AVX512F__', args: machine_args) != '' and
-        cc.get_define('__AVX512BW__', args: machine_args) != '' and
-        cc.get_define('__AVX512DQ__', args: machine_args) != ''
-    )
-
-    cpfl_avx512_cc_support = (
-        not machine_args.contains('-mno-avx512f') and
-        cc.has_argument('-mavx512f') and
-        cc.has_argument('-mavx512bw') and
-        cc.has_argument('-mavx512dq')
-    )
-
-    if cpfl_avx512_cpu_support == true or cpfl_avx512_cc_support == true
-        cflags += ['-DCC_AVX512_SUPPORT']
-    endif
+if arch_subdir == 'x86' and cc_has_avx512
+    cflags += ['-DCC_AVX512_SUPPORT']
 endif
 
 if dpdk_conf.has('RTE_HAS_JANSSON')
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v1 5/8] net/i40e: use global AVX-512 variables
  2024-09-30 17:50 [PATCH v1 0/8] centralize AVX-512 feature detection Bruce Richardson
                   ` (3 preceding siblings ...)
  2024-09-30 17:50 ` [PATCH v1 4/8] net/cpfl: " Bruce Richardson
@ 2024-09-30 17:50 ` Bruce Richardson
  2024-09-30 17:50 ` [PATCH v1 6/8] net/iavf: " Bruce Richardson
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-09-30 17:50 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/i40e/meson.build | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/net/i40e/meson.build b/drivers/net/i40e/meson.build
index 80171b9dc6..ef7b1f5d34 100644
--- a/drivers/net/i40e/meson.build
+++ b/drivers/net/i40e/meson.build
@@ -57,18 +57,9 @@ if arch_subdir == 'x86'
             c_args: [cflags, '-mavx2'])
     objs += i40e_avx2_lib.extract_objects('i40e_rxtx_vec_avx2.c')
 
-    i40e_avx512_cpu_support = (
-        cc.get_define('__AVX512F__', args: machine_args) != '' and
-        cc.get_define('__AVX512BW__', args: machine_args) != '')
-
-    i40e_avx512_cc_support = (
-        not machine_args.contains('-mno-avx512f') and
-        cc.has_argument('-mavx512f') and
-        cc.has_argument('-mavx512bw'))
-
-    if i40e_avx512_cpu_support == true or i40e_avx512_cc_support == true
+    if cc_has_avx512
         cflags += ['-DCC_AVX512_SUPPORT']
-        avx512_args = [cflags, '-mavx512f', '-mavx512bw']
+        avx512_args = cflags + cc_avx512_flags
         if cc.has_argument('-march=skylake-avx512')
             avx512_args += '-march=skylake-avx512'
         endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v1 6/8] net/iavf: use global AVX-512 variables
  2024-09-30 17:50 [PATCH v1 0/8] centralize AVX-512 feature detection Bruce Richardson
                   ` (4 preceding siblings ...)
  2024-09-30 17:50 ` [PATCH v1 5/8] net/i40e: " Bruce Richardson
@ 2024-09-30 17:50 ` Bruce Richardson
  2024-09-30 17:50 ` [PATCH v1 7/8] net/ice: " Bruce Richardson
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-09-30 17:50 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Jingjing Wu

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/iavf/meson.build | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/net/iavf/meson.build b/drivers/net/iavf/meson.build
index 83aebd5596..27d104cc12 100644
--- a/drivers/net/iavf/meson.build
+++ b/drivers/net/iavf/meson.build
@@ -39,18 +39,9 @@ if arch_subdir == 'x86'
             c_args: [cflags, '-mavx2'])
     objs += iavf_avx2_lib.extract_objects('iavf_rxtx_vec_avx2.c')
 
-    iavf_avx512_cpu_support = (
-        cc.get_define('__AVX512F__', args: machine_args) != '' and
-        cc.get_define('__AVX512BW__', args: machine_args) != '')
-
-    iavf_avx512_cc_support = (
-        not machine_args.contains('-mno-avx512f') and
-        cc.has_argument('-mavx512f') and
-        cc.has_argument('-mavx512bw'))
-
-    if iavf_avx512_cpu_support == true or iavf_avx512_cc_support == true
+    if cc_has_avx512
         cflags += ['-DCC_AVX512_SUPPORT']
-        avx512_args = [cflags, '-mavx512f', '-mavx512bw']
+        avx512_args = cflags + cc_avx512_flags
         if cc.has_argument('-march=skylake-avx512')
             avx512_args += '-march=skylake-avx512'
         endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v1 7/8] net/ice: use global AVX-512 variables
  2024-09-30 17:50 [PATCH v1 0/8] centralize AVX-512 feature detection Bruce Richardson
                   ` (5 preceding siblings ...)
  2024-09-30 17:50 ` [PATCH v1 6/8] net/iavf: " Bruce Richardson
@ 2024-09-30 17:50 ` Bruce Richardson
  2024-09-30 17:50 ` [PATCH v1 8/8] net/idpf: " Bruce Richardson
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-09-30 17:50 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/ice/meson.build | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ice/meson.build b/drivers/net/ice/meson.build
index b7f2188e62..1c9dc0cc6d 100644
--- a/drivers/net/ice/meson.build
+++ b/drivers/net/ice/meson.build
@@ -35,20 +35,9 @@ if arch_subdir == 'x86'
             c_args: [cflags, '-mavx2'])
     objs += ice_avx2_lib.extract_objects('ice_rxtx_vec_avx2.c')
 
-    ice_avx512_cpu_support = (
-            cc.get_define('__AVX512F__', args: machine_args) != '' and
-                cc.get_define('__AVX512BW__', args: machine_args) != ''
-    )
-
-    ice_avx512_cc_support = (
-            not machine_args.contains('-mno-avx512f') and
-                cc.has_argument('-mavx512f') and
-                cc.has_argument('-mavx512bw')
-    )
-
-    if ice_avx512_cpu_support == true or ice_avx512_cc_support == true
+    if cc_has_avx512
         cflags += ['-DCC_AVX512_SUPPORT']
-        avx512_args = [cflags, '-mavx512f', '-mavx512bw']
+        avx512_args = cflags + cc_avx512_flags
         if cc.has_argument('-march=skylake-avx512')
             avx512_args += '-march=skylake-avx512'
         endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v1 8/8] net/idpf: use global AVX-512 variables
  2024-09-30 17:50 [PATCH v1 0/8] centralize AVX-512 feature detection Bruce Richardson
                   ` (6 preceding siblings ...)
  2024-09-30 17:50 ` [PATCH v1 7/8] net/ice: " Bruce Richardson
@ 2024-09-30 17:50 ` Bruce Richardson
  2024-10-01 11:17 ` [PATCH v2 0/8] centralize AVX-512 feature detection Bruce Richardson
  2024-10-08 16:52 ` [PATCH v3 00/10] " Bruce Richardson
  9 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-09-30 17:50 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Jingjing Wu

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/idpf/meson.build | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/net/idpf/meson.build b/drivers/net/idpf/meson.build
index cf49ef167d..34cbdc4da0 100644
--- a/drivers/net/idpf/meson.build
+++ b/drivers/net/idpf/meson.build
@@ -14,21 +14,6 @@ sources = files(
         'idpf_rxtx.c',
 )
 
-if arch_subdir == 'x86'
-    idpf_avx512_cpu_support = (
-        cc.get_define('__AVX512F__', args: machine_args) != '' and
-        cc.get_define('__AVX512BW__', args: machine_args) != '' and
-        cc.get_define('__AVX512DQ__', args: machine_args) != ''
-    )
-
-    idpf_avx512_cc_support = (
-        not machine_args.contains('-mno-avx512f') and
-        cc.has_argument('-mavx512f') and
-        cc.has_argument('-mavx512bw') and
-        cc.has_argument('-mavx512dq')
-    )
-
-    if idpf_avx512_cpu_support == true or idpf_avx512_cc_support == true
-        cflags += ['-DCC_AVX512_SUPPORT']
-    endif
+if arch_subdir == 'x86'and cc_has_avx512
+    cflags += ['-DCC_AVX512_SUPPORT']
 endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 0/8] centralize AVX-512 feature detection
  2024-09-30 17:50 [PATCH v1 0/8] centralize AVX-512 feature detection Bruce Richardson
                   ` (7 preceding siblings ...)
  2024-09-30 17:50 ` [PATCH v1 8/8] net/idpf: " Bruce Richardson
@ 2024-10-01 11:17 ` Bruce Richardson
  2024-10-01 11:17   ` [PATCH v2 1/8] config/x86: add global defines for checking AVX-512 Bruce Richardson
                     ` (8 more replies)
  2024-10-08 16:52 ` [PATCH v3 00/10] " Bruce Richardson
  9 siblings, 9 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-01 11:17 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson

The meson code to detect CPU and compiler support for AVX512 was duplicated
across multiple drivers. Do all detection in just a single place to simplify
the code.

v2: ensure that target_has_avx512 is always defined on x86 to fix build errors

Bruce Richardson (8):
  config/x86: add global defines for checking AVX-512
  event/dlb2: use global AVX-512 variables
  common/idpf: use global AVX-512 variables
  net/cpfl: use global AVX-512 variables
  net/i40e: use global AVX-512 variables
  net/iavf: use global AVX-512 variables
  net/ice: use global AVX-512 variables
  net/idpf: use global AVX-512 variables

 config/x86/meson.build          | 19 +++++++++++----
 drivers/common/idpf/meson.build | 17 ++-----------
 drivers/event/dlb2/meson.build  | 42 +++++++--------------------------
 drivers/net/cpfl/meson.build    | 19 ++-------------
 drivers/net/i40e/meson.build    | 13 ++--------
 drivers/net/iavf/meson.build    | 13 ++--------
 drivers/net/ice/meson.build     | 15 ++----------
 drivers/net/idpf/meson.build    | 19 ++-------------
 8 files changed, 36 insertions(+), 121 deletions(-)

--
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 1/8] config/x86: add global defines for checking AVX-512
  2024-10-01 11:17 ` [PATCH v2 0/8] centralize AVX-512 feature detection Bruce Richardson
@ 2024-10-01 11:17   ` Bruce Richardson
  2024-10-01 11:17   ` [PATCH v2 2/8] event/dlb2: use global AVX-512 variables Bruce Richardson
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-01 11:17 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Konstantin Ananyev

Rather than having each driver do its own checking for AVX-512 support,
let's do it once in config/x86/meson.build and let all drivers re-use
that result.

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

diff --git a/config/x86/meson.build b/config/x86/meson.build
index 8087b9ae91..265580a555 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -14,16 +14,27 @@ if is_linux or cc.get_id() == 'gcc'
     endif
 endif
 
-# check if compiler is working with _mm512_extracti64x4_epi64
-# Ref: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82887
-if cc.has_argument('-mavx512f')
+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)
+    # 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 : '-mavx512f', name : 'AVX512 checking')
+    result = cc.compiles(code, args : cc_avx512_flags, 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) != ''
+            )
     endif
 endif
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 2/8] event/dlb2: use global AVX-512 variables
  2024-10-01 11:17 ` [PATCH v2 0/8] centralize AVX-512 feature detection Bruce Richardson
  2024-10-01 11:17   ` [PATCH v2 1/8] config/x86: add global defines for checking AVX-512 Bruce Richardson
@ 2024-10-01 11:17   ` Bruce Richardson
  2024-10-01 11:17   ` [PATCH v2 3/8] common/idpf: " Bruce Richardson
                     ` (6 subsequent siblings)
  8 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-01 11:17 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Abdullah Sevincer

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/event/dlb2/meson.build | 42 ++++++++--------------------------
 1 file changed, 9 insertions(+), 33 deletions(-)

diff --git a/drivers/event/dlb2/meson.build b/drivers/event/dlb2/meson.build
index 515d1795fe..34131fd18b 100644
--- a/drivers/event/dlb2/meson.build
+++ b/drivers/event/dlb2/meson.build
@@ -26,43 +26,19 @@ sources = files(
 # we are building 64-bit binary (checked above) AND binutils
 # can generate proper code
 
-if binutils_ok
+if target_has_avx512
+    sources += files('dlb2_avx512.c')
+    cflags += '-DCC_AVX512_SUPPORT'
 
-    # compile AVX512 version if either:
-    # a. we have AVX512VL supported in minimum instruction set
-    #    baseline
-    # b. it's not minimum instruction set, but supported by
-    #    compiler
-    #
-    # in former case, just add avx512 C file to files list
-    # in latter case, compile c file to static lib, using correct
-    # compiler flags, and then have the .o file from static lib
-    # linked into main lib.
-
-    # check if all required flags already enabled (variant a).
-    dlb2_avx512_on = false
-    if cc.get_define('__AVX512VL__', args: machine_args) != ''
-        dlb2_avx512_on = true
-    endif
-
-    if dlb2_avx512_on == true
-
-        sources += files('dlb2_avx512.c')
-        cflags += '-DCC_AVX512_SUPPORT'
-
-    elif cc.has_multi_arguments('-mavx512vl')
-
-        cflags += '-DCC_AVX512_SUPPORT'
-        avx512_tmplib = static_library('avx512_tmp',
+elif cc_has_avx512
+    cflags += '-DCC_AVX512_SUPPORT'
+    avx512_tmplib = static_library('avx512_tmp',
                                'dlb2_avx512.c',
                                dependencies: [static_rte_eal, static_rte_eventdev],
-                               c_args: cflags + ['-mavx512vl'])
-        objs += avx512_tmplib.extract_objects('dlb2_avx512.c')
-    else
-        sources += files('dlb2_sse.c')
-    endif
+                               c_args: cflags + cc_avx512_flags)
+    objs += avx512_tmplib.extract_objects('dlb2_avx512.c')
 else
-        sources += files('dlb2_sse.c')
+    sources += files('dlb2_sse.c')
 endif
 
 headers = files('rte_pmd_dlb2.h')
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 3/8] common/idpf: use global AVX-512 variables
  2024-10-01 11:17 ` [PATCH v2 0/8] centralize AVX-512 feature detection Bruce Richardson
  2024-10-01 11:17   ` [PATCH v2 1/8] config/x86: add global defines for checking AVX-512 Bruce Richardson
  2024-10-01 11:17   ` [PATCH v2 2/8] event/dlb2: use global AVX-512 variables Bruce Richardson
@ 2024-10-01 11:17   ` Bruce Richardson
  2024-10-01 11:17   ` [PATCH v2 4/8] net/cpfl: " Bruce Richardson
                     ` (5 subsequent siblings)
  8 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-01 11:17 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Jingjing Wu

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/common/idpf/meson.build | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/common/idpf/meson.build b/drivers/common/idpf/meson.build
index 80c8906f80..cf00176293 100644
--- a/drivers/common/idpf/meson.build
+++ b/drivers/common/idpf/meson.build
@@ -16,22 +16,9 @@ sources = files(
 )
 
 if arch_subdir == 'x86'
-    idpf_avx512_cpu_support = (
-        cc.get_define('__AVX512F__', args: machine_args) != '' and
-        cc.get_define('__AVX512BW__', args: machine_args) != '' and
-        cc.get_define('__AVX512DQ__', args: machine_args) != ''
-    )
-
-    idpf_avx512_cc_support = (
-        not machine_args.contains('-mno-avx512f') and
-        cc.has_argument('-mavx512f') and
-        cc.has_argument('-mavx512bw') and
-        cc.has_argument('-mavx512dq')
-    )
-
-    if idpf_avx512_cpu_support == true or idpf_avx512_cc_support == true
+    if cc_has_avx512
         cflags += ['-DCC_AVX512_SUPPORT']
-        avx512_args = [cflags, '-mavx512f', '-mavx512bw', '-mavx512dq']
+        avx512_args = [cflags] + cc_avx512_flags
         if cc.has_argument('-march=skylake-avx512')
             avx512_args += '-march=skylake-avx512'
         endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 4/8] net/cpfl: use global AVX-512 variables
  2024-10-01 11:17 ` [PATCH v2 0/8] centralize AVX-512 feature detection Bruce Richardson
                     ` (2 preceding siblings ...)
  2024-10-01 11:17   ` [PATCH v2 3/8] common/idpf: " Bruce Richardson
@ 2024-10-01 11:17   ` Bruce Richardson
  2024-10-01 11:17   ` [PATCH v2 5/8] net/i40e: " Bruce Richardson
                     ` (4 subsequent siblings)
  8 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-01 11:17 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/cpfl/meson.build | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/net/cpfl/meson.build b/drivers/net/cpfl/meson.build
index e4e0e269bd..87fcfe0bb1 100644
--- a/drivers/net/cpfl/meson.build
+++ b/drivers/net/cpfl/meson.build
@@ -22,23 +22,8 @@ sources = files(
         'cpfl_rules.c',
 )
 
-if arch_subdir == 'x86'
-    cpfl_avx512_cpu_support = (
-        cc.get_define('__AVX512F__', args: machine_args) != '' and
-        cc.get_define('__AVX512BW__', args: machine_args) != '' and
-        cc.get_define('__AVX512DQ__', args: machine_args) != ''
-    )
-
-    cpfl_avx512_cc_support = (
-        not machine_args.contains('-mno-avx512f') and
-        cc.has_argument('-mavx512f') and
-        cc.has_argument('-mavx512bw') and
-        cc.has_argument('-mavx512dq')
-    )
-
-    if cpfl_avx512_cpu_support == true or cpfl_avx512_cc_support == true
-        cflags += ['-DCC_AVX512_SUPPORT']
-    endif
+if arch_subdir == 'x86' and cc_has_avx512
+    cflags += ['-DCC_AVX512_SUPPORT']
 endif
 
 if dpdk_conf.has('RTE_HAS_JANSSON')
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 5/8] net/i40e: use global AVX-512 variables
  2024-10-01 11:17 ` [PATCH v2 0/8] centralize AVX-512 feature detection Bruce Richardson
                     ` (3 preceding siblings ...)
  2024-10-01 11:17   ` [PATCH v2 4/8] net/cpfl: " Bruce Richardson
@ 2024-10-01 11:17   ` Bruce Richardson
  2024-10-01 11:17   ` [PATCH v2 6/8] net/iavf: " Bruce Richardson
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-01 11:17 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/i40e/meson.build | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/net/i40e/meson.build b/drivers/net/i40e/meson.build
index 80171b9dc6..ef7b1f5d34 100644
--- a/drivers/net/i40e/meson.build
+++ b/drivers/net/i40e/meson.build
@@ -57,18 +57,9 @@ if arch_subdir == 'x86'
             c_args: [cflags, '-mavx2'])
     objs += i40e_avx2_lib.extract_objects('i40e_rxtx_vec_avx2.c')
 
-    i40e_avx512_cpu_support = (
-        cc.get_define('__AVX512F__', args: machine_args) != '' and
-        cc.get_define('__AVX512BW__', args: machine_args) != '')
-
-    i40e_avx512_cc_support = (
-        not machine_args.contains('-mno-avx512f') and
-        cc.has_argument('-mavx512f') and
-        cc.has_argument('-mavx512bw'))
-
-    if i40e_avx512_cpu_support == true or i40e_avx512_cc_support == true
+    if cc_has_avx512
         cflags += ['-DCC_AVX512_SUPPORT']
-        avx512_args = [cflags, '-mavx512f', '-mavx512bw']
+        avx512_args = cflags + cc_avx512_flags
         if cc.has_argument('-march=skylake-avx512')
             avx512_args += '-march=skylake-avx512'
         endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 6/8] net/iavf: use global AVX-512 variables
  2024-10-01 11:17 ` [PATCH v2 0/8] centralize AVX-512 feature detection Bruce Richardson
                     ` (4 preceding siblings ...)
  2024-10-01 11:17   ` [PATCH v2 5/8] net/i40e: " Bruce Richardson
@ 2024-10-01 11:17   ` Bruce Richardson
  2024-10-01 11:18   ` [PATCH v2 7/8] net/ice: " Bruce Richardson
                     ` (2 subsequent siblings)
  8 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-01 11:17 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Jingjing Wu

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/iavf/meson.build | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/net/iavf/meson.build b/drivers/net/iavf/meson.build
index 83aebd5596..27d104cc12 100644
--- a/drivers/net/iavf/meson.build
+++ b/drivers/net/iavf/meson.build
@@ -39,18 +39,9 @@ if arch_subdir == 'x86'
             c_args: [cflags, '-mavx2'])
     objs += iavf_avx2_lib.extract_objects('iavf_rxtx_vec_avx2.c')
 
-    iavf_avx512_cpu_support = (
-        cc.get_define('__AVX512F__', args: machine_args) != '' and
-        cc.get_define('__AVX512BW__', args: machine_args) != '')
-
-    iavf_avx512_cc_support = (
-        not machine_args.contains('-mno-avx512f') and
-        cc.has_argument('-mavx512f') and
-        cc.has_argument('-mavx512bw'))
-
-    if iavf_avx512_cpu_support == true or iavf_avx512_cc_support == true
+    if cc_has_avx512
         cflags += ['-DCC_AVX512_SUPPORT']
-        avx512_args = [cflags, '-mavx512f', '-mavx512bw']
+        avx512_args = cflags + cc_avx512_flags
         if cc.has_argument('-march=skylake-avx512')
             avx512_args += '-march=skylake-avx512'
         endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 7/8] net/ice: use global AVX-512 variables
  2024-10-01 11:17 ` [PATCH v2 0/8] centralize AVX-512 feature detection Bruce Richardson
                     ` (5 preceding siblings ...)
  2024-10-01 11:17   ` [PATCH v2 6/8] net/iavf: " Bruce Richardson
@ 2024-10-01 11:18   ` Bruce Richardson
  2024-10-01 11:18   ` [PATCH v2 8/8] net/idpf: " Bruce Richardson
  2024-10-08  8:49   ` [PATCH v2 0/8] centralize AVX-512 feature detection David Marchand
  8 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-01 11:18 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/ice/meson.build | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ice/meson.build b/drivers/net/ice/meson.build
index b7f2188e62..1c9dc0cc6d 100644
--- a/drivers/net/ice/meson.build
+++ b/drivers/net/ice/meson.build
@@ -35,20 +35,9 @@ if arch_subdir == 'x86'
             c_args: [cflags, '-mavx2'])
     objs += ice_avx2_lib.extract_objects('ice_rxtx_vec_avx2.c')
 
-    ice_avx512_cpu_support = (
-            cc.get_define('__AVX512F__', args: machine_args) != '' and
-                cc.get_define('__AVX512BW__', args: machine_args) != ''
-    )
-
-    ice_avx512_cc_support = (
-            not machine_args.contains('-mno-avx512f') and
-                cc.has_argument('-mavx512f') and
-                cc.has_argument('-mavx512bw')
-    )
-
-    if ice_avx512_cpu_support == true or ice_avx512_cc_support == true
+    if cc_has_avx512
         cflags += ['-DCC_AVX512_SUPPORT']
-        avx512_args = [cflags, '-mavx512f', '-mavx512bw']
+        avx512_args = cflags + cc_avx512_flags
         if cc.has_argument('-march=skylake-avx512')
             avx512_args += '-march=skylake-avx512'
         endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 8/8] net/idpf: use global AVX-512 variables
  2024-10-01 11:17 ` [PATCH v2 0/8] centralize AVX-512 feature detection Bruce Richardson
                     ` (6 preceding siblings ...)
  2024-10-01 11:18   ` [PATCH v2 7/8] net/ice: " Bruce Richardson
@ 2024-10-01 11:18   ` Bruce Richardson
  2024-10-08  8:49   ` [PATCH v2 0/8] centralize AVX-512 feature detection David Marchand
  8 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-01 11:18 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Jingjing Wu

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/idpf/meson.build | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/net/idpf/meson.build b/drivers/net/idpf/meson.build
index cf49ef167d..34cbdc4da0 100644
--- a/drivers/net/idpf/meson.build
+++ b/drivers/net/idpf/meson.build
@@ -14,21 +14,6 @@ sources = files(
         'idpf_rxtx.c',
 )
 
-if arch_subdir == 'x86'
-    idpf_avx512_cpu_support = (
-        cc.get_define('__AVX512F__', args: machine_args) != '' and
-        cc.get_define('__AVX512BW__', args: machine_args) != '' and
-        cc.get_define('__AVX512DQ__', args: machine_args) != ''
-    )
-
-    idpf_avx512_cc_support = (
-        not machine_args.contains('-mno-avx512f') and
-        cc.has_argument('-mavx512f') and
-        cc.has_argument('-mavx512bw') and
-        cc.has_argument('-mavx512dq')
-    )
-
-    if idpf_avx512_cpu_support == true or idpf_avx512_cc_support == true
-        cflags += ['-DCC_AVX512_SUPPORT']
-    endif
+if arch_subdir == 'x86'and cc_has_avx512
+    cflags += ['-DCC_AVX512_SUPPORT']
 endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 0/8] centralize AVX-512 feature detection
  2024-10-01 11:17 ` [PATCH v2 0/8] centralize AVX-512 feature detection Bruce Richardson
                     ` (7 preceding siblings ...)
  2024-10-01 11:18   ` [PATCH v2 8/8] net/idpf: " Bruce Richardson
@ 2024-10-08  8:49   ` David Marchand
  2024-10-08 10:02     ` Bruce Richardson
  8 siblings, 1 reply; 34+ messages in thread
From: David Marchand @ 2024-10-08  8:49 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Tue, Oct 1, 2024 at 1:19 PM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> The meson code to detect CPU and compiler support for AVX512 was duplicated
> across multiple drivers. Do all detection in just a single place to simplify
> the code.
>
> v2: ensure that target_has_avx512 is always defined on x86 to fix build errors
>
> Bruce Richardson (8):
>   config/x86: add global defines for checking AVX-512
>   event/dlb2: use global AVX-512 variables
>   common/idpf: use global AVX-512 variables
>   net/cpfl: use global AVX-512 variables
>   net/i40e: use global AVX-512 variables
>   net/iavf: use global AVX-512 variables
>   net/ice: use global AVX-512 variables
>   net/idpf: use global AVX-512 variables
>
>  config/x86/meson.build          | 19 +++++++++++----
>  drivers/common/idpf/meson.build | 17 ++-----------
>  drivers/event/dlb2/meson.build  | 42 +++++++--------------------------
>  drivers/net/cpfl/meson.build    | 19 ++-------------
>  drivers/net/i40e/meson.build    | 13 ++--------
>  drivers/net/iavf/meson.build    | 13 ++--------
>  drivers/net/ice/meson.build     | 15 ++----------
>  drivers/net/idpf/meson.build    | 19 ++-------------
>  8 files changed, 36 insertions(+), 121 deletions(-)

Thanks for this cleanup, I have two comments.

- Some drivers were going into great lenghts to check that individiual
avx512 features were available.
With this series, we end up requiring support for all features to
announce avx512 availability.
Are we perhaps disabling AVX512 support with some toolchains, out
there, supporting only part of the set?

- Some drivers were checking for presence of -mno-avx512f in
machine_args as a way to disable building any AVX512 stuff.
This gets discarded with this series.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 0/8] centralize AVX-512 feature detection
  2024-10-08  8:49   ` [PATCH v2 0/8] centralize AVX-512 feature detection David Marchand
@ 2024-10-08 10:02     ` Bruce Richardson
  2024-10-08 11:33       ` David Marchand
  0 siblings, 1 reply; 34+ messages in thread
From: Bruce Richardson @ 2024-10-08 10:02 UTC (permalink / raw)
  To: David Marchand; +Cc: dev

On Tue, Oct 08, 2024 at 10:49:39AM +0200, David Marchand wrote:
> On Tue, Oct 1, 2024 at 1:19 PM Bruce Richardson
> <bruce.richardson@intel.com> wrote:
> >
> > The meson code to detect CPU and compiler support for AVX512 was duplicated
> > across multiple drivers. Do all detection in just a single place to simplify
> > the code.
> >
> > v2: ensure that target_has_avx512 is always defined on x86 to fix build errors
> >
> > Bruce Richardson (8):
> >   config/x86: add global defines for checking AVX-512
> >   event/dlb2: use global AVX-512 variables
> >   common/idpf: use global AVX-512 variables
> >   net/cpfl: use global AVX-512 variables
> >   net/i40e: use global AVX-512 variables
> >   net/iavf: use global AVX-512 variables
> >   net/ice: use global AVX-512 variables
> >   net/idpf: use global AVX-512 variables
> >
> >  config/x86/meson.build          | 19 +++++++++++----
> >  drivers/common/idpf/meson.build | 17 ++-----------
> >  drivers/event/dlb2/meson.build  | 42 +++++++--------------------------
> >  drivers/net/cpfl/meson.build    | 19 ++-------------
> >  drivers/net/i40e/meson.build    | 13 ++--------
> >  drivers/net/iavf/meson.build    | 13 ++--------
> >  drivers/net/ice/meson.build     | 15 ++----------
> >  drivers/net/idpf/meson.build    | 19 ++-------------
> >  8 files changed, 36 insertions(+), 121 deletions(-)
> 
> Thanks for this cleanup, I have two comments.
> 
> - Some drivers were going into great lenghts to check that individiual
> avx512 features were available.
> With this series, we end up requiring support for all features to
> announce avx512 availability.
> Are we perhaps disabling AVX512 support with some toolchains, out
> there, supporting only part of the set?
> 

The various AVX-512 feature sets checked for (F, BW, VL, DQ) were all
introduced in the same hardware generation - all are available in gcc when
using -march=skylake-avx512 or later, or -march=znver4. On the toolchain
side, gcc introduced all these flags simultaneously in gcc-6 [1]. For
clang/llvm, testing with godbolt for compiler errors/warnings indicates
that all these 4 avx512 flags are available from clang 3.6 - the minimum we
support in DPDK [2]

[1] https://gcc.gnu.org/gcc-6/changes.html
[2] https://doc.dpdk.org/guides/linux_gsg/sys_reqs.html#compilation-of-the-dpdk

> - Some drivers were checking for presence of -mno-avx512f in
> machine_args as a way to disable building any AVX512 stuff.
> This gets discarded with this series.
> 

Yes, because it should no longer be necessary. The places in the build
system where we set the no-avx512f flag are reworked so that we don't have
cc_has_avx512 set.

Regards,
/Bruce

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 0/8] centralize AVX-512 feature detection
  2024-10-08 10:02     ` Bruce Richardson
@ 2024-10-08 11:33       ` David Marchand
  2024-10-08 11:35         ` Bruce Richardson
  0 siblings, 1 reply; 34+ messages in thread
From: David Marchand @ 2024-10-08 11:33 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Tue, Oct 8, 2024 at 12:03 PM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> On Tue, Oct 08, 2024 at 10:49:39AM +0200, David Marchand wrote:
> > On Tue, Oct 1, 2024 at 1:19 PM Bruce Richardson
> > <bruce.richardson@intel.com> wrote:
> > >
> > > The meson code to detect CPU and compiler support for AVX512 was duplicated
> > > across multiple drivers. Do all detection in just a single place to simplify
> > > the code.
> > >
> > > v2: ensure that target_has_avx512 is always defined on x86 to fix build errors
> > >
> > > Bruce Richardson (8):
> > >   config/x86: add global defines for checking AVX-512
> > >   event/dlb2: use global AVX-512 variables
> > >   common/idpf: use global AVX-512 variables
> > >   net/cpfl: use global AVX-512 variables
> > >   net/i40e: use global AVX-512 variables
> > >   net/iavf: use global AVX-512 variables
> > >   net/ice: use global AVX-512 variables
> > >   net/idpf: use global AVX-512 variables
> > >
> > >  config/x86/meson.build          | 19 +++++++++++----
> > >  drivers/common/idpf/meson.build | 17 ++-----------
> > >  drivers/event/dlb2/meson.build  | 42 +++++++--------------------------
> > >  drivers/net/cpfl/meson.build    | 19 ++-------------
> > >  drivers/net/i40e/meson.build    | 13 ++--------
> > >  drivers/net/iavf/meson.build    | 13 ++--------
> > >  drivers/net/ice/meson.build     | 15 ++----------
> > >  drivers/net/idpf/meson.build    | 19 ++-------------
> > >  8 files changed, 36 insertions(+), 121 deletions(-)
> >
> > Thanks for this cleanup, I have two comments.
> >
> > - Some drivers were going into great lenghts to check that individiual
> > avx512 features were available.
> > With this series, we end up requiring support for all features to
> > announce avx512 availability.
> > Are we perhaps disabling AVX512 support with some toolchains, out
> > there, supporting only part of the set?
> >
>
> The various AVX-512 feature sets checked for (F, BW, VL, DQ) were all
> introduced in the same hardware generation - all are available in gcc when
> using -march=skylake-avx512 or later, or -march=znver4. On the toolchain
> side, gcc introduced all these flags simultaneously in gcc-6 [1]. For
> clang/llvm, testing with godbolt for compiler errors/warnings indicates
> that all these 4 avx512 flags are available from clang 3.6 - the minimum we
> support in DPDK [2]
>
> [1] https://gcc.gnu.org/gcc-6/changes.html
> [2] https://doc.dpdk.org/guides/linux_gsg/sys_reqs.html#compilation-of-the-dpdk

Perfect, thanks for the details.

>
> > - Some drivers were checking for presence of -mno-avx512f in
> > machine_args as a way to disable building any AVX512 stuff.
> > This gets discarded with this series.
> >
>
> Yes, because it should no longer be necessary. The places in the build
> system where we set the no-avx512f flag are reworked so that we don't have
> cc_has_avx512 set.

Ok, it is clearer now.

Last comment on style:
$ git grep cc_avx512_flags drivers/
drivers/common/idpf/meson.build:        avx512_args = [cflags] + cc_avx512_flags
drivers/event/dlb2/meson.build:                               c_args:
cflags + cc_avx512_flags)
drivers/net/i40e/meson.build:        avx512_args = cflags + cc_avx512_flags
drivers/net/iavf/meson.build:        avx512_args = cflags + cc_avx512_flags
drivers/net/ice/meson.build:        avx512_args = cflags + cc_avx512_flags

I think it is safe to remove the [] around cflags in common/idpf, right?


Do you have some cycles to send a v2 and convert lib/net and net/virtio ?
Otherwise, can you do a followup patch for rc2?


Thanks.

-- 
David Marchand


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 0/8] centralize AVX-512 feature detection
  2024-10-08 11:33       ` David Marchand
@ 2024-10-08 11:35         ` Bruce Richardson
  0 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-08 11:35 UTC (permalink / raw)
  To: David Marchand; +Cc: dev

On Tue, Oct 08, 2024 at 01:33:16PM +0200, David Marchand wrote:
> On Tue, Oct 8, 2024 at 12:03 PM Bruce Richardson
> <bruce.richardson@intel.com> wrote:
> >
> > On Tue, Oct 08, 2024 at 10:49:39AM +0200, David Marchand wrote:
> > > On Tue, Oct 1, 2024 at 1:19 PM Bruce Richardson
> > > <bruce.richardson@intel.com> wrote:
> > > >
> > > > The meson code to detect CPU and compiler support for AVX512 was duplicated
> > > > across multiple drivers. Do all detection in just a single place to simplify
> > > > the code.
> > > >
> > > > v2: ensure that target_has_avx512 is always defined on x86 to fix build errors
> > > >
> > > > Bruce Richardson (8):
> > > >   config/x86: add global defines for checking AVX-512
> > > >   event/dlb2: use global AVX-512 variables
> > > >   common/idpf: use global AVX-512 variables
> > > >   net/cpfl: use global AVX-512 variables
> > > >   net/i40e: use global AVX-512 variables
> > > >   net/iavf: use global AVX-512 variables
> > > >   net/ice: use global AVX-512 variables
> > > >   net/idpf: use global AVX-512 variables
> > > >
> > > >  config/x86/meson.build          | 19 +++++++++++----
> > > >  drivers/common/idpf/meson.build | 17 ++-----------
> > > >  drivers/event/dlb2/meson.build  | 42 +++++++--------------------------
> > > >  drivers/net/cpfl/meson.build    | 19 ++-------------
> > > >  drivers/net/i40e/meson.build    | 13 ++--------
> > > >  drivers/net/iavf/meson.build    | 13 ++--------
> > > >  drivers/net/ice/meson.build     | 15 ++----------
> > > >  drivers/net/idpf/meson.build    | 19 ++-------------
> > > >  8 files changed, 36 insertions(+), 121 deletions(-)
> > >
> > > Thanks for this cleanup, I have two comments.
> > >
> > > - Some drivers were going into great lenghts to check that individiual
> > > avx512 features were available.
> > > With this series, we end up requiring support for all features to
> > > announce avx512 availability.
> > > Are we perhaps disabling AVX512 support with some toolchains, out
> > > there, supporting only part of the set?
> > >
> >
> > The various AVX-512 feature sets checked for (F, BW, VL, DQ) were all
> > introduced in the same hardware generation - all are available in gcc when
> > using -march=skylake-avx512 or later, or -march=znver4. On the toolchain
> > side, gcc introduced all these flags simultaneously in gcc-6 [1]. For
> > clang/llvm, testing with godbolt for compiler errors/warnings indicates
> > that all these 4 avx512 flags are available from clang 3.6 - the minimum we
> > support in DPDK [2]
> >
> > [1] https://gcc.gnu.org/gcc-6/changes.html
> > [2] https://doc.dpdk.org/guides/linux_gsg/sys_reqs.html#compilation-of-the-dpdk
> 
> Perfect, thanks for the details.
> 
> >
> > > - Some drivers were checking for presence of -mno-avx512f in
> > > machine_args as a way to disable building any AVX512 stuff.
> > > This gets discarded with this series.
> > >
> >
> > Yes, because it should no longer be necessary. The places in the build
> > system where we set the no-avx512f flag are reworked so that we don't have
> > cc_has_avx512 set.
> 
> Ok, it is clearer now.
> 
> Last comment on style:
> $ git grep cc_avx512_flags drivers/
> drivers/common/idpf/meson.build:        avx512_args = [cflags] + cc_avx512_flags
> drivers/event/dlb2/meson.build:                               c_args:
> cflags + cc_avx512_flags)
> drivers/net/i40e/meson.build:        avx512_args = cflags + cc_avx512_flags
> drivers/net/iavf/meson.build:        avx512_args = cflags + cc_avx512_flags
> drivers/net/ice/meson.build:        avx512_args = cflags + cc_avx512_flags
> 
> I think it is safe to remove the [] around cflags in common/idpf, right?
> 
Yep.

> 
> Do you have some cycles to send a v2 and convert lib/net and net/virtio ?
> Otherwise, can you do a followup patch for rc2?
> 
I'll see what I can do today.

/Bruce

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v3 00/10] centralize AVX-512 feature detection
  2024-09-30 17:50 [PATCH v1 0/8] centralize AVX-512 feature detection Bruce Richardson
                   ` (8 preceding siblings ...)
  2024-10-01 11:17 ` [PATCH v2 0/8] centralize AVX-512 feature detection Bruce Richardson
@ 2024-10-08 16:52 ` Bruce Richardson
  2024-10-08 16:52   ` [PATCH v3 01/10] config/x86: add global defines for checking AVX-512 Bruce Richardson
                     ` (10 more replies)
  9 siblings, 11 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-08 16:52 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, Bruce Richardson

The meson code to detect CPU and compiler support for AVX512 was duplicated
across multiple components. Do all detection in just a single place to simplify
the code.

v3: add in patches for net lib and virtio driver
v2: ensure that target_has_avx512 is always defined on x86 to fix build errors


Bruce Richardson (10):
  config/x86: add global defines for checking AVX-512
  event/dlb2: use global AVX-512 variables
  common/idpf: use global AVX-512 variables
  net/cpfl: use global AVX-512 variables
  net/i40e: use global AVX-512 variables
  net/iavf: use global AVX-512 variables
  net/ice: use global AVX-512 variables
  net/idpf: use global AVX-512 variables
  net/virtio: use global AVX-512 variables
  net: use global AVX-512 variables

 config/x86/meson.build          | 19 +++++++++++----
 drivers/common/idpf/meson.build | 17 ++-----------
 drivers/event/dlb2/meson.build  | 42 +++++++--------------------------
 drivers/net/cpfl/meson.build    | 19 ++-------------
 drivers/net/i40e/meson.build    | 13 ++--------
 drivers/net/iavf/meson.build    | 13 ++--------
 drivers/net/ice/meson.build     | 15 ++----------
 drivers/net/idpf/meson.build    | 19 ++-------------
 drivers/net/virtio/meson.build  | 32 ++++++++++++-------------
 lib/net/meson.build             | 40 ++++---------------------------
 10 files changed, 55 insertions(+), 174 deletions(-)

--
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v3 01/10] config/x86: add global defines for checking AVX-512
  2024-10-08 16:52 ` [PATCH v3 00/10] " Bruce Richardson
@ 2024-10-08 16:52   ` Bruce Richardson
  2024-10-08 16:52   ` [PATCH v3 02/10] event/dlb2: use global AVX-512 variables Bruce Richardson
                     ` (9 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-08 16:52 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, Bruce Richardson

Rather than having each driver do its own checking for AVX-512 support,
let's do it once in config/x86/meson.build and let all drivers re-use
that result.

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

diff --git a/config/x86/meson.build b/config/x86/meson.build
index 8087b9ae91..265580a555 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -14,16 +14,27 @@ if is_linux or cc.get_id() == 'gcc'
     endif
 endif
 
-# check if compiler is working with _mm512_extracti64x4_epi64
-# Ref: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82887
-if cc.has_argument('-mavx512f')
+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)
+    # 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 : '-mavx512f', name : 'AVX512 checking')
+    result = cc.compiles(code, args : cc_avx512_flags, 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) != ''
+            )
     endif
 endif
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v3 02/10] event/dlb2: use global AVX-512 variables
  2024-10-08 16:52 ` [PATCH v3 00/10] " Bruce Richardson
  2024-10-08 16:52   ` [PATCH v3 01/10] config/x86: add global defines for checking AVX-512 Bruce Richardson
@ 2024-10-08 16:52   ` Bruce Richardson
  2024-10-08 16:52   ` [PATCH v3 03/10] common/idpf: " Bruce Richardson
                     ` (8 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-08 16:52 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, Bruce Richardson

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/event/dlb2/meson.build | 42 ++++++++--------------------------
 1 file changed, 9 insertions(+), 33 deletions(-)

diff --git a/drivers/event/dlb2/meson.build b/drivers/event/dlb2/meson.build
index 515d1795fe..34131fd18b 100644
--- a/drivers/event/dlb2/meson.build
+++ b/drivers/event/dlb2/meson.build
@@ -26,43 +26,19 @@ sources = files(
 # we are building 64-bit binary (checked above) AND binutils
 # can generate proper code
 
-if binutils_ok
+if target_has_avx512
+    sources += files('dlb2_avx512.c')
+    cflags += '-DCC_AVX512_SUPPORT'
 
-    # compile AVX512 version if either:
-    # a. we have AVX512VL supported in minimum instruction set
-    #    baseline
-    # b. it's not minimum instruction set, but supported by
-    #    compiler
-    #
-    # in former case, just add avx512 C file to files list
-    # in latter case, compile c file to static lib, using correct
-    # compiler flags, and then have the .o file from static lib
-    # linked into main lib.
-
-    # check if all required flags already enabled (variant a).
-    dlb2_avx512_on = false
-    if cc.get_define('__AVX512VL__', args: machine_args) != ''
-        dlb2_avx512_on = true
-    endif
-
-    if dlb2_avx512_on == true
-
-        sources += files('dlb2_avx512.c')
-        cflags += '-DCC_AVX512_SUPPORT'
-
-    elif cc.has_multi_arguments('-mavx512vl')
-
-        cflags += '-DCC_AVX512_SUPPORT'
-        avx512_tmplib = static_library('avx512_tmp',
+elif cc_has_avx512
+    cflags += '-DCC_AVX512_SUPPORT'
+    avx512_tmplib = static_library('avx512_tmp',
                                'dlb2_avx512.c',
                                dependencies: [static_rte_eal, static_rte_eventdev],
-                               c_args: cflags + ['-mavx512vl'])
-        objs += avx512_tmplib.extract_objects('dlb2_avx512.c')
-    else
-        sources += files('dlb2_sse.c')
-    endif
+                               c_args: cflags + cc_avx512_flags)
+    objs += avx512_tmplib.extract_objects('dlb2_avx512.c')
 else
-        sources += files('dlb2_sse.c')
+    sources += files('dlb2_sse.c')
 endif
 
 headers = files('rte_pmd_dlb2.h')
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v3 03/10] common/idpf: use global AVX-512 variables
  2024-10-08 16:52 ` [PATCH v3 00/10] " Bruce Richardson
  2024-10-08 16:52   ` [PATCH v3 01/10] config/x86: add global defines for checking AVX-512 Bruce Richardson
  2024-10-08 16:52   ` [PATCH v3 02/10] event/dlb2: use global AVX-512 variables Bruce Richardson
@ 2024-10-08 16:52   ` Bruce Richardson
  2024-10-08 16:52   ` [PATCH v3 04/10] net/cpfl: " Bruce Richardson
                     ` (7 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-08 16:52 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, Bruce Richardson

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/common/idpf/meson.build | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/common/idpf/meson.build b/drivers/common/idpf/meson.build
index 80c8906f80..46fd45c03b 100644
--- a/drivers/common/idpf/meson.build
+++ b/drivers/common/idpf/meson.build
@@ -16,22 +16,9 @@ sources = files(
 )
 
 if arch_subdir == 'x86'
-    idpf_avx512_cpu_support = (
-        cc.get_define('__AVX512F__', args: machine_args) != '' and
-        cc.get_define('__AVX512BW__', args: machine_args) != '' and
-        cc.get_define('__AVX512DQ__', args: machine_args) != ''
-    )
-
-    idpf_avx512_cc_support = (
-        not machine_args.contains('-mno-avx512f') and
-        cc.has_argument('-mavx512f') and
-        cc.has_argument('-mavx512bw') and
-        cc.has_argument('-mavx512dq')
-    )
-
-    if idpf_avx512_cpu_support == true or idpf_avx512_cc_support == true
+    if cc_has_avx512
         cflags += ['-DCC_AVX512_SUPPORT']
-        avx512_args = [cflags, '-mavx512f', '-mavx512bw', '-mavx512dq']
+        avx512_args = cflags + cc_avx512_flags
         if cc.has_argument('-march=skylake-avx512')
             avx512_args += '-march=skylake-avx512'
         endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v3 04/10] net/cpfl: use global AVX-512 variables
  2024-10-08 16:52 ` [PATCH v3 00/10] " Bruce Richardson
                     ` (2 preceding siblings ...)
  2024-10-08 16:52   ` [PATCH v3 03/10] common/idpf: " Bruce Richardson
@ 2024-10-08 16:52   ` Bruce Richardson
  2024-10-08 16:52   ` [PATCH v3 05/10] net/i40e: " Bruce Richardson
                     ` (6 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-08 16:52 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, Bruce Richardson

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/cpfl/meson.build | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/net/cpfl/meson.build b/drivers/net/cpfl/meson.build
index e4e0e269bd..87fcfe0bb1 100644
--- a/drivers/net/cpfl/meson.build
+++ b/drivers/net/cpfl/meson.build
@@ -22,23 +22,8 @@ sources = files(
         'cpfl_rules.c',
 )
 
-if arch_subdir == 'x86'
-    cpfl_avx512_cpu_support = (
-        cc.get_define('__AVX512F__', args: machine_args) != '' and
-        cc.get_define('__AVX512BW__', args: machine_args) != '' and
-        cc.get_define('__AVX512DQ__', args: machine_args) != ''
-    )
-
-    cpfl_avx512_cc_support = (
-        not machine_args.contains('-mno-avx512f') and
-        cc.has_argument('-mavx512f') and
-        cc.has_argument('-mavx512bw') and
-        cc.has_argument('-mavx512dq')
-    )
-
-    if cpfl_avx512_cpu_support == true or cpfl_avx512_cc_support == true
-        cflags += ['-DCC_AVX512_SUPPORT']
-    endif
+if arch_subdir == 'x86' and cc_has_avx512
+    cflags += ['-DCC_AVX512_SUPPORT']
 endif
 
 if dpdk_conf.has('RTE_HAS_JANSSON')
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v3 05/10] net/i40e: use global AVX-512 variables
  2024-10-08 16:52 ` [PATCH v3 00/10] " Bruce Richardson
                     ` (3 preceding siblings ...)
  2024-10-08 16:52   ` [PATCH v3 04/10] net/cpfl: " Bruce Richardson
@ 2024-10-08 16:52   ` Bruce Richardson
  2024-10-08 16:52   ` [PATCH v3 06/10] net/iavf: " Bruce Richardson
                     ` (5 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-08 16:52 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, Bruce Richardson

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/i40e/meson.build | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/net/i40e/meson.build b/drivers/net/i40e/meson.build
index 80171b9dc6..ef7b1f5d34 100644
--- a/drivers/net/i40e/meson.build
+++ b/drivers/net/i40e/meson.build
@@ -57,18 +57,9 @@ if arch_subdir == 'x86'
             c_args: [cflags, '-mavx2'])
     objs += i40e_avx2_lib.extract_objects('i40e_rxtx_vec_avx2.c')
 
-    i40e_avx512_cpu_support = (
-        cc.get_define('__AVX512F__', args: machine_args) != '' and
-        cc.get_define('__AVX512BW__', args: machine_args) != '')
-
-    i40e_avx512_cc_support = (
-        not machine_args.contains('-mno-avx512f') and
-        cc.has_argument('-mavx512f') and
-        cc.has_argument('-mavx512bw'))
-
-    if i40e_avx512_cpu_support == true or i40e_avx512_cc_support == true
+    if cc_has_avx512
         cflags += ['-DCC_AVX512_SUPPORT']
-        avx512_args = [cflags, '-mavx512f', '-mavx512bw']
+        avx512_args = cflags + cc_avx512_flags
         if cc.has_argument('-march=skylake-avx512')
             avx512_args += '-march=skylake-avx512'
         endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v3 06/10] net/iavf: use global AVX-512 variables
  2024-10-08 16:52 ` [PATCH v3 00/10] " Bruce Richardson
                     ` (4 preceding siblings ...)
  2024-10-08 16:52   ` [PATCH v3 05/10] net/i40e: " Bruce Richardson
@ 2024-10-08 16:52   ` Bruce Richardson
  2024-10-08 16:52   ` [PATCH v3 07/10] net/ice: " Bruce Richardson
                     ` (4 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-08 16:52 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, Bruce Richardson

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/iavf/meson.build | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/net/iavf/meson.build b/drivers/net/iavf/meson.build
index 83aebd5596..27d104cc12 100644
--- a/drivers/net/iavf/meson.build
+++ b/drivers/net/iavf/meson.build
@@ -39,18 +39,9 @@ if arch_subdir == 'x86'
             c_args: [cflags, '-mavx2'])
     objs += iavf_avx2_lib.extract_objects('iavf_rxtx_vec_avx2.c')
 
-    iavf_avx512_cpu_support = (
-        cc.get_define('__AVX512F__', args: machine_args) != '' and
-        cc.get_define('__AVX512BW__', args: machine_args) != '')
-
-    iavf_avx512_cc_support = (
-        not machine_args.contains('-mno-avx512f') and
-        cc.has_argument('-mavx512f') and
-        cc.has_argument('-mavx512bw'))
-
-    if iavf_avx512_cpu_support == true or iavf_avx512_cc_support == true
+    if cc_has_avx512
         cflags += ['-DCC_AVX512_SUPPORT']
-        avx512_args = [cflags, '-mavx512f', '-mavx512bw']
+        avx512_args = cflags + cc_avx512_flags
         if cc.has_argument('-march=skylake-avx512')
             avx512_args += '-march=skylake-avx512'
         endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v3 07/10] net/ice: use global AVX-512 variables
  2024-10-08 16:52 ` [PATCH v3 00/10] " Bruce Richardson
                     ` (5 preceding siblings ...)
  2024-10-08 16:52   ` [PATCH v3 06/10] net/iavf: " Bruce Richardson
@ 2024-10-08 16:52   ` Bruce Richardson
  2024-10-08 16:52   ` [PATCH v3 08/10] net/idpf: " Bruce Richardson
                     ` (3 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-08 16:52 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, Bruce Richardson

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/ice/meson.build | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ice/meson.build b/drivers/net/ice/meson.build
index b7f2188e62..1c9dc0cc6d 100644
--- a/drivers/net/ice/meson.build
+++ b/drivers/net/ice/meson.build
@@ -35,20 +35,9 @@ if arch_subdir == 'x86'
             c_args: [cflags, '-mavx2'])
     objs += ice_avx2_lib.extract_objects('ice_rxtx_vec_avx2.c')
 
-    ice_avx512_cpu_support = (
-            cc.get_define('__AVX512F__', args: machine_args) != '' and
-                cc.get_define('__AVX512BW__', args: machine_args) != ''
-    )
-
-    ice_avx512_cc_support = (
-            not machine_args.contains('-mno-avx512f') and
-                cc.has_argument('-mavx512f') and
-                cc.has_argument('-mavx512bw')
-    )
-
-    if ice_avx512_cpu_support == true or ice_avx512_cc_support == true
+    if cc_has_avx512
         cflags += ['-DCC_AVX512_SUPPORT']
-        avx512_args = [cflags, '-mavx512f', '-mavx512bw']
+        avx512_args = cflags + cc_avx512_flags
         if cc.has_argument('-march=skylake-avx512')
             avx512_args += '-march=skylake-avx512'
         endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v3 08/10] net/idpf: use global AVX-512 variables
  2024-10-08 16:52 ` [PATCH v3 00/10] " Bruce Richardson
                     ` (6 preceding siblings ...)
  2024-10-08 16:52   ` [PATCH v3 07/10] net/ice: " Bruce Richardson
@ 2024-10-08 16:52   ` Bruce Richardson
  2024-10-08 16:52   ` [PATCH v3 09/10] net/virtio: " Bruce Richardson
                     ` (2 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-08 16:52 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, Bruce Richardson

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/idpf/meson.build | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/net/idpf/meson.build b/drivers/net/idpf/meson.build
index cf49ef167d..34cbdc4da0 100644
--- a/drivers/net/idpf/meson.build
+++ b/drivers/net/idpf/meson.build
@@ -14,21 +14,6 @@ sources = files(
         'idpf_rxtx.c',
 )
 
-if arch_subdir == 'x86'
-    idpf_avx512_cpu_support = (
-        cc.get_define('__AVX512F__', args: machine_args) != '' and
-        cc.get_define('__AVX512BW__', args: machine_args) != '' and
-        cc.get_define('__AVX512DQ__', args: machine_args) != ''
-    )
-
-    idpf_avx512_cc_support = (
-        not machine_args.contains('-mno-avx512f') and
-        cc.has_argument('-mavx512f') and
-        cc.has_argument('-mavx512bw') and
-        cc.has_argument('-mavx512dq')
-    )
-
-    if idpf_avx512_cpu_support == true or idpf_avx512_cc_support == true
-        cflags += ['-DCC_AVX512_SUPPORT']
-    endif
+if arch_subdir == 'x86'and cc_has_avx512
+    cflags += ['-DCC_AVX512_SUPPORT']
 endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v3 09/10] net/virtio: use global AVX-512 variables
  2024-10-08 16:52 ` [PATCH v3 00/10] " Bruce Richardson
                     ` (7 preceding siblings ...)
  2024-10-08 16:52   ` [PATCH v3 08/10] net/idpf: " Bruce Richardson
@ 2024-10-08 16:52   ` Bruce Richardson
  2024-10-08 16:52   ` [PATCH v3 10/10] net: " Bruce Richardson
  2024-10-09  9:05   ` [PATCH v3 00/10] centralize AVX-512 feature detection David Marchand
  10 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-08 16:52 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, Bruce Richardson

Replace per-driver checks for AVX-512 with the standard variables from
config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/virtio/meson.build | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/net/virtio/meson.build b/drivers/net/virtio/meson.build
index ef016c1566..02742da5c2 100644
--- a/drivers/net/virtio/meson.build
+++ b/drivers/net/virtio/meson.build
@@ -24,23 +24,21 @@ sources += files(
 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 += ['-DCC_AVX512_SUPPORT']
-            virtio_avx512_lib = static_library('virtio_avx512_lib',
-                          'virtio_rxtx_packed.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.c')
-            if (toolchain == 'gcc' and cc.version().version_compare('>=8.3.0'))
-                cflags += '-DVIRTIO_GCC_UNROLL_PRAGMA'
-            elif (toolchain == 'clang' and cc.version().version_compare('>=3.7.0'))
-                cflags += '-DVIRTIO_CLANG_UNROLL_PRAGMA'
-            elif (toolchain == 'icc' and cc.version().version_compare('>=16.0.0'))
-                cflags += '-DVIRTIO_ICC_UNROLL_PRAGMA'
-            endif
+    if cc_has_avx512
+        cflags += ['-DCC_AVX512_SUPPORT']
+        virtio_avx512_lib = static_library('virtio_avx512_lib',
+                'virtio_rxtx_packed.c',
+                dependencies: [static_rte_ethdev,
+                    static_rte_kvargs, static_rte_bus_pci],
+                include_directories: includes,
+                c_args: cflags + cc_avx512_flags)
+        objs += virtio_avx512_lib.extract_objects('virtio_rxtx_packed.c')
+        if (toolchain == 'gcc' and cc.version().version_compare('>=8.3.0'))
+            cflags += '-DVIRTIO_GCC_UNROLL_PRAGMA'
+        elif (toolchain == 'clang' and cc.version().version_compare('>=3.7.0'))
+            cflags += '-DVIRTIO_CLANG_UNROLL_PRAGMA'
+        elif (toolchain == 'icc' and cc.version().version_compare('>=16.0.0'))
+            cflags += '-DVIRTIO_ICC_UNROLL_PRAGMA'
         endif
     endif
     sources += files('virtio_rxtx_simple_sse.c')
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v3 10/10] net: use global AVX-512 variables
  2024-10-08 16:52 ` [PATCH v3 00/10] " Bruce Richardson
                     ` (8 preceding siblings ...)
  2024-10-08 16:52   ` [PATCH v3 09/10] net/virtio: " Bruce Richardson
@ 2024-10-08 16:52   ` Bruce Richardson
  2024-10-09  9:05   ` [PATCH v3 00/10] centralize AVX-512 feature detection David Marchand
  10 siblings, 0 replies; 34+ messages in thread
From: Bruce Richardson @ 2024-10-08 16:52 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, Bruce Richardson

Replace some library-specific checks for AVX-512 with the standard
variables from config/x86.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/net/meson.build | 40 ++++------------------------------------
 1 file changed, 4 insertions(+), 36 deletions(-)

diff --git a/lib/net/meson.build b/lib/net/meson.build
index 0b69138949..f9bef3afc9 100644
--- a/lib/net/meson.build
+++ b/lib/net/meson.build
@@ -38,25 +38,11 @@ deps += ['mbuf']
 
 if dpdk_conf.has('RTE_ARCH_X86_64')
     net_crc_sse42_cpu_support = (cc.get_define('__PCLMUL__', args: machine_args) != '')
-    net_crc_avx512_cpu_support = (
-            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) != '' and
-            cc.get_define('__VPCLMULQDQ__', args: machine_args) != ''
+    net_crc_avx512_cpu_support = (target_has_avx512 and cc.get_define('__VPCLMULQDQ__', args: machine_args) != ''
     )
 
     net_crc_sse42_cc_support = (cc.has_argument('-mpclmul') and cc.has_argument('-maes'))
-    net_crc_avx512_cc_support = (
-            not machine_args.contains('-mno-avx512f') and
-            cc.has_argument('-mavx512f') and
-            cc.has_argument('-mavx512bw') and
-            cc.has_argument('-mavx512dq') and
-            cc.has_argument('-mavx512vl') and
-            cc.has_argument('-mvpclmulqdq') and
-            cc.has_argument('-mavx2') and
-            cc.has_argument('-mavx')
-    )
+    net_crc_avx512_cc_support = (cc.has_argument('-mvpclmulqdq') and cc_has_avx512)
 
     build_static_net_crc_sse42_lib = 0
     build_static_net_crc_avx512_lib = 0
@@ -69,15 +55,7 @@ if dpdk_conf.has('RTE_ARCH_X86_64')
             cflags += ['-DCC_X86_64_AVX512_VPCLMULQDQ_SUPPORT']
         elif net_crc_avx512_cc_support == true
             build_static_net_crc_avx512_lib = 1
-            net_crc_avx512_lib_cflags = [
-                    '-mavx512f',
-                    '-mavx512bw',
-                    '-mavx512dq',
-                    '-mavx512vl',
-                    '-mvpclmulqdq',
-                    '-mavx2',
-                    '-mavx',
-            ]
+            net_crc_avx512_lib_cflags = cc_avx512_flags + ['-mvpclmulqdq']
             cflags += ['-DCC_X86_64_AVX512_VPCLMULQDQ_SUPPORT']
         endif
     elif net_crc_sse42_cc_support == true
@@ -86,17 +64,7 @@ if dpdk_conf.has('RTE_ARCH_X86_64')
         cflags += ['-DCC_X86_64_SSE42_PCLMULQDQ_SUPPORT']
         if net_crc_avx512_cc_support == true
             build_static_net_crc_avx512_lib = 1
-            net_crc_avx512_lib_cflags = [
-                    '-mpclmul',
-                    '-maes',
-                    '-mavx512f',
-                    '-mavx512bw',
-                    '-mavx512dq',
-                    '-mavx512vl',
-                    '-mvpclmulqdq',
-                    '-mavx2',
-                    '-mavx',
-            ]
+            net_crc_avx512_lib_cflags = cc_avx512_flags + ['-mvpclmulqdq', '-mpclmul']
             cflags += ['-DCC_X86_64_AVX512_VPCLMULQDQ_SUPPORT']
         endif
     endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 00/10] centralize AVX-512 feature detection
  2024-10-08 16:52 ` [PATCH v3 00/10] " Bruce Richardson
                     ` (9 preceding siblings ...)
  2024-10-08 16:52   ` [PATCH v3 10/10] net: " Bruce Richardson
@ 2024-10-09  9:05   ` David Marchand
  10 siblings, 0 replies; 34+ messages in thread
From: David Marchand @ 2024-10-09  9:05 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Tue, Oct 8, 2024 at 6:53 PM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> The meson code to detect CPU and compiler support for AVX512 was duplicated
> across multiple components. Do all detection in just a single place to simplify
> the code.
>
> v3: add in patches for net lib and virtio driver
> v2: ensure that target_has_avx512 is always defined on x86 to fix build errors
>
>
> Bruce Richardson (10):
>   config/x86: add global defines for checking AVX-512
>   event/dlb2: use global AVX-512 variables
>   common/idpf: use global AVX-512 variables
>   net/cpfl: use global AVX-512 variables
>   net/i40e: use global AVX-512 variables
>   net/iavf: use global AVX-512 variables
>   net/ice: use global AVX-512 variables
>   net/idpf: use global AVX-512 variables
>   net/virtio: use global AVX-512 variables
>   net: use global AVX-512 variables
>
>  config/x86/meson.build          | 19 +++++++++++----
>  drivers/common/idpf/meson.build | 17 ++-----------
>  drivers/event/dlb2/meson.build  | 42 +++++++--------------------------
>  drivers/net/cpfl/meson.build    | 19 ++-------------
>  drivers/net/i40e/meson.build    | 13 ++--------
>  drivers/net/iavf/meson.build    | 13 ++--------
>  drivers/net/ice/meson.build     | 15 ++----------
>  drivers/net/idpf/meson.build    | 19 ++-------------
>  drivers/net/virtio/meson.build  | 32 ++++++++++++-------------
>  lib/net/meson.build             | 40 ++++---------------------------
>  10 files changed, 55 insertions(+), 174 deletions(-)

Series applied, thanks Bruce.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2024-10-09  9:05 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-30 17:50 [PATCH v1 0/8] centralize AVX-512 feature detection Bruce Richardson
2024-09-30 17:50 ` [PATCH v1 1/8] config/x86: add global defines for checking AVX-512 Bruce Richardson
2024-09-30 17:50 ` [PATCH v1 2/8] event/dlb2: use global AVX-512 variables Bruce Richardson
2024-09-30 17:50 ` [PATCH v1 3/8] common/idpf: " Bruce Richardson
2024-09-30 17:50 ` [PATCH v1 4/8] net/cpfl: " Bruce Richardson
2024-09-30 17:50 ` [PATCH v1 5/8] net/i40e: " Bruce Richardson
2024-09-30 17:50 ` [PATCH v1 6/8] net/iavf: " Bruce Richardson
2024-09-30 17:50 ` [PATCH v1 7/8] net/ice: " Bruce Richardson
2024-09-30 17:50 ` [PATCH v1 8/8] net/idpf: " Bruce Richardson
2024-10-01 11:17 ` [PATCH v2 0/8] centralize AVX-512 feature detection Bruce Richardson
2024-10-01 11:17   ` [PATCH v2 1/8] config/x86: add global defines for checking AVX-512 Bruce Richardson
2024-10-01 11:17   ` [PATCH v2 2/8] event/dlb2: use global AVX-512 variables Bruce Richardson
2024-10-01 11:17   ` [PATCH v2 3/8] common/idpf: " Bruce Richardson
2024-10-01 11:17   ` [PATCH v2 4/8] net/cpfl: " Bruce Richardson
2024-10-01 11:17   ` [PATCH v2 5/8] net/i40e: " Bruce Richardson
2024-10-01 11:17   ` [PATCH v2 6/8] net/iavf: " Bruce Richardson
2024-10-01 11:18   ` [PATCH v2 7/8] net/ice: " Bruce Richardson
2024-10-01 11:18   ` [PATCH v2 8/8] net/idpf: " Bruce Richardson
2024-10-08  8:49   ` [PATCH v2 0/8] centralize AVX-512 feature detection David Marchand
2024-10-08 10:02     ` Bruce Richardson
2024-10-08 11:33       ` David Marchand
2024-10-08 11:35         ` Bruce Richardson
2024-10-08 16:52 ` [PATCH v3 00/10] " Bruce Richardson
2024-10-08 16:52   ` [PATCH v3 01/10] config/x86: add global defines for checking AVX-512 Bruce Richardson
2024-10-08 16:52   ` [PATCH v3 02/10] event/dlb2: use global AVX-512 variables Bruce Richardson
2024-10-08 16:52   ` [PATCH v3 03/10] common/idpf: " Bruce Richardson
2024-10-08 16:52   ` [PATCH v3 04/10] net/cpfl: " Bruce Richardson
2024-10-08 16:52   ` [PATCH v3 05/10] net/i40e: " Bruce Richardson
2024-10-08 16:52   ` [PATCH v3 06/10] net/iavf: " Bruce Richardson
2024-10-08 16:52   ` [PATCH v3 07/10] net/ice: " Bruce Richardson
2024-10-08 16:52   ` [PATCH v3 08/10] net/idpf: " Bruce Richardson
2024-10-08 16:52   ` [PATCH v3 09/10] net/virtio: " Bruce Richardson
2024-10-08 16:52   ` [PATCH v3 10/10] net: " Bruce Richardson
2024-10-09  9:05   ` [PATCH v3 00/10] centralize AVX-512 feature detection David Marchand

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).