Merge pull request #262798 from Madouura/pr/rocprofiler

rocmPackages.rocprofiler: fix rocprof and rocprofv2

authored by Peder Bergebakken Sundt and committed by GitHub b428e000 b6457765

+181 -27
+1 -1
pkgs/development/rocm-modules/5/default.nix
··· 105 105 106 106 # Needs GCC 107 107 rocprofiler = callPackage ./rocprofiler { 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 - 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 + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt 2 + index 8473a42..07ea873 100644 3 + --- a/test/CMakeLists.txt 4 + +++ b/test/CMakeLists.txt 5 + @@ -112,10 +112,6 @@ function(generate_hsaco TARGET_ID INPUT_FILE OUTPUT_FILE) 6 + DEPENDS ${INPUT_FILE} clang 7 + COMMENT "Building ${OUTPUT_FILE}..." 8 + VERBATIM) 9 + - install( 10 + - FILES ${PROJECT_BINARY_DIR}/${OUTPUT_FILE} 11 + - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests-v1 12 + - COMPONENT tests) 13 + set(HSACO_TARGET_LIST 14 + ${HSACO_TARGET_LIST} ${PROJECT_BINARY_DIR}/${OUTPUT_FILE} 15 + PARENT_SCOPE)
+111
pkgs/development/rocm-modules/5/rocprofiler/0001-fix-shell-scripts.patch
··· 1 + diff --git a/bin/rocprofv2 b/bin/rocprofv2 2 + index 92f7489..8839d4d 100755 3 + --- a/bin/rocprofv2 4 + +++ b/bin/rocprofv2 5 + @@ -2,7 +2,8 @@ 6 + set -eo pipefail 7 + CURRENT_DIR="$(dirname -- "$0")" 8 + ROCPROFV2_DIR=$(dirname -- $(realpath ${BASH_SOURCE[0]})) 9 + -ROCM_DIR=$(dirname -- "$ROCPROFV2_DIR") 10 + +ROCPROFILER_DIR=$(dirname -- "$ROCPROFV2_DIR") 11 + +ROCM_DIR=@rocmtoolkit_merged@ 12 + PLUGIN_LIST=("ctf" "perfetto" "file" "att") 13 + RUN_FROM_BUILD=0 14 + if [[ $ROCPROFV2_DIR == *"/build"* ]]; then 15 + @@ -10,7 +11,7 @@ if [[ $ROCPROFV2_DIR == *"/build"* ]]; then 16 + ROCM_DIR=$ROCPROFV2_DIR 17 + fi 18 + 19 + -export ROCPROFILER_METRICS_PATH=$ROCM_DIR/libexec/rocprofiler/counters/derived_counters.xml 20 + +export ROCPROFILER_METRICS_PATH=$ROCPROFILER_DIR/libexec/rocprofiler/counters/derived_counters.xml 21 + export LD_LIBRARY_PATH=$ROCM_DIR/lib:$LD_LIBRARY_PATH 22 + 23 + usage() { 24 + @@ -70,8 +71,8 @@ while [ 1 ]; do 25 + exit 1 26 + fi 27 + elif [[ "$1" = "--list-counters" ]]; then 28 + - export LD_PRELOAD=$LD_PRELOAD:$ROCM_DIR/lib/rocprofiler/librocprofiler_tool.so 29 + - eval $ROCM_DIR/libexec/rocprofiler/ctrl 30 + + export LD_PRELOAD=$LD_PRELOAD:$ROCPROFILER_DIR/lib/rocprofiler/librocprofiler_tool.so 31 + + eval $ROCPROFILER_DIR/libexec/rocprofiler/ctrl 32 + exit 1 33 + elif [[ "$1" = "-i" || "$1" = "--input" ]]; then 34 + if [ $2 ] && [ -n $2 ] && [ -r $2 ]; then 35 + @@ -171,7 +172,7 @@ while [ 1 ]; do 36 + if [ $RUN_FROM_BUILD == 1 ]; then 37 + ATT_PATH=$ROCM_DIR/plugin/att/att/att.py 38 + else 39 + - ATT_PATH=$ROCM_DIR/libexec/rocprofiler/att/att.py 40 + + ATT_PATH=$ROCPROFILER_DIR/libexec/rocprofiler/att/att.py 41 + export ROCPROFV2_ATT_LIB_PATH=$ROCM_DIR/lib/hsa-amd-aqlprofile/librocprofv2_att.so 42 + fi 43 + ATT_ARGV=$3 44 + @@ -236,13 +237,13 @@ if [ -n "$PMC_LINES" ] && [ ! -n "$ATT_ARGV" ]; then 45 + export OUTPUT_PATH=$FINAL_PATH 46 + fi 47 + let COUNTER=COUNTER+1 48 + - LD_PRELOAD=$LD_PRELOAD:$ROCM_DIR/lib/rocprofiler/librocprofiler_tool.so $* 49 + + LD_PRELOAD=$LD_PRELOAD:$ROCPROFILER_DIR/lib/rocprofiler/librocprofiler_tool.so $* 50 + if [ -n "$OUTPUT_PATH" ]; then 51 + echo -e "\nThe output path for the following counters: $OUTPUT_PATH" 52 + fi 53 + done 54 + else 55 + - LD_PRELOAD=$LD_PRELOAD:$ROCM_DIR/lib/rocprofiler/librocprofiler_tool.so $* 56 + + LD_PRELOAD=$LD_PRELOAD:$ROCPROFILER_DIR/lib/rocprofiler/librocprofiler_tool.so $* 57 + fi 58 + 59 + get_pmc_results_txt_path() { 60 + diff --git a/bin/rpl_run.sh b/bin/rpl_run.sh 61 + index c1a3daa..bc868a5 100755 62 + --- a/bin/rpl_run.sh 63 + +++ b/bin/rpl_run.sh 64 + @@ -24,16 +24,17 @@ 65 + 66 + time_stamp=`date +%y%m%d_%H%M%S` 67 + BIN_DIR=$(dirname $(realpath ${BASH_SOURCE[0]})) 68 + -ROOT_DIR=$(dirname $BIN_DIR) 69 + +ROCPROFILER_DIR=$(dirname $BIN_DIR) 70 + +ROOT_DIR=@rocmtoolkit_merged@ 71 + RUN_DIR=`pwd` 72 + TMP_DIR="/tmp" 73 + DATA_DIR="rpl_data_${time_stamp}_$$" 74 + 75 + -RPL_PATH=$ROOT_DIR/lib 76 + +RPL_PATH=$ROCPROFILER_DIR/lib 77 + TLIB_PATH=$RPL_PATH/rocprofiler 78 + TTLIB_PATH=$ROOT_DIR/lib/roctracer 79 + ROCM_LIB_PATH=$ROOT_DIR/lib 80 + -PROF_BIN_DIR=$ROOT_DIR/libexec/rocprofiler 81 + +PROF_BIN_DIR=$ROCPROFILER_DIR/libexec/rocprofiler 82 + 83 + if [ -z "$ROCP_PYTHON_VERSION" ] ; then 84 + ROCP_PYTHON_VERSION=python3 85 + @@ -73,7 +74,7 @@ export ROCP_METRICS=$TLIB_PATH/metrics.xml 86 + # Disable AQL-profile read API 87 + export AQLPROFILE_READ_API=0 88 + # ROC Profiler package path 89 + -export ROCP_PACKAGE_DIR=$ROOT_DIR 90 + +export ROCP_PACKAGE_DIR=$ROCPROFILER_DIR 91 + # enabled SPM KFD mode 92 + export ROCP_SPM_KFD_MODE=1 93 + 94 + @@ -350,7 +351,7 @@ convert_time_val() { 95 + 96 + ################################################################################################ 97 + # main 98 + -echo "RPL: on '$time_stamp' from '$ROOT_DIR' in '$RUN_DIR'" 99 + +echo "RPL: on '$time_stamp' from '$ROCPROFILER_DIR' in '$RUN_DIR'" 100 + # Parsing arguments 101 + if [ -z "$1" ] ; then 102 + usage 103 + @@ -557,7 +558,7 @@ elif [ "$input_type" = "txt" -o "$input_type" = "none" ] ; then 104 + else 105 + echo "<metric></metric>" > $RES_DIR/input.xml 106 + fi 107 + - input_list=`/bin/ls $RES_DIR/input*.xml` 108 + + input_list=`ls $RES_DIR/input*.xml` 109 + export ROCPROFILER_SESS=$RES_DIR 110 + else 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 + , symlinkJoin 6 + , substituteAll 5 7 , cmake 6 8 , clang 7 9 , clr 10 + , rocm-core 8 11 , rocm-thunk 12 + , rocm-device-libs 9 13 , roctracer 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 + , systemd 17 23 , gtest 18 24 , python3Packages 19 - , gpuTargets ? [ 20 - "gfx900" 21 - "gfx906" 22 - "gfx908" 23 - "gfx90a" 24 - "gfx940" 25 - "gfx941" 26 - "gfx942" 27 - "gfx1030" 28 - "gfx1100" 29 - "gfx1101" 30 - "gfx1102" 31 - ] 25 + , gpuTargets ? clr.gpuTargets 32 26 }: 33 27 34 - stdenv.mkDerivation (finalAttrs: { 28 + let 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 + }; 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 + 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 + 45 69 nativeBuildInputs = [ 46 70 cmake 47 71 clang ··· 53 77 ]; 54 78 55 79 buildInputs = [ 56 - rocm-thunk 57 - rocm-smi 58 - hsa-amd-aqlprofile-bin 59 80 numactl 60 81 libpciaccess 61 82 libxml2 62 83 elfutils 63 84 mpi 85 + systemd 64 86 gtest 65 87 ]; 66 88 89 + propagatedBuildInputs = [ rocmtoolkit-merged ]; 90 + 67 91 cmakeFlags = [ 68 92 "-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip" 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 - # Cannot find ROCm device library, pointless 83 - substituteInPlace CMakeLists.txt \ 84 - --replace "add_subdirectory(tests-v2)" "" \ 85 - --replace "add_subdirectory(samples)" "" 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" 86 110 ''; 87 111 88 - postBuild = '' 89 - # HSACO aren't being built for some reason 90 - substituteInPlace test/cmake_install.cmake \ 91 - --replace "file(INSTALL DESTINATION \"\''${CMAKE_INSTALL_PREFIX}/share/rocprofiler/tests-v1\" TYPE FILE FILES \"" "message(\"" 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 92 120 ''; 93 121 94 122 passthru.updateScript = rocmUpdateScript {