1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
{
fetchurl,
stdenv,
lib,
gfortran,
perl,
llvmPackages,
precision ? "double",
enableMpi ? false,
mpi,
withDoc ? stdenv.cc.isGNU,
testers,
}:
assert lib.elem precision [
"single"
"double"
"long-double"
"quad-precision"
];
stdenv.mkDerivation (finalAttrs: {
pname = "fftw-${precision}";
version = "3.3.11";
src = fetchurl {
urls = [
"https://fftw.org/fftw-${finalAttrs.version}.tar.gz"
"ftp://ftp.fftw.org/pub/fftw/fftw-${finalAttrs.version}.tar.gz"
];
hash = "sha256-VjDCTN6zOxMWEvfrSxqZNCNHVPnziP+GF0WNC+byOaE=";
};
outputs = [
"out"
"dev"
"man"
]
++ lib.optional withDoc "info"; # it's dev-doc only
outputBin = "dev"; # fftw-wisdom
nativeBuildInputs = [ gfortran ];
buildInputs =
lib.optionals stdenv.cc.isClang [
# TODO: This may mismatch the LLVM version sin the stdenv, see #79818.
llvmPackages.openmp
]
++ lib.optional enableMpi mpi;
configureFlags = [
"--enable-shared"
"--enable-threads"
"--enable-openmp"
]
++ lib.optional (precision != "double") "--enable-${precision}"
# https://www.fftw.org/fftw3_doc/SIMD-alignment-and-fftw_005fmalloc.html
# FFTW will try to detect at runtime whether the CPU supports these extensions
++
lib.optionals (stdenv.hostPlatform.isx86_64 && (precision == "single" || precision == "double"))
[
"--enable-sse2"
"--enable-avx"
"--enable-avx2"
"--enable-avx512"
"--enable-avx128-fma"
]
++
lib.optionals (stdenv.hostPlatform.isAarch64 && (precision == "single" || precision == "double"))
[
"--enable-neon"
]
++ lib.optionals enableMpi [
"--enable-mpi"
# link libfftw3_mpi explicitly with -lmpi
# linker on darwin requires all symbols to be resolvable at link time
# see
# https://github.com/FFTW/fftw3/issues/274
# https://github.com/spack/spack/pull/29279
"MPILIBS=-lmpi"
]
# doc generation causes Fortran wrapper generation which hard-codes gcc
++ lib.optional (!withDoc) "--disable-doc";
# fftw builds with -mtune=native by default
postPatch = ''
substituteInPlace configure --replace-fail "-mtune=native" "-mtune=generic"
'';
strictDeps = true;
enableParallelBuilding = true;
nativeCheckInputs = [ perl ];
passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
__structuredAttrs = true;
meta = {
changelog = "https://github.com/FFTW/fftw3/blob/fftw-${finalAttrs.version}/NEWS";
description = "Fastest Fourier Transform in the West library";
homepage = "https://www.fftw.org/";
license = lib.licenses.gpl2Plus;
maintainers = [ ];
pkgConfigModules = [
{
"single" = "fftw3f";
"double" = "fftw3";
"long-double" = "fftw3l";
"quad-precision" = "fftw3q";
}
.${precision}
];
platforms = lib.platforms.unix;
# quad-precision requires libquadmath from gfortran, but libquadmath is not supported on aarch64
badPlatforms = lib.optionals (precision == "quad-precision") lib.platforms.aarch64;
};
})
|