about summary refs log tree commit diff
path: root/pkgs/development/libraries/science/math/magma
diff options
context:
space:
mode:
authorDaniël de Kok <me@danieldk.eu>2021-02-10 10:19:40 +0100
committerDaniël de Kok <me@danieldk.eu>2021-02-10 10:23:49 +0100
commit83b3634174c5532e9c020f84facdf56feef49b81 (patch)
tree28c51db3a545cd572f6690c83dfed2101ab2de85 /pkgs/development/libraries/science/math/magma
parenta40939b6aec6feedb2e63b2c32c046ffc786d3c4 (diff)
magma: fix CUDA 11 build
By default, MAGMA builds against compute capability 3.0 (among other
capabilities). However, support for this capability was dropped in
CUDA 11. This change fixes CUDA 11 support by excluding 3.0.

While at it, this change also adds support for newer compute
capabilities that are not enabled by MAGMA by default (to support
older CUDA versions).
Diffstat (limited to 'pkgs/development/libraries/science/math/magma')
-rw-r--r--pkgs/development/libraries/science/math/magma/default.nix38
1 files changed, 36 insertions, 2 deletions
diff --git a/pkgs/development/libraries/science/math/magma/default.nix b/pkgs/development/libraries/science/math/magma/default.nix
index b8e3999ffe83c..c5960dddf5177 100644
--- a/pkgs/development/libraries/science/math/magma/default.nix
+++ b/pkgs/development/libraries/science/math/magma/default.nix
@@ -1,8 +1,40 @@
 { lib, stdenv, fetchurl, cmake, gfortran, ninja, cudatoolkit, libpthreadstubs, lapack, blas }:
 
-with lib;
+assert let majorIs = lib.versions.major cudatoolkit.version;
+       in majorIs == "9" || majorIs == "10" || majorIs == "11";
 
-let version = "2.5.4";
+let
+  version = "2.5.4";
+
+  # We define a specific set of CUDA compute capabilities here,
+  # because CUDA 11 does not support compute capability 3.0. Also,
+  # we use it to enable newer capabilities that are not enabled
+  # by magma by default. The list of supported architectures
+  # can be found in magma's top-level CMakeLists.txt.
+  cudaCapabilities = rec {
+    cuda9 = [
+      "Kepler"  # 3.0, 3.5
+      "Maxwell" # 5.0
+      "Pascal"  # 6.0
+      "Volta"   # 7.0
+    ];
+
+    cuda10 = [
+      "Turing"  # 7.5
+    ] ++ cuda9;
+
+    cuda11 = [
+      "sm_35"   # sm_30 is not supported by CUDA 11
+      "Maxwell" # 5.0
+      "Pascal"  # 6.0
+      "Volta"   # 7.0
+      "Turing"  # 7.5
+      "Ampere"  # 8.0
+    ];
+  };
+
+  capabilityString = lib.strings.concatStringsSep ","
+    cudaCapabilities."cuda${lib.versions.major cudatoolkit.version}";
 
 in stdenv.mkDerivation {
   pname = "magma";
@@ -17,6 +49,8 @@ in stdenv.mkDerivation {
 
   buildInputs = [ cudatoolkit libpthreadstubs lapack blas ];
 
+  cmakeFlags = [ "-DGPU_TARGET=${capabilityString}" ];
+
   doCheck = false;
 
   preConfigure = ''