[v4] build: check for broken AVX-512 compiler support

Message ID 20210720133645.938-1-liangma@liangbit.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v4] build: check for broken AVX-512 compiler support |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot success github build: passed
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Liang Ma July 20, 2021, 1:36 p.m. UTC
  From: Liang Ma <liangma@bytedance.com>

GCC 6.3.0 has a known bug which related to _mm512_extracti64x4_epi64.
Please reference https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82887

Some DPDK PMD avx512 version heavily use _mm512_extracti64x4_epi6,
which cause building failure with debug buildtype.

Therefore, it's helpful to check if compiler work with
_mm512_extracti64x4_epi6.

This patch check the compiler compile result against the test code
snippet. If the checking is failed then disable avx512.

Bugzilla ID: 717
Fixes: e6a6a138919f (net/i40e: add AVX512 vector path)
Fixes: 808a17b3c1e6 (net/ice: add Rx AVX512 offload path)
Fixes: 4b64ccb328c9 (net/iavf: fix VLAN extraction in AVX512 path)
Cc: stable@dpdk.org

Reported-by: Liang Ma <liangma@liangbit.com>
Signed-off-by: Liang Ma <liangma@bytedance.com>
Acked-by: Bruce richardson <bruce.richardson@intel.com>
---
 config/x86/meson.build | 13 +++++++++++++
 1 file changed, 13 insertions(+)
  

Comments

Thomas Monjalon July 22, 2021, 5:58 p.m. UTC | #1
20/07/2021 15:36, Liang Ma:
> From: Liang Ma <liangma@bytedance.com>
> 
> GCC 6.3.0 has a known bug which related to _mm512_extracti64x4_epi64.
> Please reference https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82887
> 
> Some DPDK PMD avx512 version heavily use _mm512_extracti64x4_epi6,
> which cause building failure with debug buildtype.
> 
> Therefore, it's helpful to check if compiler work with
> _mm512_extracti64x4_epi6.
> 
> This patch check the compiler compile result against the test code
> snippet. If the checking is failed then disable avx512.
> 
> Bugzilla ID: 717
> Fixes: e6a6a138919f (net/i40e: add AVX512 vector path)
> Fixes: 808a17b3c1e6 (net/ice: add Rx AVX512 offload path)
> Fixes: 4b64ccb328c9 (net/iavf: fix VLAN extraction in AVX512 path)
> Cc: stable@dpdk.org
> 
> Reported-by: Liang Ma <liangma@liangbit.com>
> Signed-off-by: Liang Ma <liangma@bytedance.com>
> Acked-by: Bruce richardson <bruce.richardson@intel.com>

Applied, thanks.
  

Patch

diff --git a/config/x86/meson.build b/config/x86/meson.build
index b9348c44de..87b051cd2d 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -10,6 +10,19 @@  if not is_windows
     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')
+    code = '''#include <immintrin.h>
+    void test(__m512i zmm){
+        __m256i ymm = _mm512_extracti64x4_epi64(zmm, 0);}'''
+    result = cc.compiles(code, args : '-mavx512f', name : 'AVX512 checking')
+    if result == false
+        machine_args += '-mno-avx512f'
+        warning('Broken _mm512_extracti64x4_epi64, disabling AVX512 support')
+    endif
+endif
+
 # we require SSE4.2 for DPDK
 if cc.get_define('__SSE4_2__', args: machine_args) == ''
     message('SSE 4.2 not enabled by default, explicitly enabling')