1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 rocmUpdateScript,
6 cmake,
7 rocm-cmake,
8 rocprim,
9 clr,
10 gtest,
11 buildTests ? false,
12 buildBenchmarks ? false,
13 gpuTargets ? [ ],
14}:
15
16stdenv.mkDerivation (finalAttrs: {
17 pname = "rocthrust";
18 version = "6.3.3";
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 = "rocThrust";
33 rev = "rocm-${finalAttrs.version}";
34 hash = "sha256-c1+hqP/LipaQ2/lPJo79YBd9H0n0Y7yHkxe0/INE14s=";
35 };
36
37 nativeBuildInputs = [
38 cmake
39 rocm-cmake
40 rocprim
41 clr
42 ];
43
44 buildInputs = lib.optionals buildTests [
45 gtest
46 ];
47
48 cmakeFlags = [
49 "-DHIP_ROOT_DIR=${clr}"
50 # Manually define CMAKE_INSTALL_<DIR>
51 # See: https://github.com/NixOS/nixpkgs/pull/197838
52 "-DCMAKE_INSTALL_BINDIR=bin"
53 "-DCMAKE_INSTALL_LIBDIR=lib"
54 "-DCMAKE_INSTALL_INCLUDEDIR=include"
55 ]
56 ++ lib.optionals (gpuTargets != [ ]) [
57 "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
58 ]
59 ++ lib.optionals buildTests [
60 "-DBUILD_TEST=ON"
61 ]
62 ++ lib.optionals buildBenchmarks [
63 "-DBUILD_BENCHMARKS=ON"
64 ];
65
66 postInstall =
67 lib.optionalString buildTests ''
68 mkdir -p $test/bin
69 mv $out/bin/{test_*,*.hip} $test/bin
70 ''
71 + lib.optionalString buildBenchmarks ''
72 mkdir -p $benchmark/bin
73 mv $out/bin/benchmark_* $benchmark/bin
74 ''
75 + lib.optionalString (buildTests || buildBenchmarks) ''
76 rm -rf $out/bin
77 '';
78
79 passthru.updateScript = rocmUpdateScript {
80 name = finalAttrs.pname;
81 inherit (finalAttrs.src) owner;
82 inherit (finalAttrs.src) repo;
83 };
84
85 meta = with lib; {
86 description = "ROCm parallel algorithm library";
87 homepage = "https://github.com/ROCm/rocThrust";
88 license = with licenses; [ asl20 ];
89 teams = [ teams.rocm ];
90 platforms = platforms.linux;
91 };
92})