2021-09-18 10:52:07 +00:00
|
|
|
{ fetchurl
|
|
|
|
, stdenv
|
|
|
|
, lib
|
|
|
|
, gfortran
|
|
|
|
, perl
|
2022-02-10 20:34:41 +00:00
|
|
|
, llvmPackages
|
2021-09-18 10:52:07 +00:00
|
|
|
, precision ? "double"
|
|
|
|
, enableMpi ? false
|
|
|
|
, mpi
|
2022-02-10 20:34:41 +00:00
|
|
|
, withDoc ? stdenv.cc.isGNU
|
2023-02-09 11:40:11 +00:00
|
|
|
, testers
|
2021-09-18 10:52:07 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
assert lib.elem precision [ "single" "double" "long-double" "quad-precision" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-09 11:40:11 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2022-02-10 20:34:41 +00:00
|
|
|
pname = "fftw-${precision}";
|
2022-01-13 20:06:32 +00:00
|
|
|
version = "3.3.10";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
urls = [
|
2023-02-09 11:40:11 +00:00
|
|
|
"https://fftw.org/fftw-${finalAttrs.version}.tar.gz"
|
|
|
|
"ftp://ftp.fftw.org/pub/fftw/fftw-${finalAttrs.version}.tar.gz"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
2022-01-13 20:06:32 +00:00
|
|
|
sha256 = "sha256-VskyVJhSzdz6/as4ILAgDHdCZ1vpIXnlnmIVs0DiZGc=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" "man" ]
|
2023-02-02 18:25:31 +00:00
|
|
|
++ lib.optional withDoc "info"; # it's dev-doc only
|
2020-04-24 23:36:52 +00:00
|
|
|
outputBin = "dev"; # fftw-wisdom
|
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
nativeBuildInputs = [ gfortran ];
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
buildInputs = lib.optionals stdenv.cc.isClang [
|
2020-04-24 23:36:52 +00:00
|
|
|
# TODO: This may mismatch the LLVM version sin the stdenv, see #79818.
|
|
|
|
llvmPackages.openmp
|
2023-02-02 18:25:31 +00:00
|
|
|
] ++ lib.optional enableMpi mpi;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-27 19:17:25 +00:00
|
|
|
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.optional (stdenv.isx86_64 && (precision == "single" || precision == "double"))
|
|
|
|
"--enable-sse2 --enable-avx --enable-avx2 --enable-avx512 --enable-avx128-fma"
|
|
|
|
++ lib.optional enableMpi "--enable-mpi"
|
|
|
|
# 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 "-mtune=native" "-mtune=generic"
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [ perl ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-09 11:40:11 +00:00
|
|
|
passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Fastest Fourier Transform in the West library";
|
|
|
|
homepage = "http://www.fftw.org/";
|
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
maintainers = [ maintainers.spwhitt ];
|
2023-02-09 11:40:11 +00:00
|
|
|
pkgConfigModules = [
|
|
|
|
{
|
|
|
|
"single" = "fftw3f";
|
|
|
|
"double" = "fftw3";
|
|
|
|
"long-double" = "fftw3l";
|
|
|
|
"quad-precision" = "fftw3q";
|
|
|
|
}.${precision}
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
2023-02-09 11:40:11 +00:00
|
|
|
})
|