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