lol
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 rocmUpdateScript,
6 cmake,
7 rocm-cmake,
8 clr,
9 gtest,
10 gbenchmark,
11 buildTests ? false,
12 buildBenchmarks ? false,
13 gpuTargets ? [ ],
14}:
15
16stdenv.mkDerivation (finalAttrs: {
17 pname = "rocprim";
18 version = "6.3.3";
19
20 outputs =
21 [
22 "out"
23 ]
24 ++ lib.optionals buildTests [
25 "test"
26 ]
27 ++ lib.optionals buildBenchmarks [
28 "benchmark"
29 ];
30
31 src = fetchFromGitHub {
32 owner = "ROCm";
33 repo = "rocPRIM";
34 rev = "rocm-${finalAttrs.version}";
35 hash = "sha256-0aHxpBuYIYhI2UER45YhHHL5YcxA+XeXoihcUs2AmCo=";
36 };
37
38 nativeBuildInputs = [
39 cmake
40 rocm-cmake
41 clr
42 ];
43
44 buildInputs =
45 lib.optionals buildTests [
46 gtest
47 ]
48 ++ lib.optionals buildBenchmarks [
49 gbenchmark
50 ];
51
52 cmakeFlags =
53 [
54 "-DCMAKE_BUILD_TYPE=Release"
55 # Manually define CMAKE_INSTALL_<DIR>
56 # See: https://github.com/NixOS/nixpkgs/pull/197838
57 "-DCMAKE_INSTALL_BINDIR=bin"
58 "-DCMAKE_INSTALL_LIBDIR=lib"
59 "-DCMAKE_INSTALL_INCLUDEDIR=include"
60 ]
61 ++ lib.optionals (gpuTargets != [ ]) [
62 "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
63 ]
64 ++ lib.optionals buildTests [
65 "-DBUILD_TEST=ON"
66 ]
67 ++ lib.optionals buildBenchmarks [
68 "-DBUILD_BENCHMARK=ON"
69 ];
70
71 postInstall =
72 lib.optionalString buildTests ''
73 mkdir -p $test/bin
74 mv $out/bin/test_* $test/bin
75 mv $out/bin/rocprim $test/bin
76 ''
77 + lib.optionalString buildBenchmarks ''
78 mkdir -p $benchmark/bin
79 mv $out/bin/benchmark_* $benchmark/bin
80 ''
81 + lib.optionalString (buildTests || buildBenchmarks) ''
82 rmdir $out/bin
83 '';
84
85 passthru.updateScript = rocmUpdateScript {
86 name = finalAttrs.pname;
87 inherit (finalAttrs.src) owner;
88 inherit (finalAttrs.src) repo;
89 };
90
91 meta = with lib; {
92 description = "ROCm parallel primitives";
93 homepage = "https://github.com/ROCm/rocPRIM";
94 license = with licenses; [ mit ];
95 teams = [ teams.rocm ];
96 platforms = platforms.linux;
97 };
98})