Skip to content

Commit ce6c288

Browse files
committed
Simplify compiler checks
1 parent 7264a84 commit ce6c288

File tree

2 files changed

+36
-35
lines changed

2 files changed

+36
-35
lines changed

lib/meson.build

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,41 @@
11
libtargets = []
2+
libtargets += static_library('libavx',
3+
files(
4+
'x86simdsort-avx2.cpp',
5+
),
6+
include_directories : [src],
7+
cpp_args : cpp.get_id() == 'msvc' ? ['/arch:AVX2'] : ['-march=haswell'],
8+
gnu_symbol_visibility : 'inlineshidden',
9+
dependencies: [omp_dep],
10+
)
211

3-
if cpp.has_argument('-march=haswell')
4-
libtargets += static_library('libavx',
5-
files(
6-
'x86simdsort-avx2.cpp',
7-
),
8-
include_directories : [src],
9-
cpp_args : meson.get_compiler('cpp').get_id() == 'msvc' ? ['/arch:AVX2'] : ['-march=haswell'],
10-
gnu_symbol_visibility : 'inlineshidden',
11-
dependencies: [omp_dep],
12-
)
13-
endif
14-
15-
if cpp.has_argument('-march=skylake-avx512')
16-
libtargets += static_library('libskx',
17-
files(
18-
'x86simdsort-skx.cpp',
19-
),
20-
include_directories : [src],
21-
cpp_args : meson.get_compiler('cpp').get_id() == 'msvc' ? ['/arch:AVX512'] : ['-march=skylake-avx512'],
22-
gnu_symbol_visibility : 'inlineshidden',
23-
dependencies: [omp_dep],
24-
)
25-
endif
12+
libtargets += static_library('libskx',
13+
files(
14+
'x86simdsort-skx.cpp',
15+
),
16+
include_directories : [src],
17+
cpp_args : cpp.get_id() == 'msvc' ? ['/arch:AVX512'] : ['-march=skylake-avx512'],
18+
gnu_symbol_visibility : 'inlineshidden',
19+
dependencies: [omp_dep],
20+
)
2621

27-
if cpp.has_argument('-march=icelake-client')
28-
libtargets += static_library('libicl',
29-
files(
30-
'x86simdsort-icl.cpp',
31-
),
32-
include_directories : [src],
33-
cpp_args : meson.get_compiler('cpp').get_id() == 'msvc' ? ['/arch:AVX512'] : ['-march=icelake-client'],
34-
gnu_symbol_visibility : 'inlineshidden',
35-
dependencies: [omp_dep],
36-
)
37-
endif
22+
libtargets += static_library('libicl',
23+
files(
24+
'x86simdsort-icl.cpp',
25+
),
26+
include_directories : [src],
27+
cpp_args : cpp.get_id() == 'msvc' ? ['/arch:AVX512'] : ['-march=icelake-client'],
28+
gnu_symbol_visibility : 'inlineshidden',
29+
dependencies: [omp_dep],
30+
)
3831

3932
if cancompilefp16
4033
libtargets += static_library('libspr',
4134
files(
4235
'x86simdsort-spr.cpp',
4336
),
4437
include_directories : [src],
45-
cpp_args : meson.get_compiler('cpp').get_id() == 'msvc' ? ['/arch:AVX512'] : ['-march=sapphirerapids'],
38+
cpp_args : cpp.get_id() == 'msvc' ? ['/arch:AVX512'] : ['-march=sapphirerapids'],
4639
gnu_symbol_visibility : 'inlineshidden',
4740
dependencies: [omp_dep],
4841
)

meson.build

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ bench = include_directories('benchmarks')
1111
utils = include_directories('utils')
1212
tests = include_directories('tests')
1313

14+
# check if compiler supports -march=haswell, -march=skylake-avx512 and -march=icelake-client and error out if not
15+
if cpp.get_id() != 'msvc'
16+
if not cpp.has_argument('-march=haswell') or not cpp.has_argument('-march=skylake-avx512') or not cpp.has_argument('-march=icelake-client')
17+
error('Compiler does not support -march=haswell, -march=skylake-avx512 or -march=icelake-client. Please use a newer compiler version.')
18+
endif
19+
endif
20+
1421
# Add IPP sort to benchmarks:
1522
benchipp = false
1623
ipplink = []
@@ -38,6 +45,7 @@ if get_option('use_openmp')
3845
omp_dep = declare_dependency(dependencies: omp, compile_args: ['-DXSS_USE_OPENMP'])
3946
endif
4047

48+
4149
fp16code = '''#include<immintrin.h>
4250
int main() {
4351
__m512h temp = _mm512_set1_ph(1.0f);

0 commit comments

Comments
 (0)