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