lol
1{ lib
2, stdenv
3, fetchFromGitHub
4, rocmUpdateScript
5, symlinkJoin
6, substituteAll
7, cmake
8, clang
9, clr
10, rocm-core
11, rocm-thunk
12, rocm-device-libs
13, roctracer
14, rocdbgapi
15, rocm-smi
16, hsa-amd-aqlprofile-bin
17, numactl
18, libpciaccess
19, libxml2
20, elfutils
21, mpi
22, systemd
23, gtest
24, python3Packages
25, gpuTargets ? clr.gpuTargets
26}:
27
28let
29 rocmtoolkit-merged = symlinkJoin {
30 name = "rocmtoolkit-merged";
31
32 paths = [
33 rocm-core
34 rocm-thunk
35 rocm-device-libs
36 roctracer
37 rocdbgapi
38 rocm-smi
39 hsa-amd-aqlprofile-bin
40 clr
41 ];
42
43 postBuild = ''
44 rm -rf $out/nix-support
45 '';
46 };
47in stdenv.mkDerivation (finalAttrs: {
48 pname = "rocprofiler";
49 version = "5.7.1";
50
51 src = fetchFromGitHub {
52 owner = "ROCm";
53 repo = "rocprofiler";
54 rev = "rocm-${finalAttrs.version}";
55 hash = "sha256-1s/7C9y+73ADLF/17Vepw0pZNVtYnKoP24GdwKc9X2Y=";
56 };
57
58 patches = [
59 # These just simply won't build
60 ./0000-dont-install-tests-hsaco.patch
61
62 # Fix bad paths
63 (substituteAll {
64 src = ./0001-fix-shell-scripts.patch;
65 rocmtoolkit_merged = rocmtoolkit-merged;
66 })
67 ];
68
69 nativeBuildInputs = [
70 cmake
71 clang
72 clr
73 python3Packages.lxml
74 python3Packages.cppheaderparser
75 python3Packages.pyyaml
76 python3Packages.barectf
77 ];
78
79 buildInputs = [
80 numactl
81 libpciaccess
82 libxml2
83 elfutils
84 mpi
85 systemd
86 gtest
87 ];
88
89 propagatedBuildInputs = [ rocmtoolkit-merged ];
90
91 cmakeFlags = [
92 "-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip"
93 "-DHIP_ROOT_DIR=${clr}"
94 "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
95 # Manually define CMAKE_INSTALL_<DIR>
96 # See: https://github.com/NixOS/nixpkgs/pull/197838
97 "-DCMAKE_INSTALL_BINDIR=bin"
98 "-DCMAKE_INSTALL_LIBDIR=lib"
99 "-DCMAKE_INSTALL_INCLUDEDIR=include"
100 ];
101
102 postPatch = ''
103 patchShebangs .
104
105 substituteInPlace tests-v2/featuretests/profiler/CMakeLists.txt \
106 --replace "--build-id=sha1" "--build-id=sha1 --rocm-path=${clr} --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode"
107
108 substituteInPlace test/CMakeLists.txt \
109 --replace "\''${ROCM_ROOT_DIR}/amdgcn/bitcode" "${rocm-device-libs}/amdgcn/bitcode"
110 '';
111
112 postInstall = ''
113 # Why do these not already have the executable bit set?
114 chmod +x $out/lib/rocprofiler/librocprof-tool.so
115 chmod +x $out/share/rocprofiler/tests-v1/test/ocl/SimpleConvolution
116
117 # Why do these have the executable bit set?
118 chmod -x $out/libexec/rocprofiler/counters/basic_counters.xml
119 chmod -x $out/libexec/rocprofiler/counters/derived_counters.xml
120 '';
121
122 passthru.updateScript = rocmUpdateScript {
123 name = finalAttrs.pname;
124 owner = finalAttrs.src.owner;
125 repo = finalAttrs.src.repo;
126 };
127
128 meta = with lib; {
129 description = "Profiling with perf-counters and derived metrics";
130 homepage = "https://github.com/ROCm/rocprofiler";
131 license = with licenses; [ mit ]; # mitx11
132 maintainers = teams.rocm.members;
133 platforms = platforms.linux;
134 broken = versions.minor finalAttrs.version != versions.minor clr.version || versionAtLeast finalAttrs.version "6.0.0";
135 };
136})