Skip to content

Commit 9bc1a96

Browse files
committed
[WIP] Meson build system
1 parent 7947c10 commit 9bc1a96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3627
-0
lines changed

README-meson.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Meson Build System
2+
3+
A Meson-based build system is included in order to provide a modern alternative
4+
to Autotools for those who need it (such as for better integration with IDEs
5+
and easier inclusion as subproject/dependency of other software).
6+
7+
Note that it is **EXPERIMENTAL**. It should mostly just work, but if you run
8+
into any problems, please report them on our issue tracker and consider using
9+
the Autotools system in the meantime.
10+
11+
It might one day replace Autotools for maintainer tasks, but for the sake of
12+
compatibility, there are currently no plans to remove Autotools: FFTW’s build
13+
tasks are relatively complex, it runs on a wide variety of platforms, and some
14+
(paying) users are not at liberty to drastically alter their build environment.
15+
16+
For that reason, changes to the Meson system should only touch files directly
17+
belonging to it until a decision has been made to promote it to the primary
18+
build system. This means some parts of it will not be as clean and efficient
19+
as they could be.
20+
21+
## Completeness
22+
23+
The Meson build system should have feature parity with Autotools, except for
24+
the following:
25+
26+
* Fortran wrappers (needs replacements for Autoconf-provided macros)
27+
* ARM v7a/v8 performance counters
28+
* Commercialized tarballs
29+
30+
## Requirements
31+
32+
### General
33+
34+
A recent enough version of [Meson](https://mesonbuild.com/) or a compatible
35+
implementation of it (such as [muon](https://sr.ht/~lattis/muon/)) is required.
36+
The exact minimum version is specified at the start of the `meson.build` file.
37+
38+
FFTW itself needs a C compiler. GCC and Clang are well-tested.
39+
40+
ICL and MSVC should also work, but currently only static libraries can be built
41+
successfully with Microsoft’s toolchains. For now, we strongly recommend using
42+
a MinGW-w64-based toolchain to build FFTW for Windows. [MXE](https://mxe.cc/)
43+
can be used to build one if necessary.
44+
45+
Running the test suite currently requires Perl.
46+
47+
### Git only
48+
49+
Additionally, if you have obtained this copy of FFTW from the Git repository,
50+
you will need the [Dune](https://dune.build/) build system for OCaml. Much of
51+
FFTW’s source code is *generated*, and this is required in order to build the
52+
generators. This has only been tested on x86 Linux with glibc.
53+
GNU indent is required as well, since the generated sources in FFTW releases
54+
should be formatted.
55+
Release tarballs already contain the generated sources.
56+
57+
To build the full documentation (already included in release tarballs),
58+
you need:
59+
60+
* Perl
61+
* `makeinfo`
62+
* `fig2dev` (part of transfig)
63+
* `texi2pdf` (part of texinfo).
64+
65+
To generate the Fortran wrappers (included in release tarballs), you need Perl.
66+
67+
## Usage
68+
69+
See the [Meson documentation](https://mesonbuild.com/Manual.html) for
70+
instructions, including usage with IDEs and
71+
[cross compilers](https://mesonbuild.com/Cross-compilation.html).
72+
73+
The short version:
74+
75+
```sh
76+
meson setup builddir
77+
cd builddir
78+
meson compile
79+
meson test --suite small
80+
meson install
81+
```
82+
83+
Some IDEs, like KDevelop, already support Meson. VSCode has an extension
84+
you can install from the marketplace. Once that is set up, you can simply
85+
open the FFTW source directory and everything will be configured automatically.
86+
87+
### Generating Release Tarballs
88+
89+
Assuming you have all of the above and the current Git commit is tagged, you
90+
can simply run `meson dist` in a configured build directory. This will do the
91+
following by default:
92+
93+
* Collect the sources in the current Git `HEAD` commit
94+
NOTE: NOT whatever is currently checked out, and thus NOT including untracked
95+
or modified files! Meson will warn about this and require a command line flag
96+
to proceed if it detects uncommitted changes.
97+
* Cement the tarball’s version (so it won’t depend on Git)
98+
* Generate `ChangeLog` from Git
99+
* Generate all codelets and copy them to the tarball tree
100+
* Patch `configure.ac` to match Meson’s version info
101+
* Configure the resulting sources and run the full test suite
102+
* Upon success, generate a compressed tarball and accompanying checksum file
103+
104+
If the commit is not tagged, the build system still packages a tarball, but it
105+
will print a warning and refuse to include the Autotools build system.
106+
107+
Most of the above happens in a shell script generated from
108+
`support/meson_dist.sh.in`.

api/meson.build

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# TODO: Generate Fortran wrappers
2+
summary('Fortran wrappers', '(not supported with Meson yet)', section: 'Build')
3+
4+
fftw_api_inc = include_directories('.')
5+
fftw_srcset.add(
6+
files(
7+
'apiplan.c',
8+
'configure.c',
9+
'execute-dft-c2r.c',
10+
'execute-dft-r2c.c',
11+
'execute-dft.c',
12+
'execute-r2r.c',
13+
'execute-split-dft-c2r.c',
14+
'execute-split-dft-r2c.c',
15+
'execute-split-dft.c',
16+
'execute.c',
17+
'export-wisdom-to-file.c',
18+
'export-wisdom-to-string.c',
19+
'export-wisdom.c',
20+
'f77api.c',
21+
'flops.c',
22+
'forget-wisdom.c',
23+
'import-system-wisdom.c',
24+
'import-wisdom-from-file.c',
25+
'import-wisdom-from-string.c',
26+
'import-wisdom.c',
27+
'malloc.c',
28+
'map-r2r-kind.c',
29+
'mapflags.c',
30+
'mkprinter-file.c',
31+
'mkprinter-str.c',
32+
'mktensor-iodims.c',
33+
'mktensor-iodims64.c',
34+
'mktensor-rowmajor.c',
35+
'plan-dft-1d.c',
36+
'plan-dft-2d.c',
37+
'plan-dft-3d.c',
38+
'plan-dft-c2r-1d.c',
39+
'plan-dft-c2r-2d.c',
40+
'plan-dft-c2r-3d.c',
41+
'plan-dft-c2r.c',
42+
'plan-dft-r2c-1d.c',
43+
'plan-dft-r2c-2d.c',
44+
'plan-dft-r2c-3d.c',
45+
'plan-dft-r2c.c',
46+
'plan-dft.c',
47+
'plan-guru-dft-c2r.c',
48+
'plan-guru-dft-r2c.c',
49+
'plan-guru-dft.c',
50+
'plan-guru-r2r.c',
51+
'plan-guru-split-dft-c2r.c',
52+
'plan-guru-split-dft-r2c.c',
53+
'plan-guru-split-dft.c',
54+
'plan-guru64-dft-c2r.c',
55+
'plan-guru64-dft-r2c.c',
56+
'plan-guru64-dft.c',
57+
'plan-guru64-r2r.c',
58+
'plan-guru64-split-dft-c2r.c',
59+
'plan-guru64-split-dft-r2c.c',
60+
'plan-guru64-split-dft.c',
61+
'plan-many-dft-c2r.c',
62+
'plan-many-dft-r2c.c',
63+
'plan-many-dft.c',
64+
'plan-many-r2r.c',
65+
'plan-r2r-1d.c',
66+
'plan-r2r-2d.c',
67+
'plan-r2r-3d.c',
68+
'plan-r2r.c',
69+
'print-plan.c',
70+
'rdft2-pad.c',
71+
'the-planner.c',
72+
'version.c',
73+
),
74+
)
75+
76+
install_headers(files('fftw3.h'))

dft/meson.build

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
fftw_srcset.add(
2+
files(
3+
'bluestein.c',
4+
'buffered.c',
5+
'conf.c',
6+
'ct.c',
7+
'dftw-direct.c',
8+
'dftw-directsq.c',
9+
'dftw-generic.c',
10+
'dftw-genericbuf.c',
11+
'direct.c',
12+
'generic.c',
13+
'indirect-transpose.c',
14+
'indirect.c',
15+
'kdft-dif.c',
16+
'kdft-difsq.c',
17+
'kdft-dit.c',
18+
'kdft.c',
19+
'nop.c',
20+
'plan.c',
21+
'problem.c',
22+
'rader.c',
23+
'rank-geq2.c',
24+
'solve.c',
25+
'vrank-geq1.c',
26+
'zero.c',
27+
),
28+
)
29+
30+
codelet_prelude = support_dir / 'codelet_prelude.dft'
31+
subdir('scalar')
32+
subdir('simd')

dft/scalar/codelets/meson.build

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
genfft_params = {
2+
###########################################################################
3+
# n1_<n> is a hard-coded FFT of size <n> (base cases of FFT recursion)
4+
'n1': {
5+
'generator': gen_notw,
6+
'include': 'n.h',
7+
'extra_args': [],
8+
'ns': [
9+
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 32, 64, 20, 25,
10+
# 30, 40, 50,
11+
],
12+
},
13+
###########################################################################
14+
# t1_<r> is a "twiddle" FFT of size <r>, implementing a radix-r DIT step
15+
't1': {
16+
'generator': gen_twiddle,
17+
'include': 't.h',
18+
'extra_args': [],
19+
'ns': [
20+
2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 16, 32, 64, 20, 25,
21+
# 30, 40, 50
22+
],
23+
},
24+
# t2_<r> is also a twiddle FFT, but instead of using a complete lookup table
25+
# of trig. functions, it partially generates the trig. values on the fly
26+
# (this is faster for large sizes).
27+
't2': {
28+
'generator': gen_twiddle,
29+
'include': 't.h',
30+
'extra_args': [
31+
'-twiddle-log3',
32+
'-precompute-twiddles'
33+
],
34+
'ns': [
35+
4, 8, 16, 32, 64,
36+
5, 10, 20, 25
37+
],
38+
},
39+
###########################################################################
40+
# The F (DIF) codelets are used for a kind of in-place transform algorithm,
41+
# but the planner seems to never (or hardly ever) use them on the machines
42+
# we have access to, preferring the Q codelets and the use of buffers
43+
# for sub-transforms. So, we comment them out, at least for now.
44+
45+
# f1_<r> is a "twiddle" FFT of size <r>, implementing a radix-r DIF step
46+
'f1': {
47+
'generator': gen_twiddle,
48+
'include': 'f.h',
49+
'extra_args': [
50+
'-dif'
51+
],
52+
'ns': [
53+
# 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 16, 32, 64,
54+
],
55+
},
56+
# like f1, but partially generates its trig. table on the fly
57+
'f2': {
58+
'generator': gen_twiddle,
59+
'include': 'f.h',
60+
'extra_args': [
61+
'-dif',
62+
'-twiddle-log3',
63+
'-precompute-twiddles'
64+
],
65+
'ns': [
66+
# 4, 8, 16, 32, 64,
67+
],
68+
},
69+
###########################################################################
70+
# q1_<r> is <r> twiddle FFTs of size <r> (DIF step), where the output is
71+
# transposed. This is used for in-place transposes in sizes that are
72+
# divisible by <r>^2. These codelets have size ~ <r>^2, so you should
73+
# probably not use <r> bigger than 8 or so.
74+
'q1': {
75+
'generator': gen_twidsq,
76+
'include': 'q.h',
77+
'extra_args': [
78+
'-dif',
79+
'-reload-twiddle'
80+
],
81+
'ns': [
82+
2, 4, 8,
83+
3, 5, 6
84+
],
85+
},
86+
'q2': {
87+
'generator': gen_twidsq,
88+
'include': 'q.h',
89+
'extra_args': [
90+
'-dif',
91+
'-twiddle-log3',
92+
'-precompute-twiddles'
93+
],
94+
'ns': [],
95+
},
96+
}
97+
98+
flags_common = [
99+
'-compact',
100+
'-variables', '4',
101+
'-pipeline-latency', '4'
102+
]
103+
104+
incdir = fs.relative_to(
105+
meson.current_source_dir() / '..',
106+
meson.project_source_root(),
107+
)
108+
109+
codelets = []
110+
foreach type, params : genfft_params
111+
foreach n : params['ns']
112+
codelet = f'@type@_@n@'
113+
codelets += codelet
114+
outname = codelet + '.c'
115+
116+
if generate_codelets
117+
tgt = custom_target(
118+
outname,
119+
output: outname,
120+
capture: true,
121+
command: [
122+
gen_codelet,
123+
codelet_prelude,
124+
params['generator'],
125+
flags_common,
126+
params['extra_args'],
127+
'-include', incdir / params['include'],
128+
'-n', f'@n@',
129+
'-name', codelet,
130+
],
131+
)
132+
fftw_srcset.add(tgt)
133+
fftw_extra_srcset.add(tgt)
134+
else
135+
fftw_srcset.add(files(outname))
136+
endif
137+
endforeach
138+
endforeach
139+
140+
if generate_codelets
141+
codlist = configuration_data(
142+
{'solvtab_name': 'X(solvtab_dft_standard)', 'extra_includes': ''},
143+
)
144+
145+
decls = []
146+
foreach codelet : codelets
147+
decls += f'extern void X(codelet_@codelet@)(planner *);'
148+
endforeach
149+
codlist.set('decls', '\n'.join(decls))
150+
151+
solvtab_entries = []
152+
foreach codelet : codelets
153+
solvtab_entries += f' SOLVTAB(X(codelet_@codelet@)),'
154+
endforeach
155+
codlist.set('solvtab_entries', '\n'.join(solvtab_entries))
156+
157+
cfgf = configure_file(
158+
configuration: codlist,
159+
input: support_dir / 'codlist.c.in',
160+
output: 'codlist.c',
161+
)
162+
fftw_srcset.add(cfgf)
163+
fftw_extra_srcset.add(cfgf)
164+
else
165+
fftw_srcset.add(files('codlist.c'))
166+
endif

dft/scalar/meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fftw_srcset.add(files('n.c', 't.c'))
2+
3+
subdir('codelets')

0 commit comments

Comments
 (0)