Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, stdenv
3, fetchFromGitHub
4, rocmUpdateScript
5, cmake
6, rocm-cmake
7, hip
8, gfortran
9, rocblas
10, rocsolver
11, gtest
12, lapack-reference
13, buildTests ? false
14, buildBenchmarks ? false
15, buildSamples ? false
16}:
17
18# Can also use cuSOLVER
19stdenv.mkDerivation (finalAttrs: {
20 pname = "hipsolver";
21 version = "5.4.4";
22
23 outputs = [
24 "out"
25 ] ++ lib.optionals buildTests [
26 "test"
27 ] ++ lib.optionals buildBenchmarks [
28 "benchmark"
29 ] ++ lib.optionals buildSamples [
30 "sample"
31 ];
32
33 src = fetchFromGitHub {
34 owner = "ROCmSoftwarePlatform";
35 repo = "hipSOLVER";
36 rev = "rocm-${finalAttrs.version}";
37 hash = "sha256-p9hgKqRALLItv/HTpVlTsu+m9wlwCBYPYnJcm8StIao=";
38 };
39
40 nativeBuildInputs = [
41 cmake
42 rocm-cmake
43 hip
44 gfortran
45 ];
46
47 buildInputs = [
48 rocblas
49 rocsolver
50 ] ++ lib.optionals buildTests [
51 gtest
52 ] ++ lib.optionals (buildTests || buildBenchmarks) [
53 lapack-reference
54 ];
55
56 cmakeFlags = [
57 "-DCMAKE_C_COMPILER=hipcc"
58 "-DCMAKE_CXX_COMPILER=hipcc"
59 # Manually define CMAKE_INSTALL_<DIR>
60 # See: https://github.com/NixOS/nixpkgs/pull/197838
61 "-DCMAKE_INSTALL_BINDIR=bin"
62 "-DCMAKE_INSTALL_LIBDIR=lib"
63 "-DCMAKE_INSTALL_INCLUDEDIR=include"
64 ] ++ lib.optionals buildTests [
65 "-DBUILD_CLIENTS_TESTS=ON"
66 ] ++ lib.optionals buildBenchmarks [
67 "-DBUILD_CLIENTS_BENCHMARKS=ON"
68 ] ++ lib.optionals buildSamples [
69 "-DBUILD_CLIENTS_SAMPLES=ON"
70 ];
71
72 postInstall = lib.optionalString buildTests ''
73 mkdir -p $test/bin
74 mv $out/bin/hipsolver-test $test/bin
75 '' + lib.optionalString buildBenchmarks ''
76 mkdir -p $benchmark/bin
77 mv $out/bin/hipsolver-bench $benchmark/bin
78 '' + lib.optionalString buildSamples ''
79 mkdir -p $sample/bin
80 mv clients/staging/example-* $sample/bin
81 patchelf $sample/bin/example-* --shrink-rpath --allowed-rpath-prefixes /nix/store
82 '' + lib.optionalString (buildTests || buildBenchmarks) ''
83 rmdir $out/bin
84 '';
85
86 passthru.updateScript = rocmUpdateScript {
87 name = finalAttrs.pname;
88 owner = finalAttrs.src.owner;
89 repo = finalAttrs.src.repo;
90 };
91
92 meta = with lib; {
93 description = "ROCm SOLVER marshalling library";
94 homepage = "https://github.com/ROCmSoftwarePlatform/hipSOLVER";
95 license = with licenses; [ mit ];
96 maintainers = teams.rocm.members;
97 platforms = platforms.linux;
98 broken = versions.minor finalAttrs.version != versions.minor hip.version;
99 };
100})