about summary refs log tree commit diff
path: root/pkgs/development/libraries/science/math/openblas
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2020-04-05 20:12:15 +0200
committerNiklas Hambüchen <mail@nh2.me>2020-04-08 13:46:04 +0200
commitdf907c4786e672978024556a6df6e56ced5bbd30 (patch)
tree93a54e68090191fb3e00875fc3ad84cb7fbf65d2 /pkgs/development/libraries/science/math/openblas
parent3b6539896b0721c3473fe86f00811b74ad560ba0 (diff)
openblas: Add `singleThreaded` option. Off by default.
See https://github.com/xianyi/OpenBLAS/issues/2543
Diffstat (limited to 'pkgs/development/libraries/science/math/openblas')
-rw-r--r--pkgs/development/libraries/science/math/openblas/default.nix15
1 files changed, 14 insertions, 1 deletions
diff --git a/pkgs/development/libraries/science/math/openblas/default.nix b/pkgs/development/libraries/science/math/openblas/default.nix
index 38ad31cc62573..efad842bd357f 100644
--- a/pkgs/development/libraries/science/math/openblas/default.nix
+++ b/pkgs/development/libraries/science/math/openblas/default.nix
@@ -3,6 +3,14 @@
 # pointer width, but some expect to use 32-bit integers always
 # (for compatibility with reference BLAS).
 , blas64 ? null
+# Multi-threaded applications must not call a threaded OpenBLAS
+# (the only exception is when an application uses OpenMP as its
+# *only* form of multi-threading). See
+#     https://github.com/xianyi/OpenBLAS/wiki/Faq/4bded95e8dc8aadc70ce65267d1093ca7bdefc4c#multi-threaded
+#     https://github.com/xianyi/OpenBLAS/issues/2543
+# This flag builds a single-threaded OpenBLAS using the flags
+# stated in thre.
+, singleThreaded ? false
 , buildPackages
 # Select a specific optimization target (other than the default)
 # See https://github.com/xianyi/OpenBLAS/blob/develop/TargetList.txt
@@ -146,7 +154,12 @@ stdenv.mkDerivation rec {
     NO_BINARY_MODE = if stdenv.isx86_64
         then toString (stdenv.hostPlatform != stdenv.buildPlatform)
         else stdenv.hostPlatform != stdenv.buildPlatform;
-  });
+  } // (stdenv.lib.optionalAttrs singleThreaded {
+    # As described on https://github.com/xianyi/OpenBLAS/wiki/Faq/4bded95e8dc8aadc70ce65267d1093ca7bdefc4c#multi-threaded
+    USE_THREAD = false;
+    USE_LOCKING = true; # available with openblas >= 0.3.7
+    USE_OPENMP = false; # openblas will refuse building with both USE_OPENMP=1 and USE_THREAD=0
+  }));
 
   doCheck = true;
   checkTarget = "tests";