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