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 rocsparse,
10 rocprim,
11 rocrand,
12 clr,
13 pkg-config,
14 openmp,
15 openmpi,
16 gtest,
17 buildTests ? false,
18 buildBenchmarks ? false,
19 buildSamples ? false,
20 gpuTargets ? clr.localGpuTargets or [ ], # gpuTargets = [ "gfx803" "gfx900:xnack-" "gfx906:xnack-" ... ]
21}:
22
23stdenv.mkDerivation (finalAttrs: {
24 pname = "rocalution";
25 version = "7.1.1";
26
27 outputs = [
28 "out"
29 ]
30 ++ lib.optionals buildTests [
31 "test"
32 ]
33 ++ lib.optionals buildBenchmarks [
34 "benchmark"
35 ]
36 ++ lib.optionals buildSamples [
37 "sample"
38 ];
39
40 src = fetchFromGitHub {
41 owner = "ROCm";
42 repo = "rocALUTION";
43 rev = "rocm-${finalAttrs.version}";
44 hash = "sha256-UkXbcbhaTulCqW1FZHwTyUZLFSnj7WmLYqlPqu5m6YM=";
45 };
46
47 nativeBuildInputs = [
48 cmake
49 rocm-cmake
50 clr
51 pkg-config
52 ];
53
54 buildInputs = [
55 rocblas
56 rocsparse
57 rocprim
58 rocrand
59 openmp
60 openmpi
61 ]
62 ++ lib.optionals buildTests [
63 gtest
64 ];
65
66 cmakeFlags = [
67 "-DROCM_PATH=${clr}"
68 "-DHIP_ROOT_DIR=${clr}"
69 "-DSUPPORT_HIP=ON"
70 "-DSUPPORT_OMP=ON"
71 "-DSUPPORT_MPI=ON"
72 "-DBUILD_CLIENTS_SAMPLES=${if buildSamples then "ON" else "OFF"}"
73 # Manually define CMAKE_INSTALL_<DIR>
74 # See: https://github.com/NixOS/nixpkgs/pull/197838
75 "-DCMAKE_INSTALL_BINDIR=bin"
76 "-DCMAKE_INSTALL_LIBDIR=lib"
77 "-DCMAKE_INSTALL_INCLUDEDIR=include"
78 ]
79 ++ lib.optionals (gpuTargets != [ ]) [
80 "-DAMDGPU_TARGETS=${lib.strings.concatStringsSep ";" gpuTargets}"
81 "-DGPU_TARGETS=${lib.strings.concatStringsSep ";" gpuTargets}"
82 ]
83 ++ lib.optionals buildTests [
84 "-DBUILD_CLIENTS_TESTS=ON"
85 ]
86 ++ lib.optionals buildBenchmarks [
87 "-DBUILD_CLIENTS_BENCHMARKS=ON"
88 ];
89
90 postInstall =
91 lib.optionalString buildTests ''
92 mkdir -p $test/bin
93 mv $out/bin/rocalution-test $test/bin
94 ''
95 + lib.optionalString buildBenchmarks ''
96 mkdir -p $benchmark/bin
97 mv $out/bin/rocalution-bench $benchmark/bin
98 ''
99 + lib.optionalString buildSamples ''
100 mkdir -p $sample/bin
101 mv clients/staging/* $sample/bin
102 rm $sample/bin/rocalution-test || true
103 rm $sample/bin/rocalution-bench || true
104
105 patchelf --set-rpath \
106 $out/lib:${lib.makeLibraryPath (finalAttrs.buildInputs ++ [ clr ])} \
107 $sample/bin/*
108 ''
109 + lib.optionalString (buildTests || buildBenchmarks) ''
110 rmdir $out/bin
111 '';
112
113 passthru.updateScript = rocmUpdateScript {
114 name = finalAttrs.pname;
115 inherit (finalAttrs.src) owner;
116 inherit (finalAttrs.src) repo;
117 };
118
119 meta = {
120 description = "Iterative sparse solvers for ROCm";
121 homepage = "https://github.com/ROCm/rocALUTION";
122 license = with lib.licenses; [ mit ];
123 teams = [ lib.teams.rocm ];
124 platforms = lib.platforms.linux;
125 };
126})