From 090dabd043659ff45e8f92c1d2fb4e22492e01fa Mon Sep 17 00:00:00 2001 From: Madoura Date: Thu, 24 Nov 2022 02:33:11 -0600 Subject: [PATCH] rocrand: init at 2.10.15-5.3.3 --- .../development/libraries/rocrand/default.nix | 100 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 102 insertions(+) create mode 100644 pkgs/development/libraries/rocrand/default.nix diff --git a/pkgs/development/libraries/rocrand/default.nix b/pkgs/development/libraries/rocrand/default.nix new file mode 100644 index 000000000000..cc3dbebd224b --- /dev/null +++ b/pkgs/development/libraries/rocrand/default.nix @@ -0,0 +1,100 @@ +{ lib +, stdenv +, fetchFromGitHub +, writeScript +, cmake +, rocm-cmake +, rocm-runtime +, rocm-device-libs +, rocm-comgr +, hip +, gtest ? null +, gbenchmark ? null +, buildTests ? false +, buildBenchmarks ? false +}: + +assert buildTests -> gtest != null; +assert buildBenchmarks -> gbenchmark != null; + +stdenv.mkDerivation (finalAttrs: { + pname = "rocrand"; + repoVersion = "2.10.15"; + rocmVersion = "5.3.3"; + version = "${finalAttrs.repoVersion}-${finalAttrs.rocmVersion}"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "rocRAND"; + rev = "rocm-${finalAttrs.rocmVersion}"; + hash = "sha256-awQLqPmhVxegrqqSoC8fiCQJ33bPKZlljSAXnHVcIZo="; + fetchSubmodules = true; # For inline hipRAND + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + ]; + + buildInputs = [ + rocm-runtime + rocm-device-libs + rocm-comgr + ] ++ lib.optionals buildTests [ + gtest + ] ++ lib.optionals buildBenchmarks [ + gbenchmark + ]; + + cmakeFlags = [ + "-DCMAKE_C_COMPILER=hipcc" + "-DCMAKE_CXX_COMPILER=hipcc" + "-DHIP_ROOT_DIR=${hip}" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals buildTests [ + "-DBUILD_TEST=ON" + ] ++ lib.optionals buildBenchmarks [ + "-DBUILD_BENCHMARK=ON" + ]; + + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/test_* $test/bin + '' + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/benchmark_* $benchmark/bin + '' + lib.optionalString (buildTests || buildBenchmarks) '' + rmdir $out/bin + ''; + + passthru.updateScript = writeScript "update.sh" '' + #!/usr/bin/env nix-shell + #!nix-shell -i bash -p curl jq common-updater-scripts + json="$(curl -sL "https://api.github.com/repos/ROCmSoftwarePlatform/rocRAND/releases?per_page=1")" + repoVersion="$(echo "$json" | jq '.[0].name | split(" ") | .[1]' --raw-output)" + rocmVersion="$(echo "$json" | jq '.[0].tag_name | split("-") | .[1]' --raw-output)" + update-source-version rocrand "$repoVersion" --ignore-same-hash --version-key=repoVersion + update-source-version rocrand "$rocmVersion" --ignore-same-hash --version-key=rocmVersion + ''; + + meta = with lib; { + description = "Generate pseudo-random and quasi-random numbers"; + homepage = "https://github.com/ROCmSoftwarePlatform/rocRAND"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + broken = finalAttrs.rocmVersion != hip.version; + }; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 173dd01288bd..ee119c76c159 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14977,6 +14977,8 @@ with pkgs; rocfft = callPackage ../development/libraries/rocfft { }; + rocrand = callPackage ../development/libraries/rocrand { }; + tensile = python3Packages.callPackage ../development/libraries/tensile { }; rocblas = callPackage ../development/libraries/rocblas {