at master 142 lines 3.5 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 rocmUpdateScript, 6 symlinkJoin, 7 cmake, 8 clang, 9 clr, 10 rocm-core, 11 rocm-runtime, 12 rocm-device-libs, 13 roctracer, 14 rocdbgapi, 15 numactl, 16 libpciaccess, 17 libxml2, 18 elfutils, 19 mpi, 20 systemd, 21 gtest, 22 git, 23 python3Packages, 24 gpuTargets ? clr.gpuTargets, 25}: 26 27let 28 rocmtoolkit-merged = symlinkJoin { 29 name = "rocmtoolkit-merged"; 30 31 paths = [ 32 rocm-core 33 rocm-runtime 34 rocm-device-libs 35 roctracer 36 rocdbgapi 37 clr 38 ]; 39 40 postBuild = '' 41 rm -rf $out/nix-support 42 ''; 43 }; 44in 45stdenv.mkDerivation (finalAttrs: { 46 pname = "rocprofiler"; 47 version = "6.3.3"; 48 49 src = fetchFromGitHub { 50 owner = "ROCm"; 51 repo = "rocprofiler"; 52 rev = "rocm-${finalAttrs.version}"; 53 hash = "sha256-x6DVt1logBE8aNnuwukQhsv/vRqkJALcfAF+6yEQuIk="; 54 fetchSubmodules = true; 55 }; 56 57 patches = [ 58 # These just simply won't build 59 ./0000-dont-install-tests-hsaco.patch 60 ./optional-aql-in-cmake.patch 61 ]; 62 63 nativeBuildInputs = [ 64 cmake 65 clang 66 clr 67 git 68 python3Packages.lxml 69 python3Packages.cppheaderparser 70 python3Packages.pyyaml 71 python3Packages.barectf 72 python3Packages.pandas 73 ]; 74 75 buildInputs = [ 76 numactl 77 libpciaccess 78 libxml2 79 elfutils 80 mpi 81 systemd 82 gtest 83 ]; 84 85 propagatedBuildInputs = [ rocmtoolkit-merged ]; 86 87 # HACK: allow building without aqlprofile, probably explodes at runtime if use profiling 88 env.LDFLAGS = "-z nodefs -Wl,-undefined,dynamic_lookup,--unresolved-symbols=ignore-all"; 89 #HACK: rocprofiler's cmake doesn't add these deps properly 90 env.CXXFLAGS = "-I${libpciaccess}/include -I${numactl.dev}/include -I${rocmtoolkit-merged}/include -I${elfutils.dev}/include -w"; 91 92 cmakeFlags = [ 93 "-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip" 94 "-DHIP_ROOT_DIR=${clr}" 95 "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" 96 # Manually define CMAKE_INSTALL_<DIR> 97 # See: https://github.com/NixOS/nixpkgs/pull/197838 98 "-DBUILD_TEST=OFF" 99 "-DROCPROFILER_BUILD_TESTS=0" 100 "-DROCPROFILER_BUILD_SAMPLES=0" 101 "-DCMAKE_INSTALL_BINDIR=bin" 102 "-DCMAKE_INSTALL_LIBDIR=lib" 103 "-DCMAKE_INSTALL_INCLUDEDIR=include" 104 ]; 105 106 postPatch = '' 107 patchShebangs . 108 109 substituteInPlace cmake_modules/rocprofiler_utils.cmake \ 110 --replace-fail 'function(ROCPROFILER_CHECKOUT_GIT_SUBMODULE)' 'function(ROCPROFILER_CHECKOUT_GIT_SUBMODULE) 111 return()' 112 113 substituteInPlace CMakeLists.txt \ 114 --replace-fail 'set(ROCPROFILER_BUILD_TESTS ON)' "" 115 116 substituteInPlace tests-v2/featuretests/profiler/CMakeLists.txt \ 117 --replace "--build-id=sha1" "--build-id=sha1 --rocm-path=${clr} --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode" 118 119 substituteInPlace test/CMakeLists.txt \ 120 --replace "\''${ROCM_ROOT_DIR}/amdgcn/bitcode" "${rocm-device-libs}/amdgcn/bitcode" 121 ''; 122 123 postInstall = '' 124 # Why do these have the executable bit set? 125 chmod -x $out/libexec/rocprofiler/counters/*.xml 126 ''; 127 128 passthru.updateScript = rocmUpdateScript { 129 name = finalAttrs.pname; 130 inherit (finalAttrs.src) owner; 131 inherit (finalAttrs.src) repo; 132 }; 133 passthru.rocmtoolkit-merged = rocmtoolkit-merged; 134 135 meta = with lib; { 136 description = "Profiling with perf-counters and derived metrics"; 137 homepage = "https://github.com/ROCm/rocprofiler"; 138 license = with licenses; [ mit ]; # mitx11 139 teams = [ teams.rocm ]; 140 platforms = platforms.linux; 141 }; 142})