nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 = "6.0.2";
50
51 src = fetchFromGitHub {
52 owner = "ROCm";
53 repo = "rocprofiler";
54 rev = "rocm-${finalAttrs.version}";
55 hash = "sha256-yzgw9g5cHAZpdbU44+1ScZyUcZ2I4GGfjbm9GSqCClk=";
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 # Fix for missing uint32_t not defined
69 ./0002-include-stdint-in-version.patch
70 ];
71
72 nativeBuildInputs = [
73 cmake
74 clang
75 clr
76 python3Packages.lxml
77 python3Packages.cppheaderparser
78 python3Packages.pyyaml
79 python3Packages.barectf
80 python3Packages.pandas
81 ];
82
83 buildInputs = [
84 numactl
85 libpciaccess
86 libxml2
87 elfutils
88 mpi
89 systemd
90 gtest
91 ];
92
93 propagatedBuildInputs = [ rocmtoolkit-merged ];
94
95 cmakeFlags = [
96 "-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip"
97 "-DHIP_ROOT_DIR=${clr}"
98 "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
99 # Manually define CMAKE_INSTALL_<DIR>
100 # See: https://github.com/NixOS/nixpkgs/pull/197838
101 "-DCMAKE_INSTALL_BINDIR=bin"
102 "-DCMAKE_INSTALL_LIBDIR=lib"
103 "-DCMAKE_INSTALL_INCLUDEDIR=include"
104 ];
105
106 postPatch = ''
107 patchShebangs .
108
109 substituteInPlace tests-v2/featuretests/profiler/CMakeLists.txt \
110 --replace "--build-id=sha1" "--build-id=sha1 --rocm-path=${clr} --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode"
111
112 substituteInPlace test/CMakeLists.txt \
113 --replace "\''${ROCM_ROOT_DIR}/amdgcn/bitcode" "${rocm-device-libs}/amdgcn/bitcode"
114 '';
115
116 postInstall = ''
117 # Why do these not already have the executable bit set?
118 chmod +x $out/lib/rocprofiler/librocprof-tool.so
119 chmod +x $out/share/rocprofiler/tests-v1/test/ocl/SimpleConvolution
120
121 # Why do these have the executable bit set?
122 chmod -x $out/libexec/rocprofiler/counters/basic_counters.xml
123 chmod -x $out/libexec/rocprofiler/counters/derived_counters.xml
124 '';
125
126 passthru.updateScript = rocmUpdateScript {
127 name = finalAttrs.pname;
128 owner = finalAttrs.src.owner;
129 repo = finalAttrs.src.repo;
130 };
131
132 meta = with lib; {
133 description = "Profiling with perf-counters and derived metrics";
134 homepage = "https://github.com/ROCm/rocprofiler";
135 license = with licenses; [ mit ]; # mitx11
136 maintainers = teams.rocm.members;
137 platforms = platforms.linux;
138 broken = versions.minor finalAttrs.version != versions.minor clr.version || versionAtLeast finalAttrs.version "7.0.0";
139 };
140})