about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/cuda-modules/cuda-library-samples
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/cuda-modules/cuda-library-samples')
-rw-r--r--nixpkgs/pkgs/development/cuda-modules/cuda-library-samples/extension.nix14
-rw-r--r--nixpkgs/pkgs/development/cuda-modules/cuda-library-samples/generic.nix85
2 files changed, 99 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/cuda-modules/cuda-library-samples/extension.nix b/nixpkgs/pkgs/development/cuda-modules/cuda-library-samples/extension.nix
new file mode 100644
index 000000000000..4cb34af73209
--- /dev/null
+++ b/nixpkgs/pkgs/development/cuda-modules/cuda-library-samples/extension.nix
@@ -0,0 +1,14 @@
+{hostPlatform, lib}:
+let
+  # Samples are built around the CUDA Toolkit, which is not available for
+  # aarch64. Check for both CUDA version and platform.
+  platformIsSupported = hostPlatform.isx86_64 && hostPlatform.isLinux;
+
+  # Build our extension
+  extension =
+    final: _:
+    lib.attrsets.optionalAttrs platformIsSupported {
+      cuda-library-samples = final.callPackage ./generic.nix {};
+    };
+in
+extension
diff --git a/nixpkgs/pkgs/development/cuda-modules/cuda-library-samples/generic.nix b/nixpkgs/pkgs/development/cuda-modules/cuda-library-samples/generic.nix
new file mode 100644
index 000000000000..d4182536654e
--- /dev/null
+++ b/nixpkgs/pkgs/development/cuda-modules/cuda-library-samples/generic.nix
@@ -0,0 +1,85 @@
+{
+  lib,
+  backendStdenv,
+  fetchFromGitHub,
+  cmake,
+  addOpenGLRunpath,
+  cudatoolkit,
+  cutensor,
+}:
+
+let
+  rev = "5aab680905d853bce0dbad4c488e4f7e9f7b2302";
+  src = fetchFromGitHub {
+    owner = "NVIDIA";
+    repo = "CUDALibrarySamples";
+    inherit rev;
+    sha256 = "0gwgbkq05ygrfgg5hk07lmap7n7ampxv0ha1axrv8qb748ph81xs";
+  };
+  commonAttrs = {
+    version = lib.strings.substring 0 7 rev + "-" + lib.versions.majorMinor cudatoolkit.version;
+    nativeBuildInputs = [
+      cmake
+      addOpenGLRunpath
+    ];
+    buildInputs = [cudatoolkit];
+    postFixup = ''
+      for exe in $out/bin/*; do
+        addOpenGLRunpath $exe
+      done
+    '';
+    meta = {
+      description = "examples of using libraries using CUDA";
+      longDescription = ''
+        CUDA Library Samples contains examples demonstrating the use of
+        features in the math and image processing libraries cuBLAS, cuTENSOR,
+        cuSPARSE, cuSOLVER, cuFFT, cuRAND, NPP and nvJPEG.
+      '';
+      license = lib.licenses.bsd3;
+      maintainers = with lib.maintainers; [obsidian-systems-maintenance] ++ lib.teams.cuda.members;
+    };
+  };
+in
+
+{
+  cublas = backendStdenv.mkDerivation (
+    commonAttrs
+    // {
+      pname = "cuda-library-samples-cublas";
+
+      src = "${src}/cuBLASLt";
+    }
+  );
+
+  cusolver = backendStdenv.mkDerivation (
+    commonAttrs
+    // {
+      pname = "cuda-library-samples-cusolver";
+
+      src = "${src}/cuSOLVER";
+
+      sourceRoot = "cuSOLVER/gesv";
+    }
+  );
+
+  cutensor = backendStdenv.mkDerivation (
+    commonAttrs
+    // {
+      pname = "cuda-library-samples-cutensor";
+
+      src = "${src}/cuTENSOR";
+
+      buildInputs = [cutensor];
+
+      cmakeFlags = ["-DCUTENSOR_EXAMPLE_BINARY_INSTALL_DIR=${builtins.placeholder "out"}/bin"];
+
+      # CUTENSOR_ROOT is double escaped
+      postPatch = ''
+        substituteInPlace CMakeLists.txt \
+          --replace "\''${CUTENSOR_ROOT}/include" "${cutensor.dev}/include"
+      '';
+
+      CUTENSOR_ROOT = cutensor;
+    }
+  );
+}