Skip to content

Commit

Permalink
Merge pull request #203235 from Madouura/pr/matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
mweinelt authored Nov 27, 2022
2 parents 5da55af + ad39a56 commit 29358a5
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 247 deletions.
48 changes: 20 additions & 28 deletions pkgs/development/libraries/hipsparse/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,14 @@
, hip
, gfortran
, git
, fetchzip ? null
, gtest ? null
, buildTests ? false
}:

assert buildTests -> fetchzip != null;
assert buildTests -> gtest != null;

# This can also use cuSPARSE as a backend instead of rocSPARSE
let
matrices = lib.optionalAttrs buildTests import ./deps.nix {
inherit fetchzip;
mirror1 = "https://sparse.tamu.edu/MM";
mirror2 = "https://www.cise.ufl.edu/research/sparse/MM";
};
in stdenv.mkDerivation (finalAttrs: {
stdenv.mkDerivation (finalAttrs: {
pname = "hipsparse";
repoVersion = "2.3.1";
rocmVersion = "5.3.3";
Expand Down Expand Up @@ -81,25 +73,25 @@ in stdenv.mkDerivation (finalAttrs: {
'' + lib.optionalString buildTests ''
mkdir -p matrices
ln -s ${matrices.matrix-01}/*.mtx matrices
ln -s ${matrices.matrix-02}/*.mtx matrices
ln -s ${matrices.matrix-03}/*.mtx matrices
ln -s ${matrices.matrix-04}/*.mtx matrices
ln -s ${matrices.matrix-05}/*.mtx matrices
ln -s ${matrices.matrix-06}/*.mtx matrices
ln -s ${matrices.matrix-07}/*.mtx matrices
ln -s ${matrices.matrix-08}/*.mtx matrices
ln -s ${matrices.matrix-09}/*.mtx matrices
ln -s ${matrices.matrix-10}/*.mtx matrices
ln -s ${matrices.matrix-11}/*.mtx matrices
ln -s ${matrices.matrix-12}/*.mtx matrices
ln -s ${matrices.matrix-13}/*.mtx matrices
ln -s ${matrices.matrix-14}/*.mtx matrices
ln -s ${matrices.matrix-15}/*.mtx matrices
ln -s ${matrices.matrix-16}/*.mtx matrices
ln -s ${matrices.matrix-17}/*.mtx matrices
ln -s ${matrices.matrix-18}/*.mtx matrices
ln -s ${matrices.matrix-19}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-01}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-02}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-03}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-04}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-05}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-06}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-07}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-08}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-09}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-10}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-11}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-12}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-13}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-14}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-15}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-16}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-17}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-18}/*.mtx matrices
ln -s ${rocsparse.passthru.matrices.matrix-19}/*.mtx matrices
# Not used by the original cmake, causes an error
rm matrices/*_b.mtx
Expand Down
177 changes: 0 additions & 177 deletions pkgs/development/libraries/hipsparse/deps.nix

This file was deleted.

85 changes: 43 additions & 42 deletions pkgs/development/libraries/rocsparse/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ lib
, stdenv
, fetchFromGitHub
, fetchzip
, writeScript
, cmake
, rocm-cmake
Expand All @@ -11,26 +12,18 @@
, hip
, gfortran
, git
, fetchzip ? null
, gtest ? null
, boost ? null
, python3Packages ? null
, buildTests ? false
, buildBenchmarks ? false # Seems to depend on tests
}:

assert (buildTests || buildBenchmarks) -> fetchzip != null;
assert (buildTests || buildBenchmarks) -> gtest != null;
assert (buildTests || buildBenchmarks) -> boost != null;
assert (buildTests || buildBenchmarks) -> python3Packages != null;

let
matrices = lib.optionalAttrs (buildTests || buildBenchmarks) import ./deps.nix {
inherit fetchzip;
mirror1 = "https://sparse.tamu.edu/MM";
mirror2 = "https://www.cise.ufl.edu/research/sparse/MM";
};
in stdenv.mkDerivation (finalAttrs: {
stdenv.mkDerivation (finalAttrs: {
pname = "rocsparse";
repoVersion = "2.3.2";
rocmVersion = "5.3.3";
Expand Down Expand Up @@ -90,30 +83,30 @@ in stdenv.mkDerivation (finalAttrs: {
postPatch = lib.optionalString (buildTests || buildBenchmarks) ''
mkdir -p matrices
ln -s ${matrices.matrix-01}/*.mtx matrices
ln -s ${matrices.matrix-02}/*.mtx matrices
ln -s ${matrices.matrix-03}/*.mtx matrices
ln -s ${matrices.matrix-04}/*.mtx matrices
ln -s ${matrices.matrix-05}/*.mtx matrices
ln -s ${matrices.matrix-06}/*.mtx matrices
ln -s ${matrices.matrix-07}/*.mtx matrices
ln -s ${matrices.matrix-08}/*.mtx matrices
ln -s ${matrices.matrix-09}/*.mtx matrices
ln -s ${matrices.matrix-10}/*.mtx matrices
ln -s ${matrices.matrix-11}/*.mtx matrices
ln -s ${matrices.matrix-12}/*.mtx matrices
ln -s ${matrices.matrix-13}/*.mtx matrices
ln -s ${matrices.matrix-14}/*.mtx matrices
ln -s ${matrices.matrix-15}/*.mtx matrices
ln -s ${matrices.matrix-16}/*.mtx matrices
ln -s ${matrices.matrix-17}/*.mtx matrices
ln -s ${matrices.matrix-18}/*.mtx matrices
ln -s ${matrices.matrix-19}/*.mtx matrices
ln -s ${matrices.matrix-20}/*.mtx matrices
ln -s ${matrices.matrix-21}/*.mtx matrices
ln -s ${matrices.matrix-22}/*.mtx matrices
ln -s ${matrices.matrix-23}/*.mtx matrices
ln -s ${matrices.matrix-24}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-01}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-02}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-03}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-04}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-05}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-06}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-07}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-08}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-09}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-10}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-11}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-12}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-13}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-14}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-15}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-16}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-17}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-18}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-19}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-20}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-21}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-22}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-23}/*.mtx matrices
ln -s ${finalAttrs.passthru.matrices.matrix-24}/*.mtx matrices
# Not used by the original cmake, causes an error
rm matrices/*_b.mtx
Expand All @@ -140,15 +133,23 @@ in stdenv.mkDerivation (finalAttrs: {
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/rocSPARSE/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 rocsparse "$repoVersion" --ignore-same-hash --version-key=repoVersion
update-source-version rocsparse "$rocmVersion" --ignore-same-hash --version-key=rocmVersion
'';
passthru = {
matrices = import ./deps.nix {
inherit fetchzip;
mirror1 = "https://sparse.tamu.edu/MM";
mirror2 = "https://www.cise.ufl.edu/research/sparse/MM";
};

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/rocSPARSE/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 rocsparse "$repoVersion" --ignore-same-hash --version-key=repoVersion
update-source-version rocsparse "$rocmVersion" --ignore-same-hash --version-key=rocmVersion
'';
};

meta = with lib; {
description = "ROCm SPARSE implementation";
Expand Down

0 comments on commit 29358a5

Please sign in to comment.