nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 rocmUpdateScript,
6 cmake,
7 rocm-cmake,
8 rocblas,
9 rocprim,
10 rocsparse,
11 clr,
12 fmt,
13 gtest,
14 gfortran,
15 lapack-reference,
16 buildTests ? false,
17 buildBenchmarks ? false,
18 gpuTargets ? (
19 clr.localGpuTargets or [
20 "gfx900"
21 "gfx906"
22 "gfx908"
23 "gfx90a"
24 "gfx942"
25 "gfx1010"
26 "gfx1030"
27 "gfx1100"
28 "gfx1101"
29 "gfx1102"
30 "gfx1150"
31 "gfx1151"
32 "gfx1200"
33 "gfx1201"
34 ]
35 ),
36}:
37
38stdenv.mkDerivation (finalAttrs: {
39 pname = "rocsolver${clr.gpuArchSuffix}";
40 version = "7.1.0";
41
42 outputs = [
43 "out"
44 ]
45 ++ lib.optionals buildTests [
46 "test"
47 ]
48 ++ lib.optionals buildBenchmarks [
49 "benchmark"
50 ];
51
52 src = fetchFromGitHub {
53 owner = "ROCm";
54 repo = "rocSOLVER";
55 rev = "rocm-${finalAttrs.version}";
56 hash = "sha256-U5RrV90UZiIUgLYleLJ6rFHWRFMQNyh3zezRusj7T0M=";
57 };
58
59 nativeBuildInputs = [
60 cmake
61 # no ninja, it buffers console output and nix times out long periods of no output
62 rocm-cmake
63 clr
64 ]
65 ++ lib.optionals (buildTests || buildBenchmarks) [
66 gfortran
67 ];
68
69 buildInputs = [
70 # FIXME: rocblas and rocsolver can't build in parallel
71 # but rocsolver doesn't need rocblas' offload builds at build time
72 # could we build against a rocblas-minimal?
73 rocblas
74 rocprim
75 rocsparse
76 fmt
77 ]
78 ++ lib.optionals buildTests [
79 gtest
80 ]
81 ++ lib.optionals (buildTests || buildBenchmarks) [
82 lapack-reference
83 ];
84
85 cmakeFlags = [
86 "-DHIP_CLANG_NUM_PARALLEL_JOBS=4"
87 "-DCMAKE_BUILD_TYPE=Release"
88 "-DCMAKE_VERBOSE_MAKEFILE=ON"
89 # Manually define CMAKE_INSTALL_<DIR>
90 # See: https://github.com/NixOS/nixpkgs/pull/197838
91 "-DCMAKE_INSTALL_BINDIR=bin"
92 "-DCMAKE_INSTALL_LIBDIR=lib"
93 "-DCMAKE_INSTALL_INCLUDEDIR=include"
94 ]
95 ++ lib.optionals (gpuTargets != [ ]) [
96 "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
97 ]
98 ++ lib.optionals buildTests [
99 "-DBUILD_CLIENTS_TESTS=ON"
100 ]
101 ++ lib.optionals buildBenchmarks [
102 "-DBUILD_CLIENTS_BENCHMARKS=ON"
103 ];
104
105 postInstall =
106 lib.optionalString buildTests ''
107 mkdir -p $test/bin
108 mv $out/bin/rocsolver-test $test/bin
109 ''
110 + lib.optionalString buildBenchmarks ''
111 mkdir -p $benchmark/bin
112 mv $out/bin/rocsolver-bench $benchmark/bin
113 ''
114 + lib.optionalString (buildTests || buildBenchmarks) ''
115 rmdir $out/bin
116 '';
117
118 passthru.updateScript = rocmUpdateScript {
119 name = "rocsolver";
120 inherit (finalAttrs.src) owner repo;
121 };
122
123 requiredSystemFeatures = [ "big-parallel" ];
124
125 meta = {
126 description = "ROCm LAPACK implementation";
127 homepage = "https://github.com/ROCm/rocSOLVER";
128 license = with lib.licenses; [ bsd2 ];
129 teams = [ lib.teams.rocm ];
130 platforms = lib.platforms.linux;
131 timeout = 14400; # 4 hours
132 maxSilent = 14400; # 4 hours
133 };
134})