16 , buildBenchmarks ? false # Seems to depend on tests
20 stdenv.mkDerivation (finalAttrs: {
26 ] ++ lib.optionals (buildTests || buildBenchmarks) [
28 ] ++ lib.optionals buildBenchmarks [
32 src = fetchFromGitHub {
35 rev = "rocm-${finalAttrs.version}";
36 hash = "sha256-30q9bqgZJUaNrkMXTAG+Z34yjsQ5DpJP+WBcCiEmF58=";
49 ] ++ lib.optionals (buildTests || buildBenchmarks) [
52 python3Packages.python
53 python3Packages.pyyaml
57 "-DCMAKE_CXX_COMPILER=hipcc"
58 # Manually define CMAKE_INSTALL_<DIR>
59 # See: https://github.com/NixOS/nixpkgs/pull/197838
60 "-DCMAKE_INSTALL_BINDIR=bin"
61 "-DCMAKE_INSTALL_LIBDIR=lib"
62 "-DCMAKE_INSTALL_INCLUDEDIR=include"
63 ] ++ lib.optionals (gpuTargets != [ ]) [
64 "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
65 ] ++ lib.optionals (buildTests || buildBenchmarks) [
66 "-DBUILD_CLIENTS_TESTS=ON"
67 "-DCMAKE_MATRICES_DIR=/build/source/matrices"
69 ] ++ lib.optionals buildBenchmarks [
70 "-DBUILD_CLIENTS_BENCHMARKS=ON"
73 # We have to manually generate the matrices
74 postPatch = lib.optionalString (buildTests || buildBenchmarks) ''
77 ln -s ${finalAttrs.passthru.matrices.matrix-01}/*.mtx matrices
78 ln -s ${finalAttrs.passthru.matrices.matrix-02}/*.mtx matrices
79 ln -s ${finalAttrs.passthru.matrices.matrix-03}/*.mtx matrices
80 ln -s ${finalAttrs.passthru.matrices.matrix-04}/*.mtx matrices
81 ln -s ${finalAttrs.passthru.matrices.matrix-05}/*.mtx matrices
82 ln -s ${finalAttrs.passthru.matrices.matrix-06}/*.mtx matrices
83 ln -s ${finalAttrs.passthru.matrices.matrix-07}/*.mtx matrices
84 ln -s ${finalAttrs.passthru.matrices.matrix-08}/*.mtx matrices
85 ln -s ${finalAttrs.passthru.matrices.matrix-09}/*.mtx matrices
86 ln -s ${finalAttrs.passthru.matrices.matrix-10}/*.mtx matrices
87 ln -s ${finalAttrs.passthru.matrices.matrix-11}/*.mtx matrices
88 ln -s ${finalAttrs.passthru.matrices.matrix-12}/*.mtx matrices
89 ln -s ${finalAttrs.passthru.matrices.matrix-13}/*.mtx matrices
90 ln -s ${finalAttrs.passthru.matrices.matrix-14}/*.mtx matrices
91 ln -s ${finalAttrs.passthru.matrices.matrix-15}/*.mtx matrices
92 ln -s ${finalAttrs.passthru.matrices.matrix-16}/*.mtx matrices
93 ln -s ${finalAttrs.passthru.matrices.matrix-17}/*.mtx matrices
94 ln -s ${finalAttrs.passthru.matrices.matrix-18}/*.mtx matrices
95 ln -s ${finalAttrs.passthru.matrices.matrix-19}/*.mtx matrices
96 ln -s ${finalAttrs.passthru.matrices.matrix-20}/*.mtx matrices
97 ln -s ${finalAttrs.passthru.matrices.matrix-21}/*.mtx matrices
98 ln -s ${finalAttrs.passthru.matrices.matrix-22}/*.mtx matrices
99 ln -s ${finalAttrs.passthru.matrices.matrix-23}/*.mtx matrices
100 ln -s ${finalAttrs.passthru.matrices.matrix-24}/*.mtx matrices
102 # Not used by the original cmake, causes an error
105 echo "deps/convert.cpp -> deps/mtx2csr"
106 hipcc deps/convert.cpp -O3 -o deps/mtx2csr
108 for mat in $(ls -1 matrices | cut -d "." -f 1); do
109 echo "mtx2csr: $mat.mtx -> $mat.csr"
110 deps/mtx2csr matrices/$mat.mtx matrices/$mat.csr
111 unlink matrices/$mat.mtx
115 postInstall = lib.optionalString buildBenchmarks ''
116 mkdir -p $benchmark/bin
117 cp -a $out/bin/* $benchmark/bin
118 rm $benchmark/bin/rocsparse-test
119 '' + lib.optionalString (buildTests || buildBenchmarks) ''
121 mv $out/bin/* $test/bin
122 rm $test/bin/rocsparse-bench || true
123 mv /build/source/matrices $test
128 matrices = import ./deps.nix {
130 mirror1 = "https://sparse.tamu.edu/MM";
131 mirror2 = "https://www.cise.ufl.edu/research/sparse/MM";
134 updateScript = rocmUpdateScript {
135 name = finalAttrs.pname;
136 owner = finalAttrs.src.owner;
137 repo = finalAttrs.src.repo;
142 description = "ROCm SPARSE implementation";
143 homepage = "https://github.com/ROCm/rocSPARSE";
144 license = with licenses; [ mit ];
145 maintainers = teams.rocm.members;
146 platforms = platforms.linux;
147 broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version || versionAtLeast finalAttrs.version "6.0.0";