nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 rocmUpdateScript,
6 cmake,
7 rocm-cmake,
8 clr,
9 gfortran,
10 rocblas,
11 rocsolver,
12 rocsparse,
13 suitesparse,
14 gtest,
15 lapack-reference,
16 buildTests ? false,
17 buildBenchmarks ? false,
18 buildSamples ? false,
19}:
20
21# Can also use cuSOLVER
22stdenv.mkDerivation (finalAttrs: {
23 pname = "hipsolver";
24 version = "6.3.3";
25
26 outputs = [
27 "out"
28 ]
29 ++ lib.optionals buildTests [
30 "test"
31 ]
32 ++ lib.optionals buildBenchmarks [
33 "benchmark"
34 ]
35 ++ lib.optionals buildSamples [
36 "sample"
37 ];
38
39 src = fetchFromGitHub {
40 owner = "ROCm";
41 repo = "hipSOLVER";
42 rev = "rocm-${finalAttrs.version}";
43 hash = "sha256-ZQUKU3L4DgZ5zM7pCYEix0ulRkl78x/5wJnyCndTAwk=";
44 };
45
46 nativeBuildInputs = [
47 cmake
48 rocm-cmake
49 clr
50 gfortran
51 ];
52
53 buildInputs = [
54 rocblas
55 rocsolver
56 rocsparse
57 suitesparse
58 ]
59 ++ lib.optionals buildTests [
60 gtest
61 ]
62 ++ lib.optionals (buildTests || buildBenchmarks) [
63 lapack-reference
64 ];
65
66 cmakeFlags = [
67 "-DCMAKE_CXX_COMPILER=hipcc"
68 # Manually define CMAKE_INSTALL_<DIR>
69 # See: https://github.com/NixOS/nixpkgs/pull/197838
70 "-DCMAKE_INSTALL_BINDIR=bin"
71 "-DCMAKE_INSTALL_LIBDIR=lib"
72 "-DCMAKE_INSTALL_INCLUDEDIR=include"
73 "-DBUILD_WITH_SPARSE=OFF" # FIXME: broken - can't find suitesparse/cholmod, looks fixed in master
74 ]
75 ++ lib.optionals buildTests [
76 "-DBUILD_CLIENTS_TESTS=ON"
77 ]
78 ++ lib.optionals buildBenchmarks [
79 "-DBUILD_CLIENTS_BENCHMARKS=ON"
80 ]
81 ++ lib.optionals buildSamples [
82 "-DBUILD_CLIENTS_SAMPLES=ON"
83 ];
84
85 postInstall =
86 lib.optionalString buildTests ''
87 mkdir -p $test/bin
88 mv $out/bin/hipsolver-test $test/bin
89 ''
90 + lib.optionalString buildBenchmarks ''
91 mkdir -p $benchmark/bin
92 mv $out/bin/hipsolver-bench $benchmark/bin
93 ''
94 + lib.optionalString buildSamples ''
95 mkdir -p $sample/bin
96 mv clients/staging/example-* $sample/bin
97 patchelf $sample/bin/example-* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE"
98 ''
99 + lib.optionalString (buildTests || buildBenchmarks) ''
100 rmdir $out/bin
101 '';
102
103 passthru.updateScript = rocmUpdateScript {
104 name = finalAttrs.pname;
105 inherit (finalAttrs.src) owner;
106 inherit (finalAttrs.src) repo;
107 };
108
109 meta = with lib; {
110 description = "ROCm SOLVER marshalling library";
111 homepage = "https://github.com/ROCm/hipSOLVER";
112 license = with licenses; [ mit ];
113 teams = [ teams.rocm ];
114 platforms = platforms.linux;
115 };
116})