tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
rocmPackages.rocprofiler: fix rocprof and rocprofv2
Madoura
2 years ago
977784c0
06e0ef4a
+181
-27
4 changed files
expand all
collapse all
unified
split
pkgs
development
rocm-modules
5
default.nix
rocprofiler
0000-dont-install-tests-hsaco.patch
0001-fix-shell-scripts.patch
default.nix
+1
-1
pkgs/development/rocm-modules/5/default.nix
···
105
105
106
106
# Needs GCC
107
107
rocprofiler = callPackage ./rocprofiler {
108
108
+
inherit rocmUpdateScript clr rocm-core rocm-thunk rocm-device-libs roctracer rocdbgapi rocm-smi hsa-amd-aqlprofile-bin;
108
109
inherit (llvm) clang;
109
109
-
inherit rocmUpdateScript clr rocm-thunk roctracer rocm-smi hsa-amd-aqlprofile-bin;
110
110
};
111
111
112
112
# Needs GCC
+15
pkgs/development/rocm-modules/5/rocprofiler/0000-dont-install-tests-hsaco.patch
···
1
1
+
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
2
2
+
index 8473a42..07ea873 100644
3
3
+
--- a/test/CMakeLists.txt
4
4
+
+++ b/test/CMakeLists.txt
5
5
+
@@ -112,10 +112,6 @@ function(generate_hsaco TARGET_ID INPUT_FILE OUTPUT_FILE)
6
6
+
DEPENDS ${INPUT_FILE} clang
7
7
+
COMMENT "Building ${OUTPUT_FILE}..."
8
8
+
VERBATIM)
9
9
+
- install(
10
10
+
- FILES ${PROJECT_BINARY_DIR}/${OUTPUT_FILE}
11
11
+
- DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests-v1
12
12
+
- COMPONENT tests)
13
13
+
set(HSACO_TARGET_LIST
14
14
+
${HSACO_TARGET_LIST} ${PROJECT_BINARY_DIR}/${OUTPUT_FILE}
15
15
+
PARENT_SCOPE)
+111
pkgs/development/rocm-modules/5/rocprofiler/0001-fix-shell-scripts.patch
···
1
1
+
diff --git a/bin/rocprofv2 b/bin/rocprofv2
2
2
+
index 92f7489..8839d4d 100755
3
3
+
--- a/bin/rocprofv2
4
4
+
+++ b/bin/rocprofv2
5
5
+
@@ -2,7 +2,8 @@
6
6
+
set -eo pipefail
7
7
+
CURRENT_DIR="$(dirname -- "$0")"
8
8
+
ROCPROFV2_DIR=$(dirname -- $(realpath ${BASH_SOURCE[0]}))
9
9
+
-ROCM_DIR=$(dirname -- "$ROCPROFV2_DIR")
10
10
+
+ROCPROFILER_DIR=$(dirname -- "$ROCPROFV2_DIR")
11
11
+
+ROCM_DIR=@rocmtoolkit_merged@
12
12
+
PLUGIN_LIST=("ctf" "perfetto" "file" "att")
13
13
+
RUN_FROM_BUILD=0
14
14
+
if [[ $ROCPROFV2_DIR == *"/build"* ]]; then
15
15
+
@@ -10,7 +11,7 @@ if [[ $ROCPROFV2_DIR == *"/build"* ]]; then
16
16
+
ROCM_DIR=$ROCPROFV2_DIR
17
17
+
fi
18
18
+
19
19
+
-export ROCPROFILER_METRICS_PATH=$ROCM_DIR/libexec/rocprofiler/counters/derived_counters.xml
20
20
+
+export ROCPROFILER_METRICS_PATH=$ROCPROFILER_DIR/libexec/rocprofiler/counters/derived_counters.xml
21
21
+
export LD_LIBRARY_PATH=$ROCM_DIR/lib:$LD_LIBRARY_PATH
22
22
+
23
23
+
usage() {
24
24
+
@@ -70,8 +71,8 @@ while [ 1 ]; do
25
25
+
exit 1
26
26
+
fi
27
27
+
elif [[ "$1" = "--list-counters" ]]; then
28
28
+
- export LD_PRELOAD=$LD_PRELOAD:$ROCM_DIR/lib/rocprofiler/librocprofiler_tool.so
29
29
+
- eval $ROCM_DIR/libexec/rocprofiler/ctrl
30
30
+
+ export LD_PRELOAD=$LD_PRELOAD:$ROCPROFILER_DIR/lib/rocprofiler/librocprofiler_tool.so
31
31
+
+ eval $ROCPROFILER_DIR/libexec/rocprofiler/ctrl
32
32
+
exit 1
33
33
+
elif [[ "$1" = "-i" || "$1" = "--input" ]]; then
34
34
+
if [ $2 ] && [ -n $2 ] && [ -r $2 ]; then
35
35
+
@@ -171,7 +172,7 @@ while [ 1 ]; do
36
36
+
if [ $RUN_FROM_BUILD == 1 ]; then
37
37
+
ATT_PATH=$ROCM_DIR/plugin/att/att/att.py
38
38
+
else
39
39
+
- ATT_PATH=$ROCM_DIR/libexec/rocprofiler/att/att.py
40
40
+
+ ATT_PATH=$ROCPROFILER_DIR/libexec/rocprofiler/att/att.py
41
41
+
export ROCPROFV2_ATT_LIB_PATH=$ROCM_DIR/lib/hsa-amd-aqlprofile/librocprofv2_att.so
42
42
+
fi
43
43
+
ATT_ARGV=$3
44
44
+
@@ -236,13 +237,13 @@ if [ -n "$PMC_LINES" ] && [ ! -n "$ATT_ARGV" ]; then
45
45
+
export OUTPUT_PATH=$FINAL_PATH
46
46
+
fi
47
47
+
let COUNTER=COUNTER+1
48
48
+
- LD_PRELOAD=$LD_PRELOAD:$ROCM_DIR/lib/rocprofiler/librocprofiler_tool.so $*
49
49
+
+ LD_PRELOAD=$LD_PRELOAD:$ROCPROFILER_DIR/lib/rocprofiler/librocprofiler_tool.so $*
50
50
+
if [ -n "$OUTPUT_PATH" ]; then
51
51
+
echo -e "\nThe output path for the following counters: $OUTPUT_PATH"
52
52
+
fi
53
53
+
done
54
54
+
else
55
55
+
- LD_PRELOAD=$LD_PRELOAD:$ROCM_DIR/lib/rocprofiler/librocprofiler_tool.so $*
56
56
+
+ LD_PRELOAD=$LD_PRELOAD:$ROCPROFILER_DIR/lib/rocprofiler/librocprofiler_tool.so $*
57
57
+
fi
58
58
+
59
59
+
get_pmc_results_txt_path() {
60
60
+
diff --git a/bin/rpl_run.sh b/bin/rpl_run.sh
61
61
+
index c1a3daa..bc868a5 100755
62
62
+
--- a/bin/rpl_run.sh
63
63
+
+++ b/bin/rpl_run.sh
64
64
+
@@ -24,16 +24,17 @@
65
65
+
66
66
+
time_stamp=`date +%y%m%d_%H%M%S`
67
67
+
BIN_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
68
68
+
-ROOT_DIR=$(dirname $BIN_DIR)
69
69
+
+ROCPROFILER_DIR=$(dirname $BIN_DIR)
70
70
+
+ROOT_DIR=@rocmtoolkit_merged@
71
71
+
RUN_DIR=`pwd`
72
72
+
TMP_DIR="/tmp"
73
73
+
DATA_DIR="rpl_data_${time_stamp}_$$"
74
74
+
75
75
+
-RPL_PATH=$ROOT_DIR/lib
76
76
+
+RPL_PATH=$ROCPROFILER_DIR/lib
77
77
+
TLIB_PATH=$RPL_PATH/rocprofiler
78
78
+
TTLIB_PATH=$ROOT_DIR/lib/roctracer
79
79
+
ROCM_LIB_PATH=$ROOT_DIR/lib
80
80
+
-PROF_BIN_DIR=$ROOT_DIR/libexec/rocprofiler
81
81
+
+PROF_BIN_DIR=$ROCPROFILER_DIR/libexec/rocprofiler
82
82
+
83
83
+
if [ -z "$ROCP_PYTHON_VERSION" ] ; then
84
84
+
ROCP_PYTHON_VERSION=python3
85
85
+
@@ -73,7 +74,7 @@ export ROCP_METRICS=$TLIB_PATH/metrics.xml
86
86
+
# Disable AQL-profile read API
87
87
+
export AQLPROFILE_READ_API=0
88
88
+
# ROC Profiler package path
89
89
+
-export ROCP_PACKAGE_DIR=$ROOT_DIR
90
90
+
+export ROCP_PACKAGE_DIR=$ROCPROFILER_DIR
91
91
+
# enabled SPM KFD mode
92
92
+
export ROCP_SPM_KFD_MODE=1
93
93
+
94
94
+
@@ -350,7 +351,7 @@ convert_time_val() {
95
95
+
96
96
+
################################################################################################
97
97
+
# main
98
98
+
-echo "RPL: on '$time_stamp' from '$ROOT_DIR' in '$RUN_DIR'"
99
99
+
+echo "RPL: on '$time_stamp' from '$ROCPROFILER_DIR' in '$RUN_DIR'"
100
100
+
# Parsing arguments
101
101
+
if [ -z "$1" ] ; then
102
102
+
usage
103
103
+
@@ -557,7 +558,7 @@ elif [ "$input_type" = "txt" -o "$input_type" = "none" ] ; then
104
104
+
else
105
105
+
echo "<metric></metric>" > $RES_DIR/input.xml
106
106
+
fi
107
107
+
- input_list=`/bin/ls $RES_DIR/input*.xml`
108
108
+
+ input_list=`ls $RES_DIR/input*.xml`
109
109
+
export ROCPROFILER_SESS=$RES_DIR
110
110
+
else
111
111
+
fatal "Bad input file type '$INPUT_FILE'"
+54
-26
pkgs/development/rocm-modules/5/rocprofiler/default.nix
···
2
2
, stdenv
3
3
, fetchFromGitHub
4
4
, rocmUpdateScript
5
5
+
, symlinkJoin
6
6
+
, substituteAll
5
7
, cmake
6
8
, clang
7
9
, clr
10
10
+
, rocm-core
8
11
, rocm-thunk
12
12
+
, rocm-device-libs
9
13
, roctracer
14
14
+
, rocdbgapi
10
15
, rocm-smi
11
16
, hsa-amd-aqlprofile-bin
12
17
, numactl
···
14
19
, libxml2
15
20
, elfutils
16
21
, mpi
22
22
+
, systemd
17
23
, gtest
18
24
, python3Packages
19
19
-
, gpuTargets ? [
20
20
-
"gfx900"
21
21
-
"gfx906"
22
22
-
"gfx908"
23
23
-
"gfx90a"
24
24
-
"gfx940"
25
25
-
"gfx941"
26
26
-
"gfx942"
27
27
-
"gfx1030"
28
28
-
"gfx1100"
29
29
-
"gfx1101"
30
30
-
"gfx1102"
31
31
-
]
25
25
+
, gpuTargets ? clr.gpuTargets
32
26
}:
33
27
34
34
-
stdenv.mkDerivation (finalAttrs: {
28
28
+
let
29
29
+
rocmtoolkit-merged = symlinkJoin {
30
30
+
name = "rocmtoolkit-merged";
31
31
+
32
32
+
paths = [
33
33
+
rocm-core
34
34
+
rocm-thunk
35
35
+
rocm-device-libs
36
36
+
roctracer
37
37
+
rocdbgapi
38
38
+
rocm-smi
39
39
+
hsa-amd-aqlprofile-bin
40
40
+
clr
41
41
+
];
42
42
+
43
43
+
postBuild = ''
44
44
+
rm -rf $out/nix-support
45
45
+
'';
46
46
+
};
47
47
+
in stdenv.mkDerivation (finalAttrs: {
35
48
pname = "rocprofiler";
36
49
version = "5.7.1";
37
50
···
42
55
hash = "sha256-1s/7C9y+73ADLF/17Vepw0pZNVtYnKoP24GdwKc9X2Y=";
43
56
};
44
57
58
58
+
patches = [
59
59
+
# These just simply won't build
60
60
+
./0000-dont-install-tests-hsaco.patch
61
61
+
62
62
+
# Fix bad paths
63
63
+
(substituteAll {
64
64
+
src = ./0001-fix-shell-scripts.patch;
65
65
+
rocmtoolkit_merged = rocmtoolkit-merged;
66
66
+
})
67
67
+
];
68
68
+
45
69
nativeBuildInputs = [
46
70
cmake
47
71
clang
···
53
77
];
54
78
55
79
buildInputs = [
56
56
-
rocm-thunk
57
57
-
rocm-smi
58
58
-
hsa-amd-aqlprofile-bin
59
80
numactl
60
81
libpciaccess
61
82
libxml2
62
83
elfutils
63
84
mpi
85
85
+
systemd
64
86
gtest
65
87
];
66
88
89
89
+
propagatedBuildInputs = [ rocmtoolkit-merged ];
90
90
+
67
91
cmakeFlags = [
68
92
"-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip"
69
69
-
"-DPROF_API_HEADER_PATH=${roctracer.src}/inc/ext"
70
93
"-DHIP_ROOT_DIR=${clr}"
71
94
"-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
72
95
# Manually define CMAKE_INSTALL_<DIR>
···
79
102
postPatch = ''
80
103
patchShebangs .
81
104
82
82
-
# Cannot find ROCm device library, pointless
83
83
-
substituteInPlace CMakeLists.txt \
84
84
-
--replace "add_subdirectory(tests-v2)" "" \
85
85
-
--replace "add_subdirectory(samples)" ""
105
105
+
substituteInPlace tests-v2/featuretests/profiler/CMakeLists.txt \
106
106
+
--replace "--build-id=sha1" "--build-id=sha1 --rocm-path=${clr} --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode"
107
107
+
108
108
+
substituteInPlace test/CMakeLists.txt \
109
109
+
--replace "\''${ROCM_ROOT_DIR}/amdgcn/bitcode" "${rocm-device-libs}/amdgcn/bitcode"
86
110
'';
87
111
88
88
-
postBuild = ''
89
89
-
# HSACO aren't being built for some reason
90
90
-
substituteInPlace test/cmake_install.cmake \
91
91
-
--replace "file(INSTALL DESTINATION \"\''${CMAKE_INSTALL_PREFIX}/share/rocprofiler/tests-v1\" TYPE FILE FILES \"" "message(\""
112
112
+
postInstall = ''
113
113
+
# Why do these not already have the executable bit set?
114
114
+
chmod +x $out/lib/rocprofiler/librocprof-tool.so
115
115
+
chmod +x $out/share/rocprofiler/tests-v1/test/ocl/SimpleConvolution
116
116
+
117
117
+
# Why do these have the executable bit set?
118
118
+
chmod -x $out/libexec/rocprofiler/counters/basic_counters.xml
119
119
+
chmod -x $out/libexec/rocprofiler/counters/derived_counters.xml
92
120
'';
93
121
94
122
passthru.updateScript = rocmUpdateScript {