Skip to content

Commit 15d255b

Browse files
author
Raghuveer Devulapalli
committed
Refactor openMP dependency in Meson build files
1 parent 724e92e commit 15d255b

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

lib/meson.build

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
libtargets = []
22

3-
# Add compile flags for OpenMP if enabled
4-
openmpflags = []
5-
if get_option('use_openmp')
6-
openmpflags = ['-DXSS_USE_OPENMP=true', '-fopenmp']
7-
endif
8-
93
if cpp.has_argument('-march=haswell')
104
libtargets += static_library('libavx',
115
files(
126
'x86simdsort-avx2.cpp',
137
),
148
include_directories : [src],
15-
cpp_args : ['-march=haswell', openmpflags],
9+
cpp_args : ['-march=haswell'],
1610
gnu_symbol_visibility : 'inlineshidden',
11+
dependencies: [omp_dep],
1712
)
1813
endif
1914

@@ -23,8 +18,9 @@ if cpp.has_argument('-march=skylake-avx512')
2318
'x86simdsort-skx.cpp',
2419
),
2520
include_directories : [src],
26-
cpp_args : ['-march=skylake-avx512', openmpflags],
21+
cpp_args : ['-march=skylake-avx512'],
2722
gnu_symbol_visibility : 'inlineshidden',
23+
dependencies: [omp_dep],
2824
)
2925
endif
3026

@@ -34,8 +30,9 @@ if cpp.has_argument('-march=icelake-client')
3430
'x86simdsort-icl.cpp',
3531
),
3632
include_directories : [src],
37-
cpp_args : ['-march=icelake-client', openmpflags],
33+
cpp_args : ['-march=icelake-client'],
3834
gnu_symbol_visibility : 'inlineshidden',
35+
dependencies: [omp_dep],
3936
)
4037
endif
4138

@@ -45,8 +42,9 @@ if cancompilefp16
4542
'x86simdsort-spr.cpp',
4643
),
4744
include_directories : [src],
48-
cpp_args : ['-march=sapphirerapids', openmpflags],
45+
cpp_args : ['-march=sapphirerapids'],
4946
gnu_symbol_visibility : 'inlineshidden',
47+
dependencies: [omp_dep],
5048
)
5149
endif
5250

meson.build

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ if get_option('build_vqsortbench')
2929
benchvq = true
3030
endif
3131

32+
# openMP:
33+
omp = []
34+
omp_dep = []
35+
if get_option('use_openmp')
36+
omp = dependency('openmp', required : true)
37+
omp_dep = declare_dependency(dependencies: omp, compile_args: ['-DXSS_USE_OPENMP'])
38+
endif
39+
3240
fp16code = '''#include<immintrin.h>
3341
int main() {
3442
__m512h temp = _mm512_set1_ph(1.0f);
@@ -43,8 +51,8 @@ if get_option('lib_type') == 'shared'
4351
libsimdsort = shared_library('x86simdsortcpp',
4452
'lib/x86simdsort.cpp',
4553
include_directories : [src, utils, lib],
46-
link_args : [openmpflags],
4754
link_with : [libtargets],
55+
dependencies: [omp_dep],
4856
gnu_symbol_visibility : 'inlineshidden',
4957
install : true,
5058
soversion : 1,
@@ -53,8 +61,8 @@ else
5361
libsimdsort = static_library('x86simdsortcpp',
5462
'lib/x86simdsort.cpp',
5563
include_directories : [src, utils, lib],
56-
link_args : [openmpflags],
5764
link_with : [libtargets],
65+
dependencies: [omp_dep],
5866
gnu_symbol_visibility : 'inlineshidden',
5967
install : true,
6068
pic: true,

tests/meson.build

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
libtests = []
22

3-
if get_option('use_openmp')
4-
openmpflags = ['-DXSS_USE_OPENMP=true']
5-
endif
6-
73
# Add compile flags when needed for the ASAN CI run
84
testargs = []
95
if get_option('asan_ci_dont_validate')
@@ -16,21 +12,21 @@ endif
1612

1713
libtests += static_library('tests_qsort',
1814
files('test-qsort.cpp', ),
19-
dependencies: gtest_dep,
15+
dependencies: [omp_dep, gtest_dep],
2016
include_directories : [src, lib, utils],
21-
cpp_args : [testargs, openmpflags],
17+
cpp_args : [testargs],
2218
)
2319

2420
libtests += static_library('tests_kvsort',
2521
files('test-keyvalue.cpp', ),
26-
dependencies: gtest_dep,
22+
dependencies: [omp_dep, gtest_dep],
2723
include_directories : [src, lib, utils],
28-
cpp_args : [testargs, openmpflags],
24+
cpp_args : [testargs],
2925
)
3026

3127
libtests += static_library('tests_objsort',
3228
files('test-objqsort.cpp', ),
33-
dependencies: gtest_dep,
29+
dependencies: [omp_dep, gtest_dep],
3430
include_directories : [src, lib, utils],
35-
cpp_args : [testargs, openmpflags],
31+
cpp_args : [testargs],
3632
)

0 commit comments

Comments
 (0)