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