lol
1{ lib
2, stdenv
3, fetchFromGitHub
4, cmake
5, rocm-cmake
6, rocm-runtime
7, rocm-device-libs
8, rocm-comgr
9, rocprim
10, hip
11, gtest ? null
12, buildTests ? false
13, buildBenchmarks ? false
14}:
15
16assert buildTests -> gtest != null;
17
18# Doesn't seem to work, thousands of errors compiling with no clear fix
19# Is this an upstream issue? We don't seem to be missing dependencies
20assert buildTests == false;
21assert buildBenchmarks == false;
22
23stdenv.mkDerivation rec {
24 pname = "rocthrust";
25 rocmVersion = "5.3.1";
26 version = "2.16.0-${rocmVersion}";
27
28 # Comment out these outputs until tests/benchmarks are fixed (upstream?)
29 # outputs = [
30 # "out"
31 # ] ++ lib.optionals buildTests [
32 # "test"
33 # ] ++ lib.optionals buildBenchmarks [
34 # "benchmark"
35 # ];
36
37 src = fetchFromGitHub {
38 owner = "ROCmSoftwarePlatform";
39 repo = "rocThrust";
40 rev = "rocm-${rocmVersion}";
41 hash = "sha256-cT0VyEVz86xR6qubAY2ncTxtCRTwXrNTWcFyf3mV+y0=";
42 };
43
44 nativeBuildInputs = [
45 cmake
46 rocm-cmake
47 rocprim
48 hip
49 ];
50
51 buildInputs = [
52 rocm-runtime
53 rocm-device-libs
54 rocm-comgr
55 ] ++ lib.optionals buildTests [
56 gtest
57 ];
58
59 cmakeFlags = [
60 "-DCMAKE_CXX_COMPILER=hipcc"
61 "-DHIP_ROOT_DIR=${hip}"
62 # Manually define CMAKE_INSTALL_<DIR>
63 # See: https://github.com/NixOS/nixpkgs/pull/197838
64 "-DCMAKE_INSTALL_BINDIR=bin"
65 "-DCMAKE_INSTALL_LIBDIR=lib"
66 "-DCMAKE_INSTALL_INCLUDEDIR=include"
67 ] ++ lib.optionals buildTests [
68 "-DBUILD_TEST=ON"
69 ] ++ lib.optionals buildBenchmarks [
70 "-DBUILD_BENCHMARKS=ON"
71 ];
72
73 # Comment out these outputs until tests/benchmarks are fixed (upstream?)
74 # postInstall = lib.optionalString buildTests ''
75 # mkdir -p $test/bin
76 # mv $out/bin/test_* $test/bin
77 # '' + lib.optionalString buildBenchmarks ''
78 # mkdir -p $benchmark/bin
79 # mv $out/bin/benchmark_* $benchmark/bin
80 # '' + lib.optionalString (buildTests || buildBenchmarks) ''
81 # rmdir $out/bin
82 # '';
83
84 meta = with lib; {
85 description = "ROCm parallel algorithm library";
86 homepage = "https://github.com/ROCmSoftwarePlatform/rocThrust";
87 license = with licenses; [ asl20 ];
88 maintainers = with maintainers; [ Madouura ];
89 broken = rocmVersion != hip.version;
90 };
91}