summary refs log tree commit diff
path: root/pkgs/development/libraries/fftw
diff options
context:
space:
mode:
authorTungsten842 <886724vf@anonaddy.me>2023-03-13 12:31:32 +0100
committerTungsten842 <886724vf@anonaddy.me>2023-03-13 12:31:32 +0100
commit23f23a89b325b06e3f7ff6c0a45e06271db49ead (patch)
treef989f4487ac0012dfe925d2605dff5784fc63307 /pkgs/development/libraries/fftw
parent5ad547c708bef1fed0bc35ef5bda74150a1d9075 (diff)
downloadnixpkgs-23f23a89b325b06e3f7ff6c0a45e06271db49ead.tar
nixpkgs-23f23a89b325b06e3f7ff6c0a45e06271db49ead.tar.gz
nixpkgs-23f23a89b325b06e3f7ff6c0a45e06271db49ead.tar.bz2
nixpkgs-23f23a89b325b06e3f7ff6c0a45e06271db49ead.tar.lz
nixpkgs-23f23a89b325b06e3f7ff6c0a45e06271db49ead.tar.xz
nixpkgs-23f23a89b325b06e3f7ff6c0a45e06271db49ead.tar.zst
nixpkgs-23f23a89b325b06e3f7ff6c0a45e06271db49ead.zip
fftw: enable optimizations unconditionally and build with mtune=generic
Diffstat (limited to 'pkgs/development/libraries/fftw')
-rw-r--r--pkgs/development/libraries/fftw/default.nix39
1 files changed, 19 insertions, 20 deletions
diff --git a/pkgs/development/libraries/fftw/default.nix b/pkgs/development/libraries/fftw/default.nix
index 9d83fdb4878..e09786976f7 100644
--- a/pkgs/development/libraries/fftw/default.nix
+++ b/pkgs/development/libraries/fftw/default.nix
@@ -5,10 +5,6 @@
 , perl
 , llvmPackages
 , precision ? "double"
-, enableAvx ? stdenv.hostPlatform.avxSupport
-, enableAvx2 ? stdenv.hostPlatform.avx2Support
-, enableAvx512 ? stdenv.hostPlatform.avx512Support
-, enableFma ? stdenv.hostPlatform.fmaSupport
 , enableMpi ? false
 , mpi
 , withDoc ? stdenv.cc.isGNU
@@ -40,22 +36,25 @@ stdenv.mkDerivation (finalAttrs: {
     llvmPackages.openmp
   ] ++ lib.optional enableMpi mpi;
 
-  configureFlags =
-    [ "--enable-shared"
-      "--enable-threads"
-    ]
-    ++ lib.optional (precision != "double") "--enable-${precision}"
-    # all x86_64 have sse2
-    # however, not all float sizes fit
-    ++ lib.optional (stdenv.isx86_64 && (precision == "single" || precision == "double") )  "--enable-sse2"
-    ++ lib.optional enableAvx "--enable-avx"
-    ++ lib.optional enableAvx2 "--enable-avx2"
-    ++ lib.optional enableAvx512 "--enable-avx512"
-    ++ lib.optional enableFma "--enable-fma"
-    ++ [ "--enable-openmp" ]
-    ++ lib.optional enableMpi "--enable-mpi"
-    # doc generation causes Fortran wrapper generation which hard-codes gcc
-    ++ lib.optional (!withDoc) "--disable-doc";
+  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"
+  '';
 
   enableParallelBuilding = true;