Skip to content

Commit 979f59d

Browse files
bruce-richardsondavid-marchand
authored andcommitted
build: add common checks for AVX512
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 and libraries reuse that result. Signed-off-by: Bruce Richardson <[email protected]> Acked-by: David Marchand <[email protected]>
1 parent e7bc451 commit 979f59d

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

config/x86/meson.build

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,27 @@ if is_linux or cc.get_id() == 'gcc'
1414
endif
1515
endif
1616

17-
# check if compiler is working with _mm512_extracti64x4_epi64
18-
# Ref: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82887
19-
if cc.has_argument('-mavx512f')
17+
cc_avx512_flags = ['-mavx512f', '-mavx512vl', '-mavx512dq', '-mavx512bw']
18+
cc_has_avx512 = false
19+
target_has_avx512 = false
20+
if binutils_ok and cc.has_multi_arguments(cc_avx512_flags)
21+
# check if compiler is working with _mm512_extracti64x4_epi64
22+
# Ref: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82887
2023
code = '''#include <immintrin.h>
2124
void test(__m512i zmm){
2225
__m256i ymm = _mm512_extracti64x4_epi64(zmm, 0);}'''
23-
result = cc.compiles(code, args : '-mavx512f', name : 'AVX512 checking')
26+
result = cc.compiles(code, args : cc_avx512_flags, name : 'AVX512 checking')
2427
if result == false
2528
machine_args += '-mno-avx512f'
2629
warning('Broken _mm512_extracti64x4_epi64, disabling AVX512 support')
30+
else
31+
cc_has_avx512 = true
32+
target_has_avx512 = (
33+
cc.get_define('__AVX512F__', args: machine_args) != '' and
34+
cc.get_define('__AVX512BW__', args: machine_args) != '' and
35+
cc.get_define('__AVX512DQ__', args: machine_args) != '' and
36+
cc.get_define('__AVX512VL__', args: machine_args) != ''
37+
)
2738
endif
2839
endif
2940

0 commit comments

Comments
 (0)