about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/science/math/magma/default.nix')
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/magma/default.nix58
1 files changed, 58 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix b/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix
new file mode 100644
index 000000000000..b34139e7f484
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix
@@ -0,0 +1,58 @@
+{ stdenv, fetchurl, cmake, gfortran, cudatoolkit, libpthreadstubs, lapack, blas
+, mklSupport ? false, mkl ? null
+}:
+
+assert !mklSupport || mkl != null;
+
+with stdenv.lib;
+
+let version = "2.5.0";
+
+in stdenv.mkDerivation {
+  pname = "magma";
+  inherit version;
+  src = fetchurl {
+    url = "https://icl.cs.utk.edu/projectsfiles/magma/downloads/magma-${version}.tar.gz";
+    sha256 = "0czspk93cv1fy37zyrrc9k306q4yzfxkhy1y4lj937dx8rz5rm2g";
+    name = "magma-${version}.tar.gz";
+  };
+
+  buildInputs = [ gfortran cudatoolkit libpthreadstubs cmake ]
+    ++ (if mklSupport then [ mkl ] else [ lapack blas ]);
+
+  doCheck = false;
+
+  MKLROOT = optionalString mklSupport mkl;
+
+  preConfigure = ''
+    export CC=${cudatoolkit.cc}/bin/gcc CXX=${cudatoolkit.cc}/bin/g++
+  '';
+
+  enableParallelBuilding=true;
+  buildFlags = [ "magma" "magma_sparse" ];
+
+  # MAGMA's default CMake setup does not care about installation. So we copy files directly.
+  installPhase = ''
+    mkdir -p $out
+    mkdir -p $out/include
+    mkdir -p $out/lib
+    mkdir -p $out/lib/pkgconfig
+    cp -a ../include/*.h $out/include
+    #cp -a sparse-iter/include/*.h $out/include
+    cp -a lib/*.a $out/lib
+    cat ../lib/pkgconfig/magma.pc.in                   | \
+    sed -e s:@INSTALL_PREFIX@:"$out":          | \
+    sed -e s:@CFLAGS@:"-I$out/include":    | \
+    sed -e s:@LIBS@:"-L$out/lib -lmagma -lmagma_sparse": | \
+    sed -e s:@MAGMA_REQUIRED@::                       \
+        > $out/lib/pkgconfig/magma.pc
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Matrix Algebra on GPU and Multicore Architectures";
+    license = licenses.bsd3;
+    homepage = "http://icl.cs.utk.edu/magma/index.html";
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ tbenst ];
+  };
+}