about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/science
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-09-01 11:51:02 +0000
committerAlyssa Ross <hi@alyssa.is>2023-09-01 11:51:02 +0000
commitaa4353b499e6950b7333578f936455a628145c31 (patch)
treec6332cedece2327a18d08794755b3fc0f9f1905b /nixpkgs/pkgs/development/libraries/science
parentac456d475f4e50818499b804359355c0f3b4bbf7 (diff)
parent52185f4d76c18d8348f963795dfed1de018e8dfe (diff)
downloadnixlib-aa4353b499e6950b7333578f936455a628145c31.tar
nixlib-aa4353b499e6950b7333578f936455a628145c31.tar.gz
nixlib-aa4353b499e6950b7333578f936455a628145c31.tar.bz2
nixlib-aa4353b499e6950b7333578f936455a628145c31.tar.lz
nixlib-aa4353b499e6950b7333578f936455a628145c31.tar.xz
nixlib-aa4353b499e6950b7333578f936455a628145c31.tar.zst
nixlib-aa4353b499e6950b7333578f936455a628145c31.zip
Merge https://github.com/NixOS/nixpkgs
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/science')
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix76
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/dbcsr/default.nix10
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/magma/generic.nix14
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/magma/releases.nix4
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix16
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix2
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/p4est-sc/default.nix10
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/p4est/default.nix2
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix17
9 files changed, 94 insertions, 57 deletions
diff --git a/nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix b/nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix
index e0a6ffd9d547..db85bfdd9c0b 100644
--- a/nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix
+++ b/nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix
@@ -1,6 +1,7 @@
 { stdenv,
   backendStdenv,
   lib,
+  lndir,
   zlib,
   useCudatoolkitRunfile ? false,
   cudaVersion,
@@ -10,14 +11,6 @@
   autoPatchelfHook,
   autoAddOpenGLRunpathHook,
   fetchurl,
-  # The distributed version of CUDNN includes both dynamically liked .so files,
-  # as well as statically linked .a files.  However, CUDNN is quite large
-  # (multiple gigabytes), so you can save some space in your nix store by
-  # removing the statically linked libraries if you are not using them.
-  #
-  # Setting this to true removes the statically linked .a files.
-  # Setting this to false keeps these statically linked .a files.
-  removeStatic ? false,
 }: {
   version,
   url,
@@ -48,11 +41,16 @@ in
   backendStdenv.mkDerivation {
     pname = "cudatoolkit-${cudaMajorVersion}-cudnn";
     version = versionTriple;
+    strictDeps = true;
+    outputs = ["out" "lib" "static" "dev"];
 
     src = fetchurl {
       inherit url hash;
     };
 
+    # We do need some other phases, like configurePhase, so the multiple-output setup hook works.
+    dontBuild = true;
+
     # Check and normalize Runpath against DT_NEEDED using autoPatchelf.
     # Prepend /run/opengl-driver/lib using addOpenGLRunpath for dlopen("libcudacuda.so")
     nativeBuildInputs = [
@@ -74,27 +72,49 @@ in
     #
     # Note also that version <=8.3.0 contained a subdirectory "lib64/" but in
     # version 8.3.2 it seems to have been renamed to simply "lib/".
+    #
+    # doc and dev have special output handling. Other outputs need to be moved to their own
+    # output.
+    # Note that moveToOutput operates on all outputs:
+    # https://github.com/NixOS/nixpkgs/blob/2920b6fc16a9ed5d51429e94238b28306ceda79e/pkgs/build-support/setup-hooks/multiple-outputs.sh#L105-L107
     installPhase =
       ''
         runHook preInstall
 
-        mkdir -p $out
-        cp -a include $out/include
-        [ -d "lib/" ] && cp -a lib $out/lib
-        [ -d "lib64/" ] && cp -a lib64 $out/lib64
-      ''
-      + strings.optionalString removeStatic ''
-        rm -f $out/lib/*.a
-        rm -f $out/lib64/*.a
-      ''
-      + ''
+        mkdir -p "$out"
+        mv * "$out"
+        moveToOutput "lib64" "$lib"
+        moveToOutput "lib" "$lib"
+        moveToOutput "**/*.a" "$static"
+
         runHook postInstall
       '';
 
     # Without --add-needed autoPatchelf forgets $ORIGIN on cuda>=8.0.5.
     postFixup = strings.optionalString (strings.versionAtLeast versionTriple "8.0.5") ''
-      patchelf $out/lib/libcudnn.so --add-needed libcudnn_cnn_infer.so
-      patchelf $out/lib/libcudnn_ops_infer.so --add-needed libcublas.so --add-needed libcublasLt.so
+      patchelf $lib/lib/libcudnn.so --add-needed libcudnn_cnn_infer.so
+      patchelf $lib/lib/libcudnn_ops_infer.so --add-needed libcublas.so --add-needed libcublasLt.so
+    '';
+
+    # The out output leverages the same functionality which backs the `symlinkJoin` function in
+    # Nixpkgs:
+    # https://github.com/NixOS/nixpkgs/blob/d8b2a92df48f9b08d68b0132ce7adfbdbc1fbfac/pkgs/build-support/trivial-builders/default.nix#L510
+    #
+    # That should allow us to emulate "fat" default outputs without having to actually create them.
+    #
+    # It is important that this run after the autoPatchelfHook, otherwise the symlinks in out will reference libraries in lib, creating a circular dependency.
+    postPhases = ["postPatchelf"];
+    # For each output, create a symlink to it in the out output.
+    # NOTE: We must recreate the out output here, because the setup hook will have deleted it
+    # if it was empty.
+    # NOTE: Do not use optionalString based on whether `outputs` contains only `out` -- phases
+    # which are empty strings are skipped/unset and result in errors of the form "command not
+    # found: <customPhaseName>".
+    postPatchelf = ''
+      mkdir -p "$out"
+      ${lib.meta.getExe lndir} "$lib" "$out"
+      ${lib.meta.getExe lndir} "$static" "$out"
+      ${lib.meta.getExe lndir} "$dev" "$out"
     '';
 
     passthru = {
@@ -111,6 +131,19 @@ in
       majorVersion = versions.major versionTriple;
     };
 
+    # Setting propagatedBuildInputs to false will prevent outputs known to the multiple-outputs
+    # from depending on `out` by default.
+    # https://github.com/NixOS/nixpkgs/blob/2920b6fc16a9ed5d51429e94238b28306ceda79e/pkgs/build-support/setup-hooks/multiple-outputs.sh#L196
+    # Indeed, we want to do the opposite -- fat "out" outputs that contain all the other outputs.
+    propagatedBuildOutputs = false;
+
+    # By default, if the dev output exists it just uses that.
+    # However, because we disabled propagatedBuildOutputs, dev doesn't contain libraries or
+    # anything of the sort. To remedy this, we set outputSpecified to true, and use
+    # outputsToInstall, which tells Nix which outputs to use when the package name is used
+    # unqualified (that is, without an explicit output).
+    outputSpecified = true;
+
     meta = with lib; {
       # Check that the cudatoolkit version satisfies our min/max constraints (both
       # inclusive). We mark the package as broken if it fails to satisfies the
@@ -127,5 +160,8 @@ in
       license = licenses.unfree;
       platforms = ["x86_64-linux"];
       maintainers = with maintainers; [mdaiter samuela];
+      # Force the use of the default, fat output by default (even though `dev` exists, which
+      # causes Nix to prefer that output over the others if outputSpecified isn't set).
+      outputsToInstall = ["out"];
     };
   }
diff --git a/nixpkgs/pkgs/development/libraries/science/math/dbcsr/default.nix b/nixpkgs/pkgs/development/libraries/science/math/dbcsr/default.nix
index 5a9d3c5066cc..2c576a190026 100644
--- a/nixpkgs/pkgs/development/libraries/science/math/dbcsr/default.nix
+++ b/nixpkgs/pkgs/development/libraries/science/math/dbcsr/default.nix
@@ -2,6 +2,7 @@
 , lib
 , fetchFromGitHub
 , cmake
+, mpiCheckPhaseHook
 , pkg-config
 , fypp
 , gfortran
@@ -64,13 +65,12 @@ stdenv.mkDerivation rec {
     "-DUSE_MPI=ON"
   ];
 
-  checkInputs = [ openssh ];
+  checkInputs = [
+    openssh
+    mpiCheckPhaseHook
+  ];
 
   doCheck = true;
-  preCheck = ''
-    export HYDRA_IFACE=lo  # Fix to make mpich run in a sandbox
-    export OMPI_MCA_rmaps_base_oversubscribe=1
-  '';
 
   meta = with lib; {
     description = "Distributed Block Compressed Sparse Row matrix library";
diff --git a/nixpkgs/pkgs/development/libraries/science/math/magma/generic.nix b/nixpkgs/pkgs/development/libraries/science/math/magma/generic.nix
index 04f263568ce6..b3753a63339a 100644
--- a/nixpkgs/pkgs/development/libraries/science/math/magma/generic.nix
+++ b/nixpkgs/pkgs/development/libraries/science/math/magma/generic.nix
@@ -113,13 +113,17 @@ stdenv.mkDerivation {
     lapack
     blas
   ] ++ lists.optionals cudaSupport (with cudaPackages; [
-    cuda_cudart
-    libcublas # cublas_v2.h
-    libcusparse # cusparse.h
+    cuda_cudart.dev # cuda_runtime.h
+    cuda_cudart.lib # cudart
+    cuda_cudart.static # cudart_static
+    libcublas.dev # cublas_v2.h
+    libcublas.lib # cublas
+    libcusparse.dev # cusparse.h
+    libcusparse.lib # cusparse
   ] ++ lists.optionals (strings.versionOlder cudaVersion "11.8") [
-    cuda_nvprof # <cuda_profiler_api.h>
+    cuda_nvprof.dev # <cuda_profiler_api.h>
   ] ++ lists.optionals (strings.versionAtLeast cudaVersion "11.8") [
-    cuda_profiler_api # <cuda_profiler_api.h>
+    cuda_profiler_api.dev # <cuda_profiler_api.h>
   ]) ++ lists.optionals rocmSupport [
     hip
     hipblas
diff --git a/nixpkgs/pkgs/development/libraries/science/math/magma/releases.nix b/nixpkgs/pkgs/development/libraries/science/math/magma/releases.nix
index 029f418edce3..59f495d67109 100644
--- a/nixpkgs/pkgs/development/libraries/science/math/magma/releases.nix
+++ b/nixpkgs/pkgs/development/libraries/science/math/magma/releases.nix
@@ -36,8 +36,8 @@
     ];
   }
   {
-    version = "2.7.1";
-    hash = "sha256-2chxHAR6OMrhbv3nS+4uszMyF/0nEeHpuGBsu7SuGlA=";
+    version = "2.7.2";
+    hash = "sha256-cpvBpw5RinQi/no6VFN6R0EDWne+M0n2bqxcNiV21WA=";
     supportedGpuTargets = [
       "700"
       "701"
diff --git a/nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix b/nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix
index 2eb391dda46b..c5c7b7e6427d 100644
--- a/nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix
+++ b/nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix
@@ -8,20 +8,22 @@
 , cuda_nvcc
 , cudaFlags
 , cudaVersion
+# passthru.updateScript
+, gitUpdater
 }:
 let
   # Output looks like "-gencode=arch=compute_86,code=sm_86 -gencode=arch=compute_86,code=compute_86"
   gencode = lib.concatStringsSep " " cudaFlags.gencode;
 in
 backendStdenv.mkDerivation (finalAttrs: {
-  name = "nccl-${finalAttrs.version}-cuda-${cudaVersion}";
-  version = "2.16.5-1";
+  pname = "nccl";
+  version = "2.18.5-1";
 
   src = fetchFromGitHub {
     owner = "NVIDIA";
-    repo = "nccl";
+    repo = finalAttrs.pname;
     rev = "v${finalAttrs.version}";
-    hash = "sha256-JyhhYKSVIqUKIbC1rCJozPT1IrIyRLGrTjdPjJqsYaU=";
+    hash = "sha256-vp2WitKateEt1AzSeeEvY/wM4NnUmV7XgL/gfPRUObY=";
   };
 
   outputs = [ "out" "dev" ];
@@ -63,6 +65,12 @@ backendStdenv.mkDerivation (finalAttrs: {
 
   env.NIX_CFLAGS_COMPILE = toString [ "-Wno-unused-function" ];
 
+  # Run the update script with: `nix-shell maintainers/scripts/update.nix --argstr package cudaPackages.nccl`
+  passthru.updateScript = gitUpdater {
+    inherit (finalAttrs) pname version;
+    rev-prefix = "v";
+  };
+
   enableParallelBuilding = true;
 
   meta = with lib; {
diff --git a/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix b/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix
index 92588307ca57..55438c63a5e0 100644
--- a/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix
+++ b/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix
@@ -88,7 +88,7 @@ stdenv.mkDerivation rec {
   propagatedBuildInputs = [
     abseil-cpp
     protobuf
-    python.pkgs.protobuf
+    (python.pkgs.protobuf.override { protobuf = protobuf; })
     python.pkgs.numpy
   ];
   nativeCheckInputs = [
diff --git a/nixpkgs/pkgs/development/libraries/science/math/p4est-sc/default.nix b/nixpkgs/pkgs/development/libraries/science/math/p4est-sc/default.nix
index fbd9db6a419f..bb5d212061f2 100644
--- a/nixpkgs/pkgs/development/libraries/science/math/p4est-sc/default.nix
+++ b/nixpkgs/pkgs/development/libraries/science/math/p4est-sc/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchFromGitHub
+{ lib, stdenv, fetchFromGitHub, mpiCheckPhaseHook
 , autoreconfHook, pkg-config
 , p4est-sc-debugEnable ? true, p4est-sc-mpiSupport ? true
 , mpi, openssh, zlib
@@ -47,10 +47,10 @@ stdenv.mkDerivation {
   enableParallelBuilding = true;
   makeFlags = [ "V=0" ];
 
-  preCheck = ''
-    export OMPI_MCA_rmaps_base_oversubscribe=1
-    export HYDRA_IFACE=lo
-  '';
+  nativeCheckInputs = lib.optionals mpiSupport [
+    mpiCheckPhaseHook
+    openssh
+  ];
 
   # disallow Darwin checks due to prototype incompatibility of qsort_r
   # to be fixed in a future version of the source code
diff --git a/nixpkgs/pkgs/development/libraries/science/math/p4est/default.nix b/nixpkgs/pkgs/development/libraries/science/math/p4est/default.nix
index a55c5fe573bf..1218c695590e 100644
--- a/nixpkgs/pkgs/development/libraries/science/math/p4est/default.nix
+++ b/nixpkgs/pkgs/development/libraries/science/math/p4est/default.nix
@@ -46,7 +46,7 @@ stdenv.mkDerivation {
     ++ lib.optional withMetis "--with-metis"
   ;
 
-  inherit (p4est-sc) makeFlags dontDisableStatic enableParallelBuilding preCheck doCheck;
+  inherit (p4est-sc) makeFlags dontDisableStatic enableParallelBuilding doCheck;
 
   meta = {
     branch = "prev3-develop";
diff --git a/nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix b/nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix
index 0d553376288f..e2a5e76c5586 100644
--- a/nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix
+++ b/nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix
@@ -1,5 +1,5 @@
-{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, openssh
-, mpi, blas, lapack
+{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake
+, openssh, mpiCheckPhaseHook, mpi, blas, lapack
 } :
 
 assert blas.isILP64 == lapack.isILP64;
@@ -35,7 +35,7 @@ stdenv.mkDerivation rec {
   '';
 
   nativeBuildInputs = [ cmake ];
-  nativeCheckInputs = [ openssh ];
+  nativeCheckInputs = [ openssh mpiCheckPhaseHook ];
   buildInputs = [ blas lapack ];
   propagatedBuildInputs = [ mpi ];
   hardeningDisable = lib.optionals (stdenv.isAarch64 && stdenv.isDarwin) [ "stackprotector" ];
@@ -61,17 +61,6 @@ stdenv.mkDerivation rec {
   # sometimes fail due to this
   checkFlagsArray = [ "ARGS=--timeout 10000" ];
 
-  preCheck = ''
-    # make sure the test starts even if we have less than 4 cores
-    export OMPI_MCA_rmaps_base_oversubscribe=1
-
-    # Fix to make mpich run in a sandbox
-    export HYDRA_IFACE=lo
-
-    # Run single threaded
-    export OMP_NUM_THREADS=1
-  '';
-
   meta = with lib; {
     homepage = "http://www.netlib.org/scalapack/";
     description = "Library of high-performance linear algebra routines for parallel distributed memory machines";