1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
{
lib,
stdenv,
fetchFromGitHub,
rocmUpdateScript,
symlinkJoin,
cmake,
clang,
clr,
aqlprofile,
rocm-core,
rocm-runtime,
rocm-device-libs,
roctracer,
rocdbgapi,
numactl,
libpciaccess,
libxml2,
llvm,
elfutils,
mpi,
gtest,
python3Packages,
gpuTargets ? clr.gpuTargets,
}:
let
rocmtoolkit-merged = symlinkJoin {
name = "rocmtoolkit-merged";
paths = [
rocm-core
rocm-runtime
rocm-device-libs
roctracer
rocdbgapi
clr
];
postBuild = ''
rm -rf $out/nix-support
'';
};
in
stdenv.mkDerivation (finalAttrs: {
pname = "rocprofiler";
version = "7.2.3";
src = fetchFromGitHub {
owner = "ROCm";
repo = "rocm-systems";
rev = "rocm-${finalAttrs.version}";
sparseCheckout = [
"projects/rocprofiler"
"shared"
];
fetchSubmodules = true;
hash = "sha256-Wo0pymD8LsrdczdIUEEVe5x2Id//KIFkh40kliAQgWo=";
};
sourceRoot = "${finalAttrs.src.name}/projects/rocprofiler";
nativeBuildInputs = [
cmake
clang
clr
python3Packages.lxml
python3Packages.cppheaderparser
python3Packages.pyyaml
python3Packages.barectf
python3Packages.pandas
];
buildInputs = [
llvm.clang-unwrapped
llvm.llvm
numactl
libpciaccess
libxml2
elfutils
mpi
gtest
aqlprofile
];
propagatedBuildInputs = [ rocmtoolkit-merged ];
#HACK: rocprofiler's cmake doesn't add these deps properly
env.CXXFLAGS = "-I${libpciaccess}/include -I${numactl.dev}/include -I${rocmtoolkit-merged}/include -I${elfutils.dev}/include -w";
cmakeFlags = [
"-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip"
"-DHIP_ROOT_DIR=${clr}"
"-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
# Manually define CMAKE_INSTALL_<DIR>
# See: https://github.com/NixOS/nixpkgs/pull/197838
"-DCMAKE_INSTALL_BINDIR=bin"
"-DCMAKE_INSTALL_LIBDIR=lib"
"-DCMAKE_INSTALL_INCLUDEDIR=include"
];
postPatch = ''
patchShebangs .
substituteInPlace cmake_modules/rocprofiler_utils.cmake \
--replace-fail 'function(ROCPROFILER_CHECKOUT_GIT_SUBMODULE)' 'function(ROCPROFILER_CHECKOUT_GIT_SUBMODULE)
return()'
substituteInPlace CMakeLists.txt \
--replace-fail 'set(ROCPROFILER_BUILD_TESTS ON)' ""
substituteInPlace tests-v2/featuretests/profiler/CMakeLists.txt \
--replace "--build-id=sha1" "--build-id=sha1 --rocm-path=${clr} --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode"
substituteInPlace test/CMakeLists.txt \
--replace "\''${ROCM_ROOT_DIR}/amdgcn/bitcode" "${rocm-device-libs}/amdgcn/bitcode"
'';
postInstall = ''
# Why do these have the executable bit set?
chmod -x $out/libexec/rocprofiler/counters/*.xml
# rocprof shell script wants to find it in the same bin dir, easiest to symlink in
ln -s ${clr}/bin/rocm_agent_enumerator $out/bin/rocm_agent_enumerator
'';
postFixup = ''
patchelf $out/lib/*.so \
--add-rpath ${aqlprofile}/lib \
--add-needed libhsa-amd-aqlprofile64.so
'';
passthru.updateScript = rocmUpdateScript { inherit finalAttrs; };
passthru.rocmtoolkit-merged = rocmtoolkit-merged;
meta = {
description = "Profiling with perf-counters and derived metrics";
homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/rocprofiler";
license = with lib.licenses; [ mit ]; # mitx11
teams = [ lib.teams.rocm ];
platforms = lib.platforms.linux;
};
})
|