Skip to content

Commit 5caa6fc

Browse files
volk: Add wrap
1 parent 3db35f8 commit 5caa6fc

8 files changed

Lines changed: 653 additions & 0 deletions

File tree

‎ci_config.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,14 @@
17331733
"tinyfsm:build_examples=true"
17341734
]
17351735
},
1736+
"volk": {
1737+
"build_options": [
1738+
"volk:tests=enabled"
1739+
],
1740+
"python_packages": [
1741+
"mako"
1742+
]
1743+
},
17361744
"wayland": {
17371745
"_comment": [
17381746
"- relies on Linux-specific APIs",

‎releases.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5000,6 +5000,14 @@
50005000
"0.1.3-1"
50015001
]
50025002
},
5003+
"volk": {
5004+
"dependency_names": [
5005+
"volk"
5006+
],
5007+
"versions": [
5008+
"3.3.0-1"
5009+
]
5010+
},
50035011
"vorbis": {
50045012
"dependency_names": [
50055013
"vorbis",
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
cpu_features_args = ['-DSTACK_LINE_READER_BUFFER_SIZE=1024']
2+
cpu_features_deps = []
3+
if host_machine.system() == 'darwin'
4+
cpu_features_args += '-DHAVE_SYSCTLBYNAME'
5+
endif
6+
7+
cpu_features_sources = files(
8+
'src/filesystem.c',
9+
'src/impl_aarch64_linux_or_android.c',
10+
'src/impl_aarch64_macos_or_iphone.c',
11+
'src/impl_aarch64_windows.c',
12+
'src/impl_arm_linux_or_android.c',
13+
'src/impl_loongarch_linux.c',
14+
'src/impl_mips_linux_or_android.c',
15+
'src/impl_ppc_linux.c',
16+
'src/impl_riscv_linux.c',
17+
'src/impl_s390x_linux.c',
18+
'src/impl_x86_freebsd.c',
19+
'src/impl_x86_linux_or_android.c',
20+
'src/impl_x86_macos.c',
21+
'src/impl_x86_windows.c',
22+
'src/stack_line_reader.c',
23+
'src/string_view.c',
24+
)
25+
26+
if not cpu_is_x86 and host_machine.system() != 'windows'
27+
cpu_features_sources += files('src/hwcaps.c')
28+
if cc.has_header_symbol('sys/auxv.h', 'getauxval')
29+
cpu_features_args += '-DHAVE_STRONG_GETAUXVAL'
30+
elif cc.has_header('dlfcn.h')
31+
cpu_features_args += '-DHAVE_DLFCN_H'
32+
cpu_features_deps += dependency(
33+
'dl',
34+
required: false,
35+
)
36+
endif
37+
endif
38+
39+
cpu_features_lib = static_library(
40+
'cpu_features',
41+
cpu_features_sources,
42+
c_args: cpu_features_args,
43+
include_directories: include_directories('include', 'include/internal'),
44+
dependencies: cpu_features_deps,
45+
)
46+
47+
volk_incs += include_directories('include')
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
version_conf = configuration_data()
2+
version_conf.set('VERSION_INFO_MAJOR_VERSION', version_parts[0])
3+
version_conf.set('VERSION_INFO_MINOR_VERSION', version_parts[1])
4+
version_conf.set('VERSION_INFO_MAINT_VERSION', version_parts[2])
5+
version_conf.set(
6+
'VOLK_VERSION_DECIMAL',
7+
version_parts[0].to_int() * 10000 + version_parts[1].to_int() * 100 + version_parts[2].to_int(),
8+
)
9+
10+
volk_version_h = configure_file(
11+
input: 'volk_version.h.in',
12+
output: 'volk_version.h',
13+
configuration: version_conf,
14+
install_dir: get_option('includedir') / 'volk',
15+
)
16+
17+
volk_gen_headers = []
18+
foreach name : ['volk', 'volk_cpu', 'volk_config_fixed', 'volk_typedefs']
19+
volk_gen_headers += custom_target(
20+
input: meson.project_source_root() / 'tmpl' / (name + '.tmpl.h'),
21+
output: name + '.h',
22+
command: tmpl_command,
23+
depend_files: tmpl_depends,
24+
install: true,
25+
install_dir: get_option('includedir') / 'volk',
26+
)
27+
endforeach
28+
29+
install_headers(
30+
'constants.h',
31+
'saturation_arithmetic.h',
32+
'volk_alloc.hh',
33+
'volk_avx2_fma_intrinsics.h',
34+
'volk_avx2_intrinsics.h',
35+
'volk_avx512_intrinsics.h',
36+
'volk_avx_intrinsics.h',
37+
'volk_common.h',
38+
'volk_complex.h',
39+
'volk_malloc.h',
40+
'volk_neon_intrinsics.h',
41+
'volk_prefs.h',
42+
'volk_sse3_intrinsics.h',
43+
'volk_sse_intrinsics.h',
44+
kernel_headers,
45+
subdir: 'volk',
46+
)
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
lib_incs = [volk_incs, include_directories('.')]
2+
lib_args = volk_args + ['-Dvolk_EXPORTS']
3+
tmpl_dir = meson.project_source_root() / 'tmpl'
4+
5+
volk_machines_h = custom_target(
6+
input: tmpl_dir / 'volk_machines.tmpl.h',
7+
output: 'volk_machines.h',
8+
command: tmpl_command,
9+
depend_files: tmpl_depends,
10+
)
11+
12+
volk_sources = [volk_machines_h, volk_gen_headers]
13+
foreach name : ['volk', 'volk_cpu', 'volk_machines']
14+
volk_sources += custom_target(
15+
input: tmpl_dir / (name + '.tmpl.c'),
16+
output: name + '.' + src_ext,
17+
command: tmpl_command,
18+
depend_files: tmpl_depends,
19+
)
20+
endforeach
21+
22+
foreach name : ['volk_prefs', 'volk_rank_archs', 'volk_malloc']
23+
if is_msvc
24+
volk_sources += configure_file(
25+
input: name + '.c',
26+
output: name + '.cc',
27+
copy: true,
28+
)
29+
else
30+
volk_sources += files(name + '.c')
31+
endif
32+
endforeach
33+
34+
# Each machine is compiled with the flags of its archs
35+
volk_link_whole = []
36+
machine_defs = []
37+
compiler_info = []
38+
foreach machine : available_machines
39+
flags = is_msvc ? [] : machine_flags[machine].split()
40+
machine_src = custom_target(
41+
input: tmpl_dir / 'volk_machine_xxx.tmpl.c',
42+
output: 'volk_machine_@0@.@1@'.format(machine, src_ext),
43+
command: tmpl_command + [machine],
44+
depend_files: tmpl_depends,
45+
)
46+
volk_link_whole += static_library(
47+
'volk_machine_' + machine,
48+
machine_src,
49+
volk_machines_h,
50+
volk_gen_headers,
51+
c_args: lib_args + flags,
52+
cpp_args: lib_args,
53+
include_directories: lib_incs,
54+
gnu_symbol_visibility: 'hidden',
55+
)
56+
machine_defs += '-DLV_MACHINE_' + machine.to_upper()
57+
compiler_info += ':::'.join(machine, compiler_name, ' '.join(flags))
58+
endforeach
59+
60+
if 'neonv7' in available_archs
61+
neon_asm = []
62+
foreach name : run_command(
63+
glob_command,
64+
meson.project_source_root() / 'kernels' / 'volk' / 'asm' / 'neon',
65+
'*.s',
66+
check: true,
67+
).stdout().strip().split(';')
68+
neon_asm += files('..' / 'kernels' / 'volk' / 'asm' / 'neon' / name)
69+
endforeach
70+
volk_link_whole += static_library(
71+
'volk_neon_asm',
72+
neon_asm,
73+
c_args: arch_flags['neonv7'],
74+
)
75+
endif
76+
77+
if cpu_family == 'riscv64'
78+
foreach name : run_command(
79+
glob_command,
80+
meson.project_source_root() / 'kernels' / 'volk' / 'asm' / 'riscv',
81+
'*.s',
82+
check: true,
83+
).stdout().strip().split(';')
84+
volk_sources += files('..' / 'kernels' / 'volk' / 'asm' / 'riscv' / name)
85+
endforeach
86+
endif
87+
88+
if have_orc
89+
foreach name : run_command(
90+
glob_command,
91+
meson.project_source_root() / 'kernels' / 'volk' / 'asm' / 'orc',
92+
'*.orc',
93+
check: true,
94+
).stdout().strip().split(';')
95+
volk_sources += custom_target(
96+
input: '..' / 'kernels' / 'volk' / 'asm' / 'orc' / name,
97+
output: '@BASENAME@.' + src_ext,
98+
command: [
99+
orcc,
100+
'--include',
101+
'math.h',
102+
'--implementation',
103+
'--include',
104+
'volk/volk_complex.h',
105+
'-o',
106+
'@OUTPUT@',
107+
'@INPUT@',
108+
],
109+
)
110+
endforeach
111+
endif
112+
113+
constants_conf = configuration_data()
114+
constants_conf.set('prefix', get_option('prefix').replace('\\', '\\\\'))
115+
constants_conf.set('VERSION', meson.project_version())
116+
constants_conf.set(
117+
'cmake_c_compiler_version',
118+
'@0@ @1@'.format(cc.get_id(), cc.version()),
119+
)
120+
constants_conf.set('COMPILER_INFO', '\\n'.join(compiler_info))
121+
constants_conf.set('available_machines', ';'.join(available_machines))
122+
volk_sources += configure_file(
123+
input: 'constants.c.in',
124+
output: 'constants.' + src_ext,
125+
configuration: constants_conf,
126+
)
127+
128+
if use_cpu_features
129+
volk_link_whole += cpu_features_lib
130+
endif
131+
132+
volk_lib = library(
133+
'volk',
134+
volk_sources,
135+
c_args: lib_args + machine_defs,
136+
cpp_args: lib_args + machine_defs,
137+
include_directories: lib_incs,
138+
link_whole: volk_link_whole,
139+
dependencies: [
140+
cc.find_library(
141+
'm',
142+
required: false,
143+
),
144+
cpu_features_deps,
145+
orc_dep,
146+
],
147+
gnu_symbol_visibility: 'hidden',
148+
version: meson.project_version(),
149+
soversion: soversion,
150+
install: true,
151+
)
152+
153+
# Otherwise VOLK_API is __declspec(dllimport), which a static library can't satisfy
154+
volk_dep_args = []
155+
if is_msvc and get_option('default_library') == 'static'
156+
volk_dep_args += '-Dvolk_EXPORTS'
157+
endif
158+
159+
volk_dep = declare_dependency(
160+
compile_args: volk_dep_args,
161+
link_with: volk_lib,
162+
include_directories: volk_public_incs,
163+
sources: volk_gen_headers,
164+
)
165+
meson.override_dependency('volk', volk_dep)
166+
167+
fmt_dep = dependency(
168+
'fmt',
169+
required: get_option('tests'),
170+
)
171+
if fmt_dep.found()
172+
volk_test_all = executable(
173+
'volk_test_all',
174+
'testqa.cc',
175+
'qa_utils.cc',
176+
cpp_args: volk_args,
177+
include_directories: lib_incs,
178+
dependencies: [volk_dep, fmt_dep],
179+
)
180+
foreach kernel : kernel_names
181+
test(
182+
kernel,
183+
volk_test_all,
184+
args: kernel,
185+
)
186+
endforeach
187+
endif

0 commit comments

Comments
 (0)