From fff815c7b10ae315bbc721dceb466eba73b21d6d Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Fri, 16 Oct 2026 19:45:42 -0700 Subject: [PATCH 01/79] rocmPackages.rocmUpdateScript: take maxMajor and tagPrefixes Prepare the update script for a rocmPackages_10 set built from the TheRock monorepos, whose sources are tagged therock-X.Y[.Z]: - maxMajor (default 7) replaces the hard-coded major cap, so a second set can call it with its own cap. - tagPrefixes (default [ "rocm" ]) selects which tag families count as releases. The current set keeps rocm- only, so the therock-7.x preview tags are not picked up. - setName (default "rocmPackages") is the attribute path passed to update-source-version. - Pick the highest matching version instead of the first release listed: releases are not ordered by version (a rocm-7.2.x maintenance release can be published after a newer series). - Follow GitHub's pagination (100 per page) so the highest version is found even when it is not on the first page, and fail on fetch errors instead of reporting "no valid version". No change to any derivation; passthru.updateScript only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/update.nix | 48 +++++++++++++++++------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/pkgs/development/rocm-modules/update.nix b/pkgs/development/rocm-modules/update.nix index 7ffc5f9a7e6cb..71b281e816fa0 100644 --- a/pkgs/development/rocm-modules/update.nix +++ b/pkgs/development/rocm-modules/update.nix @@ -1,6 +1,12 @@ { lib, writeScript, + # Newest major this set accepts; a newer major goes into a new rocmPackages_X. + maxMajor ? 7, + # Tag prefixes this set's versions are published under (rocm-X.Y.Z, therock-X.Y[.Z]). + tagPrefixes ? [ "rocm" ], + # Attribute path of the package set, for update-source-version. + setName ? "rocmPackages", }: { @@ -8,10 +14,17 @@ name ? finalAttrs.pname, owner ? finalAttrs.src.owner, repo ? finalAttrs.src.repo, - page ? "releases?per_page=10", - # input: array of [ { tag_name: "rocm-6.x.x", }, ... ]. some entries may have bad names like rocm-test-date we want to skip - # output: first tag_name/name that's a proper version if any - filter ? "map(.tag_name // .name) | map(select(test(\"^rocm-[0-9]+\\\\.[0-9]+(\\\\.[0-9]+)?$\"))) | first | ltrimstr(\"rocm-\")", + page ? "releases?per_page=100", + # input: array of [ { tag_name: "rocm-7.2.4", }, { tag_name: "therock-10.1" }, ... ]. some entries + # may have bad names like rocm-test-date we want to skip + # output: the highest proper version with an accepted prefix and major <= maxMajor, if any. + # Releases are not ordered by version (a rocm-7.2.x maintenance release can follow therock-10.1). + filter ? lib.concatStringsSep " | " [ + "map(.tag_name // .name)" + "map(select(test(\"^(${lib.concatStringsSep "|" tagPrefixes})-[0-9]+\\\\.[0-9]+(\\\\.[0-9]+)?$\")) | sub(\"^(${lib.concatStringsSep "|" tagPrefixes})-\"; \"\"))" + "map(select((split(\".\")[0] | tonumber) <= ${toString maxMajor}))" + "sort_by(split(\".\") | map(tonumber)) | last // empty" + ], }: let @@ -23,14 +36,21 @@ let #!nix-shell -i bash -p curl jq common-updater-scripts set -euo pipefail - fetch_releases() { + fetch_releases() ( local api_url="https://api.github.com/repos/${owner}/${repo}/${page}" - if [ "${page}" = "releases" ]; then - api_url="$api_url?per_page=4" + local headers + headers="$(mktemp)" + trap 'rm -f "$headers"' EXIT + local -a auth=() + if [[ -n "''${GITHUB_TOKEN:-}" ]]; then + auth=(-H "Authorization: Bearer $GITHUB_TOKEN") fi - >&2 echo $api_url - curl ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} -sL "$api_url" - } + while [[ -n "$api_url" ]]; do + curl "''${auth[@]}" -fsSL --dump-header "$headers" "$api_url" || return + printf '\n' + api_url="$(tr -d '\r' < "$headers" | sed -nE 's/^link:.*<([^>]+)>; rel="next".*/\1/ip')" + done + ) find_valid_version() { local releases="$1" @@ -40,7 +60,7 @@ let echo "$releases" | jq -r 'if type == "array" then . else [.] end | ${filter}' } - releases="$(fetch_releases)" + releases="$(fetch_releases | jq -s 'map(if type == "array" then . else [.] end) | add')" version="$(find_valid_version "$releases")" if [ -z "$version" ]; then @@ -52,12 +72,12 @@ let >&2 echo parsed version "$version_arr" from "$version" - if (( ''${version_arr[0]} > 7 )); then - echo "'rocmPackages.${pname}' is already at its maximum allowed version.''\nAny further upgrades should go into 'rocmPackages_X.${pname}'." >&2 + if (( ''${version_arr[0]} > ${toString maxMajor} )); then + echo "'${setName}.${pname}' is already at its maximum allowed version.''\nAny further upgrades should go into 'rocmPackages_X.${pname}'." >&2 exit 1 fi - update-source-version rocmPackages.${pname} "$version" --ignore-same-hash + update-source-version ${setName}.${pname} "$version" --ignore-same-hash ''; in [ updateScript ] From f636197cb36c98c59e5bea8e1ffd69245ebb0296 Mon Sep 17 00:00:00 2001 From: aaravrav <37036762+aaravrav@users.noreply.github.com> Date: Fri, 16 Oct 2026 23:20:55 +0530 Subject: [PATCH 02/79] llvmPackages_23.openmp: fix build for LLVM 23+ (cherry picked from commit ab348e2dc2527cb2f052d28b248427eb49689d66) --- .../compilers/llvm/common/openmp/default.nix | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/pkgs/development/compilers/llvm/common/openmp/default.nix b/pkgs/development/compilers/llvm/common/openmp/default.nix index 2601e294fccfe..d6792fa1a94b5 100644 --- a/pkgs/development/compilers/llvm/common/openmp/default.nix +++ b/pkgs/development/compilers/llvm/common/openmp/default.nix @@ -36,15 +36,28 @@ stdenv.mkDerivation (finalAttrs: { strictDeps = true; __structuredAttrs = true; } - '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/openmp "$out" - '' + ( + '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/openmp "$out" + '' + + lib.optionalString (lib.versionAtLeast release_version "23") '' + mkdir -p "$out/llvm" + cp -r ${monorepoSrc}/llvm/cmake "$out/llvm" + cp -r ${monorepoSrc}/llvm/utils "$out/llvm" + cp -r ${monorepoSrc}/third-party "$out" + cp -r ${monorepoSrc}/runtimes "$out" + '' + ) else src; - sourceRoot = "${finalAttrs.src.name}/openmp"; + # LLVM 23 removed OpenMP's standalone build + # https://openmp.llvm.org/Building.html + sourceRoot = + "${finalAttrs.src.name}/" + + (if lib.versionAtLeast release_version "23" then "runtimes" else "openmp"); outputs = [ "out" @@ -89,6 +102,9 @@ stdenv.mkDerivation (finalAttrs: { (lib.cmakeFeature "OPT_TOOL" "${llvm}/bin/opt") (lib.cmakeFeature "LINK_TOOL" "${llvm}/bin/llvm-link") ] + ++ lib.optionals (lib.versionAtLeast release_version "23") [ + (lib.cmakeFeature "LLVM_ENABLE_RUNTIMES" "openmp") + ] ++ devExtraCmakeFlags; doCheck = false; @@ -96,7 +112,9 @@ stdenv.mkDerivation (finalAttrs: { checkTarget = "check-openmp"; preCheck = '' - patchShebangs ../tools/archer/tests/deflake.bash + patchShebangs ${ + if lib.versionAtLeast release_version "23" then "../../openmp" else ".." + }/tools/archer/tests/deflake.bash ''; __structuredAttrs = true; From c6ad124cbca76ee73dfc1c81373e2602c247a49d Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:35 -0700 Subject: [PATCH 03/79] rocmPackages_10: init Add an empty rocmPackages_10 scope next to rocmPackages, sharing its structure (rocm-modules/10/default.nix is derived from rocm-modules/default.nix). The following PRs add the ROCm 10.1 packages to it tier by tier; a final PR on staging switches rocmPackages over. Following the rocmPackages_5/_6 layout. It is deliberately not wrapped in recurseIntoAttrs, so Hydra and the CI rebuild count are unaffected until the switch. The update script runs with maxMajor = 10, the therock- tag prefix, and setName = "rocmPackages_10". Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 19 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 21 insertions(+) create mode 100644 pkgs/development/rocm-modules/10/default.nix diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix new file mode 100644 index 0000000000000..47b10a6e9e7f7 --- /dev/null +++ b/pkgs/development/rocm-modules/10/default.nix @@ -0,0 +1,19 @@ +{ + lib, + newScope, +}: + +let + outer = lib.makeScope newScope (self: { + + rocmUpdateScript = self.callPackage ../update.nix { + maxMajor = 10; + tagPrefixes = [ + "rocm" + "therock" + ]; + setName = "rocmPackages_10"; + }; + }); +in +outer diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e85402023569b..63d4d6a926e7d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1855,6 +1855,8 @@ with pkgs; dvtm-unstable = callPackage ../tools/misc/dvtm/unstable.nix { }; rocmPackages = recurseIntoAttrs (callPackage ../development/rocm-modules { }); + # Kept out of Hydra until the default ROCm scope switches. + rocmPackages_10 = callPackage ../development/rocm-modules/10 { }; tsm-client-withGui = callPackage ../by-name/ts/tsm-client/package.nix { enableGui = true; }; From 0fbffa86e22b11671fbd4aeaf42732e86839ee96 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:36 -0700 Subject: [PATCH 04/79] rocmPackages_10: copy llvm from rocmPackages Verbatim copies of the rocmPackages (ROCm 7.2.4) expressions for llvm, rocm-device-libs, not yet part of the rocmPackages_10 scope. The following commits update each one to ROCm 10.1, so their diffs read against 7.2.4. Assisted-by: Claude Code (claude-opus-5-5) --- .../clang-bodge-ignore-systemwide-incls.diff | 23 + .../rocm-modules/10/llvm/clang-log-jobs.diff | 40 ++ .../rocm-modules/10/llvm/default.nix | 614 ++++++++++++++++++ .../opt-offload-compress-on-by-default.patch | 22 + .../llvm/perf-increase-namestring-size.patch | 28 + .../perf-shorten-gcclib-include-paths.patch | 59 ++ .../10/rocm-device-libs/cmake.patch | 43 ++ .../10/rocm-device-libs/default.nix | 67 ++ 8 files changed, 896 insertions(+) create mode 100644 pkgs/development/rocm-modules/10/llvm/clang-bodge-ignore-systemwide-incls.diff create mode 100644 pkgs/development/rocm-modules/10/llvm/clang-log-jobs.diff create mode 100644 pkgs/development/rocm-modules/10/llvm/default.nix create mode 100644 pkgs/development/rocm-modules/10/llvm/opt-offload-compress-on-by-default.patch create mode 100644 pkgs/development/rocm-modules/10/llvm/perf-increase-namestring-size.patch create mode 100644 pkgs/development/rocm-modules/10/llvm/perf-shorten-gcclib-include-paths.patch create mode 100644 pkgs/development/rocm-modules/10/rocm-device-libs/cmake.patch create mode 100644 pkgs/development/rocm-modules/10/rocm-device-libs/default.nix diff --git a/pkgs/development/rocm-modules/10/llvm/clang-bodge-ignore-systemwide-incls.diff b/pkgs/development/rocm-modules/10/llvm/clang-bodge-ignore-systemwide-incls.diff new file mode 100644 index 0000000000000..5f44dbe15655c --- /dev/null +++ b/pkgs/development/rocm-modules/10/llvm/clang-bodge-ignore-systemwide-incls.diff @@ -0,0 +1,23 @@ +diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp +index 57368104c914..71c57f72078e 100644 +--- a/lib/Driver/ToolChains/Linux.cpp ++++ b/lib/Driver/ToolChains/Linux.cpp +@@ -640,6 +640,7 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs, + return; + + // LOCAL_INCLUDE_DIR ++ if (!SysRoot.empty()) + addSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/usr/local/include")); + // TOOL_INCLUDE_DIR + AddMultilibIncludeArgs(DriverArgs, CC1Args); +@@ -672,8 +673,10 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs, + // Add an include of '/include' directly. This isn't provided by default by + // system GCCs, but is often used with cross-compiling GCCs, and harmless to + // add even when Clang is acting as-if it were a system compiler. ++ if (!SysRoot.empty()) + addExternCSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/include")); + ++ if (!SysRoot.empty()) + addExternCSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/usr/include")); + + if (!DriverArgs.hasArg(options::OPT_nobuiltininc) && getTriple().isMusl()) diff --git a/pkgs/development/rocm-modules/10/llvm/clang-log-jobs.diff b/pkgs/development/rocm-modules/10/llvm/clang-log-jobs.diff new file mode 100644 index 0000000000000..3a3a712c8bbaf --- /dev/null +++ b/pkgs/development/rocm-modules/10/llvm/clang-log-jobs.diff @@ -0,0 +1,40 @@ +diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp +index 06f5e7e7e335..8407d664886a 100644 +--- a/lib/Driver/Compilation.cpp ++++ b/lib/Driver/Compilation.cpp +@@ -340,6 +340,9 @@ private: + void Compilation::ExecuteJobs(const JobList &Jobs, + FailingCommandList &FailingCommands, + bool LogOnly) const { ++ // If >1 job, log as each job finishes so can see progress while building many offloads ++ const bool logJobs = Jobs.size() > 1; ++ auto start_time = std::chrono::steady_clock::now(); + // According to UNIX standard, driver need to continue compiling all the + // inputs on the command line even one of them failed. + // In all but CLMode, execute all the jobs unless the necessary inputs for the +@@ -364,11 +367,25 @@ void Compilation::ExecuteJobs(const JobList &Jobs, + + JS.setJobState(Next, JobScheduler::JS_RUN); + auto Work = [&, Next]() { ++ auto job_start_time = std::chrono::steady_clock::now(); + const Command *FailingCommand = nullptr; + if (int Res = ExecuteCommand(*Next, FailingCommand, LogOnly)) { + FailingCommands.push_back(std::make_pair(Res, FailingCommand)); + JS.setJobState(Next, JobScheduler::JS_FAIL); + } else { ++ if (logJobs && Next) { ++ auto now = std::chrono::steady_clock::now(); ++ auto job_duration = std::chrono::duration_cast(now - job_start_time).count(); ++ auto duration = std::chrono::duration_cast(now - start_time).count(); ++ if (duration > 10 && job_duration > 0) { ++ if (Next->getOutputFilenames().empty()) ++ if (Next->getExecutable()) llvm::errs() << "Job completed: " << Next->getExecutable() << "\n"; ++ else (llvm::errs() << "Job completed: "), Next->Print(llvm::errs(), "\n", true); ++ else ++ llvm::errs() << "Job completed: " << Next->getOutputFilenames().front().c_str() << "\n"; ++ } ++ } ++ + JS.setJobState(Next, JobScheduler::JS_DONE); + } + }; diff --git a/pkgs/development/rocm-modules/10/llvm/default.nix b/pkgs/development/rocm-modules/10/llvm/default.nix new file mode 100644 index 0000000000000..4fbb9fb0d1c92 --- /dev/null +++ b/pkgs/development/rocm-modules/10/llvm/default.nix @@ -0,0 +1,614 @@ +{ + lib, + stdenv, + # LLVM version closest to ROCm fork to override + llvmPackages_22, + overrideCC, + lndir, + rocm-device-libs, + fetchFromGitHub, + runCommand, + symlinkJoin, + rdfind, + zstd, + gcc-unwrapped, + glibc, + libffi, + libxml2, + removeReferencesTo, + fetchpatch, + # Build compilers and stdenv suitable for profiling + # leaving compressed line tables (-g1 -gz) unstripped + # TODO: Should also apply to downstream packages which use rocmClangStdenv? + profilableStdenv ? false, + # FIXME: proper two-stage bootstrap & PGO/BOLT/LTO + # LTO currently disabled due to llvm 22 vs 22.1 bitcode mismatch between + # llvmPackages_22 (22.1) and ROCm LLVM (22.0). Uses new bitcode attr + # 105 nocreateundeforpoison fails to link hipify. + # Whether to use LTO when building the ROCm toolchain + # Slows down this toolchain's build, for typical ROCm usecase + # time saved building composable_kernel and other heavy packages + # will outweight that. ~3-4% speedup multiplied by thousands + # of corehours. + withLto ? false, + # whether rocm stdenv uses libcxx (clang c++ stdlib) instead of gcc stdlibc++ + withLibcxx ? false, +}: + +let + version = "7.2.4"; + # major version of this should be the clang version ROCm forked from + rocmLlvmVersion = "22.0.0-rocm"; + # llvmPackages_base version should match rocmLlvmVersion + # so libllvm's bitcode is compatible with the built toolchain + llvmPackages_base = llvmPackages_22; + llvmPackagesNoBintools = llvmPackages_base.override { + bootBintools = null; + bootBintoolsNoLibc = null; + }; + + stdenvToBuildRocmLlvm = + if withLibcxx then + overrideCC llvmPackagesNoBintools.libcxxStdenv llvmPackagesNoBintools.clangUseLLVM + else + # oddly fuse-ld=lld fails without this override + overrideCC llvmPackagesNoBintools.stdenv ( + llvmPackagesNoBintools.libstdcxxClang.override { + inherit (llvmPackages_base) bintools; + } + ); + + gcc-include = runCommand "gcc-include" { } '' + mkdir -p $out + ln -s ${gcc-unwrapped}/include/ $out/ + ln -s ${gcc-unwrapped}/lib/ $out/ + ''; + + disallowedRefsForToolchain = [ + stdenv.cc + stdenv.cc.cc + stdenv.cc.bintools + gcc-unwrapped + stdenvToBuildRocmLlvm + stdenvToBuildRocmLlvm.cc + stdenvToBuildRocmLlvm.cc.cc + ]; + # A prefix for use as the GCC prefix when building rocm-toolchain + gcc-prefix-headers = symlinkJoin { + name = "gcc-prefix-headers"; + paths = [ + glibc.dev + gcc-unwrapped.out + ]; + disallowedRequisites = [ + glibc.dev + gcc-unwrapped.out + ]; + postBuild = '' + rm -rf $out/{bin,libexec,nix-support,lib64,share,etc} + rm $out/lib/gcc/x86_64-unknown-linux-gnu/*/plugin/include/auto-host.h + + mkdir /build/tmpout + mv $out/* /build/tmpout + cp -Lr --no-preserve=mode /build/tmpout/* $out/ + set -x + versionedIncludePath="$(echo $out/include/c++/*/)" + mv $versionedIncludePath/* $out/include/c++/ + rm -rf $versionedIncludePath/ + ''; + }; + gcc-prefix = symlinkJoin { + name = "gcc-prefix"; + paths = [ + gcc-prefix-headers + glibc + gcc-unwrapped.lib + ]; + disallowedRequisites = [ + glibc.dev + gcc-unwrapped.out + ]; + postBuild = '' + rm -rf $out/{bin,libexec,nix-support,lib64,share,etc} + rm $out/lib/ld-linux-x86-64.so.2 + ln -s $out $out/x86_64-unknown-linux-gnu + ''; + }; + llvmSrc = fetchFromGitHub { + owner = "ROCm"; + repo = "llvm-project"; + tag = "rocm-${version}"; + hash = "sha256-TwFvQimbax2E37ZC/52lNkHXCgyBNfSGDBaqmas2x/s="; + }; + llvmMajorVersion = lib.versions.major rocmLlvmVersion; + # An llvmPackages (pkgs/development/compilers/llvm/) built from ROCm LLVM's source tree + llvmPackagesRocm = llvmPackages_base.override (_old: { + stdenv = stdenvToBuildRocmLlvm; + + # not setting gitRelease = because that causes patch selection logic to use git patches + # ROCm LLVM is closer to 20 official + # gitRelease = {}; officialRelease = null; + officialRelease = { }; # Set but empty because we're overriding everything from it. + # this version determines which patches are applied + version = rocmLlvmVersion; + src = llvmSrc; + monorepoSrc = llvmSrc; + doCheck = false; + }); + refsToRemove = builtins.concatStringsSep " -t " [ + stdenvToBuildRocmLlvm + stdenvToBuildRocmLlvm.cc + stdenvToBuildRocmLlvm.cc.cc + stdenv.cc + stdenv.cc.cc + stdenv.cc.bintools + ]; + # Hacky way to avoid nixfmt indenting the entire scope body suggested by @emilazy + overrideLlvmPackagesRocm = + f: + let + overridenScope = llvmPackagesRocm.overrideScope (final: prev: f { inherit final prev; }); + in + { + inherit (overridenScope) + # Expose only a limited set of packages that we care about for ROCm + bintools + compiler-rt + compiler-rt-libc + clang + clang-unwrapped + libcxx + lld + llvm + rocm-toolchain + rocmClangStdenv + openmp + ; + }; + sysrootCompiler = + { + cc, + name, + paths, + linkPaths, + }: + let + linked = symlinkJoin { inherit name paths; }; + in + runCommand name + { + pname = name; + # If this is erroring, try why-depends --precise on the symlinkJoin of inputs to look for the problem + # nix why-depends --precise .#rocmPackages.llvm.rocm-toolchain.linked /store/path/its/not/allowed + outputChecks.out.disallowedRequisites = disallowedRefsForToolchain; + passthru.linked = linked; + inherit linkPaths; + __structuredAttrs = true; + # TODO(@LunNova): Try to use --sysroot with clang in its original location instead of + # relying on copying the binary? + # $clang/bin/clang++ --sysroot=$rocm-toolchain is not equivalent + # to a clang copied to $rocm-toolchain/bin here, have not yet figured out why + } + '' + mkdir -p $out/ + cp --reflink=auto -rL ${linked}/* $out/ + chmod -R +rw $out + mkdir -p $out/usr + ln -s $out/ $out/usr/local + # we don't need mixed 32 bit, the presence of lib64 is used by LLVM to decide it's a multilib sysroot + rm -rf $out/lib64 + rm -rf $out/lib/cmake $out/lib/lib*.a + mkdir -p $out/lib/clang/${llvmMajorVersion}/lib/linux/ + ln -s $out/lib/linux/libclang_rt.* $out/lib/clang/${llvmMajorVersion}/lib/linux/ + mkdir -p $out/lib/clang/${llvmMajorVersion}/lib/${stdenv.hostPlatform.config}/ + for f in $out/lib/linux/*-${stdenv.hostPlatform.parsed.cpu.name}.*; do + [ -e "$f" ] || continue + base="$(basename "$f" | sed 's/-${stdenv.hostPlatform.parsed.cpu.name}\././')" + ln -sf "$f" "$out/lib/clang/${llvmMajorVersion}/lib/${stdenv.hostPlatform.config}/$base" + done + + find $out -type f -exec sed -i "s|${cc.out}|$out|g" {} + + find $out -type f -exec sed -i "s|${cc.dev}|$out|g" {} + + + # Clang config file: redirect resource dir to the sysroot (where compiler-rt + # lives) and set GCC install prefix for header/library search + cat > $out/bin/${stdenv.hostPlatform.config}.cfg <> $out/nix-support/setup-hook + echo 'export CXX=clang++' >> $out/nix-support/setup-hook + ''; + tablegenUsage = x: !(lib.strings.hasInfix "llvm-tblgen" x); + llvmTargetsFlag = "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${ + { + "x86_64" = "X86"; + "aarch64" = "AArch64"; + } + .${stdenv.targetPlatform.parsed.cpu.name} + or (throw "Unsupported CPU architecture: ${stdenv.targetPlatform.parsed.cpu.name}") + }"; + llvmMeta = { + # TODO(@LunNova): it would be nice to support aarch64 for rocmPackages + platforms = [ "x86_64-linux" ]; + }; + # TODO(@LunNova): Some of this might be worth supporting in llvmPackages, dropping from here + commonCmakeFlags = [ + llvmTargetsFlag + # Compression support is required for compressed offload kernels + # Set FORCE_ON so that failure to find the compression lib will be a build error + (lib.cmakeFeature "LLVM_ENABLE_ZSTD" "FORCE_ON") + # required for threaded ThinLTO to work + (lib.cmakeBool "LLVM_ENABLE_THREADS" true) + # third-party/benchmark is broken in rocm-7.2.0 + # error: '__COUNTER__' is a C2y extension [-Werror,-Wc2y-extensions] + (lib.cmakeBool "LLVM_INCLUDE_BENCHMARKS" false) + # LLVM tries to call git to embed VCS info if FORCE_VC_ aren't set + (lib.cmakeFeature "LLVM_FORCE_VC_REVISION" "rocm-${version}") + (lib.cmakeFeature "LLVM_FORCE_VC_REPOSITORY" "https://github.com/ROCm/llvm-project") + (lib.cmakeFeature "LLVM_VERSION_SUFFIX" "") + (lib.cmakeBool "LLVM_ENABLE_LIBCXX" withLibcxx) + (lib.cmakeFeature "CLANG_DEFAULT_CXX_STDLIB" (if withLibcxx then "libc++" else "libstdc++")) + (lib.cmakeFeature "CLANG_VENDOR" "nixpkgs-AMD") + (lib.cmakeFeature "CLANG_REPOSITORY_STRING" "https://github.com/ROCm/llvm-project/tree/rocm-${version}") + ] + ++ lib.optionals withLibcxx [ + (lib.cmakeFeature "CLANG_DEFAULT_RTLIB" "compiler-rt") + ] + ++ lib.optionals withLto [ + (lib.cmakeBool "CMAKE_INTERPROCEDURAL_OPTIMIZATION" true) + (lib.cmakeBool "LLVM_ENABLE_FATLTO" false) + ] + ++ lib.optionals (withLto && stdenvToBuildRocmLlvm.cc.isClang) [ + (lib.cmakeFeature "LLVM_ENABLE_LTO" "FULL") + (lib.cmakeFeature "LLVM_USE_LINKER" "lld") + ]; + + llvmExtraCflags = lib.concatStringsSep " " ( + lib.optionals (stdenv.hostPlatform.system == "x86_64-linux") [ + # Unprincipled decision to build x86_64 ROCm clang for at least skylake and tune for zen3+ + # In practice building the ROCm package set with anything earlier than zen3 is annoying + # and earlier than skylake is implausible due to too few cores and too little RAM + # Speeds up composable_kernel builds by ~4% + # If this causes trouble in practice we can drop this. Set since 2025-03-24. + "-march=skylake" + "-mtune=znver3" + ] + ++ lib.optionals profilableStdenv [ + # compressed line only debug info for profiling + "-gz" + "-g1" + ] + ); + inherit (llvmPackagesRocm) libcxx; +in +overrideLlvmPackagesRocm (s: { + libllvm = (s.prev.libllvm.override { }).overrideAttrs (old: { + patches = [ + # Backport select ptr combine fixes so our LLVM 22 sdag fix backport can apply + (fetchpatch { + name = "amdgpu-add-baseline-load-select-ptr-combine-test.patch"; + url = "https://github.com/llvm/llvm-project/commit/ac27b2455ad7c89cc1f928de7beb05933a035031.patch"; + relative = "llvm"; + hash = "sha256-1mine1h/oqnn2tKDYW4FntyZXu/foyifrKGkqKOHrPg="; + }) + (fetchpatch { + name = "amdgpu-fix-treating-divergent-loads-as-uniform.patch"; + url = "https://github.com/llvm/llvm-project/commit/d3c3c6bab5df051d9db12ea96add2211df9d81be.patch"; + relative = "llvm"; + hash = "sha256-9VB77d4d+nwX8s+JBq1PXmbmqT7oD6lRC0uDIrTgjjo="; + }) + (fetchpatch { + name = "dag-allow-select-ptr-combine-for-non-0-address-spaces.patch"; + url = "https://github.com/llvm/llvm-project/commit/0e1cb2de90aafa1d5dbd46fc9e6c4e743700fa8b.patch"; + relative = "llvm"; + hash = "sha256-6Pj3pRESaho60YhXWwaQxEKteSuziZseeT4FbZqZANk="; + }) + ] + # https://github.com/NixOS/nixpkgs/pull/564039 introduces minimal-arm64e_x1-support.patch that depends on llvm 22.1.0 + # Patches to clang, compiler-rt-libc, and these patches bridge the gap between llvm 22.0.0 and ~22.1.8 + # arm64e_x1: Can be removed when upgrading to rocm 10 + ++ [ + (fetchpatch { + name = "wasm-add-wasm32-linux-muslwali-target.patch"; + url = "https://github.com/llvm/llvm-project/commit/7e7c923b5890e62f4b5920c2f8a2e51f586a186c.patch"; + relative = "llvm"; + hash = "sha256-KbM7M4osxaaxkn5UN+csNm+aKvaWgJ0KQnKHHpI+Qxo="; + }) + (fetchpatch { + name = "adt-allow-arbitrary-number-of-cases-in-stringswitch.patch"; + url = "https://github.com/llvm/llvm-project/commit/8642762ac356f0b8432b78d7a32c1f5213e494b3.patch"; + relative = "llvm"; + hash = "sha256-aQBmMSJ+aunE7HLpfIizBH7Be1kmcN6nxUk2sV9d3Qo="; + }) + (fetchpatch { + name = "adt-migrate-stringswitch-cases-to-new-overload.patch"; + url = "https://github.com/llvm/llvm-project/commit/2ed7baafc3bf5b4321e3f77dfb1ce291e62bcadc.patch"; + relative = "llvm"; + hash = "sha256-cV9POhuJFCnjCdPL6Lym2cmKLeW/2k34N2rwauxU7MA="; + }) + (fetchpatch { + name = "lfi-introduce-aarch64-lfi-target.patch"; + url = "https://github.com/llvm/llvm-project/commit/2c05ae4b8f85927d55f862fdf61bea564e2ea944.patch"; + relative = "llvm"; + hash = "sha256-yxvmZg3BTlIrNeer90cYnF7yuRyraeVg1nbiaRVr+zc="; + }) + ] + ++ old.patches + ++ [ + ./perf-increase-namestring-size.patch + # v64i8 shuffle lowering inf loop on VBMI targets, hangs whisper-cpp etc + # https://github.com/NixOS/nixpkgs/issues/497745 + (fetchpatch { + # https://github.com/llvm/llvm-project/pull/182832 + name = "llvm-x86-v64i8-add-test-coverage.patch"; + url = "https://github.com/llvm/llvm-project/commit/0e3a96d0ec01e3575674d72c4e23bf98affdca28.patch"; + relative = "llvm"; + hash = "sha256-qhRkB8Fjz/fNacuGv1OFkiTNOQ0/QQ9p4pLFudwrTzM="; + }) + (fetchpatch { + # https://github.com/llvm/llvm-project/pull/182852 + name = "llvm-x86-v64i8-prefer-vpermv3-on-vbmi.patch"; + url = "https://github.com/llvm/llvm-project/commit/8f5880d3ae4e5dfc748985d90e5413671028aa3e.patch"; + relative = "llvm"; + hash = "sha256-4DU6gu/1+iQpzvVYBlTTUKtw77QSRyTja4hdel4D5Cw="; + }) + (fetchpatch { + # https://github.com/llvm/llvm-project/pull/183109 + name = "llvm-x86-v64i8-skip-repeated-mask-lane-permute-on-vbmi.patch"; + url = "https://github.com/llvm/llvm-project/commit/1b9fea021840f17c41ea980300d0fc45e7285909.patch"; + relative = "llvm"; + hash = "sha256-9Akm78QQr8BIMrVWwDG3poWS1HuQ0hpIQWfke3oADgg="; + }) + # TODO: consider reapplying "Don't include aliases in RegisterClassInfo::IgnoreCSRForAllocOrder" + # it was reverted as it's a pessimization for non-GPU archs, but this compiler + # is used mostly for amdgpu + ]; + dontStrip = profilableStdenv; + hardeningDisable = [ "all" ]; + nativeBuildInputs = old.nativeBuildInputs ++ [ removeReferencesTo ]; + buildInputs = old.buildInputs ++ [ + zstd + ]; + preFixup = '' + moveToOutput "lib/lib*.a" "$dev" + moveToOutput "lib/cmake" "$dev" + sed -Ei "s|$lib/lib/(lib[^/]*)\.a|$dev/lib/\1.a|g" $dev/lib/cmake/llvm/*.cmake + ''; + env = (old.env or { }) // { + NIX_CFLAGS_COMPILE = "${(old.env or { }).NIX_CFLAGS_COMPILE or ""} ${llvmExtraCflags}"; + }; + cmakeFlags = (builtins.filter tablegenUsage old.cmakeFlags) ++ commonCmakeFlags; + # Ensure we don't leak refs to compiler that was used to bootstrap this LLVM + disallowedReferences = (old.disallowedReferences or [ ]) ++ disallowedRefsForToolchain; + postFixup = '' + ${old.postFixup or ""} + find $lib -type f -exec remove-references-to -t ${refsToRemove} {} + + ''; + meta = old.meta // llvmMeta; + }); + lld = + (s.prev.lld.override { + }).overrideAttrs + (old: { + dontStrip = profilableStdenv; + hardeningDisable = [ "all" ]; + nativeBuildInputs = old.nativeBuildInputs ++ [ + removeReferencesTo + ]; + buildInputs = old.buildInputs ++ [ + zstd + ]; + env = (old.env or { }) // { + NIX_CFLAGS_COMPILE = "${(old.env or { }).NIX_CFLAGS_COMPILE or ""} ${llvmExtraCflags}"; + }; + cmakeFlags = (builtins.filter tablegenUsage old.cmakeFlags) ++ commonCmakeFlags; + # Ensure we don't leak refs to compiler that was used to bootstrap this LLVM + disallowedReferences = (old.disallowedReferences or [ ]) ++ disallowedRefsForToolchain; + postFixup = '' + ${old.postFixup or ""} + find $lib -type f -exec remove-references-to -t ${refsToRemove} {} + + ''; + meta = old.meta // llvmMeta; + }); + clang-unwrapped = ( + (s.prev.clang-unwrapped.override { + enableClangToolsExtra = false; + }).overrideAttrs + (old: { + passthru = old.passthru // { + inherit gcc-prefix; + }; + patches = [ + (fetchpatch { + # [clang][cmake] Add option to control scan-build-py installation (#172727) + name = "clang-scan-build-py-configurable.patch"; + url = "https://github.com/llvm/llvm-project/commit/f5759eeb63a3a5ce7d555c13c3126cea84e0c7b1.patch"; + relative = "clang"; + hash = "sha256-73IDPGZWKX4vny3x5FJ3/NQw8XRad9UNwfYkvQdMB4s="; + }) + ] + # arm64e_x1: Can be removed when upgrading to rocm 10 + ++ [ + (fetchpatch { + name = "wasm-add-wasm32-linux-muslwali-target.patch"; + url = "https://github.com/llvm/llvm-project/commit/7e7c923b5890e62f4b5920c2f8a2e51f586a186c.patch"; + relative = "clang"; + hash = "sha256-QGqil4rs9wFFa8J25ghWKTE8YG2+AbGG81dt5ReAw9k="; + }) + (fetchpatch { + name = "adt-migrate-stringswitch-cases-to-new-overload.patch"; + url = "https://github.com/llvm/llvm-project/commit/2ed7baafc3bf5b4321e3f77dfb1ce291e62bcadc.patch"; + relative = "clang"; + hash = "sha256-w9sS+pwawHqxGkTAWMinzF1r9ZyWMTmI119X/NdQoc8="; + }) + (fetchpatch { + name = "lfi-introduce-aarch64-lfi-target.patch"; + url = "https://github.com/llvm/llvm-project/commit/2c05ae4b8f85927d55f862fdf61bea564e2ea944.patch"; + relative = "clang"; + hash = "sha256-CcwqLvhDAJSr3dkRDqJKe3pVD2G+w5JMgtGkUx6pUPc="; + }) + ] + ++ old.patches + ++ [ + # Never add FHS include paths + ./clang-bodge-ignore-systemwide-incls.diff + # Prevents builds timing out if a single compiler invocation is very slow but + # per-arch jobs are completing by ensuring there's terminal output + ./clang-log-jobs.diff + ./opt-offload-compress-on-by-default.patch + ./perf-shorten-gcclib-include-paths.patch + (fetchpatch { + # [ClangOffloadBundler]: Add GetBundleIDsInFile to OffloadBundler + hash = "sha256-OsarDZXuJ5vAXTP4i0NBUeK/r6tQPumaqmMWkf29UtM="; + url = "https://github.com/GZGavinZhao/rocm-llvm-project/commit/c7de294b0d1d25f277f9d1cbb2c9e09c7600e210.patch"; + relative = "clang"; + }) + ]; + # ROCm 7.2 commits 4dda51261a6 "Replace hostexec with upstream rpc" + # and 2ca1509d6d2 "Put the RTL, Back!", added CGEmitEmissaryExec.cpp which + # includes ../../openmp/device/include/EmissaryIds.h, breaking + # standalone clang builds. The upstream PR llvm/llvm-project#175265 + # ("[OpenMP] support for Emissary APIs") moves EmissaryIds.h into + # clang/lib/Headers/ so this should not be needed once that lands + # and ROCm rebases onto it. + postUnpack = '' + ${old.postUnpack or ""} + mkdir -p "''${sourceRoot}/openmp/device/include" + ln -s "${llvmSrc}/openmp/device/include/EmissaryIds.h" "''${sourceRoot}/openmp/device/include/" + ''; + hardeningDisable = [ "all" ]; + nativeBuildInputs = old.nativeBuildInputs ++ [ + removeReferencesTo + ]; + buildInputs = old.buildInputs ++ [ + zstd + ]; + env = (old.env or { }) // { + NIX_CFLAGS_COMPILE = "${(old.env or { }).NIX_CFLAGS_COMPILE or ""} ${llvmExtraCflags}"; + }; + dontStrip = profilableStdenv; + # Ensure we don't leak refs to compiler that was used to bootstrap this LLVM + disallowedReferences = (old.disallowedReferences or [ ]) ++ disallowedRefsForToolchain; + # Enable structured attrs for separateDebugInfo, because it is required with disallowedReferences set + __structuredAttrs = true; + # https://github.com/llvm/llvm-project/blob/6976deebafa8e7de993ce159aa6b82c0e7089313/clang/cmake/caches/DistributionExample-stage2.cmake#L9-L11 + cmakeFlags = + # TODO: Remove in followup, tblgen now works correctly but would rebuild + (builtins.filter tablegenUsage old.cmakeFlags) ++ commonCmakeFlags; + preFixup = '' + ${toString old.preFixup or ""} + moveToOutput "lib/lib*.a" "$dev" + moveToOutput "lib/cmake" "$dev" + mkdir -p $dev/lib/clang/ + ln -s $lib/lib/clang/${llvmMajorVersion} $dev/lib/clang/ + sed -Ei "s|$lib/lib/(lib[^/]*)\.a|$dev/lib/\1.a|g" $dev/lib/cmake/clang/*.cmake + ''; + postFixup = '' + ${toString old.postFixup or ""} + find $lib -type f -exec remove-references-to -t ${refsToRemove} {} + + find $dev -type f -exec remove-references-to -t ${refsToRemove} {} + + ''; + meta = old.meta // llvmMeta; + }) + ); + # A clang that understands standard include searching in a GNU sysroot and will put GPU libs in include path + # in the right order + # and expects its libc to be in the sysroot + rocm-toolchain = + with s.final; + (sysrootCompiler { + cc = clang-unwrapped; + name = "rocm-toolchain"; + paths = [ + clang-unwrapped.out + clang-unwrapped.lib + bintools.out + compiler-rt.out + openmp.out + openmp.dev + ] + ++ lib.optionals withLibcxx [ + libcxx + ] + ++ lib.optionals (!withLibcxx) [ + glibc + glibc.dev + ]; + linkPaths = [ + bintools.bintools.out + ] + ++ lib.optionals (!withLibcxx) [ + gcc-include.out + ]; + }) + // { + version = llvmMajorVersion; + cc = rocm-toolchain; + libllvm = llvm; + isClang = true; + isGNU = false; + }; + compiler-rt-libc = s.prev.compiler-rt-libc.overrideAttrs (old: { + patches = [ + # arm64e_x1: Can be removed when upgrading to rocm 10 + (fetchpatch { + name = "lfi-introduce-aarch64-lfi-target.patch"; + url = "https://github.com/llvm/llvm-project/commit/2c05ae4b8f85927d55f862fdf61bea564e2ea944.patch"; + relative = "compiler-rt"; + hash = "sha256-xgvVXG+IGa9qwv60ioER6N5nC7XPRPEDHVUrQ5n9RBI="; + }) + ] + ++ old.patches; + meta = old.meta // llvmMeta; + }); + compiler-rt = s.final.compiler-rt-libc; + clang = s.final.rocm-toolchain; + + rocmClangStdenv = with s.final; overrideCC (if withLibcxx then libcxxStdenv else stdenv) clang; + + # Projects + openmp = + with s.final; + (llvmPackagesRocm.openmp.override { + llvm = llvm; + clang-unwrapped = clang-unwrapped; + }).overrideAttrs + (old: { + disallowedReferences = (old.disallowedReferences or [ ]) ++ disallowedRefsForToolchain; + nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ + removeReferencesTo + ]; + cmakeFlags = + old.cmakeFlags + ++ commonCmakeFlags + ++ [ + "-DDEVICELIBS_ROOT=${rocm-device-libs.src}" + # OMPD support is broken in ROCm 6.3+ Haven't investigated why. + "-DLIBOMP_OMPD_SUPPORT:BOOL=FALSE" + "-DLIBOMP_OMPD_GDB_SUPPORT:BOOL=FALSE" + ]; + buildInputs = old.buildInputs ++ [ + clang-unwrapped + zstd + libxml2 + libffi + ]; + postFixup = '' + ${old.postFixup or ""} + ln -s $out/lib/libomp.so $dev/lib/libomp.so + ''; + }); + # AMD has a separate MLIR impl which we package under rocmPackages.rocmlir + # It would be an error to rely on the original mlir package from this scope + mlir = null; +}) diff --git a/pkgs/development/rocm-modules/10/llvm/opt-offload-compress-on-by-default.patch b/pkgs/development/rocm-modules/10/llvm/opt-offload-compress-on-by-default.patch new file mode 100644 index 0000000000000..d5cb1a363ea5d --- /dev/null +++ b/pkgs/development/rocm-modules/10/llvm/opt-offload-compress-on-by-default.patch @@ -0,0 +1,22 @@ +From 762511ad9c9cac7769a795cc4df888a1559dca02 Mon Sep 17 00:00:00 2001 +From: Luna Nova +Date: Mon, 16 Dec 2024 14:56:57 -0800 +Subject: [PATCH] [AMDGPU] CommonArgs: Enable offload compression by default + +--- + clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp +index 33f12fb2d075d..ba35f65210c7a 100644 +--- a/lib/Driver/ToolChains/CommonArgs.cpp ++++ b/lib/Driver/ToolChains/CommonArgs.cpp +@@ -2914,7 +2914,7 @@ void tools::addHIPRuntimeLibArgs(const ToolChain &TC, Compilation &C, + void tools::addOffloadCompressArgs(const llvm::opt::ArgList &TCArgs, + llvm::opt::ArgStringList &CmdArgs) { + if (TCArgs.hasFlag(options::OPT_offload_compress, +- options::OPT_no_offload_compress, false)) ++ options::OPT_no_offload_compress, true)) + CmdArgs.push_back("--compress"); + if (TCArgs.hasArg(options::OPT_v)) + CmdArgs.push_back("-verbose"); diff --git a/pkgs/development/rocm-modules/10/llvm/perf-increase-namestring-size.patch b/pkgs/development/rocm-modules/10/llvm/perf-increase-namestring-size.patch new file mode 100644 index 0000000000000..84046a588630a --- /dev/null +++ b/pkgs/development/rocm-modules/10/llvm/perf-increase-namestring-size.patch @@ -0,0 +1,28 @@ +From a57eb548d46a37e4aed33eefccc9e6374b579ff9 Mon Sep 17 00:00:00 2001 +From: Luna Nova +Date: Mon, 16 Dec 2024 13:58:54 -0800 +Subject: [PATCH] [AMDGPU] TargetMachine: increase NameString size to 256 + +128 is too small a default for compilers used to build +AMD's rocBLAS, composable_kernel and similar libs because +they use very long symbol names such as +device_gemm_xdl_universal_bf16_bf16_bf16_mk_nk_mn_comp_default_instance + +This fixes spending ~10% of compile time in malloc inside this function. +--- + llvm/lib/Target/TargetMachine.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp +index abd0fdf2390c0..86ce468b75643 100644 +--- a/lib/Target/TargetMachine.cpp ++++ b/lib/Target/TargetMachine.cpp +@@ -270,7 +270,7 @@ MCSymbol *TargetMachine::getSymbol(const GlobalValue *GV) const { + if (MCSymbol *TargetSymbol = TLOF->getTargetSymbol(GV, *this)) + return TargetSymbol; + +- SmallString<128> NameStr; ++ SmallString<256> NameStr; + getNameWithPrefix(NameStr, GV, TLOF->getMangler()); + return TLOF->getContext().getOrCreateSymbol(NameStr); + } diff --git a/pkgs/development/rocm-modules/10/llvm/perf-shorten-gcclib-include-paths.patch b/pkgs/development/rocm-modules/10/llvm/perf-shorten-gcclib-include-paths.patch new file mode 100644 index 0000000000000..b23a3886c3d00 --- /dev/null +++ b/pkgs/development/rocm-modules/10/llvm/perf-shorten-gcclib-include-paths.patch @@ -0,0 +1,59 @@ +From 8c64deff2a82fcca5b521362193a1fd8b1a0dca7 Mon Sep 17 00:00:00 2001 +From: Luna Nova +Date: Tue, 17 Dec 2024 04:29:11 -0800 +Subject: [PATCH] HACK: Get canonical GCC include path so doesn't have + ../../../../ + +This allows more of the strings used in compilation to fit inside +fixed size stack allocated buffers instead of spilling into the heap +--- + lib/Driver/ToolChains/Gnu.cpp | 16 ++++++++++------ + 1 file changed, 10 insertions(+), 6 deletions(-) + +diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp +index 07df9864636..b1201b999f0 100644 +--- a/lib/Driver/ToolChains/Gnu.cpp ++++ b/lib/Driver/ToolChains/Gnu.cpp +@@ -3326,29 +3326,33 @@ static bool addLibStdCXXIncludePaths(llvm::vfs::FileSystem &vfs, + if (!vfs.exists(IncludeDir)) + return false; + ++ SmallString<260> CanonicalIncludeDir; ++ if (vfs.getRealPath(IncludeDir, CanonicalIncludeDir)) ++ return false; ++ + // Debian native gcc uses g++-multiarch-incdir.diff which uses + // include/x86_64-linux-gnu/c++/10$IncludeSuffix instead of + // include/c++/10/x86_64-linux-gnu$IncludeSuffix. +- std::string Dir = IncludeDir.str(); + StringRef Include = +- llvm::sys::path::parent_path(llvm::sys::path::parent_path(Dir)); ++ llvm::sys::path::parent_path(llvm::sys::path::parent_path(CanonicalIncludeDir)); + std::string Path = +- (Include + "/" + Triple + Dir.substr(Include.size()) + IncludeSuffix) ++ (Include + "/" + Triple + CanonicalIncludeDir.substr(Include.size()) + IncludeSuffix) + .str(); + if (DetectDebian && !vfs.exists(Path)) + return false; + + // GPLUSPLUS_INCLUDE_DIR +- ToolChain::addSystemInclude(DriverArgs, CC1Args, IncludeDir); ++ ToolChain::addSystemInclude(DriverArgs, CC1Args, CanonicalIncludeDir); + // GPLUSPLUS_TOOL_INCLUDE_DIR. If Triple is not empty, add a target-dependent + // include directory. + if (DetectDebian) + ToolChain::addSystemInclude(DriverArgs, CC1Args, Path); + else if (!Triple.empty()) + ToolChain::addSystemInclude(DriverArgs, CC1Args, +- IncludeDir + "/" + Triple + IncludeSuffix); ++ CanonicalIncludeDir + "/" + Triple + IncludeSuffix); + // GPLUSPLUS_BACKWARD_INCLUDE_DIR +- ToolChain::addSystemInclude(DriverArgs, CC1Args, IncludeDir + "/backward"); ++ if (vfs.exists(CanonicalIncludeDir + "/backward")) ++ ToolChain::addSystemInclude(DriverArgs, CC1Args, CanonicalIncludeDir + "/backward"); + return true; + } + +-- +2.52.0 + diff --git a/pkgs/development/rocm-modules/10/rocm-device-libs/cmake.patch b/pkgs/development/rocm-modules/10/rocm-device-libs/cmake.patch new file mode 100644 index 0000000000000..500ff37a99052 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocm-device-libs/cmake.patch @@ -0,0 +1,43 @@ +diff --git a/cmake/Packages.cmake b/cmake/Packages.cmake +index 07c60eb..c736b3e 100644 +--- a/cmake/Packages.cmake ++++ b/cmake/Packages.cmake +@@ -12,24 +12,29 @@ set_target_properties(${target} PROPERTIES + IMPORTED_LOCATION \"${target_path}\")") + endforeach() + configure_file(AMDDeviceLibsConfig.cmake.in +- ${PACKAGE_PREFIX}/AMDDeviceLibsConfig.cmake ++ lib/cmake/AMDDeviceLibs/AMDDeviceLibsConfig.cmake + @ONLY) + + + set(install_path_suffix "amdgcn/bitcode") + + # Generate the install-tree package. +-# We do not know the absolute path to the intall tree until we are installed, +-# so we calculate it dynamically in AMD_DEVICE_LIBS_PREFIX_CODE and use +-# relative paths in the target imports in AMD_DEVICE_LIBS_TARGET_CODE. +-set(AMD_DEVICE_LIBS_PREFIX_CODE " ++if(IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}") ++ set(AMD_DEVICE_LIBS_PREFIX_CODE "set(AMD_DEVICE_LIBS_PREFIX \"${CMAKE_INSTALL_PREFIX}\")") ++else() ++ # We do not know the absolute path to the install tree until we are installed, ++ # so we calculate it dynamically in AMD_DEVICE_LIBS_PREFIX_CODE and use ++ # relative paths in the target imports in AMD_DEVICE_LIBS_TARGET_CODE. ++ set(AMD_DEVICE_LIBS_PREFIX_CODE " + # Derive absolute install prefix from config file path. + get_filename_component(AMD_DEVICE_LIBS_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") +-string(REGEX REPLACE "/" ";" count "${PACKAGE_PREFIX}") +-foreach(p ${count}) +- set(AMD_DEVICE_LIBS_PREFIX_CODE "${AMD_DEVICE_LIBS_PREFIX_CODE} ++ string(REGEX REPLACE "/" ";" count "${PACKAGE_PREFIX}") ++ foreach(p ${count}) ++ set(AMD_DEVICE_LIBS_PREFIX_CODE "${AMD_DEVICE_LIBS_PREFIX_CODE} + get_filename_component(AMD_DEVICE_LIBS_PREFIX \"\${AMD_DEVICE_LIBS_PREFIX}\" PATH)") +-endforeach() ++ endforeach() ++endif() ++ + set(AMD_DEVICE_LIBS_TARGET_CODE) + foreach(target ${AMDGCN_LIB_LIST}) + get_target_property(target_name ${target} ARCHIVE_OUTPUT_NAME) diff --git a/pkgs/development/rocm-modules/10/rocm-device-libs/default.nix b/pkgs/development/rocm-modules/10/rocm-device-libs/default.nix new file mode 100644 index 0000000000000..41034d2c64803 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocm-device-libs/default.nix @@ -0,0 +1,67 @@ +{ + lib, + stdenv, + cmake, + ninja, + zlib, + zstd, + llvm, + python3, +}: + +let + llvmNativeTarget = + if stdenv.hostPlatform.isx86_64 then + "X86" + else if stdenv.hostPlatform.isAarch64 then + "AArch64" + else + throw "Unsupported ROCm LLVM platform"; +in +stdenv.mkDerivation (finalAttrs: { + pname = "rocm-device-libs"; + # In-tree with ROCm LLVM + inherit (llvm.llvm) version; + src = llvm.llvm.monorepoSrc; + sourceRoot = "${finalAttrs.src.name}/amd/device-libs"; + strictDeps = true; + __structuredAttrs = true; + + postPatch = + # Use our sysrooted toolchain instead of direct clang target + '' + substituteInPlace cmake/OCL.cmake \ + --replace-fail '$' "${llvm.rocm-toolchain}/bin/clang" + ''; + + patches = [ + ./cmake.patch + ]; + + nativeBuildInputs = [ + cmake + ninja + python3 + llvm.rocm-toolchain + ]; + + buildInputs = [ + llvm.llvm + llvm.clang-unwrapped + zlib + zstd + ]; + + cmakeFlags = [ + "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}" + ]; + + meta = { + description = "Set of AMD-specific device-side language runtime libraries"; + homepage = "https://github.com/ROCm/ROCm-Device-Libs"; + license = lib.licenses.ncsa; + maintainers = with lib.maintainers; [ lovesegfault ]; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) From 417d349dc4a1da04ff2301f6d08ac9f18ce19eb7 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:37 -0700 Subject: [PATCH 05/79] rocmPackages_10.llvm: init at 10.1 (LLVM 24) Update the rocmPackages.llvm copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.llvm: 7.2.4 -> 10.1.0, build LLVM 24 on the llvmPackages_23 base": ROCm 10.1's llvm-project fork is LLVM 24 (LLVMVersion.cmake: LLVM_VERSION_MAJOR 24), sourced from the therock-10.1 tag. nixpkgs has no released llvmPackages_24, and the 24.0.0-git snapshot (llvmPackages_git) is an alias reserved for testing whose package-set splice resolves through that alias, so it cannot be evaluated with allowAliases = false (as CI does). Keep the released llvmPackages_23 as the base: it only supplies the shared compilers/llvm/common packaging and the bootstrap clang/bintools, while rocmLlvmVersion = "24.0.0-rocm" selects the LLVM 24 patch set for ROCm's own source. LTO is off, so the base's bitcode version is moot. Toolchain changes for the LLVM 22 -> 24 jump: - Drop the LLVM 22 backports (select-ptr-combine, arm64e_x1 bridge, v64i8 VBMI shuffle, scan-build-py option): all upstream in LLVM 24. - Drop the CompressedOffloadBundle::decompress postPatch and the EmissaryIds postUnpack symlink: ROCm 10.1 uses the raw_ostream* decompress form and removed CGEmitEmissaryExec.cpp/EmissaryIds.h (llvm#175265). - Replace the GZGavinZhao GetBundleIDsInFile fetchpatch (no longer applies) with a locally rebased clang-add-getbundleidsinfile.diff; it adds the set-returning OffloadBundler::GetBundleIDsInFile the comgr ISA-compat patch calls. - Drop clang-log-jobs.diff: LLVM 24 rewrote Compilation::ExecuteJobs around parallel offload job groups, so the patched loop no longer exists; it was cosmetic CI-progress logging. - Put zstd's lib dir on the toolchain default link path: LLVM 24's clang-linker-wrapper links libzstd when combining compressed offload images (--offload-compress defaults on). - Rebase rocm-device-libs' cmake.patch and guard rocm-comgr's EnvLLVMPath substitution against a null default. Revised during the split review: Set LIBOMP_COPY_EXPORTS to FALSE for openmp: ROCm's llvm-project defaults it to TRUE (upstream LLVM: FALSE), which copies libomp and its generated headers into the source tree. The generic LLVM >= 23 runtimes build of openmp (upstream PR 575569, carried at the bottom of this stack) then needs no writable copy of the source. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 36 +++- .../10/llvm/clang-add-getbundleidsinfile.diff | 75 +++++++ .../rocm-modules/10/llvm/clang-log-jobs.diff | 40 ---- .../rocm-modules/10/llvm/default.nix | 187 +++--------------- 4 files changed, 131 insertions(+), 207 deletions(-) create mode 100644 pkgs/development/rocm-modules/10/llvm/clang-add-getbundleidsinfile.diff delete mode 100644 pkgs/development/rocm-modules/10/llvm/clang-log-jobs.diff diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 47b10a6e9e7f7..a82d45132733c 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -1,19 +1,35 @@ { lib, + callPackage, newScope, }: let - outer = lib.makeScope newScope (self: { + outer = lib.makeScope newScope ( + self: + let + inherit (self) llvm; + in + { - rocmUpdateScript = self.callPackage ../update.nix { - maxMajor = 10; - tagPrefixes = [ - "rocm" - "therock" - ]; - setName = "rocmPackages_10"; - }; - }); + rocmUpdateScript = self.callPackage ../update.nix { + maxMajor = 10; + tagPrefixes = [ + "rocm" + "therock" + ]; + setName = "rocmPackages_10"; + }; + + ## ROCm ## + llvm = lib.recurseIntoAttrs ( + callPackage ./llvm/default.nix { + # rocm-device-libs is used for .src only + # otherwise would cause infinite recursion + inherit (self) rocm-device-libs; + } + ); + } + ); in outer diff --git a/pkgs/development/rocm-modules/10/llvm/clang-add-getbundleidsinfile.diff b/pkgs/development/rocm-modules/10/llvm/clang-add-getbundleidsinfile.diff new file mode 100644 index 0000000000000..ea6c9193ef34a --- /dev/null +++ b/pkgs/development/rocm-modules/10/llvm/clang-add-getbundleidsinfile.diff @@ -0,0 +1,75 @@ +--- a/include/clang/Driver/OffloadBundler.h 2026-10-07 22:36:18.030705685 -0700 ++++ b/include/clang/Driver/OffloadBundler.h 2026-10-07 22:36:50.353394217 -0700 +@@ -23,6 +23,7 @@ + #include "llvm/TargetParser/Triple.h" + #include + #include ++#include + + namespace clang { + +@@ -64,6 +65,13 @@ + ListBundleIDsInFile(llvm::StringRef InputFileName, + const OffloadBundlerConfig &BundlerConfig); + ++ // Collect available bundle IDs into a std::set. Return true if an error was ++ // found. ++ static llvm::Error ++ GetBundleIDsInFile(llvm::StringRef InputFileName, ++ const OffloadBundlerConfig &BundlerConfig, ++ std::set &BundleIds); ++ + llvm::Error BundleFiles(); + llvm::Error UnbundleFiles(); + llvm::Error UnbundleArchive(); +--- a/lib/Driver/OffloadBundler.cpp 2026-10-07 22:36:18.033306744 -0700 ++++ b/lib/Driver/OffloadBundler.cpp 2026-10-07 22:36:50.372606013 -0700 +@@ -1087,6 +1087,48 @@ + return Error::success(); + } + ++// Collect available bundle IDs into a std::set. Return true if an error was ++// found. ++Error OffloadBundler::GetBundleIDsInFile(StringRef InputFileName, ++ const OffloadBundlerConfig &BundlerConfig, ++ std::set &BundleIDs) { ++ // Open Input file. ++ ErrorOr> CodeOrErr = ++ MemoryBuffer::getFileOrSTDIN(InputFileName); ++ if (std::error_code EC = CodeOrErr.getError()) ++ return createFileError(InputFileName, EC); ++ ++ // Decompress the input if necessary. ++ Expected> DecompressedBufferOrErr = ++ CompressedOffloadBundle::decompress( ++ **CodeOrErr, BundlerConfig.Verbose ? &llvm::errs() : nullptr); ++ if (!DecompressedBufferOrErr) ++ return createStringError( ++ inconvertibleErrorCode(), ++ "Failed to decompress input: " + ++ llvm::toString(DecompressedBufferOrErr.takeError())); ++ ++ MemoryBuffer &DecompressedInput = **DecompressedBufferOrErr; ++ ++ // Select the right files handler. ++ Expected> FileHandlerOrErr = ++ CreateFileHandler(DecompressedInput, BundlerConfig); ++ if (!FileHandlerOrErr) ++ return FileHandlerOrErr.takeError(); ++ ++ std::unique_ptr &FH = *FileHandlerOrErr; ++ assert(FH); ++ ++ std::set BundleIDsRefs; ++ if (auto Error = FH->getBundleIDs(DecompressedInput, BundleIDsRefs)) ++ return Error; ++ ++ for (auto bundle_id : BundleIDsRefs) ++ BundleIDs.insert(bundle_id.str()); ++ ++ return Error::success(); ++} ++ + /// @brief Checks if a code object \p CodeObjectInfo is compatible with a given + /// target \p TargetInfo. + /// @link https://clang.llvm.org/docs/ClangOffloadBundler.html#bundle-entry-id diff --git a/pkgs/development/rocm-modules/10/llvm/clang-log-jobs.diff b/pkgs/development/rocm-modules/10/llvm/clang-log-jobs.diff deleted file mode 100644 index 3a3a712c8bbaf..0000000000000 --- a/pkgs/development/rocm-modules/10/llvm/clang-log-jobs.diff +++ /dev/null @@ -1,40 +0,0 @@ -diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp -index 06f5e7e7e335..8407d664886a 100644 ---- a/lib/Driver/Compilation.cpp -+++ b/lib/Driver/Compilation.cpp -@@ -340,6 +340,9 @@ private: - void Compilation::ExecuteJobs(const JobList &Jobs, - FailingCommandList &FailingCommands, - bool LogOnly) const { -+ // If >1 job, log as each job finishes so can see progress while building many offloads -+ const bool logJobs = Jobs.size() > 1; -+ auto start_time = std::chrono::steady_clock::now(); - // According to UNIX standard, driver need to continue compiling all the - // inputs on the command line even one of them failed. - // In all but CLMode, execute all the jobs unless the necessary inputs for the -@@ -364,11 +367,25 @@ void Compilation::ExecuteJobs(const JobList &Jobs, - - JS.setJobState(Next, JobScheduler::JS_RUN); - auto Work = [&, Next]() { -+ auto job_start_time = std::chrono::steady_clock::now(); - const Command *FailingCommand = nullptr; - if (int Res = ExecuteCommand(*Next, FailingCommand, LogOnly)) { - FailingCommands.push_back(std::make_pair(Res, FailingCommand)); - JS.setJobState(Next, JobScheduler::JS_FAIL); - } else { -+ if (logJobs && Next) { -+ auto now = std::chrono::steady_clock::now(); -+ auto job_duration = std::chrono::duration_cast(now - job_start_time).count(); -+ auto duration = std::chrono::duration_cast(now - start_time).count(); -+ if (duration > 10 && job_duration > 0) { -+ if (Next->getOutputFilenames().empty()) -+ if (Next->getExecutable()) llvm::errs() << "Job completed: " << Next->getExecutable() << "\n"; -+ else (llvm::errs() << "Job completed: "), Next->Print(llvm::errs(), "\n", true); -+ else -+ llvm::errs() << "Job completed: " << Next->getOutputFilenames().front().c_str() << "\n"; -+ } -+ } -+ - JS.setJobState(Next, JobScheduler::JS_DONE); - } - }; diff --git a/pkgs/development/rocm-modules/10/llvm/default.nix b/pkgs/development/rocm-modules/10/llvm/default.nix index 4fbb9fb0d1c92..f235f751a9ee2 100644 --- a/pkgs/development/rocm-modules/10/llvm/default.nix +++ b/pkgs/development/rocm-modules/10/llvm/default.nix @@ -1,8 +1,9 @@ { lib, stdenv, - # LLVM version closest to ROCm fork to override - llvmPackages_22, + # Packaging base only; there is no llvmPackages_24, and the llvmPackages_git + # alias fails with allowAliases = false. + llvmPackages_23, overrideCC, lndir, rocm-device-libs, @@ -16,14 +17,13 @@ libffi, libxml2, removeReferencesTo, - fetchpatch, # Build compilers and stdenv suitable for profiling # leaving compressed line tables (-g1 -gz) unstripped # TODO: Should also apply to downstream packages which use rocmClangStdenv? profilableStdenv ? false, # FIXME: proper two-stage bootstrap & PGO/BOLT/LTO - # LTO currently disabled due to llvm 22 vs 22.1 bitcode mismatch between - # llvmPackages_22 (22.1) and ROCm LLVM (22.0). Uses new bitcode attr + # LTO currently disabled due to bitcode mismatch between the nixpkgs + # llvmPackages_23 and ROCm LLVM (24.0.0git). Uses new bitcode attr # 105 nocreateundeforpoison fails to link hipify. # Whether to use LTO when building the ROCm toolchain # Slows down this toolchain's build, for typical ROCm usecase @@ -36,12 +36,14 @@ }: let - version = "7.2.4"; + version = "10.1"; + # ROCm/TheRock two-component tag (therock-.) for all monorepo/llvm sources + srcTag = "therock-${version}"; # major version of this should be the clang version ROCm forked from - rocmLlvmVersion = "22.0.0-rocm"; - # llvmPackages_base version should match rocmLlvmVersion - # so libllvm's bitcode is compatible with the built toolchain - llvmPackages_base = llvmPackages_22; + rocmLlvmVersion = "24.0.0-rocm"; + # The base's own libllvm is used only to bootstrap (LTO is off, see withLto), + # so a released base one major behind ROCm's LLVM is fine. + llvmPackages_base = llvmPackages_23; llvmPackagesNoBintools = llvmPackages_base.override { bootBintools = null; bootBintoolsNoLibc = null; @@ -117,18 +119,17 @@ let llvmSrc = fetchFromGitHub { owner = "ROCm"; repo = "llvm-project"; - tag = "rocm-${version}"; - hash = "sha256-TwFvQimbax2E37ZC/52lNkHXCgyBNfSGDBaqmas2x/s="; + tag = srcTag; + hash = "sha256-WkgJF0D4XsrWKbJO+vKow9CrNIKL/PqOXRwrB3ECsQE="; }; llvmMajorVersion = lib.versions.major rocmLlvmVersion; # An llvmPackages (pkgs/development/compilers/llvm/) built from ROCm LLVM's source tree llvmPackagesRocm = llvmPackages_base.override (_old: { stdenv = stdenvToBuildRocmLlvm; - # not setting gitRelease = because that causes patch selection logic to use git patches - # ROCm LLVM is closer to 20 official - # gitRelease = {}; officialRelease = null; - officialRelease = { }; # Set but empty because we're overriding everything from it. + # Keep the official (not git) patch-selection path: ROCm LLVM tracks official + # releases closely. Set but empty because we're overriding everything from it. + officialRelease = { }; # this version determines which patches are applied version = rocmLlvmVersion; src = llvmSrc; @@ -212,8 +213,10 @@ let # Clang config file: redirect resource dir to the sysroot (where compiler-rt # lives) and set GCC install prefix for header/library search + # -L zstd: clang-linker-wrapper links -lzstd for compressed offload images. cat > $out/bin/${stdenv.hostPlatform.config}.cfg < Date: Thu, 22 Oct 2026 07:18:37 -0700 Subject: [PATCH 06/79] rocmPackages_10.rocm-device-libs: init at 24.0.0-rocm Update the rocmPackages.rocm-device-libs copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.llvm: 7.2.4 -> 10.1.0, build LLVM 24 on the llvmPackages_23 base": ROCm 10.1's llvm-project fork is LLVM 24 (LLVMVersion.cmake: LLVM_VERSION_MAJOR 24), sourced from the therock-10.1 tag. nixpkgs has no released llvmPackages_24, and the 24.0.0-git snapshot (llvmPackages_git) is an alias reserved for testing whose package-set splice resolves through that alias, so it cannot be evaluated with allowAliases = false (as CI does). Keep the released llvmPackages_23 as the base: it only supplies the shared compilers/llvm/common packaging and the bootstrap clang/bintools, while rocmLlvmVersion = "24.0.0-rocm" selects the LLVM 24 patch set for ROCm's own source. LTO is off, so the base's bitcode version is moot. Toolchain changes for the LLVM 22 -> 24 jump: - Drop the LLVM 22 backports (select-ptr-combine, arm64e_x1 bridge, v64i8 VBMI shuffle, scan-build-py option): all upstream in LLVM 24. - Drop the CompressedOffloadBundle::decompress postPatch and the EmissaryIds postUnpack symlink: ROCm 10.1 uses the raw_ostream* decompress form and removed CGEmitEmissaryExec.cpp/EmissaryIds.h (llvm#175265). - Replace the GZGavinZhao GetBundleIDsInFile fetchpatch (no longer applies) with a locally rebased clang-add-getbundleidsinfile.diff; it adds the set-returning OffloadBundler::GetBundleIDsInFile the comgr ISA-compat patch calls. - Drop clang-log-jobs.diff: LLVM 24 rewrote Compilation::ExecuteJobs around parallel offload job groups, so the patched loop no longer exists; it was cosmetic CI-progress logging. - Put zstd's lib dir on the toolchain default link path: LLVM 24's clang-linker-wrapper links libzstd when combining compressed offload images (--offload-compress defaults on). - Rebase rocm-device-libs' cmake.patch and guard rocm-comgr's EnvLLVMPath substitution against a null default. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 7 +++++++ .../10/rocm-device-libs/cmake.patch | 21 ++++++------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index a82d45132733c..07d5e6bca5694 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -2,6 +2,7 @@ lib, callPackage, newScope, + stdenv, }: let @@ -9,8 +10,11 @@ let self: let inherit (self) llvm; + rocmClangStdenv = llvm.rocmClangStdenv; in { + inherit rocmClangStdenv; + stdenv = rocmClangStdenv; rocmUpdateScript = self.callPackage ../update.nix { maxMajor = 10; @@ -29,6 +33,9 @@ let inherit (self) rocm-device-libs; } ); + inherit (self.llvm) rocm-toolchain clang openmp; + + rocm-device-libs = self.callPackage ./rocm-device-libs { }; } ); in diff --git a/pkgs/development/rocm-modules/10/rocm-device-libs/cmake.patch b/pkgs/development/rocm-modules/10/rocm-device-libs/cmake.patch index 500ff37a99052..89160e66970e3 100644 --- a/pkgs/development/rocm-modules/10/rocm-device-libs/cmake.patch +++ b/pkgs/development/rocm-modules/10/rocm-device-libs/cmake.patch @@ -1,8 +1,6 @@ -diff --git a/cmake/Packages.cmake b/cmake/Packages.cmake -index 07c60eb..c736b3e 100644 ---- a/cmake/Packages.cmake -+++ b/cmake/Packages.cmake -@@ -12,24 +12,29 @@ set_target_properties(${target} PROPERTIES +--- a/cmake/Packages.cmake 2026-09-20 19:45:16.236395164 -0700 ++++ b/cmake/Packages.cmake 2026-09-20 19:45:16.252171984 -0700 +@@ -12,21 +12,25 @@ IMPORTED_LOCATION \"${target_path}\")") endforeach() configure_file(AMDDeviceLibsConfig.cmake.in @@ -10,20 +8,14 @@ index 07c60eb..c736b3e 100644 + lib/cmake/AMDDeviceLibs/AMDDeviceLibsConfig.cmake @ONLY) - - set(install_path_suffix "amdgcn/bitcode") - # Generate the install-tree package. --# We do not know the absolute path to the intall tree until we are installed, --# so we calculate it dynamically in AMD_DEVICE_LIBS_PREFIX_CODE and use --# relative paths in the target imports in AMD_DEVICE_LIBS_TARGET_CODE. + # We do not know the absolute path to the intall tree until we are installed, + # so we calculate it dynamically in AMD_DEVICE_LIBS_PREFIX_CODE and use + # relative paths in the target imports in AMD_DEVICE_LIBS_TARGET_CODE. -set(AMD_DEVICE_LIBS_PREFIX_CODE " +if(IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}") + set(AMD_DEVICE_LIBS_PREFIX_CODE "set(AMD_DEVICE_LIBS_PREFIX \"${CMAKE_INSTALL_PREFIX}\")") +else() -+ # We do not know the absolute path to the install tree until we are installed, -+ # so we calculate it dynamically in AMD_DEVICE_LIBS_PREFIX_CODE and use -+ # relative paths in the target imports in AMD_DEVICE_LIBS_TARGET_CODE. + set(AMD_DEVICE_LIBS_PREFIX_CODE " # Derive absolute install prefix from config file path. get_filename_component(AMD_DEVICE_LIBS_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") @@ -37,7 +29,6 @@ index 07c60eb..c736b3e 100644 -endforeach() + endforeach() +endif() -+ set(AMD_DEVICE_LIBS_TARGET_CODE) foreach(target ${AMDGCN_LIB_LIST}) get_target_property(target_name ${target} ARCHIVE_OUTPUT_NAME) From ab8f71a8f46295aab46dcf202d323fa4c17a8af5 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:41 -0700 Subject: [PATCH 07/79] rocmPackages_10: copy runtime from rocmPackages Verbatim copies of the rocmPackages (ROCm 7.2.4) expressions for rocm-core, rocm-cmake, rocprofiler-register, rocm-runtime, rocm-comgr, rocminfo, amdsmi, rocm-smi, hip-common, roctracer, clr, hipify, half, not yet part of the rocmPackages_10 scope. The following commits update each one to ROCm 10.1, so their diffs read against 7.2.4. Assisted-by: Claude Code (claude-opus-5-5) --- .../rocm-modules/10/amdsmi/default.nix | 96 +++++ .../amdsmi/drm-struct-redefinition-fix.patch | 35 ++ .../10/clr/cmake-find-x11-libgl.patch | 40 ++ .../rocm-modules/10/clr/default.nix | 345 ++++++++++++++++++ .../10/clr/test-hiprtc-type-traits.cpp | 68 ++++ .../10/clr/test-hiprtc-type-traits.nix | 57 +++ .../rocm-modules/10/clr/test-isa-compat.nix | 74 ++++ .../rocm-modules/10/clr/test-opencl-cts.nix | 28 ++ .../rocm-modules/10/clr/test-rocm-smi.nix | 27 ++ .../rocm-modules/10/half/default.nix | 35 ++ .../rocm-modules/10/hip-common/default.nix | 46 +++ .../rocm-modules/10/hipify/default.nix | 66 ++++ .../rocm-modules/10/rocm-cmake/default.nix | 34 ++ .../rocm-modules/10/rocm-comgr/default.nix | 88 +++++ .../fix-ccob-compat-output-filename.patch | 11 + .../rocm-modules/10/rocm-core/default.nix | 95 +++++ .../10/rocm-core/env-rocm-path.patch | 22 ++ .../rocm-modules/10/rocm-runtime/default.nix | 109 ++++++ .../10/rocm-runtime/queue-failure.patch | 71 ++++ .../remove-hsa-aqlprofile-dep.patch | 27 ++ .../rocm-modules/10/rocm-smi/default.nix | 78 ++++ .../rocm-modules/10/rocminfo/default.nix | 57 +++ .../10/rocprofiler-register/default.nix | 97 +++++ .../rocm-modules/10/roctracer/default.nix | 118 ++++++ 24 files changed, 1724 insertions(+) create mode 100644 pkgs/development/rocm-modules/10/amdsmi/default.nix create mode 100644 pkgs/development/rocm-modules/10/amdsmi/drm-struct-redefinition-fix.patch create mode 100644 pkgs/development/rocm-modules/10/clr/cmake-find-x11-libgl.patch create mode 100644 pkgs/development/rocm-modules/10/clr/default.nix create mode 100644 pkgs/development/rocm-modules/10/clr/test-hiprtc-type-traits.cpp create mode 100644 pkgs/development/rocm-modules/10/clr/test-hiprtc-type-traits.nix create mode 100644 pkgs/development/rocm-modules/10/clr/test-isa-compat.nix create mode 100644 pkgs/development/rocm-modules/10/clr/test-opencl-cts.nix create mode 100644 pkgs/development/rocm-modules/10/clr/test-rocm-smi.nix create mode 100644 pkgs/development/rocm-modules/10/half/default.nix create mode 100644 pkgs/development/rocm-modules/10/hip-common/default.nix create mode 100644 pkgs/development/rocm-modules/10/hipify/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocm-cmake/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocm-comgr/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocm-comgr/fix-ccob-compat-output-filename.patch create mode 100644 pkgs/development/rocm-modules/10/rocm-core/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocm-core/env-rocm-path.patch create mode 100644 pkgs/development/rocm-modules/10/rocm-runtime/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocm-runtime/queue-failure.patch create mode 100644 pkgs/development/rocm-modules/10/rocm-runtime/remove-hsa-aqlprofile-dep.patch create mode 100644 pkgs/development/rocm-modules/10/rocm-smi/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocminfo/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocprofiler-register/default.nix create mode 100644 pkgs/development/rocm-modules/10/roctracer/default.nix diff --git a/pkgs/development/rocm-modules/10/amdsmi/default.nix b/pkgs/development/rocm-modules/10/amdsmi/default.nix new file mode 100644 index 0000000000000..d483dde8b6e8a --- /dev/null +++ b/pkgs/development/rocm-modules/10/amdsmi/default.nix @@ -0,0 +1,96 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + pkg-config, + libdrm, + python, + wrapPython, + autoPatchelfHook, +}: + +let + esmi_ib_src = fetchFromGitHub { + owner = "amd"; + repo = "esmi_ib_library"; + tag = "esmi_pkg_ver-4.2"; + hash = "sha256-czF9ezkAO0PuDkXh8y639AcOZH+KVcWiXPX74H5W/nw="; + }; +in +stdenv.mkDerivation (finalAttrs: { + pname = "amdsmi"; + version = "7.2.4"; + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-systems"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/amdsmi" + "shared" + ]; + hash = "sha256-TFi+3txemvV6K827e8S3hZOd9jcj4Qzop6V9CdKrpLg="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/amdsmi"; + + postPatch = '' + substituteInPlace goamdsmi_shim/CMakeLists.txt \ + --replace-fail "amd_smi)" ${"'"}''${AMD_SMI_TARGET})' \ + --replace-fail 'target_link_libraries(''${GOAMDSMI_SHIM_TARGET} -L' '#' + substituteInPlace CMakeLists.txt \ + --replace-fail "if(NOT latest_esmi_tag STREQUAL current_esmi_tag)" "if(OFF)" + + # Manually unpack esmi_ib_src and add amd_hsmp.h so execute-process git clone doesn't run + cp -rf --no-preserve=mode ${esmi_ib_src} ./esmi_ib_library + mkdir -p ./esmi_ib_library/include/asm + cp ./include/amd_smi/impl/amd_hsmp.h ./esmi_ib_library/include/asm/amd_hsmp.h + ''; + + patches = [ + # Fix error: redefinition of 'struct drm_color_ctm_3x4' + # https://github.com/ROCm/amdsmi/pull/165 + ./drm-struct-redefinition-fix.patch + ]; + + nativeBuildInputs = [ + cmake + pkg-config + wrapPython + autoPatchelfHook + ]; + + buildInputs = [ + libdrm + ]; + + cmakeFlags = [ + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ]; + + postInstall = '' + mkdir -p $out/${python.sitePackages} + ln -s $out/share/amd_smi/amdsmi $out/${python.sitePackages}/amdsmi + + makeWrapperArgs=(--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libdrm ]}) + wrapPythonProgramsIn $out + rm $out/bin/amd-smi + ln -sf $out/libexec/amdsmi_cli/amdsmi_cli.py $out/bin/amd-smi + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "System management interface for AMD GPUs supported by ROCm"; + homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/amdsmi"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ lovesegfault ]; + teams = [ lib.teams.rocm ]; + platforms = [ "x86_64-linux" ]; + mainProgram = "amd-smi"; + }; +}) diff --git a/pkgs/development/rocm-modules/10/amdsmi/drm-struct-redefinition-fix.patch b/pkgs/development/rocm-modules/10/amdsmi/drm-struct-redefinition-fix.patch new file mode 100644 index 0000000000000..caf23edcef57a --- /dev/null +++ b/pkgs/development/rocm-modules/10/amdsmi/drm-struct-redefinition-fix.patch @@ -0,0 +1,35 @@ +From b8b4a6bcfe35ba9539a120cfd16573123ddd9241 Mon Sep 17 00:00:00 2001 +From: "Sv. Lockal" +Date: Mon, 15 Dec 2025 03:46:35 +0800 +Subject: [PATCH] Fix compilation with libdrm-2.4.130 + +Fix error: redefinition of 'struct drm_color_ctm_3x4'. + +drm_color_ctm_3x4 structure is now defined in https://github.com/torvalds/linux/commit/e5719e7f19009d4fbedf685fc22eec9cd8de154f#diff-4c51fb416ec7cc69566cd7b795ee57eb070aa1006ad65d6962081f039ffb2718 + +As this structure is unused and not a part of amdsmi public interface, +it is safe to remove it. +--- + include/amd_smi/impl/amdgpu_drm.h | 9 --------- + 1 file changed, 9 deletions(-) + +diff --git a/include/amd_smi/impl/amdgpu_drm.h b/include/amd_smi/impl/amdgpu_drm.h +index b56a5ac4b..0e483d13b 100644 +--- a/include/amd_smi/impl/amdgpu_drm.h ++++ b/include/amd_smi/impl/amdgpu_drm.h +@@ -1625,15 +1625,6 @@ struct drm_amdgpu_info_uq_metadata { + #define AMDGPU_FAMILY_GC_11_5_0 150 /* GC 11.5.0 */ + #define AMDGPU_FAMILY_GC_12_0_0 152 /* GC 12.0.0 */ + +-/* FIXME wrong namespace! */ +-struct drm_color_ctm_3x4 { +- /* +- * Conversion matrix with 3x4 dimensions in S31.32 sign-magnitude +- * (not two's complement!) format. +- */ +- __u64 matrix[12]; +-}; +- + #if defined(__cplusplus) + } + #endif diff --git a/pkgs/development/rocm-modules/10/clr/cmake-find-x11-libgl.patch b/pkgs/development/rocm-modules/10/clr/cmake-find-x11-libgl.patch new file mode 100644 index 0000000000000..5a36a2c2c74d0 --- /dev/null +++ b/pkgs/development/rocm-modules/10/clr/cmake-find-x11-libgl.patch @@ -0,0 +1,40 @@ +diff --git a/rocclr/cmake/ROCclr.cmake b/rocclr/cmake/ROCclr.cmake +index 3f233b72f..67bdc62ee 100644 +--- a/rocclr/cmake/ROCclr.cmake ++++ b/rocclr/cmake/ROCclr.cmake +@@ -44,6 +44,19 @@ find_package(Threads REQUIRED) + + find_package(AMD_OPENCL) + ++# Find X11 package ++find_package(X11 REQUIRED) ++if(NOT X11_FOUND) ++ message(FATAL_ERROR "X11 libraries not found") ++endif() ++ ++# Find OpenGL package ++find_package(OpenGL REQUIRED) ++if(NOT OpenGL_FOUND) ++ message(FATAL_ERROR "OpenGL not found") ++endif() ++ ++ + add_library(rocclr STATIC) + + include(ROCclrCompilerOptions) +@@ -123,9 +136,14 @@ target_include_directories(rocclr PUBLIC + ${ROCCLR_SRC_DIR}/device + ${ROCCLR_SRC_DIR}/elf + ${ROCCLR_SRC_DIR}/include ++ ${X11_INCLUDE_DIR} ++ ${OPENGL_INCLUDE_DIR} + ${AMD_OPENCL_INCLUDE_DIRS}) + +-target_link_libraries(rocclr PUBLIC Threads::Threads) ++target_link_libraries(rocclr PUBLIC ++ Threads::Threads ++ ${X11_LIBRARIES} ++ ${OPENGL_LIBRARIES}) + # IPC on Windows is not supported + if(UNIX) + target_link_libraries(rocclr PUBLIC rt) diff --git a/pkgs/development/rocm-modules/10/clr/default.nix b/pkgs/development/rocm-modules/10/clr/default.nix new file mode 100644 index 0000000000000..554c76d845c04 --- /dev/null +++ b/pkgs/development/rocm-modules/10/clr/default.nix @@ -0,0 +1,345 @@ +{ + lib, + stdenv, + callPackage, + fetchFromGitHub, + fetchpatch, + rocmUpdateScript, + makeWrapper, + cmake, + perl, + hip-common, + hipcc, + rocm-device-libs, + rocm-comgr, + rocm-runtime, + rocm-core, + roctracer, + rocminfo, + rocm-smi, + rocprofiler-register, + symlinkJoin, + numactl, + libffi, + zstd, + zlib, + libGL, + libxml2, + libx11, + python3Packages, + llvm, + khronos-ocl-icd-loader, + gcc-unwrapped, + writeShellScriptBin, + localGpuTargets ? null, +}: + +let + inherit (rocm-core) ROCM_LIBPATCH_VERSION; + # HIP_CLANG_PATH or ROCM_PATH/llvm + # Note: relying on ROCM_PATH/llvm is bad for cross + hipClang = symlinkJoin { + name = "hipClang"; + paths = [ + # FIXME: if we don't put this first aotriton build fails with ld.lld: -flavor gnu + # Probably wrapper jank + llvm.bintools.bintools + llvm.rocm-toolchain + ]; + postBuild = '' + rm -rf $out/{include,lib,share,etc,nix-support,usr} + ''; + }; + hipClangPath = "${hipClang}/bin"; + wrapperArgs = [ + "--prefix PATH : $out/bin" + "--prefix LD_LIBRARY_PATH : ${rocm-runtime}" + "--set HIP_PLATFORM amd" + "--set HIP_PATH $out" + "--set HIP_CLANG_PATH ${hipClangPath}" + "--set DEVICE_LIB_PATH ${rocm-device-libs}/amdgcn/bitcode" + "--set HSA_PATH ${rocm-runtime}" + "--set ROCM_PATH $out" + ]; + amdclang = writeShellScriptBin "amdclang" '' + exec ${hipClang}/bin/clang "$@" + ''; + amdclangxx = writeShellScriptBin "amdclang++" '' + exec ${hipClang}/bin/clang++ "$@" + ''; +in +stdenv.mkDerivation (finalAttrs: { + pname = "clr"; + version = "7.2.4"; + + outputs = [ + "out" + "icd" + ]; + + __structuredAttrs = true; + strictDeps = true; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-systems"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/clr" + "shared" + ]; + hash = "sha256-//cQBKlSB9uSP4fBgJpI1FxnqlzyQN913CHVGa2tqv8="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/clr"; + + nativeBuildInputs = [ + makeWrapper + cmake + perl + python3Packages.python + python3Packages.cppheaderparser + amdclang + amdclangxx + ]; + + buildInputs = [ + llvm.llvm + numactl + libGL + libxml2 + libx11 + khronos-ocl-icd-loader + hipClang + libffi + zstd + zlib + rocprofiler-register + ]; + + propagatedBuildInputs = [ + rocm-core + rocm-device-libs + rocm-comgr + rocm-runtime + rocminfo + hipClangPath + ]; + + cmakeBuildType = "RelWithDebInfo"; + separateDebugInfo = true; + + cmakeFlags = [ + (lib.cmakeFeature "CMAKE_POLICY_DEFAULT_CMP0072" "NEW") # Prefer newer OpenGL libraries + (lib.cmakeBool "CLR_BUILD_HIP" true) + (lib.cmakeBool "CLR_BUILD_OCL" true) + (lib.cmakeFeature "HIP_COMMON_DIR" hip-common.outPath) + (lib.cmakeFeature "HIPCC_BIN_DIR" "${hipcc}/bin") + (lib.cmakeFeature "HIP_PLATFORM" "amd") + (lib.cmakeFeature "PROF_API_HEADER_PATH" "${roctracer.src}/inc/ext") + (lib.cmakeFeature "ROCM_PATH" rocminfo.outPath) + (lib.cmakeBool "BUILD_ICD" true) + (lib.cmakeFeature "AMD_ICD_LIBRARY_DIR" khronos-ocl-icd-loader.outPath) + + # Temporarily set variables to work around upstream CMakeLists issue + # Can be removed once https://github.com/ROCm/rocm-cmake/issues/121 is fixed + (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") + (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") + (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") + ]; + + env.LLVM_DIR = ""; + + patches = [ + ./cmake-find-x11-libgl.patch + (fetchpatch { + # [PATCH] rocclr: Extend HIP ISA compatibility checks + hash = "sha256-3MsDL+OQg24wH1RDhbao74RuIbzEAmduwla9KOPzQ/M="; + url = "https://github.com/GZGavinZhao/rocm-systems/commit/039cb23b24d739adb8c0f9de8b550d9f557de031.patch"; + relative = "projects/clr"; + }) + ]; + + postPatch = '' + patchShebangs hipamd/*.sh + patchShebangs hipamd/src + '' + # We're not on Windows so these are never installed to hipcc... + + '' + substituteInPlace hipamd/CMakeLists.txt \ + --replace-fail "install(PROGRAMS \''${HIPCC_BIN_DIR}/hipcc.bat DESTINATION bin)" "" \ + --replace-fail "install(PROGRAMS \''${HIPCC_BIN_DIR}/hipconfig.bat DESTINATION bin)" "" + '' + + '' + substituteInPlace hipamd/src/hip_embed_pch.sh \ + --replace-fail "\''$LLVM_DIR/bin/clang" "${hipClangPath}/clang" \ + --replace-fail "\''$LLVM_DIR/bin/llvm-mc" "${lib.getExe' llvm.bintools.bintools "llvm-mc"}" + '' + + '' + substituteInPlace opencl/khronos/icd/loader/icd_platform.h \ + --replace-fail '#define ICD_VENDOR_PATH "/etc/OpenCL/vendors/";' \ + '#define ICD_VENDOR_PATH "/run/opengl-driver/etc/OpenCL/vendors/";' + '' + # HIP defines __noinline__ as an empty macro for host compilers, which breaks + # [[__gnu__::__noinline__]] in libstdc++ 16's + # https://github.com/ROCm/rocm-systems/pull/12596 + + '' + substituteInPlace hipamd/include/hip/amd_detail/host_defines.h \ + --replace-fail $'#define __noinline__\n' "" + ''; + + postInstall = '' + chmod +x $out/bin/* + patchShebangs $out/bin + + cp ${amdclang}/bin/* $out/bin/ + cp ${amdclangxx}/bin/* $out/bin/ + + for prog in hip{cc,config}; do + wrapProgram $out/bin/$prog ${lib.concatStringsSep " " wrapperArgs} + done + + mkdir -p $out/nix-support/ + echo ' + export HIP_PATH="${placeholder "out"}" + export HIP_PLATFORM=amd + export HIP_DEVICE_LIB_PATH="${rocm-device-libs}/amdgcn/bitcode" + export NIX_CC_USE_RESPONSE_FILE=0 + export HIP_CLANG_PATH="${hipClangPath}" + export ROCM_LIBPATCH_VERSION="${ROCM_LIBPATCH_VERSION}" + export HSA_PATH="${rocm-runtime}"' > $out/nix-support/setup-hook + + # Just link rocminfo, it's easier + ln -s ${rocminfo}/bin/* $out/bin + ln -s ${rocm-core}/include/* $out/include/ + + # Replace rocm-opencl-icd functionality + mkdir -p $icd/etc/OpenCL/vendors + echo "$out/lib/libamdocl64.so" > $icd/etc/OpenCL/vendors/amdocl64.icd + + # add version info to output (downstream rocmPackages look for this) + ln -s ${rocm-core}/.info/ $out/.info + + ln -s ${hipClang} $out/llvm + ''; + + # libamdhip64.so dlopens its own bare name for hipGetProcAddress symbol resolution, + # same pattern with libhiprtc.so, so add own lib directory to all .so's + # RPATHs so they can find themselves and neighbouring libs + # Must be in postFixup so it runs after patchelf --shrink-rpath which removes + # the apparently useless rpath + postFixup = '' + patchelf --add-rpath "$out/lib" "$out"/lib/*.so + ''; + + disallowedRequisites = [ + gcc-unwrapped + ]; + + passthru = { + # All known and valid general GPU targets + # We cannot use this for each ROCm library, as each defines their own supported targets + # See: https://github.com/ROCm/ROCm/blob/77cbac4abab13046ee93d8b5bf410684caf91145/README.md#library-target-matrix + gpuTargets = lib.forEach [ + # "9-generic" # can handle all Vega variants + "900" # MI25, Vega 56/64 + # "902" # Vega 8 + # "909" # Renoir Vega APU + # "90c" # Renoir Vega APU + # Past this point cards need their own kernels for perf despite gfx9-generic compat + "906" # MI50/60, Radeon VII - adds dot product & mixed precision FMA ops + "908" # MI100 - adds MFMA (matrix fused multiply-add) ops + "90a" # MI210/MI250 - additional MFMA variants + # "9-4-generic" - since only 942 is valid for 6.4 target it directly + # 940/1 - never released publicly, maybe HPE cray specific MI3xx? + "942" # MI300A/X, MI325X + "950" # MI350X, MI355X + # "10-1-generic" # fine for all RDNA1 cards + "1010" + # "10-3-generic" + "1030" # W6800, various Radeon cards + # 1100 through 1103 = RDNA3 + # "11-generic" # will handle 7600, hopefully ryzen AI series iGPUs + "1100" + "1101" + "1102" + "1103" # RDNA3 iGPU like Radeon 780M + "1150" # Strix Point + "1151" # Strix Halo + # "12-generic" + "1200" # RX 9060 + "1201" # RX 9070 + XT + ] (target: "gfx${target}"); + + inherit hipClangPath; + + updateScript = rocmUpdateScript { inherit finalAttrs; }; + + impureTests = { + # bash $(nix-build -A rocmPackages.clr.impureTests.rocm-smi) + rocm-smi = callPackage ./test-rocm-smi.nix { + inherit rocm-smi; + clr = finalAttrs.finalPackage; + }; + # Simple subset of opencl-cts test_basic + opencl-cts = callPackage ./test-opencl-cts.nix { + clr = finalAttrs.finalPackage; + }; + generic-arch = callPackage ./test-isa-compat.nix { + clr = finalAttrs.finalPackage; + name = "generic-arch"; + offloadArches = [ + "gfx9-generic" + "gfx10-1-generic" + "gfx10-3-generic" + "gfx11-generic" + "gfx12-generic" + ]; + }; + isa-compat = callPackage ./test-isa-compat.nix { + clr = finalAttrs.finalPackage; + name = "isa-compat"; + offloadArches = [ + "gfx900" + "gfx1010" + "gfx1030" + ]; + }; + spirv = callPackage ./test-isa-compat.nix { + clr = finalAttrs.finalPackage; + name = "spirv"; + offloadArches = [ + "amdgcnspirv" + ]; + }; + hiprtc-type-traits = callPackage ./test-hiprtc-type-traits.nix { + clr = finalAttrs.finalPackage; + inherit rocm-smi; + }; + }; + + selectGpuTargets = + { + supported ? [ ], + }: + supported; + gpuArchSuffix = ""; + } + // lib.optionalAttrs (localGpuTargets != null) { + inherit localGpuTargets; + gpuArchSuffix = "-" + (builtins.concatStringsSep "-" localGpuTargets); + selectGpuTargets = + { + supported ? [ ], + }: + if supported == [ ] then localGpuTargets else lib.lists.intersectLists localGpuTargets supported; + }; + + meta = { + description = "AMD Common Language Runtime for hipamd, opencl, and rocclr"; + homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/clr"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ lovesegfault ]; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/clr/test-hiprtc-type-traits.cpp b/pkgs/development/rocm-modules/10/clr/test-hiprtc-type-traits.cpp new file mode 100644 index 0000000000000..39a99f39eae11 --- /dev/null +++ b/pkgs/development/rocm-modules/10/clr/test-hiprtc-type-traits.cpp @@ -0,0 +1,68 @@ +#include +#include +#include +#include + +#define CHECK_HIP(expr) do { \ + if ((expr) != hipSuccess) { \ + std::cerr << #expr << " failed" << std::endl; \ + return 1; \ + } \ +} while(0) + +#define CHECK_HIPRTC(expr) do { \ + hiprtcResult _res = (expr); \ + if (_res != HIPRTC_SUCCESS) { \ + std::cerr << #expr << " failed: " << hiprtcGetErrorString(_res) << std::endl; \ + hiprtcGetProgramLogSize(prog, &log_size); \ + if (log_size > 0) { \ + std::string log(log_size, '\0'); \ + hiprtcGetProgramLog(prog, log.data()); \ + std::cerr << "Compile log:\n" << log << std::endl; \ + } \ + return 1; \ + } \ +} while(0) + +static const char* kernelSource = R"( + #include + + extern "C" __global__ void test_kernel(int* out) { + static_assert(std::is_same::type>::value, + "type_traits not working"); + out[0] = 5; + } +)"; + +int main() { + hiprtcProgram prog; + size_t log_size = 0; + CHECK_HIPRTC(hiprtcCreateProgram(&prog, kernelSource, "test.hip", 0, nullptr, nullptr)); + CHECK_HIPRTC(hiprtcCompileProgram(prog, 0, nullptr)); + + size_t code_size; + CHECK_HIPRTC(hiprtcGetCodeSize(prog, &code_size)); + std::string code(code_size, '\0'); + CHECK_HIPRTC(hiprtcGetCode(prog, code.data())); + hiprtcDestroyProgram(&prog); + + hipModule_t module; + hipFunction_t kernel; + CHECK_HIP(hipModuleLoadData(&module, code.data())); + CHECK_HIP(hipModuleGetFunction(&kernel, module, "test_kernel")); + + int* d_out; + int h_out = 0; + CHECK_HIP(hipMalloc(&d_out, sizeof(int))); + void* args[] = { &d_out }; + CHECK_HIP(hipModuleLaunchKernel(kernel, 1, 1, 1, 1, 1, 1, 0, nullptr, args, nullptr)); + CHECK_HIP(hipMemcpy(&h_out, d_out, sizeof(int), hipMemcpyDeviceToHost)); + + if (h_out != 5) { + std::cerr << "Kernel output mismatch: expected 5, got " << h_out << std::endl; + return 1; + } + + std::cout << "HIPRTC type_traits test passed (output=" << h_out << ")" << std::endl; + return 0; +} diff --git a/pkgs/development/rocm-modules/10/clr/test-hiprtc-type-traits.nix b/pkgs/development/rocm-modules/10/clr/test-hiprtc-type-traits.nix new file mode 100644 index 0000000000000..f0f3628fcdaa3 --- /dev/null +++ b/pkgs/development/rocm-modules/10/clr/test-hiprtc-type-traits.nix @@ -0,0 +1,57 @@ +{ + lib, + stdenv, + makeImpureTest, + clr, + rocm-smi, +}: +# minimal hiprtc test that compiles a kernel using at runtime +# mirrors an migraphx workload, better test/iteration UX to be able to confirm +# with just a build up to clr +let + hiprtc-test = stdenv.mkDerivation { + pname = "hiprtc-type-traits-test"; + version = "0"; + + dontUnpack = true; + + nativeBuildInputs = [ clr ]; + + buildPhase = '' + runHook preBuild + hipcc -o hiprtc-test ${./test-hiprtc-type-traits.cpp} -lhiprtc + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + mkdir -p $out/bin + cp hiprtc-test $out/bin/ + runHook postInstall + ''; + }; +in +makeImpureTest { + name = "hiprtc-type-traits"; + testedPackage = "rocmPackages.clr"; + + sandboxPaths = [ + "/sys" + "/dev/dri" + "/dev/kfd" + ]; + + nativeBuildInputs = [ + hiprtc-test + rocm-smi + ]; + + testScript = '' + rocm-smi + hiprtc-test + ''; + + meta = { + teams = [ lib.teams.rocm ]; + }; +} diff --git a/pkgs/development/rocm-modules/10/clr/test-isa-compat.nix b/pkgs/development/rocm-modules/10/clr/test-isa-compat.nix new file mode 100644 index 0000000000000..2eca8edbff3d5 --- /dev/null +++ b/pkgs/development/rocm-modules/10/clr/test-isa-compat.nix @@ -0,0 +1,74 @@ +{ + lib, + stdenv, + makeImpureTest, + fetchFromGitHub, + clr, + rocm-smi, + name, + offloadArches, +}: + +let + # TODO: swap to another tiny test if this breaks; upstream is archived but fine for now + vectoradd = stdenv.mkDerivation { + pname = "rocm-hip-vectoradd"; + version = "2024-04-11"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "HIP-Examples"; + rev = "cdf9d101acd9a3fc89ee750f73c1f1958cbd5cc3"; + hash = "sha256-/I1KmOBFbEZIjA1vRE+2tPTtEKtOgazjCbnZtr+87E0="; + }; + + nativeBuildInputs = [ + clr + ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + amdclang++ -x hip -o $out/bin/vectoradd \ + ${lib.concatMapStringsSep " " (arch: "--offload-arch=${arch}") offloadArches} \ + vectorAdd/vectoradd_hip.cpp + + runHook postInstall + ''; + + meta = { + description = "vectorAdd HIP example for ROCm"; + homepage = "https://github.com/ROCm/HIP-Examples"; + license = lib.licenses.unfree; + platforms = lib.platforms.linux; + teams = [ lib.teams.rocm ]; + }; + }; + +in +makeImpureTest { + inherit name; + testedPackage = "rocmPackages.clr"; + + sandboxPaths = [ + "/sys" + "/dev/dri" + "/dev/kfd" + ]; + + nativeBuildInputs = [ + vectoradd + rocm-smi + ]; + + testScript = '' + rocm-smi + + vectoradd + ''; + + meta = { + teams = [ lib.teams.rocm ]; + }; +} diff --git a/pkgs/development/rocm-modules/10/clr/test-opencl-cts.nix b/pkgs/development/rocm-modules/10/clr/test-opencl-cts.nix new file mode 100644 index 0000000000000..77929531f9009 --- /dev/null +++ b/pkgs/development/rocm-modules/10/clr/test-opencl-cts.nix @@ -0,0 +1,28 @@ +{ + lib, + makeImpureTest, + opencl-cts, + clr, +}: + +makeImpureTest { + name = "opencl-cts"; + testedPackage = "rocmPackages.clr"; + + sandboxPaths = [ + "/sys" + "/dev/dri" + "/dev/kfd" + ]; + + nativeBuildInputs = [ opencl-cts ]; + OCL_ICD_VENDORS = "${clr.icd}/etc/OpenCL/vendors"; + + testScript = '' + test_basic arraycopy arrayreadwrite astype barrier vector_swizzle work_item_functions + ''; + + meta = { + teams = [ lib.teams.rocm ]; + }; +} diff --git a/pkgs/development/rocm-modules/10/clr/test-rocm-smi.nix b/pkgs/development/rocm-modules/10/clr/test-rocm-smi.nix new file mode 100644 index 0000000000000..e03655907c7b1 --- /dev/null +++ b/pkgs/development/rocm-modules/10/clr/test-rocm-smi.nix @@ -0,0 +1,27 @@ +{ + lib, + makeImpureTest, + clinfo, + clr, + rocm-smi, +}: + +makeImpureTest { + name = "rocm-smi"; + testedPackage = "rocmPackages.clr"; + nativeBuildInputs = [ + clinfo + rocm-smi + ]; + OCL_ICD_VENDORS = "${clr.icd}/etc/OpenCL/vendors"; + + testScript = '' + # Test fails if the number of platforms is 0 + clinfo | grep -E 'Number of platforms * [1-9]' + rocm-smi | grep -A1 GPU + ''; + + meta = { + teams = [ lib.teams.rocm ]; + }; +} diff --git a/pkgs/development/rocm-modules/10/half/default.nix b/pkgs/development/rocm-modules/10/half/default.nix new file mode 100644 index 0000000000000..8541b82d596fe --- /dev/null +++ b/pkgs/development/rocm-modules/10/half/default.nix @@ -0,0 +1,35 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "half"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "half"; + tag = "rocm-${finalAttrs.version}"; + hash = "sha256-If9O5BEeymsLN+C0drZsPSxEWXpJTxeDBGNHNXSumm4="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + ]; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "C++ library for half precision floating point arithmetics"; + homepage = "https://github.com/ROCm/half"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.unix; + }; +}) diff --git a/pkgs/development/rocm-modules/10/hip-common/default.nix b/pkgs/development/rocm-modules/10/hip-common/default.nix new file mode 100644 index 0000000000000..f2415ab549c33 --- /dev/null +++ b/pkgs/development/rocm-modules/10/hip-common/default.nix @@ -0,0 +1,46 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "hip-common"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-systems"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/hip" + "shared" + ]; + hash = "sha256-orfTXKjcZJ5E73cmXEyltZVYhCQo8FLExVHM3J/rqUM="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/hip"; + + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + + mkdir -p $out + mv * $out + + runHook postInstall + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "C++ Heterogeneous-Compute Interface for Portability"; + homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/hip"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ lovesegfault ]; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/hipify/default.nix b/pkgs/development/rocm-modules/10/hipify/default.nix new file mode 100644 index 0000000000000..b121f0859dce6 --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipify/default.nix @@ -0,0 +1,66 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + llvm, + zlib, + zstd, + perl, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "hipify"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "HIPIFY"; + tag = "rocm-${finalAttrs.version}"; + hash = "sha256-LC0lnYetV7RPVw92zew6za6bDH4zmnERXUM4MVaRVtc="; + }; + + strictDeps = true; + + nativeBuildInputs = [ + cmake + perl + llvm.rocm-toolchain + ]; + + buildInputs = [ + llvm.llvm + llvm.clang-unwrapped + perl + zlib + zstd + ]; + + env.CXXFLAGS = "-I${lib.getInclude llvm.llvm}/include -I${lib.getInclude llvm.clang-unwrapped}/include"; + + postPatch = '' + substituteInPlace CMakeLists.txt \ + --replace-fail "\''${LLVM_TOOLS_BINARY_DIR}/clang" "${llvm.rocm-toolchain}/bin/clang" + chmod +x bin/* + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + postInstall = '' + rm $out/bin/hipify-perl + chmod +x $out/bin/* + chmod +x $out/libexec/* + patchShebangs $out/bin/ + patchShebangs $out/libexec/ + ln -s $out/{libexec/hipify,bin}/hipify-perl + ''; + + meta = { + description = "Convert CUDA to Portable C++ Code"; + homepage = "https://github.com/ROCm/HIPIFY"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocm-cmake/default.nix b/pkgs/development/rocm-modules/10/rocm-cmake/default.nix new file mode 100644 index 0000000000000..dac12d5d0fccc --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocm-cmake/default.nix @@ -0,0 +1,34 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + rocm-core, + cmake, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocm-cmake"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-cmake"; + tag = "rocm-${finalAttrs.version}"; + hash = "sha256-gY6jzIIN1pSXGbCMN6y35Q/VJgbIqWDRjD8aI/fc1L0="; + }; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ rocm-core ]; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "CMake modules for common build tasks for the ROCm stack"; + homepage = "https://github.com/ROCm/rocm-cmake"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.unix; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocm-comgr/default.nix b/pkgs/development/rocm-modules/10/rocm-comgr/default.nix new file mode 100644 index 0000000000000..e7663a1f7130a --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocm-comgr/default.nix @@ -0,0 +1,88 @@ +{ + lib, + stdenv, + fetchpatch, + cmake, + llvm, + python3, + rocm-device-libs, + zlib, + zstd, +}: + +let + llvmNativeTarget = + if stdenv.hostPlatform.isx86_64 then + "X86" + else if stdenv.hostPlatform.isAarch64 then + "AArch64" + else + throw "Unsupported ROCm LLVM platform"; +in +stdenv.mkDerivation (finalAttrs: { + pname = "rocm-comgr"; + # In-tree with ROCm LLVM + inherit (llvm.llvm) version; + src = llvm.llvm.monorepoSrc; + sourceRoot = "${finalAttrs.src.name}/amd/comgr"; + strictDeps = true; + + patches = [ + # [Comgr] Extend ISA compatibility + (fetchpatch { + hash = "sha256-X2VPGigK582J+a/u2Kg74w25/+CTpVWU9D3Eqgnb2PU="; + url = "https://github.com/GZGavinZhao/rocm-llvm-project/commit/7002dc04863d38c57cfd2e6fc60a1cf5a613fd8e.patch"; + relative = "amd/comgr"; + }) + # [Comgr] Extend ISA compatibility for CCOB + (fetchpatch { + hash = "sha256-/50I+PqxL3oaQMqg5vR7+ibUcXO1SvfXBdw/sybRt1o="; + url = "https://github.com/GZGavinZhao/rocm-llvm-project/commit/2c1e44fc3eacadcafdd4ada3e3184a092b6f26c5.patch"; + relative = "amd/comgr"; + }) + # Fix: CCOB compat patch used coerced (featureless) name for output filename, + # causing CLR's code_obj_map key to miss when looking up device ISA with features + ./fix-ccob-compat-output-filename.patch + ]; + + postPatch = + # Fix relative path assumption for libllvm + '' + substituteInPlace cmake/opencl_header.cmake \ + --replace-fail "\''${CLANG_CMAKE_DIR}/../../../" "${llvm.clang-unwrapped.lib}" + '' + # Bake LLVM root for cfg/includes or HIPRTC can't find C++ stdlib headers (e.g. ). + + '' + substituteInPlace src/comgr-env.cpp \ + --replace-fail \ + 'return EnvLLVMPath;' \ + 'return EnvLLVMPath ? EnvLLVMPath : "${llvm.rocm-toolchain}";' + ''; + + nativeBuildInputs = [ + cmake + python3 + ]; + + buildInputs = [ + llvm.llvm + llvm.clang-unwrapped + llvm.lld + rocm-device-libs + zlib + zstd + ]; + + cmakeFlags = [ + "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}" + ]; + + meta = { + description = "APIs for compiling and inspecting AMDGPU code objects"; + homepage = "https://github.com/ROCm/ROCm-CompilerSupport/tree/amd-stg-open/lib/comgr"; + license = lib.licenses.ncsa; + maintainers = with lib.maintainers; [ lovesegfault ]; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocm-comgr/fix-ccob-compat-output-filename.patch b/pkgs/development/rocm-modules/10/rocm-comgr/fix-ccob-compat-output-filename.patch new file mode 100644 index 0000000000000..813f419ef3a9b --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocm-comgr/fix-ccob-compat-output-filename.patch @@ -0,0 +1,11 @@ +--- a/src/comgr-compiler.cpp ++++ b/src/comgr-compiler.cpp +@@ -1425,7 +1425,7 @@ + // Add an output file for each target + SmallString<128> OutputFilePath = OutputDir; + sys::path::append(OutputFilePath, +- OutputPrefix + "-" + CompatEntry + "." + FileExtension); ++ OutputPrefix + "-" + Entry + "." + FileExtension); + + BundlerConfig.TargetNames.emplace_back(CompatEntry); + BundlerConfig.OutputFileNames.emplace_back(OutputFilePath); diff --git a/pkgs/development/rocm-modules/10/rocm-core/default.nix b/pkgs/development/rocm-modules/10/rocm-core/default.nix new file mode 100644 index 0000000000000..861c6107935ee --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocm-core/default.nix @@ -0,0 +1,95 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + writeText, +}: + +# rocm-core is used by most distros for a few purposes: +# - meta package that all rocm packages depend so `apt-get remove rocm-core` removes all rocm packages +# - provide overall ROCM_PATH +# - provide rocm version info and path to rocm version headers +# only the last usage makes sense in nixpkgs +let + padIfSingle = s: if lib.stringLength s == 1 then "0${s}" else s; +in +stdenv.mkDerivation (finalAttrs: { + pname = "rocm-core"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-systems"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocm-core" + "shared" + ]; + hash = "sha256-Y3WuDwruD5zKN2epwfUCZAGq5vgxCT27awJN8JxmOsY="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rocm-core"; + + patches = [ + ./env-rocm-path.patch + ]; + + nativeBuildInputs = [ cmake ]; + env = { + ROCM_LIBPATCH_VERSION = "${lib.versions.major finalAttrs.version}${padIfSingle (lib.versions.minor finalAttrs.version)}${padIfSingle (lib.versions.patch finalAttrs.version)}"; + BUILD_ID = "nixpkgs-${finalAttrs.env.ROCM_LIBPATCH_VERSION}"; + ROCM_BUILD_ID = "${finalAttrs.env.BUILD_ID}"; + }; + cmakeFlags = [ + "-DROCM_LIBPATCH_VERSION=${finalAttrs.env.ROCM_LIBPATCH_VERSION}" + "-DROCM_VERSION=${finalAttrs.version}" + "-DBUILD_ID=${finalAttrs.env.BUILD_ID}" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_LIBEXECDIR=libexec" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + "-DCMAKE_INSTALL_BINDIR=bin" + ]; + + setupHook = writeText "setupHook.sh" '' + export ROCM_VERSION="${finalAttrs.version}" + export ROCM_LIBPATCH_VERSION="${finalAttrs.env.ROCM_LIBPATCH_VERSION}" + export ROCM_BUILD_ID="${finalAttrs.env.ROCM_BUILD_ID}" + ''; + + doInstallCheck = true; + preInstallCheck = + # Test that the CMake config file can be included and sets expected vars + '' + mkdir test_project + pushd test_project + + echo ' + cmake_minimum_required(VERSION 3.16) + project(test_rocm_core) + find_package(rocm-core REQUIRED) + if(NOT DEFINED ROCM_CORE_INCLUDE_DIR) + message(FATAL_ERROR "ROCM_CORE_INCLUDE_DIR not set") + endif() + message(STATUS "Found ROCM_CORE_INCLUDE_DIR: ''${ROCM_CORE_INCLUDE_DIR}") + message(STATUS "Found ROCM_PATH: ''${ROCM_PATH}") + ' > CMakeLists.txt + + CMAKE_PREFIX_PATH="$out" cmake . + popd + + . $out/nix-support/setup-hook + env | grep '^ROCM' + ''; + + passthru.ROCM_LIBPATCH_VERSION = finalAttrs.env.ROCM_LIBPATCH_VERSION; + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "Utility for getting the ROCm release version"; + homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/rocm-core"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocm-core/env-rocm-path.patch b/pkgs/development/rocm-modules/10/rocm-core/env-rocm-path.patch new file mode 100644 index 0000000000000..a40fa33b90cec --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocm-core/env-rocm-path.patch @@ -0,0 +1,22 @@ +In FHS distros rocm-core expects to be installed colocated with a full set of ROCM packages. +In nixpkgs contexts, we don't want rocm-core to be a ROCM_PATH root. +diff --git a/cmake_modules/rocm-core-config.cmake.in b/cmake_modules/rocm-core-config.cmake.in +index f5fe07c..9d72c9c 100644 +--- a/cmake_modules/rocm-core-config.cmake.in ++++ b/cmake_modules/rocm-core-config.cmake.in +@@ -11,7 +11,14 @@ set_and_check(rocm_core_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") + set_and_check(ROCM_CORE_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") + set_and_check(rocm_core_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") + set_and_check(ROCM_CORE_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") +-set_and_check(ROCM_PATH "${PACKAGE_PREFIX_DIR}") ++# Set ROCM_PATH with priority: existing value > environment variable > package prefix ++if(NOT DEFINED ROCM_PATH) ++ if(DEFINED ENV{ROCM_PATH}) ++ set(ROCM_PATH "$ENV{ROCM_PATH}") ++ else() ++ set_and_check(ROCM_PATH "${PACKAGE_PREFIX_DIR}") ++ endif() ++endif() + + get_filename_component(ROCM_CORE_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + include("${ROCM_CORE_CMAKE_DIR}/rocmCoreTargets.cmake") diff --git a/pkgs/development/rocm-modules/10/rocm-runtime/default.nix b/pkgs/development/rocm-modules/10/rocm-runtime/default.nix new file mode 100644 index 0000000000000..255fce0eb24ec --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocm-runtime/default.nix @@ -0,0 +1,109 @@ +{ + lib, + stdenv, + fetchFromGitHub, + fetchpatch, + rocmUpdateScript, + pkg-config, + cmake, + xxd, + rocm-device-libs, + rocprofiler-register, + elfutils, + libdrm, + numactl, + llvm, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocm-runtime"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-systems"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocr-runtime" + "shared" + ]; + hash = "sha256-hcyjOLMtoBX/p6r6R9Bl9635DuvI6rTn1KziHMeyYM0="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rocr-runtime"; + + cmakeBuildType = "RelWithDebInfo"; + separateDebugInfo = true; + __structuredAttrs = true; + strictDeps = true; + + nativeBuildInputs = [ + pkg-config + cmake + xxd # used by create_hsaco_ascii_file.sh + llvm.rocm-toolchain + ]; + + buildInputs = [ + llvm.clang-unwrapped + llvm.llvm + elfutils + libdrm + numactl + rocprofiler-register + ]; + + cmakeFlags = [ + "-DBUILD_SHARED_LIBS=ON" + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ]; + + patches = [ + # Vendored upstream PR for fix for segfault when queue allocation fails + # https://github.com/ROCm/rocm-systems/pull/2850 + ./queue-failure.patch + (fetchpatch { + # [PATCH] rocr: Extend HIP ISA compatibility check + hash = "sha256-8r2Lb5lBfFaZC3knCxfXGcnkzNv6JxOKyJn2rD5gus4="; + url = "https://github.com/GZGavinZhao/rocm-systems/commit/dcef23cf896f4dcbc7ed81abeaa4ec2208dcdd8c.patch"; + relative = "projects/rocr-runtime"; + }) + (fetchpatch { + # [PATCH] kfd_ioctl: fix UB due to 1 << 31 + url = "https://github.com/ROCm/ROCR-Runtime/commit/41bfc66aef437a5b349f71105fa4b907cc7e17d5.patch"; + hash = "sha256-A7VhPR3eSsmjq2cTBSjBIz9i//WiNjoXm0EsRKtF+ns="; + }) + # This causes a circular dependency, aqlprofile relies on hsa-runtime64 + # which is part of rocm-runtime + # Worked around by having rocprofiler load aqlprofile directly + ./remove-hsa-aqlprofile-dep.patch + ]; + + postPatch = '' + patchShebangs --build \ + runtime/hsa-runtime/core/runtime/trap_handler/create_trap_handler_header.sh \ + runtime/hsa-runtime/core/runtime/blit_shaders/create_blit_shader_header.sh \ + runtime/hsa-runtime/image/blit_src/create_hsaco_ascii_file.sh + patchShebangs --host image core runtime + + substituteInPlace CMakeLists.txt \ + --replace 'hsa/include/hsa' 'include/hsa' + + substituteInPlace runtime/hsa-runtime/image/blit_src/CMakeLists.txt \ + --replace-fail 'COMMAND clang' "COMMAND ${llvm.rocm-toolchain}/bin/clang" + + export HIP_DEVICE_LIB_PATH="${rocm-device-libs}/amdgcn/bitcode" + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "Platform runtime for ROCm"; + homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/rocr-runtime"; + license = lib.licenses.ncsa; + maintainers = with lib.maintainers; [ lovesegfault ]; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocm-runtime/queue-failure.patch b/pkgs/development/rocm-modules/10/rocm-runtime/queue-failure.patch new file mode 100644 index 0000000000000..f9087144bc229 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocm-runtime/queue-failure.patch @@ -0,0 +1,71 @@ +From b7717446c85d08b2d7c0c60ba3ac0eff11ee6120 Mon Sep 17 00:00:00 2001 +From: Luna Nova +Date: Tue, 20 Jan 2026 12:55:45 -0800 +Subject: [PATCH 1/2] rocm-runtime: fix crash in QueueCreate due to trying to + free non allocated scratch + +if (scratch.main_queue_base != nullptr) before calling ReleaseQueueMainScratch +because ReleaseQueueMainScratch is only valid if main_queue_base is set +and the scope guard can fire for an error allocating the queue. +--- + .../runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +index 01b01fe869..83db40dacc 100644 +--- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp ++++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +@@ -1792,7 +1792,9 @@ hsa_status_t GpuAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type, u + scratch.main_queue_base = nullptr; + scratch.main_queue_process_offset = 0; + +- MAKE_NAMED_SCOPE_GUARD(scratchGuard, [&]() { ReleaseQueueMainScratch(scratch); }); ++ MAKE_NAMED_SCOPE_GUARD(scratchGuard, [&]() { ++ if (scratch.main_queue_base != nullptr) ReleaseQueueMainScratch(scratch); ++ }); + + if (scratch.main_size != 0) { + AcquireQueueMainScratch(scratch); +-- +2.52.0 + + +From 9c1746cd76a703e4d2321dc2ffe85fc61bfd2f21 Mon Sep 17 00:00:00 2001 +From: Luna Nova +Date: Tue, 20 Jan 2026 13:00:32 -0800 +Subject: [PATCH 2/2] rocm-runtime: log for errors in QueueCreate + +--- + .../runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +index 83db40dacc..ae68732eb5 100644 +--- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp ++++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +@@ -1799,6 +1799,9 @@ hsa_status_t GpuAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type, u + if (scratch.main_size != 0) { + AcquireQueueMainScratch(scratch); + if (scratch.main_queue_base == nullptr) { ++ LogPrint(HSA_AMD_LOG_FLAG_INFO, ++ "Failed to allocate scratch memory for queue, size=%zu, node=%u", ++ scratch.main_size, node_id()); + return HSA_STATUS_ERROR_OUT_OF_RESOURCES; + } + } +@@ -1827,7 +1830,11 @@ hsa_status_t GpuAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type, u + node_id())); + } + +- if (!shared_queue) return HSA_STATUS_ERROR_OUT_OF_RESOURCES; ++ if (!shared_queue) { ++ LogPrint(HSA_AMD_LOG_FLAG_INFO, ++ "Failed to allocate shared queue descriptor memory, node=%u", node_id()); ++ return HSA_STATUS_ERROR_OUT_OF_RESOURCES; ++ } + + auto aql_queue = new AqlQueue(shared_queue, this, size, node_id(), scratch, event_callback, data, + flags); +-- +2.52.0 + diff --git a/pkgs/development/rocm-modules/10/rocm-runtime/remove-hsa-aqlprofile-dep.patch b/pkgs/development/rocm-modules/10/rocm-runtime/remove-hsa-aqlprofile-dep.patch new file mode 100644 index 0000000000000..b8ed57d049bc9 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocm-runtime/remove-hsa-aqlprofile-dep.patch @@ -0,0 +1,27 @@ +libhsa-amd-aqlprofile64 library is unfree +Bug: https://github.com/ROCm/ROCm/issues/1781 +--- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp ++++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +@@ -1333,11 +1333,6 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const { + setFlag(HSA_EXTENSION_AMD_PC_SAMPLING); + } + +- if (os::LibHandle lib = os::LoadLib(kAqlProfileLib)) { +- os::CloseLib(lib); +- setFlag(HSA_EXTENSION_AMD_AQLPROFILE); +- } +- + setFlag(HSA_EXTENSION_AMD_PROFILER); + + break; +--- a/runtime/hsa-runtime/core/runtime/hsa.cpp ++++ b/runtime/hsa-runtime/core/runtime/hsa.cpp +@@ -490,7 +490,7 @@ hsa_status_t hsa_system_get_major_extension_table(uint16_t extension, uint16_t v + return HSA_STATUS_SUCCESS; + } + +- if (extension == HSA_EXTENSION_AMD_AQLPROFILE) { ++ if (0) { + if (version_major != hsa_ven_amd_aqlprofile_VERSION_MAJOR) { + debug_print("aqlprofile API incompatible ver %d, current ver %d\n", + version_major, hsa_ven_amd_aqlprofile_VERSION_MAJOR); diff --git a/pkgs/development/rocm-modules/10/rocm-smi/default.nix b/pkgs/development/rocm-modules/10/rocm-smi/default.nix new file mode 100644 index 0000000000000..ad53094199161 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocm-smi/default.nix @@ -0,0 +1,78 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + pkg-config, + libdrm, + cmake, + wrapPython, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocm-smi"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-systems"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocm-smi-lib" + "shared" + ]; + hash = "sha256-Si8SbeVKUBtqk6h2QJ9ssQV68bLq6TvESrYXJuArHd8="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rocm-smi-lib"; + + __structuredAttrs = true; + strictDeps = true; + + propagatedBuildInputs = [ + libdrm + ]; + + nativeBuildInputs = [ + cmake + wrapPython + pkg-config + ]; + + cmakeFlags = [ + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") + (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") + (lib.cmakeFeature "CMAKE_INSTALL_LIBEXECDIR" "libexec") + (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") + ]; + + postInstall = + # wrap python programs, but undo two that need to be importable at that path + '' + wrapPythonProgramsIn $out + mv $out/libexec/rocm_smi/.rsmiBindingsInit.py-wrapped $out/libexec/rocm_smi/rsmiBindingsInit.py + mv $out/libexec/rocm_smi/.rsmiBindings.py-wrapped $out/libexec/rocm_smi/rsmiBindings.py + '' + # workaround: propagate libdrm/ manually + # rocm-toolchain doesn't automatically add buildInputs to isystem include path like + # wrapper based toolchains, cmake files often don't find_package(rocm-smi) so + # can't rely on cmake propagated interface + # upstream have been shipping libdrm copied into /opt/rocm + + '' + ln -s ${libdrm.dev}/include/libdrm/ $out/include/ + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "System management interface for AMD GPUs supported by ROCm"; + homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/rocm-smi-lib"; + changelog = "https://github.com/ROCm/rocm-systems/releases/tag/${finalAttrs.src.tag}"; + license = lib.licenses.mit; + mainProgram = "rocm-smi"; + maintainers = with lib.maintainers; [ lovesegfault ]; + teams = [ lib.teams.rocm ]; + platforms = [ "x86_64-linux" ]; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocminfo/default.nix b/pkgs/development/rocm-modules/10/rocminfo/default.nix new file mode 100644 index 0000000000000..1cfbe4ddc9b7e --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocminfo/default.nix @@ -0,0 +1,57 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + rocm-runtime, + busybox, + python3, + gnugrep, +}: + +stdenv.mkDerivation (finalAttrs: { + version = "7.2.4"; + pname = "rocminfo"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-systems"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocminfo" + "shared" + ]; + hash = "sha256-0esRBEXVibC2uzyonpc0ABNNHQ2NAWZrBmmg6p1zP0c="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rocminfo"; + + strictDeps = true; + + nativeBuildInputs = [ + cmake + rocm-cmake + python3 + ]; + + buildInputs = [ rocm-runtime ]; + cmakeFlags = [ "-DROCRTST_BLD_TYPE=Release" ]; + + prePatch = '' + patchShebangs rocm_agent_enumerator + sed 's,lsmod | grep ,${busybox}/bin/lsmod | ${gnugrep}/bin/grep ,' -i rocminfo.cc + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "ROCm Application for Reporting System Info"; + homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/rocminfo"; + license = lib.licenses.ncsa; + mainProgram = "rocminfo"; + maintainers = with lib.maintainers; [ lovesegfault ]; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocprofiler-register/default.nix b/pkgs/development/rocm-modules/10/rocprofiler-register/default.nix new file mode 100644 index 0000000000000..710985790d708 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprofiler-register/default.nix @@ -0,0 +1,97 @@ +{ + lib, + stdenv, + numactl, + libpciaccess, + libxml2, + elfutils, + glog, + fmt, + fetchFromGitHub, + rocmUpdateScript, + cmake, + clang, + python3Packages, + fetchpatch, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocprofiler-register"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-systems"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocprofiler-register" + "shared" + ]; + hash = "sha256-XhxED3LHIjxBcSVyyEC3pgg0fyKyfKtHkF7umExSboM="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rocprofiler-register"; + + patches = [ + (fetchpatch { + # [rocprofiler-sdk][rocprofiler-register] add CPackComponent + url = "https://github.com/ROCm/rocm-systems/commit/ef7253365c420ca486f074b9e9119a222e30fea0.patch"; + hash = "sha256-dwqvZ4AaTcOk2mSnxgHp/NbhjlD8W6KVz1H5ZF4i/Tw="; + relative = "projects/rocprofiler-register"; + }) + (fetchpatch { + # [rocprofiler-register] Fix compilation with system fmt/glog + url = "https://github.com/ROCm/rocm-systems/commit/c8ad2522083c6e00539ce5c1c22df766c20084fb.patch"; + hash = "sha256-VloRKV6kUzIfIInltx/bV1EM0FUfeQZrVAx6qgdsLyg="; + relative = "projects/rocprofiler-register"; + }) + (fetchpatch { + # fix(rocprofiler-sdk): include fmt/format.h instead of fmt/core.h for fmt::format + # fmt 12.2.0 changes the meaning of fmt/core.h so it no longer includes + # fmt::format, so this upstream commit switches to the correct header. + url = "https://github.com/ROCm/rocm-systems/commit/e2f588592ecfb0653ed5b3078753186325adf70a.patch"; + hash = "sha256-ip/s7tmUptcXMen3fyQJYKiZKwoe3SH0XqTVb0YBA7k="; + relative = "projects/rocprofiler-register"; + }) + ]; + + nativeBuildInputs = [ + cmake + clang + ]; + + buildInputs = [ + numactl + libpciaccess + libxml2 + elfutils + glog + fmt + + python3Packages.lxml + python3Packages.cppheaderparser + python3Packages.pyyaml + python3Packages.barectf + python3Packages.pandas + ]; + cmakeFlags = [ + "-DROCPROFILER_REGISTER_BUILD_TESTS=0" + "-DROCPROFILER_REGISTER_BUILD_SAMPLES=0" + "-DROCPROFILER_REGISTER_BUILD_GLOG=OFF" + "-DROCPROFILER_REGISTER_BUILD_FMT=OFF" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ]; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "Profiling with perf-counters and derived metrics"; + homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/rocprofiler-register"; + license = lib.licenses.mit; # mitx11 + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/roctracer/default.nix b/pkgs/development/rocm-modules/10/roctracer/default.nix new file mode 100644 index 0000000000000..6cc979eb3648e --- /dev/null +++ b/pkgs/development/rocm-modules/10/roctracer/default.nix @@ -0,0 +1,118 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + clr, + rocm-device-libs, + libxml2, + doxygen, + graphviz, + gcc-unwrapped, + libbacktrace, + rocm-runtime, + python3Packages, + buildDocs ? false, # Nothing seems to be generated, so not making the output + buildTests ? false, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "roctracer"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildDocs [ + "doc" + ] + ++ lib.optionals buildTests [ + "test" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-systems"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/roctracer" + "shared" + ]; + hash = "sha256-Ps9b/MMdxXthGV96ZDg0kZGPdmn7Sy5if1a/Fjx2fEE="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/roctracer"; + + nativeBuildInputs = [ + cmake + clr + ] + ++ lib.optionals buildDocs [ + doxygen + graphviz + ]; + + buildInputs = [ + libxml2 + libbacktrace + python3Packages.python + python3Packages.cppheaderparser + ]; + + cmakeFlags = [ + "-DCMAKE_MODULE_PATH=${clr}/hip/cmake" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ]; + + env.NIX_CFLAGS_COMPILE = toString [ + # Needed with GCC 12 + "-Wno-error=array-bounds" + ]; + + postPatch = '' + export HIP_DEVICE_LIB_PATH=${rocm-device-libs}/amdgcn/bitcode + '' + + lib.optionalString (!buildTests) '' + substituteInPlace CMakeLists.txt \ + --replace "add_subdirectory(test)" "" + ''; + + # Tests always fail, probably need GPU + # doCheck = buildTests; + + postInstall = + lib.optionalString buildDocs '' + mkdir -p $doc + '' + + lib.optionalString buildTests '' + mkdir -p $test/bin + # Not sure why this is an install target + find $out/test -executable -type f -exec mv {} $test/bin \; + rm $test/bin/{*.sh,*.py} + patchelf --set-rpath $out/lib:${ + lib.makeLibraryPath ( + finalAttrs.buildInputs + ++ [ + clr + gcc-unwrapped.lib + rocm-runtime + ] + ) + } $test/bin/* + rm -rf $out/test + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "Tracer callback/activity library"; + homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/roctracer"; + license = lib.licenses.mit; # mitx11 + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) From 33512497088ff39fd3b29c4b30758fe0859d9ed5 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:41 -0700 Subject: [PATCH 08/79] rocmPackages_10: share hipcc, rocm-docs-core with rocmPackages hipcc, rocm-docs-core are unchanged between ROCm 7.2.4 and 10.1 (no 10.x upstream release, or versioned independently of ROCm), so the rocmPackages_10 scope calls the existing expression instead of copying it. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 07d5e6bca5694..22be4a41f52ed 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -2,6 +2,7 @@ lib, callPackage, newScope, + python3Packages, stdenv, }: @@ -10,6 +11,7 @@ let self: let inherit (self) llvm; + origStdenv = stdenv; rocmClangStdenv = llvm.rocmClangStdenv; in { @@ -36,6 +38,10 @@ let inherit (self.llvm) rocm-toolchain clang openmp; rocm-device-libs = self.callPackage ./rocm-device-libs { }; + + rocm-docs-core = python3Packages.callPackage ../rocm-docs-core { }; + + hipcc = self.callPackage ../hipcc { stdenv = origStdenv; }; } ); in From 05c1a15114af3e0c05d96eef7f6babff5038cec0 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:42 -0700 Subject: [PATCH 09/79] rocmPackages_10.rocm-core: init at 10.1 Update the rocmPackages.rocm-core copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Revised during the split review: Report the padded version (10.1.0) in the setup hook as well, the three-part form 7.2.4 exported; ROCM_VERSION is only read from the environment as a CPack fallback in comgr and hipcc. Keep the version helper in the outer let. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ .../rocm-modules/10/rocm-core/default.nix | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 22be4a41f52ed..03cf5ad7aa6dc 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -37,6 +37,8 @@ let ); inherit (self.llvm) rocm-toolchain clang openmp; + rocm-core = self.callPackage ./rocm-core { stdenv = origStdenv; }; + rocm-device-libs = self.callPackage ./rocm-device-libs { }; rocm-docs-core = python3Packages.callPackage ../rocm-docs-core { }; diff --git a/pkgs/development/rocm-modules/10/rocm-core/default.nix b/pkgs/development/rocm-modules/10/rocm-core/default.nix index 861c6107935ee..d28c0668477bf 100644 --- a/pkgs/development/rocm-modules/10/rocm-core/default.nix +++ b/pkgs/development/rocm-modules/10/rocm-core/default.nix @@ -14,20 +14,22 @@ # only the last usage makes sense in nixpkgs let padIfSingle = s: if lib.stringLength s == 1 then "0${s}" else s; + # TheRock tags are two-component (therock-10.1); ROCm reports X.Y.Z. + rocmVersion = version: lib.versions.pad 3 version; in stdenv.mkDerivation (finalAttrs: { pname = "rocm-core"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/rocm-core" "shared" ]; - hash = "sha256-Y3WuDwruD5zKN2epwfUCZAGq5vgxCT27awJN8JxmOsY="; + hash = "sha256-3bEmFF4jivCslDINOTA5nIu1/nreGWZuIMYMxaUgd18="; }; sourceRoot = "${finalAttrs.src.name}/projects/rocm-core"; @@ -37,13 +39,13 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ cmake ]; env = { - ROCM_LIBPATCH_VERSION = "${lib.versions.major finalAttrs.version}${padIfSingle (lib.versions.minor finalAttrs.version)}${padIfSingle (lib.versions.patch finalAttrs.version)}"; + ROCM_LIBPATCH_VERSION = "${lib.versions.major (rocmVersion finalAttrs.version)}${padIfSingle (lib.versions.minor (rocmVersion finalAttrs.version))}${padIfSingle (lib.versions.patch (rocmVersion finalAttrs.version))}"; BUILD_ID = "nixpkgs-${finalAttrs.env.ROCM_LIBPATCH_VERSION}"; ROCM_BUILD_ID = "${finalAttrs.env.BUILD_ID}"; }; cmakeFlags = [ "-DROCM_LIBPATCH_VERSION=${finalAttrs.env.ROCM_LIBPATCH_VERSION}" - "-DROCM_VERSION=${finalAttrs.version}" + "-DROCM_VERSION=${rocmVersion finalAttrs.version}" "-DBUILD_ID=${finalAttrs.env.BUILD_ID}" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_LIBEXECDIR=libexec" @@ -52,7 +54,7 @@ stdenv.mkDerivation (finalAttrs: { ]; setupHook = writeText "setupHook.sh" '' - export ROCM_VERSION="${finalAttrs.version}" + export ROCM_VERSION="${rocmVersion finalAttrs.version}" export ROCM_LIBPATCH_VERSION="${finalAttrs.env.ROCM_LIBPATCH_VERSION}" export ROCM_BUILD_ID="${finalAttrs.env.ROCM_BUILD_ID}" ''; From 6019ee572f047cd827fc469970f74faa3afa1d96 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:43 -0700 Subject: [PATCH 10/79] rocmPackages_10.rocm-cmake: init at 10.1 Update the rocmPackages.rocm-cmake copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ pkgs/development/rocm-modules/10/rocm-cmake/default.nix | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 03cf5ad7aa6dc..0b51f8101a9f9 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -39,6 +39,8 @@ let rocm-core = self.callPackage ./rocm-core { stdenv = origStdenv; }; + rocm-cmake = self.callPackage ./rocm-cmake { stdenv = origStdenv; }; + rocm-device-libs = self.callPackage ./rocm-device-libs { }; rocm-docs-core = python3Packages.callPackage ../rocm-docs-core { }; diff --git a/pkgs/development/rocm-modules/10/rocm-cmake/default.nix b/pkgs/development/rocm-modules/10/rocm-cmake/default.nix index dac12d5d0fccc..1c0a5e4e7a220 100644 --- a/pkgs/development/rocm-modules/10/rocm-cmake/default.nix +++ b/pkgs/development/rocm-modules/10/rocm-cmake/default.nix @@ -9,13 +9,13 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocm-cmake"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-cmake"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-gY6jzIIN1pSXGbCMN6y35Q/VJgbIqWDRjD8aI/fc1L0="; + tag = "therock-${finalAttrs.version}"; + hash = "sha256-im6UO0crO0Jc27zkTsdvJYPHit8IGlw/vDPGrmP1XqY="; }; nativeBuildInputs = [ cmake ]; From b6a21406da3dbaef515d1b1d16c3ecee2c95b82f Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:43 -0700 Subject: [PATCH 11/79] rocmPackages_10.rocprofiler-register: init at 10.1 Update the rocmPackages.rocprofiler-register copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From the mass bump: - rocprofiler-register: drop 3 fetchpatches now upstream. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 3 ++ .../10/rocprofiler-register/default.nix | 29 ++----------------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 0b51f8101a9f9..037a55b1cb309 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -46,6 +46,9 @@ let rocm-docs-core = python3Packages.callPackage ../rocm-docs-core { }; hipcc = self.callPackage ../hipcc { stdenv = origStdenv; }; + rocprofiler-register = self.callPackage ./rocprofiler-register { + inherit (llvm) clang; + }; } ); in diff --git a/pkgs/development/rocm-modules/10/rocprofiler-register/default.nix b/pkgs/development/rocm-modules/10/rocprofiler-register/default.nix index 710985790d708..7effd89bd26fd 100644 --- a/pkgs/development/rocm-modules/10/rocprofiler-register/default.nix +++ b/pkgs/development/rocm-modules/10/rocprofiler-register/default.nix @@ -17,43 +17,20 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocprofiler-register"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/rocprofiler-register" "shared" ]; - hash = "sha256-XhxED3LHIjxBcSVyyEC3pgg0fyKyfKtHkF7umExSboM="; + hash = "sha256-/y+ZerbaSKyHfEttomNtmF5zccnpqsQFNw/5gjGBuyA="; }; sourceRoot = "${finalAttrs.src.name}/projects/rocprofiler-register"; - patches = [ - (fetchpatch { - # [rocprofiler-sdk][rocprofiler-register] add CPackComponent - url = "https://github.com/ROCm/rocm-systems/commit/ef7253365c420ca486f074b9e9119a222e30fea0.patch"; - hash = "sha256-dwqvZ4AaTcOk2mSnxgHp/NbhjlD8W6KVz1H5ZF4i/Tw="; - relative = "projects/rocprofiler-register"; - }) - (fetchpatch { - # [rocprofiler-register] Fix compilation with system fmt/glog - url = "https://github.com/ROCm/rocm-systems/commit/c8ad2522083c6e00539ce5c1c22df766c20084fb.patch"; - hash = "sha256-VloRKV6kUzIfIInltx/bV1EM0FUfeQZrVAx6qgdsLyg="; - relative = "projects/rocprofiler-register"; - }) - (fetchpatch { - # fix(rocprofiler-sdk): include fmt/format.h instead of fmt/core.h for fmt::format - # fmt 12.2.0 changes the meaning of fmt/core.h so it no longer includes - # fmt::format, so this upstream commit switches to the correct header. - url = "https://github.com/ROCm/rocm-systems/commit/e2f588592ecfb0653ed5b3078753186325adf70a.patch"; - hash = "sha256-ip/s7tmUptcXMen3fyQJYKiZKwoe3SH0XqTVb0YBA7k="; - relative = "projects/rocprofiler-register"; - }) - ]; - nativeBuildInputs = [ cmake clang From 05b4e342ae88e138e097d5c26044f8cf66b14adf Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:44 -0700 Subject: [PATCH 12/79] rocmPackages_10.rocm-runtime: init at 10.1 Update the rocmPackages.rocm-runtime copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.rocm-runtime: drop patches upstreamed in ROCr 1.21": ROCm 10 ships ROCr 1.21, which carries the queue-failure fix (PR #2850), the kfd_ioctl 1<<31 UB fix, and refactors aqlprofile to a runtime dlopen (removing the build-time circular dependency). Drop the three now-obsolete patches and add python3 for the new trap_handler find_package(Python3). Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 4 ++ .../rocm-modules/10/rocm-runtime/default.nix | 20 ++---- .../10/rocm-runtime/queue-failure.patch | 71 ------------------- .../remove-hsa-aqlprofile-dep.patch | 27 ------- 4 files changed, 9 insertions(+), 113 deletions(-) delete mode 100644 pkgs/development/rocm-modules/10/rocm-runtime/queue-failure.patch delete mode 100644 pkgs/development/rocm-modules/10/rocm-runtime/remove-hsa-aqlprofile-dep.patch diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 037a55b1cb309..a4b612431bb56 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -43,6 +43,10 @@ let rocm-device-libs = self.callPackage ./rocm-device-libs { }; + rocm-runtime = self.callPackage ./rocm-runtime { + stdenv = origStdenv; + }; + rocm-docs-core = python3Packages.callPackage ../rocm-docs-core { }; hipcc = self.callPackage ../hipcc { stdenv = origStdenv; }; diff --git a/pkgs/development/rocm-modules/10/rocm-runtime/default.nix b/pkgs/development/rocm-modules/10/rocm-runtime/default.nix index 255fce0eb24ec..4bcecc40cd034 100644 --- a/pkgs/development/rocm-modules/10/rocm-runtime/default.nix +++ b/pkgs/development/rocm-modules/10/rocm-runtime/default.nix @@ -6,6 +6,7 @@ rocmUpdateScript, pkg-config, cmake, + python3, xxd, rocm-device-libs, rocprofiler-register, @@ -17,17 +18,17 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocm-runtime"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/rocr-runtime" "shared" ]; - hash = "sha256-hcyjOLMtoBX/p6r6R9Bl9635DuvI6rTn1KziHMeyYM0="; + hash = "sha256-fY6/ofaZe94ZK7An6bSHcLj0T92OCQCflnBk5onVzzo="; }; sourceRoot = "${finalAttrs.src.name}/projects/rocr-runtime"; @@ -39,6 +40,7 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ pkg-config cmake + python3 # trap_handler/CMakeLists.txt: find_package(Python3 Interpreter) xxd # used by create_hsaco_ascii_file.sh llvm.rocm-toolchain ]; @@ -60,24 +62,12 @@ stdenv.mkDerivation (finalAttrs: { ]; patches = [ - # Vendored upstream PR for fix for segfault when queue allocation fails - # https://github.com/ROCm/rocm-systems/pull/2850 - ./queue-failure.patch (fetchpatch { # [PATCH] rocr: Extend HIP ISA compatibility check hash = "sha256-8r2Lb5lBfFaZC3knCxfXGcnkzNv6JxOKyJn2rD5gus4="; url = "https://github.com/GZGavinZhao/rocm-systems/commit/dcef23cf896f4dcbc7ed81abeaa4ec2208dcdd8c.patch"; relative = "projects/rocr-runtime"; }) - (fetchpatch { - # [PATCH] kfd_ioctl: fix UB due to 1 << 31 - url = "https://github.com/ROCm/ROCR-Runtime/commit/41bfc66aef437a5b349f71105fa4b907cc7e17d5.patch"; - hash = "sha256-A7VhPR3eSsmjq2cTBSjBIz9i//WiNjoXm0EsRKtF+ns="; - }) - # This causes a circular dependency, aqlprofile relies on hsa-runtime64 - # which is part of rocm-runtime - # Worked around by having rocprofiler load aqlprofile directly - ./remove-hsa-aqlprofile-dep.patch ]; postPatch = '' diff --git a/pkgs/development/rocm-modules/10/rocm-runtime/queue-failure.patch b/pkgs/development/rocm-modules/10/rocm-runtime/queue-failure.patch deleted file mode 100644 index f9087144bc229..0000000000000 --- a/pkgs/development/rocm-modules/10/rocm-runtime/queue-failure.patch +++ /dev/null @@ -1,71 +0,0 @@ -From b7717446c85d08b2d7c0c60ba3ac0eff11ee6120 Mon Sep 17 00:00:00 2001 -From: Luna Nova -Date: Tue, 20 Jan 2026 12:55:45 -0800 -Subject: [PATCH 1/2] rocm-runtime: fix crash in QueueCreate due to trying to - free non allocated scratch - -if (scratch.main_queue_base != nullptr) before calling ReleaseQueueMainScratch -because ReleaseQueueMainScratch is only valid if main_queue_base is set -and the scope guard can fire for an error allocating the queue. ---- - .../runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -index 01b01fe869..83db40dacc 100644 ---- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -+++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -@@ -1792,7 +1792,9 @@ hsa_status_t GpuAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type, u - scratch.main_queue_base = nullptr; - scratch.main_queue_process_offset = 0; - -- MAKE_NAMED_SCOPE_GUARD(scratchGuard, [&]() { ReleaseQueueMainScratch(scratch); }); -+ MAKE_NAMED_SCOPE_GUARD(scratchGuard, [&]() { -+ if (scratch.main_queue_base != nullptr) ReleaseQueueMainScratch(scratch); -+ }); - - if (scratch.main_size != 0) { - AcquireQueueMainScratch(scratch); --- -2.52.0 - - -From 9c1746cd76a703e4d2321dc2ffe85fc61bfd2f21 Mon Sep 17 00:00:00 2001 -From: Luna Nova -Date: Tue, 20 Jan 2026 13:00:32 -0800 -Subject: [PATCH 2/2] rocm-runtime: log for errors in QueueCreate - ---- - .../runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -diff --git a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -index 83db40dacc..ae68732eb5 100644 ---- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -+++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -@@ -1799,6 +1799,9 @@ hsa_status_t GpuAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type, u - if (scratch.main_size != 0) { - AcquireQueueMainScratch(scratch); - if (scratch.main_queue_base == nullptr) { -+ LogPrint(HSA_AMD_LOG_FLAG_INFO, -+ "Failed to allocate scratch memory for queue, size=%zu, node=%u", -+ scratch.main_size, node_id()); - return HSA_STATUS_ERROR_OUT_OF_RESOURCES; - } - } -@@ -1827,7 +1830,11 @@ hsa_status_t GpuAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type, u - node_id())); - } - -- if (!shared_queue) return HSA_STATUS_ERROR_OUT_OF_RESOURCES; -+ if (!shared_queue) { -+ LogPrint(HSA_AMD_LOG_FLAG_INFO, -+ "Failed to allocate shared queue descriptor memory, node=%u", node_id()); -+ return HSA_STATUS_ERROR_OUT_OF_RESOURCES; -+ } - - auto aql_queue = new AqlQueue(shared_queue, this, size, node_id(), scratch, event_callback, data, - flags); --- -2.52.0 - diff --git a/pkgs/development/rocm-modules/10/rocm-runtime/remove-hsa-aqlprofile-dep.patch b/pkgs/development/rocm-modules/10/rocm-runtime/remove-hsa-aqlprofile-dep.patch deleted file mode 100644 index b8ed57d049bc9..0000000000000 --- a/pkgs/development/rocm-modules/10/rocm-runtime/remove-hsa-aqlprofile-dep.patch +++ /dev/null @@ -1,27 +0,0 @@ -libhsa-amd-aqlprofile64 library is unfree -Bug: https://github.com/ROCm/ROCm/issues/1781 ---- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -+++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -@@ -1333,11 +1333,6 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const { - setFlag(HSA_EXTENSION_AMD_PC_SAMPLING); - } - -- if (os::LibHandle lib = os::LoadLib(kAqlProfileLib)) { -- os::CloseLib(lib); -- setFlag(HSA_EXTENSION_AMD_AQLPROFILE); -- } -- - setFlag(HSA_EXTENSION_AMD_PROFILER); - - break; ---- a/runtime/hsa-runtime/core/runtime/hsa.cpp -+++ b/runtime/hsa-runtime/core/runtime/hsa.cpp -@@ -490,7 +490,7 @@ hsa_status_t hsa_system_get_major_extension_table(uint16_t extension, uint16_t v - return HSA_STATUS_SUCCESS; - } - -- if (extension == HSA_EXTENSION_AMD_AQLPROFILE) { -+ if (0) { - if (version_major != hsa_ven_amd_aqlprofile_VERSION_MAJOR) { - debug_print("aqlprofile API incompatible ver %d, current ver %d\n", - version_major, hsa_ven_amd_aqlprofile_VERSION_MAJOR); From 3ae4d90afecc56eb4972e11fd0442e1dc9345782 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:44 -0700 Subject: [PATCH 13/79] rocmPackages_10.rocm-comgr: init at 24.0.0-rocm Update the rocmPackages.rocm-comgr copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.rocm-comgr: rebase ISA-compat CCOB patch for LLVM 24": The "[Comgr] Extend ISA compatibility for CCOB" change (GZGavinZhao 2c1e44fc) no longer applies as a fetchpatch: LLVM 24's comgr inserted comgr-unpackage-command.h into comgr-compiler.cpp's include block (shifting the comgr-metadata.h include past patch's default fuzz) and moved the unbundle() body ~477 lines down. Rebase it locally as comgr-isa-compat-ccob.patch against therock-10.1. The OffloadBundler::GetBundleIDsInFile it calls is provided clang-side by clang-add-getbundleidsinfile.diff in the llvm module. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 + .../10/rocm-comgr/comgr-isa-compat-ccob.patch | 97 +++++++++++++++++++ .../rocm-modules/10/rocm-comgr/default.nix | 14 +-- 3 files changed, 106 insertions(+), 7 deletions(-) create mode 100644 pkgs/development/rocm-modules/10/rocm-comgr/comgr-isa-compat-ccob.patch diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index a4b612431bb56..16120eabf2833 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -47,6 +47,8 @@ let stdenv = origStdenv; }; + rocm-comgr = self.callPackage ./rocm-comgr { }; + rocm-docs-core = python3Packages.callPackage ../rocm-docs-core { }; hipcc = self.callPackage ../hipcc { stdenv = origStdenv; }; diff --git a/pkgs/development/rocm-modules/10/rocm-comgr/comgr-isa-compat-ccob.patch b/pkgs/development/rocm-modules/10/rocm-comgr/comgr-isa-compat-ccob.patch new file mode 100644 index 0000000000000..f2c93adf45a26 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocm-comgr/comgr-isa-compat-ccob.patch @@ -0,0 +1,97 @@ +--- a/src/comgr-compiler.cpp ++++ b/src/comgr-compiler.cpp +@@ -20,6 +20,7 @@ + #include "comgr-diagnostic-handler.h" + #include "comgr-env.h" + #include "comgr-libcxx-headers.h" ++#include "comgr-metadata.h" + #include "comgr-resource-directory.h" + #include "comgr-spirv-command.h" + #include "comgr-unbundle-command.h" +@@ -1855,17 +1856,72 @@ + size_t Index = OutputPrefix.find_last_of("."); + OutputPrefix = OutputPrefix.substr(0, Index); + ++ std::set CoEntryIds; ++ if (auto Error = OffloadBundler::GetBundleIDsInFile(InputFilePath, BundlerConfig, CoEntryIds)) { ++ if (env::shouldEmitVerboseLogs()) { ++ LogS << "Failed to get bundle IDs in " ++ << InputFilePath ++ << ", not trying to coerce compatible archs\n"; ++ LogS.flush(); ++ } ++ } ++ std::set> entry_ids_with_idents; ++ for (const auto& CoEntryId : CoEntryIds) { ++ std::string TargetIdent; ++ size_t Pos = std::string::npos; ++ for (const auto& Prefix : {"hipv4-", "hip-"}) { ++ if ((Pos = CoEntryId.find(Prefix)) == 0) { ++ TargetIdent = CoEntryId.substr(std::char_traits::length(Prefix)); ++ break; ++ } ++ } ++ ++ if (TargetIdent.empty()) { ++ continue; ++ } ++ ++ entry_ids_with_idents.emplace(CoEntryId, TargetIdent); ++ } ++ ++ // Bundler target and output names + for (StringRef Entry : ActionInfo->BundleEntryIDs) { ++ std::string CompatEntry = Entry.str(); ++ ++ std::string EntryIdent; ++ size_t Pos = std::string::npos; ++ for (const auto& Prefix : {"hipv4-", "hip-"}) { ++ if ((Pos = Entry.find(Prefix)) == 0) { ++ EntryIdent = Entry.substr(std::char_traits::length(Prefix)); ++ break; ++ } ++ } ++ ++ if (!EntryIdent.empty()) { ++ std::string BestEntry; ++ for (const auto& [CoEntry, CoIdent] : entry_ids_with_idents) { ++ if (EntryIdent == CoIdent) { ++ BestEntry = CoEntry; ++ break; ++ } else if (metadata::isCompatibleIsaName(EntryIdent, CoIdent)) { ++ BestEntry = CoEntry; ++ } ++ } ++ ++ if (!BestEntry.empty()) { ++ CompatEntry = BestEntry; ++ } ++ } ++ + // Add an output file for each target + SmallString<128> OutputFilePath = OutputDir; + sys::path::append(OutputFilePath, +- OutputPrefix + "-" + Entry + "." + FileExtension); ++ OutputPrefix + "-" + CompatEntry + "." + FileExtension); + +- BundlerConfig.TargetNames.emplace_back(Entry); ++ BundlerConfig.TargetNames.emplace_back(CompatEntry); + BundlerConfig.OutputFileNames.emplace_back(OutputFilePath); + + if (env::shouldEmitVerboseLogs()) { +- LogS << "\tBundle Entry ID: " << Entry << "\n" ++ LogS << "\tBundle (Compat)Entry ID: " << CompatEntry << "\n" + << "\tOutput Filename: " << OutputFilePath << "\n"; + LogS.flush(); + } +--- a/src/comgr-metadata.h ++++ b/src/comgr-metadata.h +@@ -37,6 +37,8 @@ + + bool isValidIsaName(llvm::StringRef IsaName); + ++bool isCompatibleIsaName(llvm::StringRef IsaName, llvm::StringRef CodeObjectIsaName); ++ + amd_comgr_status_t getElfIsaName(DataObject *DataP, std::string &IsaName); + + amd_comgr_status_t lookUpCodeObject(DataObject *DataP, diff --git a/pkgs/development/rocm-modules/10/rocm-comgr/default.nix b/pkgs/development/rocm-modules/10/rocm-comgr/default.nix index e7663a1f7130a..fa6640d5c1f33 100644 --- a/pkgs/development/rocm-modules/10/rocm-comgr/default.nix +++ b/pkgs/development/rocm-modules/10/rocm-comgr/default.nix @@ -34,12 +34,12 @@ stdenv.mkDerivation (finalAttrs: { url = "https://github.com/GZGavinZhao/rocm-llvm-project/commit/7002dc04863d38c57cfd2e6fc60a1cf5a613fd8e.patch"; relative = "amd/comgr"; }) - # [Comgr] Extend ISA compatibility for CCOB - (fetchpatch { - hash = "sha256-/50I+PqxL3oaQMqg5vR7+ibUcXO1SvfXBdw/sybRt1o="; - url = "https://github.com/GZGavinZhao/rocm-llvm-project/commit/2c1e44fc3eacadcafdd4ada3e3184a092b6f26c5.patch"; - relative = "amd/comgr"; - }) + # [Comgr] Extend ISA compatibility for CCOB. + # Rebased from GZGavinZhao/rocm-llvm-project 2c1e44fc onto the LLVM 24 comgr + # (comgr-compiler.cpp's include block and unbundle() body moved). The + # OffloadBundler::GetBundleIDsInFile it calls is provided by the clang-side + # clang-add-getbundleidsinfile.diff in the llvm module. + ./comgr-isa-compat-ccob.patch # Fix: CCOB compat patch used coerced (featureless) name for output filename, # causing CLR's code_obj_map key to miss when looking up device ISA with features ./fix-ccob-compat-output-filename.patch @@ -55,7 +55,7 @@ stdenv.mkDerivation (finalAttrs: { + '' substituteInPlace src/comgr-env.cpp \ --replace-fail \ - 'return EnvLLVMPath;' \ + 'return EnvLLVMPath ? EnvLLVMPath : "";' \ 'return EnvLLVMPath ? EnvLLVMPath : "${llvm.rocm-toolchain}";' ''; From 3166d74391bf7f6e5927fbe524106df793195699 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:45 -0700 Subject: [PATCH 14/79] rocmPackages_10.rocminfo: init at 10.1 Update the rocmPackages.rocminfo copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ pkgs/development/rocm-modules/10/rocminfo/default.nix | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 16120eabf2833..834bdb6efef81 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -49,6 +49,8 @@ let rocm-comgr = self.callPackage ./rocm-comgr { }; + rocminfo = self.callPackage ./rocminfo { stdenv = origStdenv; }; + rocm-docs-core = python3Packages.callPackage ../rocm-docs-core { }; hipcc = self.callPackage ../hipcc { stdenv = origStdenv; }; diff --git a/pkgs/development/rocm-modules/10/rocminfo/default.nix b/pkgs/development/rocm-modules/10/rocminfo/default.nix index 1cfbe4ddc9b7e..2da6d54f403de 100644 --- a/pkgs/development/rocm-modules/10/rocminfo/default.nix +++ b/pkgs/development/rocm-modules/10/rocminfo/default.nix @@ -12,18 +12,18 @@ }: stdenv.mkDerivation (finalAttrs: { - version = "7.2.4"; + version = "10.1"; pname = "rocminfo"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/rocminfo" "shared" ]; - hash = "sha256-0esRBEXVibC2uzyonpc0ABNNHQ2NAWZrBmmg6p1zP0c="; + hash = "sha256-oK9fUtHb2qvFTpQ/9KE6LfiopDUvoreApZtsDb9aGvA="; }; sourceRoot = "${finalAttrs.src.name}/projects/rocminfo"; From d35f8f2e1bc82c7afd79a0e87ae9c5efdc7c1c3d Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:46 -0700 Subject: [PATCH 15/79] rocmPackages_10.amdsmi: init at 10.1 Update the rocmPackages.amdsmi copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.amdsmi: adapt to 27.0.0 ABI": amdsmi 27.0.0 (SONAME libamd_smi.so.27) requires libnl-3/libnl-genl-3 and libmnl; add them. py-interface/CMakeLists.txt now FATAL_ERRORs at configure time if it cannot locate a system python3 (it probes /usr/bin/python3 and /usr/libexec/platform-python, neither in the sandbox) unless AMDSMI_SYSTEM_PYTHON_SITELIB is set. The install it guards is DESTDIR-gated (nix uses CMAKE_INSTALL_PREFIX) and thus skipped anyway, so pass nix's sitePackages to satisfy the guard. Revised during the split review: Drop the drm_color_ctm_3x4 patch: amdsmi 10.1 builds without it against libdrm 2.4.134, whose drm_mode.h shares the bundled copy's include guard. Pin esmi_ib_library by the commit amdsmi pins. Link libamd_smi.so with -Bsymbolic-functions: with librocm_smi64 loaded (as after import torch) its exported rsmi_init was interposed and amdsmi enumerated no GPUs, so torch.cuda.device_count() was 0. Assisted-by: Claude Code (claude-opus-5-5) --- .../rocm-modules/10/amdsmi/default.nix | 40 ++++++++++--------- .../amdsmi/drm-struct-redefinition-fix.patch | 35 ---------------- pkgs/development/rocm-modules/10/default.nix | 5 +++ 3 files changed, 27 insertions(+), 53 deletions(-) delete mode 100644 pkgs/development/rocm-modules/10/amdsmi/drm-struct-redefinition-fix.patch diff --git a/pkgs/development/rocm-modules/10/amdsmi/default.nix b/pkgs/development/rocm-modules/10/amdsmi/default.nix index d483dde8b6e8a..abb1ecd74e48e 100644 --- a/pkgs/development/rocm-modules/10/amdsmi/default.nix +++ b/pkgs/development/rocm-modules/10/amdsmi/default.nix @@ -6,62 +6,57 @@ cmake, pkg-config, libdrm, + libnl, + libmnl, python, wrapPython, autoPatchelfHook, + binutils, }: let esmi_ib_src = fetchFromGitHub { owner = "amd"; repo = "esmi_ib_library"; - tag = "esmi_pkg_ver-4.2"; - hash = "sha256-czF9ezkAO0PuDkXh8y639AcOZH+KVcWiXPX74H5W/nw="; + # The commit amdsmi pins (tag esmi_pkg_ver-5.2.1.1) + rev = "d494a3194ceb4cc4dbb2debf9fcbe8773c6d3bef"; + hash = "sha256-StSYzyIujaH8UJIRpfJC0lf+oVT9fWflJgQONvRqu70="; }; in stdenv.mkDerivation (finalAttrs: { pname = "amdsmi"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/amdsmi" "shared" ]; - hash = "sha256-TFi+3txemvV6K827e8S3hZOd9jcj4Qzop6V9CdKrpLg="; + hash = "sha256-CmCVPmqgU0HtqIBuJUs+Nr7LRKtngOaNNsWFek9Nino="; }; sourceRoot = "${finalAttrs.src.name}/projects/amdsmi"; postPatch = '' - substituteInPlace goamdsmi_shim/CMakeLists.txt \ - --replace-fail "amd_smi)" ${"'"}''${AMD_SMI_TARGET})' \ - --replace-fail 'target_link_libraries(''${GOAMDSMI_SHIM_TARGET} -L' '#' - substituteInPlace CMakeLists.txt \ - --replace-fail "if(NOT latest_esmi_tag STREQUAL current_esmi_tag)" "if(OFF)" - - # Manually unpack esmi_ib_src and add amd_hsmp.h so execute-process git clone doesn't run + # Pre-populate esmi_ib_library so CMake does not FetchContent it. cp -rf --no-preserve=mode ${esmi_ib_src} ./esmi_ib_library mkdir -p ./esmi_ib_library/include/asm cp ./include/amd_smi/impl/amd_hsmp.h ./esmi_ib_library/include/asm/amd_hsmp.h ''; - patches = [ - # Fix error: redefinition of 'struct drm_color_ctm_3x4' - # https://github.com/ROCm/amdsmi/pull/165 - ./drm-struct-redefinition-fix.patch - ]; - nativeBuildInputs = [ cmake pkg-config wrapPython autoPatchelfHook + binutils # CMake resolves link-lib SONAMEs via `objdump -p` ]; buildInputs = [ libdrm + libnl # pkg_check_modules libnl-3.0 + libnl-genl-3.0 + libmnl # pkg_check_modules libmnl ]; cmakeFlags = [ @@ -70,6 +65,15 @@ stdenv.mkDerivation (finalAttrs: { "-DCMAKE_INSTALL_BINDIR=bin" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_INCLUDEDIR=include" + # py-interface/CMakeLists.txt fails without a system python3 unless this is set. + "-DAMDSMI_SYSTEM_PYTHON_SITELIB=${placeholder "out"}/${python.sitePackages}" + # libamd_smi.so still exports rsmi_init, and its own call to it goes + # through the PLT. Once librocm_smi64 is loaded globally (torch's + # libtorch_hip needs it), that call binds to rocm_smi's copy, amdsmi's own + # state is never initialised, and enumeration returns no processors: + # torch.cuda.device_count() is then 0. Upstream links only the wheel's + # libamd_smi_python.so this way; do the same for the system library. + "-DCMAKE_SHARED_LINKER_FLAGS=-Wl,-Bsymbolic-functions" ]; postInstall = '' diff --git a/pkgs/development/rocm-modules/10/amdsmi/drm-struct-redefinition-fix.patch b/pkgs/development/rocm-modules/10/amdsmi/drm-struct-redefinition-fix.patch deleted file mode 100644 index caf23edcef57a..0000000000000 --- a/pkgs/development/rocm-modules/10/amdsmi/drm-struct-redefinition-fix.patch +++ /dev/null @@ -1,35 +0,0 @@ -From b8b4a6bcfe35ba9539a120cfd16573123ddd9241 Mon Sep 17 00:00:00 2001 -From: "Sv. Lockal" -Date: Mon, 15 Dec 2025 03:46:35 +0800 -Subject: [PATCH] Fix compilation with libdrm-2.4.130 - -Fix error: redefinition of 'struct drm_color_ctm_3x4'. - -drm_color_ctm_3x4 structure is now defined in https://github.com/torvalds/linux/commit/e5719e7f19009d4fbedf685fc22eec9cd8de154f#diff-4c51fb416ec7cc69566cd7b795ee57eb070aa1006ad65d6962081f039ffb2718 - -As this structure is unused and not a part of amdsmi public interface, -it is safe to remove it. ---- - include/amd_smi/impl/amdgpu_drm.h | 9 --------- - 1 file changed, 9 deletions(-) - -diff --git a/include/amd_smi/impl/amdgpu_drm.h b/include/amd_smi/impl/amdgpu_drm.h -index b56a5ac4b..0e483d13b 100644 ---- a/include/amd_smi/impl/amdgpu_drm.h -+++ b/include/amd_smi/impl/amdgpu_drm.h -@@ -1625,15 +1625,6 @@ struct drm_amdgpu_info_uq_metadata { - #define AMDGPU_FAMILY_GC_11_5_0 150 /* GC 11.5.0 */ - #define AMDGPU_FAMILY_GC_12_0_0 152 /* GC 12.0.0 */ - --/* FIXME wrong namespace! */ --struct drm_color_ctm_3x4 { -- /* -- * Conversion matrix with 3x4 dimensions in S31.32 sign-magnitude -- * (not two's complement!) format. -- */ -- __u64 matrix[12]; --}; -- - #if defined(__cplusplus) - } - #endif diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 834bdb6efef81..486046756902b 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -12,6 +12,7 @@ let let inherit (self) llvm; origStdenv = stdenv; + pyPackages = python3Packages; rocmClangStdenv = llvm.rocmClangStdenv; in { @@ -51,6 +52,10 @@ let rocminfo = self.callPackage ./rocminfo { stdenv = origStdenv; }; + amdsmi = pyPackages.callPackage ./amdsmi { + inherit (self) rocmUpdateScript; + }; + rocm-docs-core = python3Packages.callPackage ../rocm-docs-core { }; hipcc = self.callPackage ../hipcc { stdenv = origStdenv; }; From b592665fb563656d7eb8de0ff7eb2286982be77a Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:46 -0700 Subject: [PATCH 16/79] rocmPackages_10.rocm-smi: init at 10.1 Update the rocmPackages.rocm-smi copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 4 ++++ pkgs/development/rocm-modules/10/rocm-smi/default.nix | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 486046756902b..b96aa6b235f13 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -56,6 +56,10 @@ let inherit (self) rocmUpdateScript; }; + rocm-smi = pyPackages.callPackage ./rocm-smi { + inherit (self) rocmUpdateScript; + }; + rocm-docs-core = python3Packages.callPackage ../rocm-docs-core { }; hipcc = self.callPackage ../hipcc { stdenv = origStdenv; }; diff --git a/pkgs/development/rocm-modules/10/rocm-smi/default.nix b/pkgs/development/rocm-modules/10/rocm-smi/default.nix index ad53094199161..35fc58c037bfa 100644 --- a/pkgs/development/rocm-modules/10/rocm-smi/default.nix +++ b/pkgs/development/rocm-modules/10/rocm-smi/default.nix @@ -11,17 +11,17 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocm-smi"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/rocm-smi-lib" "shared" ]; - hash = "sha256-Si8SbeVKUBtqk6h2QJ9ssQV68bLq6TvESrYXJuArHd8="; + hash = "sha256-t5yMLdDaylgdhreVzWBmhY5rFvNSGRs3v2bZcRQyqI0="; }; sourceRoot = "${finalAttrs.src.name}/projects/rocm-smi-lib"; From f409337ca0b729ef9711d50803b98663ddddc5ba Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:47 -0700 Subject: [PATCH 17/79] rocmPackages_10.hip-common: init at 10.1 Update the rocmPackages.hip-common copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ pkgs/development/rocm-modules/10/hip-common/default.nix | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index b96aa6b235f13..63fd18ac140c9 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -62,6 +62,8 @@ let rocm-docs-core = python3Packages.callPackage ../rocm-docs-core { }; + hip-common = self.callPackage ./hip-common { }; + hipcc = self.callPackage ../hipcc { stdenv = origStdenv; }; rocprofiler-register = self.callPackage ./rocprofiler-register { inherit (llvm) clang; diff --git a/pkgs/development/rocm-modules/10/hip-common/default.nix b/pkgs/development/rocm-modules/10/hip-common/default.nix index f2415ab549c33..c791e60f5b31a 100644 --- a/pkgs/development/rocm-modules/10/hip-common/default.nix +++ b/pkgs/development/rocm-modules/10/hip-common/default.nix @@ -7,17 +7,17 @@ stdenv.mkDerivation (finalAttrs: { pname = "hip-common"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/hip" "shared" ]; - hash = "sha256-orfTXKjcZJ5E73cmXEyltZVYhCQo8FLExVHM3J/rqUM="; + hash = "sha256-MP92iAemtjBLt9hy4JJpud+UfT2xolfm7mtLknrU5EE="; }; sourceRoot = "${finalAttrs.src.name}/projects/hip"; From e48aa86745d9ddf6670829c52d20b7a6a816fab4 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:48 -0700 Subject: [PATCH 18/79] rocmPackages_10.roctracer: init at 10.1 Update the rocmPackages.roctracer copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ pkgs/development/rocm-modules/10/roctracer/default.nix | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 63fd18ac140c9..f8da269205aef 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -68,6 +68,8 @@ let rocprofiler-register = self.callPackage ./rocprofiler-register { inherit (llvm) clang; }; + + roctracer = self.callPackage ./roctracer { }; } ); in diff --git a/pkgs/development/rocm-modules/10/roctracer/default.nix b/pkgs/development/rocm-modules/10/roctracer/default.nix index 6cc979eb3648e..0fd5b25342c38 100644 --- a/pkgs/development/rocm-modules/10/roctracer/default.nix +++ b/pkgs/development/rocm-modules/10/roctracer/default.nix @@ -19,7 +19,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "roctracer"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -34,12 +34,12 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/roctracer" "shared" ]; - hash = "sha256-Ps9b/MMdxXthGV96ZDg0kZGPdmn7Sy5if1a/Fjx2fEE="; + hash = "sha256-1pXWl8yUlfw5C3PFhrLxXPwHxscu1+AHx+lEqhl59vk="; }; sourceRoot = "${finalAttrs.src.name}/projects/roctracer"; From 0204dbfba8f5a14b0b37cbbfa943721fced8bad2 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:48 -0700 Subject: [PATCH 19/79] rocmPackages_10.clr: init at 10.1 Update the rocmPackages.clr copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- .../rocm-modules/10/clr/default.nix | 11 ++++-- pkgs/development/rocm-modules/10/default.nix | 36 +++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/clr/default.nix b/pkgs/development/rocm-modules/10/clr/default.nix index 554c76d845c04..238c9ae4ba023 100644 --- a/pkgs/development/rocm-modules/10/clr/default.nix +++ b/pkgs/development/rocm-modules/10/clr/default.nix @@ -70,7 +70,7 @@ let in stdenv.mkDerivation (finalAttrs: { pname = "clr"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -83,12 +83,12 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/clr" "shared" ]; - hash = "sha256-//cQBKlSB9uSP4fBgJpI1FxnqlzyQN913CHVGa2tqv8="; + hash = "sha256-uK/JD5p72os15+n6Jw6aU0xELphBHdYnVu7NmXC3BA4="; }; sourceRoot = "${finalAttrs.src.name}/projects/clr"; @@ -212,6 +212,11 @@ stdenv.mkDerivation (finalAttrs: { ln -s ${rocminfo}/bin/* $out/bin ln -s ${rocm-core}/include/* $out/include/ + # Installed by opencl/CMakeLists.txt; the ICD file would collide with $icd's. + # https://github.com/ROCm/rocm-systems/blob/therock-10.1/projects/clr/opencl/CMakeLists.txt#L124-L143 + rm $out/etc/OpenCL/vendors/amdocl64.icd $out/etc/ld.so.conf.d/10-rocm-opencl.conf + rmdir $out/etc/OpenCL/vendors $out/etc/OpenCL $out/etc/ld.so.conf.d $out/etc + # Replace rocm-opencl-icd functionality mkdir -p $icd/etc/OpenCL/vendors echo "$out/lib/libamdocl64.so" > $icd/etc/OpenCL/vendors/amdocl64.icd diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index f8da269205aef..75f32e901a185 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -65,6 +65,9 @@ let hip-common = self.callPackage ./hip-common { }; hipcc = self.callPackage ../hipcc { stdenv = origStdenv; }; + + # Replaces hip, opencl-runtime, and rocclr + clr = self.callPackage ./clr { }; rocprofiler-register = self.callPackage ./rocprofiler-register { inherit (llvm) clang; }; @@ -72,5 +75,38 @@ let roctracer = self.callPackage ./roctracer { }; } ); + scopeForArches = + arches: + outer.overrideScope ( + _final: prev: { + clr = prev.clr.override { + localGpuTargets = arches; + }; + } + ); in outer +// lib.genAttrs outer.clr.gpuTargets (arch: scopeForArches [ arch ]) +// { + gfx9 = scopeForArches [ + "gfx906" + "gfx908" + "gfx90a" + "gfx942" + ]; + gfx10 = scopeForArches [ + "gfx1010" + "gfx1030" + ]; + gfx11 = scopeForArches [ + "gfx1100" + "gfx1101" + "gfx1102" + "gfx1150" + "gfx1151" + ]; + gfx12 = scopeForArches [ + "gfx1200" + "gfx1201" + ]; +} From 5271f129886fa6da7f08874969cbe59d216c57e9 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:49 -0700 Subject: [PATCH 20/79] rocmPackages_10.hipify: init at 10.1 Update the rocmPackages.hipify copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 4 ++++ pkgs/development/rocm-modules/10/hipify/default.nix | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 75f32e901a185..3356c1c61fdf2 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -68,6 +68,10 @@ let # Replaces hip, opencl-runtime, and rocclr clr = self.callPackage ./clr { }; + + hipify = self.callPackage ./hipify { + stdenv = origStdenv; + }; rocprofiler-register = self.callPackage ./rocprofiler-register { inherit (llvm) clang; }; diff --git a/pkgs/development/rocm-modules/10/hipify/default.nix b/pkgs/development/rocm-modules/10/hipify/default.nix index b121f0859dce6..5f35a82d79f46 100644 --- a/pkgs/development/rocm-modules/10/hipify/default.nix +++ b/pkgs/development/rocm-modules/10/hipify/default.nix @@ -12,13 +12,13 @@ stdenv.mkDerivation (finalAttrs: { pname = "hipify"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "HIPIFY"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-LC0lnYetV7RPVw92zew6za6bDH4zmnERXUM4MVaRVtc="; + tag = "therock-${finalAttrs.version}"; + hash = "sha256-Ayw+jfXmeK9XDy1C+cmalTIDStvr6kGY2n78x5b2KYk="; }; strictDeps = true; From 00b0bf3ccf636d5f6ab539e379785b86375363c7 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:50 -0700 Subject: [PATCH 21/79] rocmPackages_10.half: init at 10.1 Update the rocmPackages.half copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 29 +++++++++++++++++++ .../rocm-modules/10/half/default.nix | 4 +-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 3356c1c61fdf2..fc71188cf36b6 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -1,8 +1,10 @@ { lib, + config, callPackage, newScope, python3Packages, + openmpi, stdenv, }: @@ -13,6 +15,7 @@ let inherit (self) llvm; origStdenv = stdenv; pyPackages = python3Packages; + openmpi-orig = openmpi; rocmClangStdenv = llvm.rocmClangStdenv; in { @@ -72,11 +75,37 @@ let hipify = self.callPackage ./hipify { stdenv = origStdenv; }; + + # hsakmt was merged into rocm-runtime + hsakmt = self.rocm-runtime; rocprofiler-register = self.callPackage ./rocprofiler-register { inherit (llvm) clang; }; roctracer = self.callPackage ./roctracer { }; + + half = self.callPackage ./half { }; + + # Even if config.rocmSupport is false we need rocmSupport true + # version of ucc/ucx in openmpi in this package set + openmpi = openmpi-orig.override ( + prev: + let + ucx = prev.ucx.override { + enableCuda = false; + enableRocm = true; + rocmPackages = self; + }; + in + { + inherit ucx; + ucc = prev.ucc.override { + enableCuda = false; + inherit ucx; + }; + } + ); + mpi = self.openmpi; } ); scopeForArches = diff --git a/pkgs/development/rocm-modules/10/half/default.nix b/pkgs/development/rocm-modules/10/half/default.nix index 8541b82d596fe..ae57c10d2caeb 100644 --- a/pkgs/development/rocm-modules/10/half/default.nix +++ b/pkgs/development/rocm-modules/10/half/default.nix @@ -9,12 +9,12 @@ stdenv.mkDerivation (finalAttrs: { pname = "half"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "half"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; hash = "sha256-If9O5BEeymsLN+C0drZsPSxEWXpJTxeDBGNHNXSumm4="; }; From d3030b36fb5104ce01d21e63338e9d63694d3677 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:53 -0700 Subject: [PATCH 22/79] rocmPackages_10: copy profiling and debugging tools, RCCL Verbatim copies of the rocmPackages (ROCm 7.2.4) expressions for aqlprofile, rocprof-trace-decoder, rocdbgapi, rocgdb, rocr-debug-agent, rocprofiler, rdc, rccl, rocprofiler-sdk, rocshmem, not yet part of the rocmPackages_10 scope. The following commits update each one to ROCm 10.1, so their diffs read against 7.2.4. Assisted-by: Claude Code (claude-opus-5-5) --- .../rocm-modules/10/aqlprofile/default.nix | 42 +++ .../rocm-modules/10/rccl/default.nix | 158 +++++++++++ .../10/rccl/fix_hw_reg_hw_id_gt_gfx10.patch | 33 +++ .../10/rccl/rccl-test-missing-iomanip.diff | 10 + .../rocm-modules/10/rdc/default.nix | 150 ++++++++++ .../10/rdc/fix-cmake-cxxflags.patch | 217 +++++++++++++++ .../10/rdc/fix-libcap-pkgconfig.patch | 57 ++++ .../rocm-modules/10/rocdbgapi/default.nix | 109 ++++++++ .../rocm-modules/10/rocgdb/default.nix | 113 ++++++++ .../10/rocprof-trace-decoder/default.nix | 85 ++++++ .../fix-test-dependency.patch | 15 + .../use-system-dependencies.patch | 81 ++++++ ...missing-CPackComponent-cmake-include.patch | 25 ++ ...2-allow-using-system-yaml-dependency.patch | 68 +++++ ...-allow-using-system-elfio-dependency.patch | 70 +++++ ...4-allow-using-system-otf2-dependency.patch | 54 ++++ ...5-allow-using-system-json-dependency.patch | 54 ++++ .../0006-fix-amd-comgr-resolution.patch | 154 +++++++++++ ...udes-and-api-changes-with-fmt-v12.2..patch | 260 ++++++++++++++++++ ...ilation-errors-from-missing-includes.patch | 93 +++++++ ...ocprofiler-sdk-guard-ompt-auto-start.patch | 50 ++++ .../10/rocprofiler-sdk/default.nix | 226 +++++++++++++++ .../rocm-modules/10/rocprofiler/default.nix | 141 ++++++++++ .../10/rocr-debug-agent/default.nix | 55 ++++ .../rocm-modules/10/rocshmem/default.nix | 69 +++++ 25 files changed, 2389 insertions(+) create mode 100644 pkgs/development/rocm-modules/10/aqlprofile/default.nix create mode 100644 pkgs/development/rocm-modules/10/rccl/default.nix create mode 100644 pkgs/development/rocm-modules/10/rccl/fix_hw_reg_hw_id_gt_gfx10.patch create mode 100644 pkgs/development/rocm-modules/10/rccl/rccl-test-missing-iomanip.diff create mode 100644 pkgs/development/rocm-modules/10/rdc/default.nix create mode 100644 pkgs/development/rocm-modules/10/rdc/fix-cmake-cxxflags.patch create mode 100644 pkgs/development/rocm-modules/10/rdc/fix-libcap-pkgconfig.patch create mode 100644 pkgs/development/rocm-modules/10/rocdbgapi/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocgdb/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocprof-trace-decoder/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocprof-trace-decoder/fix-test-dependency.patch create mode 100644 pkgs/development/rocm-modules/10/rocprof-trace-decoder/use-system-dependencies.patch create mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0001-fix-missing-CPackComponent-cmake-include.patch create mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0002-allow-using-system-yaml-dependency.patch create mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0003-allow-using-system-elfio-dependency.patch create mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0004-allow-using-system-otf2-dependency.patch create mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0005-allow-using-system-json-dependency.patch create mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0006-fix-amd-comgr-resolution.patch create mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0007-fix-missing-includes-and-api-changes-with-fmt-v12.2..patch create mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0008-fix-compilation-errors-from-missing-includes.patch create mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0009-rocprofiler-sdk-guard-ompt-auto-start.patch create mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocprofiler/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocr-debug-agent/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocshmem/default.nix diff --git a/pkgs/development/rocm-modules/10/aqlprofile/default.nix b/pkgs/development/rocm-modules/10/aqlprofile/default.nix new file mode 100644 index 0000000000000..34b1d92f3d57f --- /dev/null +++ b/pkgs/development/rocm-modules/10/aqlprofile/default.nix @@ -0,0 +1,42 @@ +{ + lib, + stdenv, + clr, + cmake, + fetchFromGitHub, + rocmUpdateScript, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "aqlprofile"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-systems"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/aqlprofile" + "shared" + ]; + hash = "sha256-74HjB5Ughu17rSRx9mfCCsPJI4TVyXnT4aU7vIbm7ak="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/aqlprofile"; + + env.CXXFLAGS = "-DROCP_LD_AQLPROFILE=1"; + + nativeBuildInputs = [ + cmake + clr + ]; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "AQLPROFILE library for AMD HSA runtime API extension support"; + homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/aqlprofile"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rccl/default.nix b/pkgs/development/rocm-modules/10/rccl/default.nix new file mode 100644 index 0000000000000..1dbcd0c84945c --- /dev/null +++ b/pkgs/development/rocm-modules/10/rccl/default.nix @@ -0,0 +1,158 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + rocm-smi, + rocm-core, + pkg-config, + clr, + mscclpp, + perl, + hipify, + python3, + fmt, + gtest, + chrpath, + roctracer, + rocprofiler, + rocprofiler-register, + autoPatchelfHook, + buildTests ? false, + gpuTargets ? (clr.localGpuTargets or [ ]), + # for passthru.tests + rccl, +}: + +let + useAsan = buildTests; + useUbsan = buildTests; + san = lib.optionalString (useAsan || useUbsan) ( + "-fno-gpu-sanitize -fsanitize=undefined " + + (lib.optionalString useAsan "-fsanitize=address -shared-libsan ") + ); +in +# Note: we can't properly test or make use of multi-node collective ops +# https://github.com/NixOS/nixpkgs/issues/366242 tracks kernel support +# kfd_peerdirect support which is on out-of-tree amdkfd in ROCm/ROCK-Kernel-Driver +# infiniband ib_peer_mem support isn't in the mainline kernel but is carried by some distros +stdenv.mkDerivation (finalAttrs: { + pname = "rccl${clr.gpuArchSuffix}"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildTests [ + "test" + ]; + + patches = [ + ./rccl-test-missing-iomanip.diff + ./fix_hw_reg_hw_id_gt_gfx10.patch + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rccl"; + tag = "rocm-${finalAttrs.version}"; + hash = "sha256-A1IQYIDWqu3JLiPQ70G52s1/0ZweQxFlgMUH81qJWmU="; + }; + + requiredSystemFeatures = [ "big-parallel" ]; # Very resource intensive LTO + + nativeBuildInputs = [ + cmake + rocm-cmake + clr + perl + hipify + python3 + pkg-config + autoPatchelfHook # ASAN doesn't add rpath without this + ]; + + buildInputs = [ + rocm-smi + fmt + gtest + roctracer + rocprofiler + rocprofiler-register + mscclpp + ] + ++ lib.optionals buildTests [ + chrpath + ]; + + cmakeFlags = [ + "-DHIP_CLANG_NUM_PARALLEL_JOBS=4" + "-DROCM_PATH=${clr}" + "-DHIP_COMPILER=${clr}/bin/amdclang++" + "-DCMAKE_CXX_COMPILER=${clr}/bin/amdclang++" + "-DROCM_PATCH_VERSION=${rocm-core.ROCM_LIBPATCH_VERSION}" + "-DROCM_VERSION=${rocm-core.ROCM_LIBPATCH_VERSION}" + "-DBUILD_BFD=OFF" # Can't get it to detect bfd.h + "-DENABLE_MSCCL_KERNEL=ON" + # FIXME: this is still running a download because if(NOT mscclpp_nccl_FOUND) is commented out T_T + "-DENABLE_MSCCLPP=OFF" + #"-DMSCCLPP_ROOT=${mscclpp}" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] + ++ lib.optionals (gpuTargets != [ ]) [ + # AMD can't make up their minds and keep changing which one is used in different projects. + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ] + ++ lib.optionals buildTests [ + "-DBUILD_TESTS=ON" + ]; + + # -O2 and -fno-strict-aliasing due to UB issues in RCCL :c + # Reported upstream + env.CFLAGS = "-I${clr}/include -I${roctracer}/include -O2 -fno-strict-aliasing ${san}-fno-omit-frame-pointer -momit-leaf-frame-pointer"; + env.CXXFLAGS = "-I${clr}/include -I${roctracer}/include -O2 -fno-strict-aliasing ${san}-fno-omit-frame-pointer -momit-leaf-frame-pointer"; + env.LDFLAGS = "${san}"; + postPatch = '' + patchShebangs src tools + substituteInPlace CMakeLists.txt \ + --replace-fail '${"\${HOST_OS_ID}"}' '"ubuntu"' \ + --replace-fail 'target_include_directories(rccl PRIVATE ''${ROCM_SMI_INCLUDE_DIR})' \ + 'target_include_directories(rccl PRIVATE ''${ROCM_SMI_INCLUDE_DIRS})' + ''; + + postInstall = + lib.optionalString useAsan '' + patchelf --add-needed ${clr}/llvm/lib/linux/libclang_rt.asan-${stdenv.hostPlatform.parsed.cpu.name}.so $out/lib/librccl.so + '' + + lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/* $test/bin + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + # This package with sanitizers + manual integration test binaries built + # must be ran manually + passthru.tests.rccl = rccl.override { + buildTests = true; + }; + + meta = { + description = "ROCm communication collectives library"; + homepage = "https://github.com/ROCm/rccl"; + license = with lib.licenses; [ + bsd2 + bsd3 + ]; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rccl/fix_hw_reg_hw_id_gt_gfx10.patch b/pkgs/development/rocm-modules/10/rccl/fix_hw_reg_hw_id_gt_gfx10.patch new file mode 100644 index 0000000000000..c69000814a8a6 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rccl/fix_hw_reg_hw_id_gt_gfx10.patch @@ -0,0 +1,33 @@ +fix: __trace_hwreg should use HW_REG_HW_ID1 for all gfx10/11/12 +diff --git a/src/device/common.h b/src/device/common.h +index c6c61021..742885f4 100644 +--- a/src/device/common.h ++++ b/src/device/common.h +@@ -26,8 +26,9 @@ + { __atomic_store_n((DST), (SRC), __ATOMIC_SEQ_CST); } + #endif + +-#if defined(__gfx1100__) || defined(__gfx1101__) || defined(__gfx1102__) || defined(__gfx1200__) || defined(__gfx1201__) +-#define __trace_hwreg() ++#if defined(__GFX10__) || defined(__GFX11__) || defined(__GFX12__) ++#define __trace_hwreg() \ ++ asm volatile ("s_getreg_b32 %0, hwreg(HW_REG_HW_ID1)" : "=s" (collTrace->data_0)); + #else + #define __trace_hwreg() \ + asm volatile ("s_getreg_b32 %0, hwreg(HW_REG_HW_ID)" : "=s" (collTrace->data_0)); +diff --git a/tools/JitterBench/Common.hpp b/tools/JitterBench/Common.hpp +index bad12a1b..b59856a8 100644 +--- a/tools/JitterBench/Common.hpp ++++ b/tools/JitterBench/Common.hpp +@@ -43,9 +43,9 @@ THE SOFTWARE. + #endif + + // Macro for collecting HW_REG_HW_ID +-#if defined(__gfx1100__) || defined(__gfx1101__) || defined(__gfx1102__) || defined(__NVCC__) ++#if defined(__GFX10__) || defined(__GFX11__) || defined(__GFX12__) + #define GetHwId(val) \ +- val = 0 ++ asm volatile ("s_getreg_b32 %0, hwreg(HW_REG_HW_ID1)" : "=s" (val)); + #else + #define GetHwId(val) \ + asm volatile ("s_getreg_b32 %0, hwreg(HW_REG_HW_ID)" : "=s" (val)); diff --git a/pkgs/development/rocm-modules/10/rccl/rccl-test-missing-iomanip.diff b/pkgs/development/rocm-modules/10/rccl/rccl-test-missing-iomanip.diff new file mode 100644 index 0000000000000..3cc54a83c1429 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rccl/rccl-test-missing-iomanip.diff @@ -0,0 +1,10 @@ +--- a/test/common/TestBed.cpp ++++ b/test/common/TestBed.cpp +@@ -4,6 +4,7 @@ + * See LICENSE.txt for license information + ************************************************************************/ + #include ++#include + #include "TestBed.hpp" + #include + diff --git a/pkgs/development/rocm-modules/10/rdc/default.nix b/pkgs/development/rocm-modules/10/rdc/default.nix new file mode 100644 index 0000000000000..8c5debc4dec47 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rdc/default.nix @@ -0,0 +1,150 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + pkg-config, + amdsmi, + rocm-smi, + rocm-runtime, + libcap, + libdrm, + grpc, + protobuf, + openssl, + doxygen, + graphviz, + texliveSmall, + gtest, + buildDocs ? true, + buildTests ? false, +}: + +let + latex = lib.optionalAttrs buildDocs ( + texliveSmall.withPackages ( + ps: with ps; [ + changepage + latexmk + varwidth + multirow + hanging + adjustbox + collectbox + stackengine + enumitem + alphalph + wasysym + sectsty + tocloft + newunicodechar + etoc + helvetic + wasy + courier + ] + ) + ); +in +stdenv.mkDerivation (finalAttrs: { + pname = "rdc"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildDocs [ + "doc" + ] + ++ lib.optionals buildTests [ + "test" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-systems"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rdc" + "shared" + ]; + hash = "sha256-SmySauRxFnEQJVTjGYf4TpmQclTwZG2RZrk3u6ko5Qo="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rdc"; + + patches = [ + # https://github.com/ROCm/rocm-systems/pull/2423 + ./fix-cmake-cxxflags.patch + # https://github.com/ROCm/rocm-systems/pull/2424 + ./fix-libcap-pkgconfig.patch + ]; + + nativeBuildInputs = [ + cmake + pkg-config + protobuf + ] + ++ lib.optionals buildDocs [ + doxygen + graphviz + latex + ]; + + buildInputs = [ + amdsmi + rocm-smi + rocm-runtime + libcap + libdrm + grpc + openssl + ] + ++ lib.optionals buildTests [ + gtest + ]; + + cmakeFlags = [ + "-DCMAKE_VERBOSE_MAKEFILE=ON" + "-DRDC_INSTALL_PREFIX=${placeholder "out"}" + "-DBUILD_RVS=OFF" # TODO: Needs RVS package + "-DBUILD_ROCRTEST=ON" + "-DRSMI_INC_DIR=${rocm-smi}/include" + "-DRSMI_LIB_DIR=${rocm-smi}/lib" + "-DGRPC_ROOT=${grpc}" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + "-DCMAKE_INSTALL_LIBEXECDIR=libexec" + "-DCMAKE_INSTALL_DOCDIR=doc" + ] + ++ lib.optionals buildTests [ + "-DBUILD_TESTS=ON" + ]; + + postPatch = '' + substituteInPlace CMakeLists.txt \ + --replace-fail "file(STRINGS /etc/os-release LINUX_DISTRO LIMIT_COUNT 1 REGEX \"NAME=\")" "set(LINUX_DISTRO \"NixOS\")" + ''; + + postInstall = '' + find $out/bin -executable -type f -exec \ + patchelf {} --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" \; + '' + + lib.optionalString buildTests '' + mkdir -p $test + mv $out/bin/rdctst_tests $test/bin + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "Simplifies administration and addresses infrastructure challenges in cluster and datacenter environments"; + homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/rdc"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rdc/fix-cmake-cxxflags.patch b/pkgs/development/rocm-modules/10/rdc/fix-cmake-cxxflags.patch new file mode 100644 index 0000000000000..bf7f3dbb0eef4 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rdc/fix-cmake-cxxflags.patch @@ -0,0 +1,217 @@ +From 92f25181dbf722cb749e445851580df4ea779299 Mon Sep 17 00:00:00 2001 +From: Luna Nova +Date: Sun, 21 Dec 2025 08:01:08 -0800 +Subject: [PATCH 1/2] fix(rdc): set CMAKE_CXX_FLAGS after project() to avoid + clobbering env + +CMAKE_CXX_FLAGS' initial value is set from $CXXFLAGS on project() call +so the previous location ignored CXXFLAGS from env or CMake toolchain +config. + +Ref: https://cmake.org/cmake/help/v4.2/variable/CMAKE_LANG_FLAGS_INIT.html +Fixes: 874a7b438f ("CMAKE - Fix build types") +--- + CMakeLists.txt | 48 +++++++++++++++++++------------------ + 1 file changed, 25 insertions(+), 23 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 907c9fbff42..8b386c7be3d 100755 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -55,29 +55,6 @@ set_property( + PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel" + ) + +-# Set compile flags +-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64 -msse -msse2") +-set(CMAKE_CXX_FLAGS_DEBUG +- "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -DDEBUG" +- CACHE STRING +- "Flags for Debug builds" +-) +-set(CMAKE_CXX_FLAGS_RELEASE +- "${CMAKE_CXX_FLAGS_RELEASE} -O2 -s -DNDEBUG" +- CACHE STRING +- "Flags for Release builds" +-) +-set(CMAKE_CXX_FLAGS_RELWITHDEBINFO +- "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG" +- CACHE STRING +- "Flags for RelWithDebInfo builds" +-) +-set(CMAKE_CXX_FLAGS_MINSIZEREL +- "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG" +- CACHE STRING +- "Flags for MinSizeRel builds" +-) +- + set(CMAKE_MODULE_PATH + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/" + CACHE INTERNAL +@@ -155,6 +132,31 @@ project(${RDC} VERSION "${VERSION_STRING}" HOMEPAGE_URL "https://github.com/Rade + # this must go after project() + include(GNUInstallDirs) + ++# NB: CMAKE__FLAGS are initialized from environment (CXXFLAGS et al.) ++# during project(). Setting them before project() discards env and toolchain ++# defaults. Cf. CMAKE__FLAGS_INIT for toolchain overrides. ++set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64 -msse -msse2") ++set(CMAKE_CXX_FLAGS_DEBUG ++ "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -DDEBUG" ++ CACHE STRING ++ "Flags for Debug builds" ++) ++set(CMAKE_CXX_FLAGS_RELEASE ++ "${CMAKE_CXX_FLAGS_RELEASE} -O2 -s -DNDEBUG" ++ CACHE STRING ++ "Flags for Release builds" ++) ++set(CMAKE_CXX_FLAGS_RELWITHDEBINFO ++ "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG" ++ CACHE STRING ++ "Flags for RelWithDebInfo builds" ++) ++set(CMAKE_CXX_FLAGS_MINSIZEREL ++ "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG" ++ CACHE STRING ++ "Flags for MinSizeRel builds" ++) ++ + set(COMMON_DIR "${CMAKE_CURRENT_SOURCE_DIR}/common") + + set(GRPC_ROOT_DEFAULT "/usr") + +From 0c8710c3570963b29c709b1cd1f78b15fd73a950 Mon Sep 17 00:00:00 2001 +From: Luna Nova +Date: Sun, 21 Dec 2025 08:13:04 -0800 +Subject: [PATCH 2/2] fix(rdc): don't reimplement CMake default build type flag + logic + +The previous approach was overly complicated and added nothing. CMake already defaults +similar flags for each of the default supported build types. +Additionally, the previous flags broke AArch64 as -m64 -msse are incompatible. +It's not necessary to explicitly set this with modern toolchains. + +Fixes: 874a7b438f ("CMAKE - Fix build types") +Fixes: bc7f01e992 ("Initial RDC commit") +--- + CMakeLists.txt | 25 +--------------------- + example/CMakeLists.txt | 26 ++--------------------- + tests/example/CMakeLists.txt | 24 +-------------------- + 3 files changed, 4 insertions(+), 71 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8b386c7be3d..251fcddd653 100755 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -132,30 +132,7 @@ project(${RDC} VERSION "${VERSION_STRING}" HOMEPAGE_URL "https://github.com/Rade + # this must go after project() + include(GNUInstallDirs) + +-# NB: CMAKE__FLAGS are initialized from environment (CXXFLAGS et al.) +-# during project(). Setting them before project() discards env and toolchain +-# defaults. Cf. CMAKE__FLAGS_INIT for toolchain overrides. +-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64 -msse -msse2") +-set(CMAKE_CXX_FLAGS_DEBUG +- "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -DDEBUG" +- CACHE STRING +- "Flags for Debug builds" +-) +-set(CMAKE_CXX_FLAGS_RELEASE +- "${CMAKE_CXX_FLAGS_RELEASE} -O2 -s -DNDEBUG" +- CACHE STRING +- "Flags for Release builds" +-) +-set(CMAKE_CXX_FLAGS_RELWITHDEBINFO +- "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG" +- CACHE STRING +- "Flags for RelWithDebInfo builds" +-) +-set(CMAKE_CXX_FLAGS_MINSIZEREL +- "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG" +- CACHE STRING +- "Flags for MinSizeRel builds" +-) ++add_compile_options(-Wall -Wextra) + + set(COMMON_DIR "${CMAKE_CURRENT_SOURCE_DIR}/common") + +diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt +index 378a2005818..7c51307ec38 100755 +--- a/example/CMakeLists.txt ++++ b/example/CMakeLists.txt +@@ -31,30 +31,6 @@ cmake_minimum_required(VERSION 3.15) + option(CMAKE_VERBOSE_MAKEFILE "Enable verbose output" ON) + option(CMAKE_EXPORT_COMPILE_COMMANDS "Export compile commands for linters and autocompleters" ON) + +-# Set compile flags +-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64 -msse -msse2") +-set(CMAKE_CXX_FLAGS_DEBUG +- "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -DDEBUG" +- CACHE STRING +- "Flags for Debug builds" +-) +-# note: no '-s' here unlike other CMakeLists.txt +-set(CMAKE_CXX_FLAGS_RELEASE +- "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG" +- CACHE STRING +- "Flags for Release builds" +-) +-set(CMAKE_CXX_FLAGS_RELWITHDEBINFO +- "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG" +- CACHE STRING +- "Flags for RelWithDebInfo builds" +-) +-set(CMAKE_CXX_FLAGS_MINSIZEREL +- "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG" +- CACHE STRING +- "Flags for MinSizeRel builds" +-) +- + set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard to use") + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) +@@ -66,6 +42,8 @@ endif() + + project(RDC_example) + ++add_compile_options(-Wall -Wextra) ++ + # provides cmake_print_variables(VAR) + include(CMakePrintHelpers) + +diff --git a/tests/example/CMakeLists.txt b/tests/example/CMakeLists.txt +index d5614f387bd..13c2f3857a1 100755 +--- a/tests/example/CMakeLists.txt ++++ b/tests/example/CMakeLists.txt +@@ -22,29 +22,7 @@ message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&") + message(" Cmake Example Lib ") + message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&") + +-# Set compile flags +-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64 -msse -msse2") +-set(CMAKE_CXX_FLAGS_DEBUG +- "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -DDEBUG" +- CACHE STRING +- "Flags for Debug builds" +-) +-# note: no '-s' here unlike other CMakeLists.txt +-set(CMAKE_CXX_FLAGS_RELEASE +- "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG" +- CACHE STRING +- "Flags for Release builds" +-) +-set(CMAKE_CXX_FLAGS_RELWITHDEBINFO +- "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG" +- CACHE STRING +- "Flags for RelWithDebInfo builds" +-) +-set(CMAKE_CXX_FLAGS_MINSIZEREL +- "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG" +- CACHE STRING +- "Flags for MinSizeRel builds" +-) ++add_compile_options(-Wall -Wextra) + + # Required Defines first: + diff --git a/pkgs/development/rocm-modules/10/rdc/fix-libcap-pkgconfig.patch b/pkgs/development/rocm-modules/10/rdc/fix-libcap-pkgconfig.patch new file mode 100644 index 0000000000000..54e7303ce88f3 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rdc/fix-libcap-pkgconfig.patch @@ -0,0 +1,57 @@ +From 299f2c770ff0abf07b8f394f154168d2aa78aa60 Mon Sep 17 00:00:00 2001 +From: Luna Nova +Date: Sun, 21 Dec 2025 08:23:01 -0800 +Subject: [PATCH] fix(rdc): use pkg-config to find libcap + +If libcap isn't available in system wide FHS include paths building would fail. +Fix this by using pkg-config to find libcap which provides both the library +to link and include dirs. +--- + CMakeLists.txt | 6 +++--- + rdc_libs/rdc/CMakeLists.txt | 2 +- + server/CMakeLists.txt | 2 +- + 3 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 907c9fbff42..00e0a9dd87d 100755 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -192,9 +192,9 @@ mark_as_advanced( + CPACK_GENERATOR + ) + +-# check if libcap exists +-# needed for sys/capabilities.h +-find_library(LIB_CAP NAMES cap REQUIRED) ++# needed for sys/capability.h ++find_package(PkgConfig REQUIRED) ++pkg_check_modules(LIBCAP REQUIRED IMPORTED_TARGET libcap) + + if(BUILD_STANDALONE AND GRPC_ROOT STREQUAL GRPC_ROOT_DEFAULT) + message( +diff --git a/rdc_libs/rdc/CMakeLists.txt b/rdc_libs/rdc/CMakeLists.txt +index d4e368edca5..f9a3ac4c487 100644 +--- a/rdc_libs/rdc/CMakeLists.txt ++++ b/rdc_libs/rdc/CMakeLists.txt +@@ -71,7 +71,7 @@ set(RDC_LIB_INC_LIST + message("RDC_LIB_INC_LIST=${RDC_LIB_INC_LIST}") + + add_library(${RDC_LIB} SHARED ${RDC_LIB_SRC_LIST} ${RDC_LIB_INC_LIST}) +-target_link_libraries(${RDC_LIB} ${BOOTSTRAP_LIB} pthread amd_smi cap) ++target_link_libraries(${RDC_LIB} ${BOOTSTRAP_LIB} pthread amd_smi PkgConfig::LIBCAP) + target_include_directories( + ${RDC_LIB} + PRIVATE "${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/include" "${AMD_SMI_INCLUDE_DIR}" +diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt +index baf0d851c86..0a6e71dda1c 100755 +--- a/server/CMakeLists.txt ++++ b/server/CMakeLists.txt +@@ -97,7 +97,7 @@ target_link_libraries( + pthread + rt + gRPC::grpc++ +- cap ++ PkgConfig::LIBCAP + dl + amd_smi + rdc_bootstrap diff --git a/pkgs/development/rocm-modules/10/rocdbgapi/default.nix b/pkgs/development/rocm-modules/10/rocdbgapi/default.nix new file mode 100644 index 0000000000000..8cceaa35137b3 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocdbgapi/default.nix @@ -0,0 +1,109 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + rocm-comgr, + rocm-runtime, + hwdata, + texliveSmall, + doxygen, + graphviz, + writableTmpDirAsHomeHook, + buildDocs ? true, +}: + +let + latex = lib.optionalAttrs buildDocs ( + texliveSmall.withPackages ( + ps: with ps; [ + changepage + latexmk + varwidth + multirow + hanging + adjustbox + collectbox + stackengine + enumitem + alphalph + wasysym + sectsty + tocloft + newunicodechar + etoc + helvetic + wasy + courier + tabularray + ltablex + ninecolors + xltabular + ] + ) + ); +in +stdenv.mkDerivation (finalAttrs: { + pname = "rocdbgapi"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildDocs [ + "doc" + ]; + + buildFlags = lib.optionals buildDocs [ "doc" ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "ROCdbgapi"; + tag = "rocm-${finalAttrs.version}"; + hash = "sha256-KqvhwfIv8pbr8WbnfAKl71fg5yxbwYcpzZcGU9Htdkc="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + ] + ++ lib.optionals buildDocs [ + writableTmpDirAsHomeHook + latex + doxygen + graphviz + ]; + + buildInputs = [ + rocm-comgr + rocm-runtime + hwdata + ]; + + cmakeFlags = [ + "-DPCI_IDS_PATH=${hwdata}/share/hwdata" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ]; + + postInstall = lib.optionalString buildDocs '' + mkdir -p $doc/share/doc/amd-dbgapi/ + mv $out/share/html/amd-dbgapi $doc/share/doc/amd-dbgapi/html + rmdir $out/share/html + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "Debugger support for control of execution and inspection state of AMD's GPU architectures"; + homepage = "https://github.com/ROCm/ROCdbgapi"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocgdb/default.nix b/pkgs/development/rocm-modules/10/rocgdb/default.nix new file mode 100644 index 0000000000000..918f624b673d2 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocgdb/default.nix @@ -0,0 +1,113 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + pkg-config, + texinfo, + bison, + flex, + glibc, + zlib, + zstd, + gmp, + mpfr, + ncurses, + expat, + rocdbgapi, + perl, + python3, + babeltrace, + sourceHighlight, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocgdb"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "ROCgdb"; + tag = "rocm-${finalAttrs.version}"; + hash = "sha256-oml/HLExnnjh7+axeWPZRWecpwK2BnzVOaGvXYhrxKs="; + }; + + nativeBuildInputs = [ + pkg-config + texinfo # For makeinfo + bison + flex + perl # used in mkinstalldirs script during installPhase + python3 + ]; + + buildInputs = [ + zlib + zstd + gmp + mpfr + ncurses + expat + rocdbgapi + python3 + babeltrace + sourceHighlight + ]; + + configureFlags = [ + # Ensure we build the amdgpu target + "--enable-targets=${stdenv.targetPlatform.config},amdgcn-amd-amdhsa" + "--with-amd-dbgapi=yes" + + "--with-iconv-path=${glibc.bin}" + "--enable-tui" + "--with-babeltrace=${babeltrace}" + "--with-python=python3" + "--with-system-zlib" + "--with-system-zstd" + "--enable-64-bit-bfd" + "--with-gmp=${gmp.dev}" + "--with-mpfr=${mpfr.dev}" + "--with-expat=${expat}" + + # So the installed binary is called "rocgdb" instead on plain "gdb" + "--program-prefix=roc" + + # Disable building many components not used or incompatible with the amdgcn target + "--disable-sim" + "--disable-gdbserver" + "--disable-ld" + "--disable-gas" + "--disable-gdbserver" + "--disable-gdbtk" + "--disable-gprofng" + "--disable-shared" + ]; + + postPatch = '' + for file in *; do + if [ -f "$file" ]; then + patchShebangs "$file" + fi + done + ''; + + # The source directory for ROCgdb (based on upstream GDB) contains multiple project + # of GNU’s toolchain (binutils and onther), we only need to install the GDB part. + installPhase = '' + make install-gdb + ''; + + env.CFLAGS = "-Wno-switch -Wno-format-nonliteral -I${zstd.dev}/include -I${zlib.dev}/include -I${expat.dev}/include -I${ncurses.dev}/include"; + env.CXXFLAGS = finalAttrs.env.CFLAGS; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "ROCm source-level debugger for Linux, based on GDB"; + homepage = "https://github.com/ROCm/ROCgdb"; + license = lib.licenses.gpl3Plus; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocprof-trace-decoder/default.nix b/pkgs/development/rocm-modules/10/rocprof-trace-decoder/default.nix new file mode 100644 index 0000000000000..3ab1bb6446886 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprof-trace-decoder/default.nix @@ -0,0 +1,85 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmPackages, + cmake, + python3, + nlohmann_json, + gtest, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocprof-trace-decoder"; + version = "0.1.7"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-systems"; + # No tags (yet?) + rev = "feeca99950c590e0b8228733405c4a1a10fa4773"; + sparseCheckout = [ + "projects/rocprof-trace-decoder" + "shared" + ]; + hash = "sha256-aJhPiZf5380jj2IeCipgcTEQYogr5R19UnVwKRGnkxo="; + }; + + sourceRoot = "${finalAttrs.src.name}/projects/rocprof-trace-decoder"; + + patches = [ + ./use-system-dependencies.patch + # https://github.com/ROCm/rocm-systems/pull/3800 + ./fix-test-dependency.patch + ]; + + strictDeps = true; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ + rocmPackages.rocm-comgr + rocmPackages.rocm-runtime + ]; + + cmakeFlags = [ + (lib.cmakeBool "BUILD_TESTS" finalAttrs.finalPackage.doCheck) + ]; + + nativeCheckInputs = [ + python3 + ]; + + checkInputs = [ + nlohmann_json + gtest + ]; + + preCheck = '' + patchShebangs test + ''; + + checkPhase = + let + # Sanitize tests fail because the UBSan runtime (__ubsan_vptr_type_cache) is not available for + # LD_PRELOAD in the sandbox. + skipPattern = "_sanitize$"; + in + '' + runHook preCheck + + ctest --test-dir . --output-on-failure -E '${skipPattern}' + + runHook postCheck + ''; + + doCheck = true; + + meta = { + description = "Library for decoding ROCm thread trace data"; + homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/rocprof-trace-decoder"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocprof-trace-decoder/fix-test-dependency.patch b/pkgs/development/rocm-modules/10/rocprof-trace-decoder/fix-test-dependency.patch new file mode 100644 index 0000000000000..7278ec688094a --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprof-trace-decoder/fix-test-dependency.patch @@ -0,0 +1,15 @@ +diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt +index a923cadce53..95a4d3a807f 100644 +--- a/test/CMakeLists.txt ++++ b/test/CMakeLists.txt +@@ -186,7 +186,9 @@ if(BUILD_INTEGRATION_TESTS) + WORKING_DIRECTORY + ${TEST_BIN_DIR} + FIXTURES_REQUIRED +- unpack_data) ++ unpack_data ++ DEPENDS ++ ${DATA}_execute) + endif() + endforeach(DATA) + endif() diff --git a/pkgs/development/rocm-modules/10/rocprof-trace-decoder/use-system-dependencies.patch b/pkgs/development/rocm-modules/10/rocprof-trace-decoder/use-system-dependencies.patch new file mode 100644 index 0000000000000..1f821a1110882 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprof-trace-decoder/use-system-dependencies.patch @@ -0,0 +1,81 @@ +diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt +index a923cad..53b0f49 100644 +--- a/test/CMakeLists.txt ++++ b/test/CMakeLists.txt +@@ -34,13 +34,7 @@ if(DISABLE_COMGR) + endif() + + if(NOT APPLE AND BUILD_INTEGRATION_TESTS) +- # Add nlohmann JSON as an external dependency +- include(FetchContent) +- FetchContent_Declare( +- json +- GIT_REPOSITORY https://github.com/nlohmann/json.git +- GIT_TAG v3.11.3) +- FetchContent_MakeAvailable(json) ++ find_package(nlohmann_json REQUIRED) + + add_subdirectory(att-tool) + endif() +diff --git a/test/att-tool/CMakeLists.txt b/test/att-tool/CMakeLists.txt +index 208af16..acd161f 100644 +--- a/test/att-tool/CMakeLists.txt ++++ b/test/att-tool/CMakeLists.txt +@@ -1,7 +1,7 @@ + # + # ATT decoder wrapper library for use by the rocprofv3 tool + # +-find_library(COMGR REQUIRED NAMES amd_comgr HINTS /opt/rocm/lib) ++find_library(COMGR REQUIRED NAMES amd_comgr) + + set(ATT_TOOL_SOURCE_FILES + waitcnt/analysis.cpp +@@ -19,8 +19,11 @@ set(ATT_TOOL_SOURCE_FILES + + set(DECODER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../source/) + +-set(INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../include/ ${DECODER_SRC} ${CMAKE_CURRENT_SOURCE_DIR} ${json_SOURCE_DIR}/include /opt/rocm/include) +-set(LINK_LIBS ${COMGR} pthread) ++set(INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../include/ ${DECODER_SRC} ${CMAKE_CURRENT_SOURCE_DIR}) ++find_path(COMGR_INCLUDE_DIR REQUIRED NAMES amd_comgr.h PATH_SUFFIXES amd_comgr) ++find_path(HSA_INCLUDE_DIR REQUIRED NAMES hsa/amd_hsa_elf.h) ++set(LINK_LIBS ${COMGR} pthread nlohmann_json::nlohmann_json) ++list(APPEND INCLUDE_DIRS ${COMGR_INCLUDE_DIR} ${HSA_INCLUDE_DIR}) + + # Sources re-globbed only for sanitizer builds + file(GLOB ATT_DECODER_V3_FILES +diff --git a/test/att-tool/sdk/disassembly.hpp b/test/att-tool/sdk/disassembly.hpp +index c054143..ec3d6d2 100644 +--- a/test/att-tool/sdk/disassembly.hpp ++++ b/test/att-tool/sdk/disassembly.hpp +@@ -22,7 +22,7 @@ + + #pragma once + +-#include ++#include + #include + + #include +diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt +index 8adafc0..9501efe 100644 +--- a/test/unit/CMakeLists.txt ++++ b/test/unit/CMakeLists.txt +@@ -9,16 +9,7 @@ project(att-decoder-unit-tests LANGUAGES CXX) + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + +-# Fetch GoogleTest +-include(FetchContent) +-FetchContent_Declare( +- googletest +- GIT_REPOSITORY https://github.com/google/googletest.git +- GIT_TAG v1.14.0) +-set(INSTALL_GTEST +- OFF +- CACHE BOOL "" FORCE) +-FetchContent_MakeAvailable(googletest) ++find_package(GTest REQUIRED) + + enable_testing() + diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0001-fix-missing-CPackComponent-cmake-include.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0001-fix-missing-CPackComponent-cmake-include.patch new file mode 100644 index 0000000000000..1e65ac7a76ee5 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0001-fix-missing-CPackComponent-cmake-include.patch @@ -0,0 +1,25 @@ +From 5ae420cc204d0afb1ad388ddbceec237a4164569 Mon Sep 17 00:00:00 2001 +From: Anund +Date: Sun, 11 Oct 2026 17:28:05 +1100 +Subject: [PATCH 1/8] fix missing CPackComponent cmake include + +--- + cmake/rocprofiler_config_packaging.cmake | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/cmake/rocprofiler_config_packaging.cmake b/cmake/rocprofiler_config_packaging.cmake +index 84c2ecf230..55d9f58f38 100644 +--- a/cmake/rocprofiler_config_packaging.cmake ++++ b/cmake/rocprofiler_config_packaging.cmake +@@ -126,6 +126,8 @@ endif() + list(APPEND _DEB_PACKAGE_DEPENDS ${ROCPROFILER_CPACK_DEBIAN_PACKAGE_DEPENDS}) + list(APPEND _RPM_PACKAGE_REQUIRES ${ROCPROFILER_CPACK_RPM_PACKAGE_REQUIRES}) + ++include(CPackComponent) ++ + foreach(COMPONENT_GROUP ${ROCPROFILER_COMPONENT_GROUPS}) + set(_DEP "${COMPONENT_DEP_${COMPONENT_GROUP}}") + set(_NAME "${COMPONENT_NAME_${COMPONENT_GROUP}}") +-- +2.55.0 + diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0002-allow-using-system-yaml-dependency.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0002-allow-using-system-yaml-dependency.patch new file mode 100644 index 0000000000000..3fa335a25eb9a --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0002-allow-using-system-yaml-dependency.patch @@ -0,0 +1,68 @@ +From 0477671140ffc3d1b50e1cca69f107b51112faa8 Mon Sep 17 00:00:00 2001 +From: Anund +Date: Sun, 11 Oct 2026 17:29:27 +1100 +Subject: [PATCH 2/8] allow using system yaml dependency + +--- + cmake/rocprofiler_options.cmake | 2 ++ + external/CMakeLists.txt | 29 +++++++++++++++++------------ + 2 files changed, 19 insertions(+), 12 deletions(-) + +diff --git a/cmake/rocprofiler_options.cmake b/cmake/rocprofiler_options.cmake +index 08d1032635..faee11049f 100644 +--- a/cmake/rocprofiler_options.cmake ++++ b/cmake/rocprofiler_options.cmake +@@ -65,6 +65,8 @@ rocprofiler_add_option(ROCPROFILER_BUILD_PYBIND11 + "Enable building pybind11 library internally" ON) + rocprofiler_add_option(ROCPROFILER_BUILD_GOTCHA + "Enable building gotcha library internally" ON) ++rocprofiler_add_option(ROCPROFILER_BUILD_YAML_CPP ++ "Enable building yaml-cpp library internally" ON) + if(ROCPROFILER_BUILD_TESTS) + rocprofiler_add_option( + ROCPROFILER_BUILD_GTEST +diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt +index 5bee3dc032..cab59c07bd 100644 +--- a/external/CMakeLists.txt ++++ b/external/CMakeLists.txt +@@ -131,20 +131,25 @@ if(NOT TARGET PTL::ptl-static) + add_subdirectory(ptl EXCLUDE_FROM_ALL) + endif() + +-rocprofiler_checkout_git_submodule( +- RECURSIVE +- RELATIVE_PATH external/yaml-cpp +- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} +- REPO_URL https://github.com/jbeder/yaml-cpp.git +- REPO_BRANCH "master") ++if(ROCPROFILER_BUILD_YAML_CPP) ++ rocprofiler_checkout_git_submodule( ++ RECURSIVE ++ RELATIVE_PATH external/yaml-cpp ++ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ++ REPO_URL https://github.com/jbeder/yaml-cpp.git ++ REPO_BRANCH "master") + +-add_subdirectory(yaml-cpp EXCLUDE_FROM_ALL) ++ add_subdirectory(yaml-cpp EXCLUDE_FROM_ALL) + +-target_link_libraries(rocprofiler-sdk-yaml-cpp +- INTERFACE $) +-target_include_directories( +- rocprofiler-sdk-yaml-cpp +- INTERFACE $) ++ target_link_libraries(rocprofiler-sdk-yaml-cpp ++ INTERFACE $) ++ target_include_directories( ++ rocprofiler-sdk-yaml-cpp ++ INTERFACE $) ++else() ++ find_package(yaml-cpp 0.8.0 REQUIRED) ++ target_link_libraries(rocprofiler-sdk-yaml-cpp INTERFACE yaml-cpp::yaml-cpp) ++endif() + + # checkout submodule if not already checked out or clone repo if no .gitmodules file + rocprofiler_checkout_git_submodule( +-- +2.55.0 + diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0003-allow-using-system-elfio-dependency.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0003-allow-using-system-elfio-dependency.patch new file mode 100644 index 0000000000000..702f380edb420 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0003-allow-using-system-elfio-dependency.patch @@ -0,0 +1,70 @@ +From 27cec58fefe73c26ccca212ebbc002a0b9c1bfa5 Mon Sep 17 00:00:00 2001 +From: Anund +Date: Sun, 11 Oct 2026 17:29:50 +1100 +Subject: [PATCH 3/8] allow using system elfio dependency + +--- + cmake/rocprofiler_options.cmake | 2 ++ + external/CMakeLists.txt | 33 +++++++++++++++++++-------------- + 2 files changed, 21 insertions(+), 14 deletions(-) + +diff --git a/cmake/rocprofiler_options.cmake b/cmake/rocprofiler_options.cmake +index faee11049f..a09af6c2c9 100644 +--- a/cmake/rocprofiler_options.cmake ++++ b/cmake/rocprofiler_options.cmake +@@ -67,6 +67,8 @@ rocprofiler_add_option(ROCPROFILER_BUILD_GOTCHA + "Enable building gotcha library internally" ON) + rocprofiler_add_option(ROCPROFILER_BUILD_YAML_CPP + "Enable building yaml-cpp library internally" ON) ++rocprofiler_add_option(ROCPROFILER_BUILD_ELFIO ++ "Enable building ELFIO library internally" ON) + if(ROCPROFILER_BUILD_TESTS) + rocprofiler_add_option( + ROCPROFILER_BUILD_GTEST +diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt +index cab59c07bd..a75229edf3 100644 +--- a/external/CMakeLists.txt ++++ b/external/CMakeLists.txt +@@ -201,20 +201,25 @@ target_link_libraries( + INTERFACE $) + + # ELFIO +-rocprofiler_checkout_git_submodule( +- RECURSIVE +- RELATIVE_PATH external/elfio +- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} +- REPO_URL https://github.com/serge1/ELFIO.git +- REPO_BRANCH "Release_3.12") +- +-set(ELFIO_BUILD_EXAMPLES OFF) +-set(ELFIO_BUILD_TESTS OFF) +-add_subdirectory(elfio EXCLUDE_FROM_ALL) +-if(TARGET rocprofiler-sdk-elfio) +- get_target_property(ELFIO_INCLUDE_DIR elfio::elfio INTERFACE_INCLUDE_DIRECTORIES) +- target_include_directories(rocprofiler-sdk-elfio SYSTEM +- INTERFACE ${ELFIO_INCLUDE_DIR}) ++if(ROCPROFILER_BUILD_ELFIO) ++ rocprofiler_checkout_git_submodule( ++ RECURSIVE ++ RELATIVE_PATH external/elfio ++ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ++ REPO_URL https://github.com/serge1/ELFIO.git ++ REPO_BRANCH "Release_3.12") ++ ++ set(ELFIO_BUILD_EXAMPLES OFF) ++ set(ELFIO_BUILD_TESTS OFF) ++ add_subdirectory(elfio EXCLUDE_FROM_ALL) ++ if(TARGET rocprofiler-sdk-elfio) ++ get_target_property(ELFIO_INCLUDE_DIR elfio::elfio INTERFACE_INCLUDE_DIRECTORIES) ++ target_include_directories(rocprofiler-sdk-elfio SYSTEM ++ INTERFACE ${ELFIO_INCLUDE_DIR}) ++ endif() ++else() ++ find_package(elfio REQUIRED GLOBAL) ++ target_link_libraries(rocprofiler-sdk-elfio INTERFACE elfio::elfio) + endif() + + # +-- +2.55.0 + diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0004-allow-using-system-otf2-dependency.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0004-allow-using-system-otf2-dependency.patch new file mode 100644 index 0000000000000..61a2888f79f8c --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0004-allow-using-system-otf2-dependency.patch @@ -0,0 +1,54 @@ +From d2c8a5872c8d2af1bc8c203ad75f7c1c83cfb919 Mon Sep 17 00:00:00 2001 +From: Anund +Date: Sun, 11 Oct 2026 17:30:13 +1100 +Subject: [PATCH 4/8] allow using system otf2 dependency + +--- + cmake/rocprofiler_options.cmake | 2 ++ + external/CMakeLists.txt | 17 +++++++++-------- + 2 files changed, 11 insertions(+), 8 deletions(-) + +diff --git a/cmake/rocprofiler_options.cmake b/cmake/rocprofiler_options.cmake +index a09af6c2c9..19e092df06 100644 +--- a/cmake/rocprofiler_options.cmake ++++ b/cmake/rocprofiler_options.cmake +@@ -69,6 +69,8 @@ rocprofiler_add_option(ROCPROFILER_BUILD_YAML_CPP + "Enable building yaml-cpp library internally" ON) + rocprofiler_add_option(ROCPROFILER_BUILD_ELFIO + "Enable building ELFIO library internally" ON) ++rocprofiler_add_option(ROCPROFILER_BUILD_OTF2 ++ "Enable building OTF2 library internally" ON) + if(ROCPROFILER_BUILD_TESTS) + rocprofiler_add_option( + ROCPROFILER_BUILD_GTEST +diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt +index a75229edf3..e1be3df85e 100644 +--- a/external/CMakeLists.txt ++++ b/external/CMakeLists.txt +@@ -225,14 +225,15 @@ endif() + # + # OTF2 + # +-add_subdirectory(otf2) +- +-rocprofiler_checkout_git_submodule( +- RECURSIVE +- RELATIVE_PATH external/json +- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} +- REPO_URL https://github.com/nlohmann/json.git +- REPO_BRANCH "develop") ++if(ROCPROFILER_BUILD_OTF2) ++ add_subdirectory(otf2) ++else() ++ find_package(PkgConfig REQUIRED) ++ pkg_check_modules(OTF2 REQUIRED IMPORTED_TARGET otf2) ++ add_library(otf2 INTERFACE) ++ add_library(otf2::otf2 ALIAS otf2) ++ target_link_libraries(otf2 INTERFACE PkgConfig::OTF2) ++endif() + + # + # JSON +-- +2.55.0 + diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0005-allow-using-system-json-dependency.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0005-allow-using-system-json-dependency.patch new file mode 100644 index 0000000000000..b6cb539682c45 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0005-allow-using-system-json-dependency.patch @@ -0,0 +1,54 @@ +From 3c42b2a8491b44fa58940fcd44b45c64f1b43cf1 Mon Sep 17 00:00:00 2001 +From: Anund +Date: Sun, 11 Oct 2026 17:30:36 +1100 +Subject: [PATCH 5/8] allow using system json dependency + +--- + cmake/rocprofiler_options.cmake | 2 ++ + external/CMakeLists.txt | 17 +++++++++++++++++ + 2 files changed, 19 insertions(+) + +diff --git a/cmake/rocprofiler_options.cmake b/cmake/rocprofiler_options.cmake +index 19e092df06..b7a7a6cbdd 100644 +--- a/cmake/rocprofiler_options.cmake ++++ b/cmake/rocprofiler_options.cmake +@@ -71,6 +71,8 @@ rocprofiler_add_option(ROCPROFILER_BUILD_ELFIO + "Enable building ELFIO library internally" ON) + rocprofiler_add_option(ROCPROFILER_BUILD_OTF2 + "Enable building OTF2 library internally" ON) ++rocprofiler_add_option(ROCPROFILER_BUILD_JSON ++ "Enable building JSON library internally" ON) + if(ROCPROFILER_BUILD_TESTS) + rocprofiler_add_option( + ROCPROFILER_BUILD_GTEST +diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt +index e1be3df85e..a282232f22 100644 +--- a/external/CMakeLists.txt ++++ b/external/CMakeLists.txt +@@ -243,6 +243,23 @@ target_include_directories( + rocprofiler-sdk-json SYSTEM + INTERFACE $) + ++if(ROCPROFILER_BUILD_JSON) ++ rocprofiler_checkout_git_submodule( ++ RECURSIVE ++ RELATIVE_PATH external/json ++ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ++ REPO_URL https://github.com/nlohmann/json.git ++ REPO_BRANCH "develop") ++ ++ add_subdirectory(json) ++ target_include_directories( ++ rocprofiler-sdk-json SYSTEM ++ INTERFACE $) ++else() ++ find_package(nlohmann_json REQUIRED GLOBAL) ++ target_link_libraries(rocprofiler-sdk-json INTERFACE nlohmann_json::nlohmann_json) ++endif() ++ + # + # SQLite3 + # +-- +2.55.0 + diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0006-fix-amd-comgr-resolution.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0006-fix-amd-comgr-resolution.patch new file mode 100644 index 0000000000000..03103ec734619 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0006-fix-amd-comgr-resolution.patch @@ -0,0 +1,154 @@ +From 9977c287e106d9c494546212a3544e238363e219 Mon Sep 17 00:00:00 2001 +From: Anund +Date: Sun, 11 Oct 2026 16:52:24 +1100 +Subject: [PATCH 6/8] fix amd-comgr resolution + +--- + .../lib/att-tool/waitcnt/tests/CMakeLists.txt | 1 + + source/lib/python/utilities.cmake | 3 ++- + .../counters/tests/CMakeLists.txt | 2 ++ + .../pc_sampling/parser/tests/CMakeLists.txt | 20 ++++++++++++++----- + .../lib/rocprofiler-sdk/tests/CMakeLists.txt | 2 ++ + .../thread_trace/tests/CMakeLists.txt | 1 + + 6 files changed, 23 insertions(+), 6 deletions(-) + +diff --git a/source/lib/att-tool/waitcnt/tests/CMakeLists.txt b/source/lib/att-tool/waitcnt/tests/CMakeLists.txt +index 8a13e80cbe..48b3debc93 100644 +--- a/source/lib/att-tool/waitcnt/tests/CMakeLists.txt ++++ b/source/lib/att-tool/waitcnt/tests/CMakeLists.txt +@@ -10,6 +10,7 @@ target_link_libraries( + rocprofiler-sdk::rocprofiler-sdk-common-library + rocprofiler-sdk::rocprofiler-sdk-glog + rocprofiler-sdk::rocprofiler-sdk-static-library ++ rocprofiler-sdk::rocprofiler-sdk-amd-comgr + GTest::gtest + GTest::gtest_main) + target_sources(att-decoder-waitcnt-test PRIVATE att_decoder_waitcnt_test.cpp) +diff --git a/source/lib/python/utilities.cmake b/source/lib/python/utilities.cmake +index 1bc9171a3e..21bc9cfb3d 100644 +--- a/source/lib/python/utilities.cmake ++++ b/source/lib/python/utilities.cmake +@@ -209,7 +209,8 @@ function(rocprofiler_rocpd_python_bindings _VERSION) + rocprofiler-sdk::rocprofiler-sdk-gotcha + rocprofiler-sdk::rocprofiler-sdk-dw + rocprofiler-sdk::rocprofiler-sdk-static-library +- rocprofiler-sdk::rocprofiler-sdk-rocpd-library) ++ rocprofiler-sdk::rocprofiler-sdk-rocpd-library ++ rocprofiler-sdk::rocprofiler-sdk-amd-comgr) + + # if "Development" is specified instead of "Development.Module", we need to link to + # python libraries +diff --git a/source/lib/rocprofiler-sdk/counters/tests/CMakeLists.txt b/source/lib/rocprofiler-sdk/counters/tests/CMakeLists.txt +index 5e0d73e0f0..38251a7acc 100644 +--- a/source/lib/rocprofiler-sdk/counters/tests/CMakeLists.txt ++++ b/source/lib/rocprofiler-sdk/counters/tests/CMakeLists.txt +@@ -51,6 +51,7 @@ target_sources( + target_link_libraries( + counter_test_constants + PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library ++ rocprofiler-sdk::rocprofiler-sdk-amd-comgr + rocprofiler-sdk::rocprofiler-sdk-static-library + rocprofiler-sdk::rocprofiler-sdk-hip + rocprofiler-sdk::rocprofiler-sdk-hsa-runtime) +@@ -73,6 +74,7 @@ target_link_libraries( + rocprofiler-sdk::rocprofiler-sdk-hsa-runtime + rocprofiler-sdk::rocprofiler-sdk-hip + rocprofiler-sdk::rocprofiler-sdk-common-library ++ rocprofiler-sdk::rocprofiler-sdk-amd-comgr + rocprofiler-sdk::rocprofiler-sdk-static-library + GTest::gtest + GTest::gtest_main) +diff --git a/source/lib/rocprofiler-sdk/pc_sampling/parser/tests/CMakeLists.txt b/source/lib/rocprofiler-sdk/pc_sampling/parser/tests/CMakeLists.txt +index 1c512054d6..3bb64572e1 100644 +--- a/source/lib/rocprofiler-sdk/pc_sampling/parser/tests/CMakeLists.txt ++++ b/source/lib/rocprofiler-sdk/pc_sampling/parser/tests/CMakeLists.txt +@@ -30,7 +30,9 @@ target_include_directories(pcs_gfx9_test PRIVATE ${PCTEST_INCLUDE_DIR}) + target_link_libraries( + pcs_gfx9_test + PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library +- rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest ++ rocprofiler-sdk::rocprofiler-sdk-amd-comgr ++ rocprofiler-sdk::rocprofiler-sdk-static-library ++ GTest::gtest + GTest::gtest_main) + + gtest_add_tests( +@@ -52,7 +54,9 @@ target_include_directories(pcs_id_test PRIVATE ${PCTEST_INCLUDE_DIR}) + target_link_libraries( + pcs_id_test + PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library +- rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest ++ rocprofiler-sdk::rocprofiler-sdk-amd-comgr ++ rocprofiler-sdk::rocprofiler-sdk-static-library ++ GTest::gtest + GTest::gtest_main) + + gtest_add_tests( +@@ -75,7 +79,9 @@ target_include_directories(pcs_bench_test PRIVATE ${PCTEST_INCLUDE_DIR}) + target_link_libraries( + pcs_bench_test + PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library +- rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest ++ rocprofiler-sdk::rocprofiler-sdk-amd-comgr ++ rocprofiler-sdk::rocprofiler-sdk-static-library ++ GTest::gtest + GTest::gtest_main) + + add_executable(pcs_thread_test) +@@ -88,7 +94,9 @@ target_include_directories(pcs_thread_test PRIVATE ${PCTEST_INCLUDE_DIR}) + target_link_libraries( + pcs_thread_test + PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library +- rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest ++ rocprofiler-sdk::rocprofiler-sdk-amd-comgr ++ rocprofiler-sdk::rocprofiler-sdk-static-library ++ GTest::gtest + GTest::gtest_main) + + gtest_add_tests( +@@ -111,7 +119,9 @@ target_include_directories(pcs_gfx12_test PRIVATE ${PCTEST_INCLUDE_DIR}) + target_link_libraries( + pcs_gfx12_test + PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library +- rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest ++ rocprofiler-sdk::rocprofiler-sdk-amd-comgr ++ rocprofiler-sdk::rocprofiler-sdk-static-library ++ GTest::gtest + GTest::gtest_main) + + gtest_add_tests( +diff --git a/source/lib/rocprofiler-sdk/tests/CMakeLists.txt b/source/lib/rocprofiler-sdk/tests/CMakeLists.txt +index d71aa7c297..70dfe3376d 100644 +--- a/source/lib/rocprofiler-sdk/tests/CMakeLists.txt ++++ b/source/lib/rocprofiler-sdk/tests/CMakeLists.txt +@@ -28,6 +28,7 @@ target_sources(rocprofiler-sdk-lib-tests PRIVATE ${rocprofiler_lib_sources} + target_link_libraries( + rocprofiler-sdk-lib-tests + PRIVATE rocprofiler-sdk::rocprofiler-sdk-static-library ++ rocprofiler-sdk::rocprofiler-sdk-amd-comgr + rocprofiler-sdk::rocprofiler-sdk-common-library + rocprofiler-sdk::counter-test-constants + rocprofiler-sdk::rocprofiler-sdk-hsa-runtime +@@ -59,6 +60,7 @@ target_sources(rocprofiler-sdk-lib-tests-shared PRIVATE ${rocprofiler_shared_lib + target_link_libraries( + rocprofiler-sdk-lib-tests-shared + PRIVATE rocprofiler-sdk::rocprofiler-sdk-shared-library ++ rocprofiler-sdk::rocprofiler-sdk-amd-comgr + rocprofiler-sdk::rocprofiler-sdk-common-library + rocprofiler-sdk::rocprofiler-sdk-hsa-runtime + rocprofiler-sdk::rocprofiler-sdk-drm +diff --git a/source/lib/rocprofiler-sdk/thread_trace/tests/CMakeLists.txt b/source/lib/rocprofiler-sdk/thread_trace/tests/CMakeLists.txt +index 62acae39fb..7e867ba0a7 100644 +--- a/source/lib/rocprofiler-sdk/thread_trace/tests/CMakeLists.txt ++++ b/source/lib/rocprofiler-sdk/thread_trace/tests/CMakeLists.txt +@@ -14,6 +14,7 @@ target_link_libraries( + rocprofiler-sdk::rocprofiler-sdk-glog + rocprofiler-sdk::rocprofiler-sdk-hsa-runtime + rocprofiler-sdk::rocprofiler-sdk-hip ++ rocprofiler-sdk::rocprofiler-sdk-amd-comgr + rocprofiler-sdk::rocprofiler-sdk-common-library + GTest::gtest + GTest::gtest_main +-- +2.55.0 + diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0007-fix-missing-includes-and-api-changes-with-fmt-v12.2..patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0007-fix-missing-includes-and-api-changes-with-fmt-v12.2..patch new file mode 100644 index 0000000000000..970e2a89b67d4 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0007-fix-missing-includes-and-api-changes-with-fmt-v12.2..patch @@ -0,0 +1,260 @@ +From eb68d5d6dcdb085dc3d8d18576fee7cf998f6512 Mon Sep 17 00:00:00 2001 +From: Anund +Date: Sun, 11 Oct 2026 16:59:59 +1100 +Subject: [PATCH 7/8] fix missing includes and api changes with fmt v12.2.0 + +--- + source/lib/common/logging.cpp | 1 + + source/lib/output/generateRocpd.cpp | 1 + + source/lib/output/generateStats.cpp | 1 + + source/lib/output/metadata.cpp | 1 - + source/lib/output/metadata.hpp | 2 +- + source/lib/output/sql/common.hpp | 1 + + source/lib/python/rocpd/libpyrocpd.cpp | 1 + + source/lib/python/rocpd/source/serialization/sql.cpp | 3 +++ + source/lib/python/rocpd/source/sql_generator.hpp | 3 +++ + source/lib/rocprofiler-sdk-tool/tool.cpp | 3 ++- + source/lib/rocprofiler-sdk/counters/tests/device_counting.cpp | 1 + + source/lib/rocprofiler-sdk/counters/tests/dimension.cpp | 1 + + source/lib/rocprofiler-sdk/hip/details/format.hpp | 4 ++-- + source/lib/rocprofiler-sdk/hsa/aql_packet.cpp | 2 +- + source/lib/rocprofiler-sdk/hsa/details/fmt.hpp | 3 +++ + source/lib/rocprofiler-sdk/ompt.cpp | 2 +- + .../pc_sampling/parser/pc_record_interface.cpp | 2 ++ + source/lib/tests/common/parse.cpp | 1 + + 18 files changed, 26 insertions(+), 7 deletions(-) + +diff --git a/source/lib/common/logging.cpp b/source/lib/common/logging.cpp +index 6c07322b06..24aecbc23d 100644 +--- a/source/lib/common/logging.cpp ++++ b/source/lib/common/logging.cpp +@@ -25,6 +25,7 @@ + #include "lib/common/filesystem.hpp" + + #include ++#include + #include + #include + +diff --git a/source/lib/output/generateRocpd.cpp b/source/lib/output/generateRocpd.cpp +index 564a9bd45f..65d9a5d7cf 100644 +--- a/source/lib/output/generateRocpd.cpp ++++ b/source/lib/output/generateRocpd.cpp +@@ -56,6 +56,7 @@ + #include + + #include ++#include + #include + #include + +diff --git a/source/lib/output/generateStats.cpp b/source/lib/output/generateStats.cpp +index 22c1a7f425..3860be129b 100644 +--- a/source/lib/output/generateStats.cpp ++++ b/source/lib/output/generateStats.cpp +@@ -33,6 +33,7 @@ + #include + + #include ++#include + + #include + #include +diff --git a/source/lib/output/metadata.cpp b/source/lib/output/metadata.cpp +index abe9e00b50..f68d46de5b 100644 +--- a/source/lib/output/metadata.cpp ++++ b/source/lib/output/metadata.cpp +@@ -41,7 +41,6 @@ + #include + #include + +-#include + #include + + #include +diff --git a/source/lib/output/metadata.hpp b/source/lib/output/metadata.hpp +index 069401f962..a283896f29 100644 +--- a/source/lib/output/metadata.hpp ++++ b/source/lib/output/metadata.hpp +@@ -45,7 +45,7 @@ + #include + #include + +-#include ++#include + + #include + #include +diff --git a/source/lib/output/sql/common.hpp b/source/lib/output/sql/common.hpp +index 40fb8df9a8..97f96e06c4 100644 +--- a/source/lib/output/sql/common.hpp ++++ b/source/lib/output/sql/common.hpp +@@ -29,6 +29,7 @@ + #include "lib/common/units.hpp" + + #include ++#include + #include + + #include +diff --git a/source/lib/python/rocpd/libpyrocpd.cpp b/source/lib/python/rocpd/libpyrocpd.cpp +index 009afd694b..8ad4eb3458 100644 +--- a/source/lib/python/rocpd/libpyrocpd.cpp ++++ b/source/lib/python/rocpd/libpyrocpd.cpp +@@ -55,6 +55,7 @@ + #include + + #include ++#include + #include + #include + #include +diff --git a/source/lib/python/rocpd/source/serialization/sql.cpp b/source/lib/python/rocpd/source/serialization/sql.cpp +index d10e878be5..9192abc45b 100644 +--- a/source/lib/python/rocpd/source/serialization/sql.cpp ++++ b/source/lib/python/rocpd/source/serialization/sql.cpp +@@ -23,6 +23,9 @@ + #include "lib/python/rocpd/source/serialization/sql.hpp" + #include "lib/output/sql/common.hpp" + ++#include ++#include ++ + namespace cereal + { + SQLite3InputArchive::SQLite3InputArchive(sqlite3* conn, +diff --git a/source/lib/python/rocpd/source/sql_generator.hpp b/source/lib/python/rocpd/source/sql_generator.hpp +index 6284857afb..881ad23a72 100644 +--- a/source/lib/python/rocpd/source/sql_generator.hpp ++++ b/source/lib/python/rocpd/source/sql_generator.hpp +@@ -38,6 +38,9 @@ + #include + #include + ++#include ++#include ++ + namespace rocpd + { + namespace tool = ::rocprofiler::tool; +diff --git a/source/lib/rocprofiler-sdk-tool/tool.cpp b/source/lib/rocprofiler-sdk-tool/tool.cpp +index 7b03fa3eb8..6ddb2274e5 100644 +--- a/source/lib/rocprofiler-sdk-tool/tool.cpp ++++ b/source/lib/rocprofiler-sdk-tool/tool.cpp +@@ -78,7 +78,8 @@ + #include + #include + +-#include ++#include ++#include + + #include + #include +diff --git a/source/lib/rocprofiler-sdk/counters/tests/device_counting.cpp b/source/lib/rocprofiler-sdk/counters/tests/device_counting.cpp +index 9587b219f3..d82a6ec40b 100644 +--- a/source/lib/rocprofiler-sdk/counters/tests/device_counting.cpp ++++ b/source/lib/rocprofiler-sdk/counters/tests/device_counting.cpp +@@ -39,6 +39,7 @@ + #include + + #include ++#include + #include + #include + #include +diff --git a/source/lib/rocprofiler-sdk/counters/tests/dimension.cpp b/source/lib/rocprofiler-sdk/counters/tests/dimension.cpp +index 387c167bd0..22fcda9bf7 100644 +--- a/source/lib/rocprofiler-sdk/counters/tests/dimension.cpp ++++ b/source/lib/rocprofiler-sdk/counters/tests/dimension.cpp +@@ -39,6 +39,7 @@ + #include + + #include ++#include + #include + #include + #include +diff --git a/source/lib/rocprofiler-sdk/hip/details/format.hpp b/source/lib/rocprofiler-sdk/hip/details/format.hpp +index f65cf016a6..46f734d65d 100644 +--- a/source/lib/rocprofiler-sdk/hip/details/format.hpp ++++ b/source/lib/rocprofiler-sdk/hip/details/format.hpp +@@ -31,8 +31,8 @@ + #include + #include + +-#include "fmt/core.h" +-#include "fmt/ranges.h" ++#include ++#include + + #define ROCP_SDK_HIP_FORMATTER(TYPE, ...) \ + template <> \ +diff --git a/source/lib/rocprofiler-sdk/hsa/aql_packet.cpp b/source/lib/rocprofiler-sdk/hsa/aql_packet.cpp +index f1c0c3a56e..389a182e9d 100644 +--- a/source/lib/rocprofiler-sdk/hsa/aql_packet.cpp ++++ b/source/lib/rocprofiler-sdk/hsa/aql_packet.cpp +@@ -21,7 +21,7 @@ + // THE SOFTWARE. + + #include "lib/rocprofiler-sdk/hsa/aql_packet.hpp" +-#include ++#include + #include + #include + #include "lib/common/logging.hpp" +diff --git a/source/lib/rocprofiler-sdk/hsa/details/fmt.hpp b/source/lib/rocprofiler-sdk/hsa/details/fmt.hpp +index c136a2739c..f0d7d9e94f 100644 +--- a/source/lib/rocprofiler-sdk/hsa/details/fmt.hpp ++++ b/source/lib/rocprofiler-sdk/hsa/details/fmt.hpp +@@ -22,6 +22,9 @@ + + #include "lib/rocprofiler-sdk/hsa/queue.hpp" + ++#include ++#include ++ + namespace fmt + { + template <> +diff --git a/source/lib/rocprofiler-sdk/ompt.cpp b/source/lib/rocprofiler-sdk/ompt.cpp +index a9ccc571c8..0d7166465a 100644 +--- a/source/lib/rocprofiler-sdk/ompt.cpp ++++ b/source/lib/rocprofiler-sdk/ompt.cpp +@@ -31,7 +31,7 @@ + #include + #include + +-#include ++#include + #include + #include + +diff --git a/source/lib/rocprofiler-sdk/pc_sampling/parser/pc_record_interface.cpp b/source/lib/rocprofiler-sdk/pc_sampling/parser/pc_record_interface.cpp +index 8d418df50e..a4163529c1 100644 +--- a/source/lib/rocprofiler-sdk/pc_sampling/parser/pc_record_interface.cpp ++++ b/source/lib/rocprofiler-sdk/pc_sampling/parser/pc_record_interface.cpp +@@ -24,6 +24,8 @@ + + #include "lib/common/utility.hpp" + ++#include ++ + template <> + uint64_t + PCSamplingParserContext::alloc( +diff --git a/source/lib/tests/common/parse.cpp b/source/lib/tests/common/parse.cpp +index 5e3b63c85f..ccfc0912bc 100644 +--- a/source/lib/tests/common/parse.cpp ++++ b/source/lib/tests/common/parse.cpp +@@ -23,6 +23,7 @@ + #include + + #include ++#include + #include + + #include +-- +2.55.0 + diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0008-fix-compilation-errors-from-missing-includes.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0008-fix-compilation-errors-from-missing-includes.patch new file mode 100644 index 0000000000000..ab694273ab2c2 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0008-fix-compilation-errors-from-missing-includes.patch @@ -0,0 +1,93 @@ +From 3346d7d75513445c19f04a9e972216522752e469 Mon Sep 17 00:00:00 2001 +From: Anund +Date: Sun, 11 Oct 2026 17:00:20 +1100 +Subject: [PATCH 8/8] fix compilation errors from missing includes + +--- + source/lib/att-tool/att_lib_wrapper.hpp | 2 ++ + source/lib/att-tool/wave.hpp | 1 + + source/lib/rocprofiler-sdk-rocpd/sql.cpp | 1 + + source/lib/rocprofiler-sdk/counters/metrics.cpp | 1 + + source/lib/rocprofiler-sdk/counters/metrics.hpp | 1 + + source/lib/rocprofiler-sdk/tests/status.cpp | 1 + + 6 files changed, 7 insertions(+) + +diff --git a/source/lib/att-tool/att_lib_wrapper.hpp b/source/lib/att-tool/att_lib_wrapper.hpp +index e7e58c5991..7dcd000a43 100644 +--- a/source/lib/att-tool/att_lib_wrapper.hpp ++++ b/source/lib/att-tool/att_lib_wrapper.hpp +@@ -28,9 +28,11 @@ + #include + + #include ++#include + #include + #include + #include ++#include + #include + + namespace rocprofiler +diff --git a/source/lib/att-tool/wave.hpp b/source/lib/att-tool/wave.hpp +index 1a7b1adda6..65686d8ea3 100644 +--- a/source/lib/att-tool/wave.hpp ++++ b/source/lib/att-tool/wave.hpp +@@ -29,6 +29,7 @@ + #include "waitcnt/analysis.hpp" + #include "wstates.hpp" + ++#include + #include + #include + #include +diff --git a/source/lib/rocprofiler-sdk-rocpd/sql.cpp b/source/lib/rocprofiler-sdk-rocpd/sql.cpp +index b052ec51c3..7e8742686e 100644 +--- a/source/lib/rocprofiler-sdk-rocpd/sql.cpp ++++ b/source/lib/rocprofiler-sdk-rocpd/sql.cpp +@@ -39,6 +39,7 @@ + #include + + #include ++#include + #include + #include + +diff --git a/source/lib/rocprofiler-sdk/counters/metrics.cpp b/source/lib/rocprofiler-sdk/counters/metrics.cpp +index 201ae4fd25..4780a0ba31 100644 +--- a/source/lib/rocprofiler-sdk/counters/metrics.cpp ++++ b/source/lib/rocprofiler-sdk/counters/metrics.cpp +@@ -45,6 +45,7 @@ + #include // for dladdr + #include + #include ++#include + #include + #include + +diff --git a/source/lib/rocprofiler-sdk/counters/metrics.hpp b/source/lib/rocprofiler-sdk/counters/metrics.hpp +index 7915bc8805..a893c2c9b3 100644 +--- a/source/lib/rocprofiler-sdk/counters/metrics.hpp ++++ b/source/lib/rocprofiler-sdk/counters/metrics.hpp +@@ -35,6 +35,7 @@ + #include + #include + #include ++#include + + namespace rocprofiler + { +diff --git a/source/lib/rocprofiler-sdk/tests/status.cpp b/source/lib/rocprofiler-sdk/tests/status.cpp +index a5a492101d..b01f511b99 100644 +--- a/source/lib/rocprofiler-sdk/tests/status.cpp ++++ b/source/lib/rocprofiler-sdk/tests/status.cpp +@@ -25,6 +25,7 @@ + + #include + ++#include + #include + + TEST(rocprofiler_lib, error_string) +-- +2.55.0 + diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0009-rocprofiler-sdk-guard-ompt-auto-start.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0009-rocprofiler-sdk-guard-ompt-auto-start.patch new file mode 100644 index 0000000000000..147d79483318e --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0009-rocprofiler-sdk-guard-ompt-auto-start.patch @@ -0,0 +1,50 @@ +From 502d2df0ddd84f0f2fa718b9a02ee0f01f36dac1 Mon Sep 17 00:00:00 2001 +From: Luna Nova +Date: Tue, 2 Jun 2026 01:31:05 -0700 +Subject: [PATCH] [rocprofiler-sdk] don't auto-start OMPT tool before glog is + initialized + +The OpenMP runtime resolves its weak ompt_start_tool to the strong symbol we +export and calls it during OpenMP init. That can fire from an unrelated +library's constructor (observed: OpenBLAS calling omp_get_num_places) while +librocprofiler-sdk is still being dlopen'd. init_logging() then dereferences +glog's gflags FLAGS_vmodule, whose backing pointer is still null until glog's +static initializers run, and the process segfaults on `import torch`. + +The init order is not reliably fixable from here: a dependency cycle among the +ROCm libraries makes the loader run our constructors before libglog's, so a +flag set by our own constructor does not imply glog is ready. Instead gate the +tool start on glog itself, by testing whether gflags has populated FLAGS_vmodule +yet; reading the raw pointer is safe even before construction. It is read via an +asm label because the gflags header only exposes it as a reference, which the +compiler assumes is never null. Declining (nullptr) when glog is not yet ready +is a valid OMPT "no tool" response; deliberate profiling (rocprofv3 preloads the +tool early, before such constructors) is unaffected. +--- + source/lib/rocprofiler-sdk/ompt.cpp | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/source/lib/rocprofiler-sdk/ompt.cpp b/source/lib/rocprofiler-sdk/ompt.cpp +index a9ccc57..3231087 100644 +--- a/source/lib/rocprofiler-sdk/ompt.cpp ++++ b/source/lib/rocprofiler-sdk/ompt.cpp +@@ -199,6 +199,8 @@ finalize_ompt() + } // namespace ompt + } // namespace rocprofiler + ++extern void* const rocprofiler_glog_vmodule_flag asm("_ZN3fLS13FLAGS_vmoduleB5cxx11E"); ++ + extern "C" { + + rocprofiler_status_t +@@ -245,6 +247,8 @@ ompt_start_tool(unsigned int omp_version, const char* runtime_version) ROCPROFIL + ompt_start_tool_result_t* + ompt_start_tool(unsigned int omp_version, const char* runtime_version) + { ++ if(rocprofiler_glog_vmodule_flag == nullptr) return nullptr; ++ + ::rocprofiler::registration::init_logging(); + ::rocprofiler::registration::initialize(); + return rocprofiler_ompt_start_tool(omp_version, runtime_version); +-- +2.54.0 diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/default.nix b/pkgs/development/rocm-modules/10/rocprofiler-sdk/default.nix new file mode 100644 index 0000000000000..a93c5e93c4e3e --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprofiler-sdk/default.nix @@ -0,0 +1,226 @@ +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + ninja, + pkg-config, + clr, + rocm-cmake, + rocm-runtime, + rocprofiler-register, + rocprof-trace-decoder, + aqlprofile, + rocm-comgr, + rocmUpdateScript, + rccl, + python3, + python3Packages, + libdrm, + elfutils, + sqlite, + otf2, + zlib, + zstd, + xz, + numactl, + fmt, + glog, + gtest, + fetchpatch, + yaml-cpp, + elfio, + nlohmann_json, + makeWrapper, + gpuTargets ? (clr.localGpuTargets or clr.gpuTargets), + buildTests ? false, + buildSamples ? false, +}: + +# FIXME: devendor remaining git submodules: +# external/cereal -> https://github.com/jrmadsen/cereal +# external/gotcha -> https://github.com/jrmadsen/GOTCHA +# external/perfetto -> https://github.com/google/perfetto +# external/ptl -> https://github.com/jrmadsen/PTL + +# rocprofiler-sdk is the home of rocprofv3 +stdenv.mkDerivation (finalAttrs: { + pname = "rocprofiler-sdk"; + version = "7.2.4"; + + outputs = [ + "out" + "dev" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-systems"; + tag = "rocm-${finalAttrs.version}"; + hash = "sha256-7XCxu917Mgp3SQAKlTWj3ympgwOYW3aJFcOv/GhPk1c="; + fetchSubmodules = true; + sparseCheckout = [ + "projects/rocprofiler-sdk" + ]; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rocprofiler-sdk"; + + strictDeps = true; + + nativeBuildInputs = [ + cmake + ninja + pkg-config + clr + python3 + makeWrapper + ]; + + buildInputs = [ + clr + rocm-cmake + rocm-runtime + rocprofiler-register + aqlprofile + rocm-comgr + libdrm + elfutils + sqlite + otf2 + zlib + zstd + xz + numactl + fmt + glog + gtest + yaml-cpp + elfio + nlohmann_json + rccl + python3Packages.pybind11 + ]; + + patches = [ + (fetchpatch { + # Fix missing amd_comgr linkage in pc-sampling integration test + url = "https://github.com/ROCm/rocm-systems/commit/94a4595a5d02bc066f7a32e1b2134a99a5231213.patch"; + hash = "sha256-86Fx0bKL0pvXTwVN8QJL+yzCbMYkmMaKzcU4PYcW6ig="; + relative = "projects/rocprofiler-sdk"; + }) + ] + ++ [ + # Just the missing CPackComponent reference sourced from this commit: + # https://github.com/ROCm/rocm-systems/commit/86ee7b2eb2273adaf1181ef9a6b2091465c6f0c7 + ./0001-fix-missing-CPackComponent-cmake-include.patch + ] + ++ [ + # Can be removed when a release contains the changes found in this pr: + # https://github.com/ROCm/rocm-systems/pull/4721 + ./0002-allow-using-system-yaml-dependency.patch + ./0003-allow-using-system-elfio-dependency.patch + ./0004-allow-using-system-otf2-dependency.patch + ./0005-allow-using-system-json-dependency.patch + ./0006-fix-amd-comgr-resolution.patch + ] + ++ [ + # Sourced from several commits that address issues with fmt, dropping conflicting changes no longer needed to build + # https://github.com/ROCm/rocm-systems/commit/36d9d33d90879bfbd406498011070ebd929a56b1 + # https://github.com/ROCm/rocm-systems/commit/e2f588592ecfb0653ed5b3078753186325adf70a + # https://github.com/ROCm/rocm-systems/commit/86ee7b2eb2273adaf1181ef9a6b2091465c6f0c7 (just the fmt changes) + ./0007-fix-missing-includes-and-api-changes-with-fmt-v12.2..patch + ] + ++ [ + # One new import failure added to source commit: + # https://github.com/ROCm/rocm-systems/pull/4721/changes/f7f24a54cbe55425fbefc87c7a3d0f4c85224948 + # which is also part of https://github.com/ROCm/rocm-systems/pull/4721 + ./0008-fix-compilation-errors-from-missing-includes.patch + ] + ++ [ + # Prevent a segfault on `import torch` (and other consumers that link + # librocprofiler-sdk for tracing) when OpenMP auto-discovers our + # ompt_start_tool before glog is initialized. Upstream incidentally fixes + # this by dropping glog in rocm-systems d80117889b3f + # "[rocprofiler-sdk] Migrate from glog to Abseil Logging (#4668)", which + # is too invasive (40 files + new abseil submodule) to backport. + ./0009-rocprofiler-sdk-guard-ompt-auto-start.patch + ]; + + postPatch = '' + # NixOS' ROCm distribution does not support libomptarget yet + substituteInPlace samples/CMakeLists.txt \ + --replace-fail 'add_subdirectory(openmp_target)' '# add_subdirectory(openmp_target)' + substituteInPlace tests/CMakeLists.txt \ + --replace-fail 'add_subdirectory(openmp-tools)' '# add_subdirectory(openmp-tools)' + substituteInPlace tests/bin/CMakeLists.txt \ + --replace-fail 'add_subdirectory(openmp)' '# add_subdirectory(openmp)' + + # This requires building perfetto's trace-processor-shell via a weird external script + substituteInPlace tests/CMakeLists.txt \ + --replace-fail 'add_subdirectory(pytest-packages)' "" + + patchShebangs source/libexec/rocprofiler-sdk/rocprofiler-sdk-launch-compiler/rocprofiler-sdk-launch-compiler.sh + ''; + + cmakeFlags = [ + (lib.cmakeBool "ROCPROFILER_BUILD_GHC_FS" false) + (lib.cmakeBool "ROCPROFILER_BUILD_FMT" false) + (lib.cmakeBool "ROCPROFILER_BUILD_GLOG" false) + (lib.cmakeBool "ROCPROFILER_BUILD_GTEST" false) + (lib.cmakeBool "ROCPROFILER_BUILD_PYBIND11" false) + (lib.cmakeBool "ROCPROFILER_BUILD_YAML_CPP" false) + (lib.cmakeBool "ROCPROFILER_BUILD_ELFIO" false) + (lib.cmakeBool "ROCPROFILER_BUILD_OTF2" false) + (lib.cmakeBool "ROCPROFILER_BUILD_JSON" false) + (lib.cmakeBool "ROCPROFILER_BUILD_TESTS" buildTests) + (lib.cmakeBool "ROCPROFILER_BUILD_SAMPLES" buildSamples) + (lib.cmakeBool "ROCPROFILER_BUILD_BENCHMARK" false) + (lib.cmakeBool "ROCPROFILER_BUILD_WERROR" false) + # rocprofiler-sdk's CMake file doesn't add this dependency properly. + "-DCMAKE_HIP_FLAGS=-I${rocm-runtime}/include" + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + # Required for rocprofiler-sdk-launch-compiler.sh + "-DCMAKE_INSTALL_LIBEXECDIR=libexec" + "--debug-find-pkg=amd_comgr" + "--trace-source=tests/pc_sampling/CMakeLists.txt" + "--trace-expand" + ] + ++ lib.optionals (buildTests || buildSamples) [ + # rocprofiler-sdk normally doesn't depend on which GPU is in the system, only when + # building tests or samples. + (lib.cmakeFeature "GPU_TARGETS" (lib.concatStringsSep ";" gpuTargets)) + ]; + cxxCMakeFlags = [ + "-Wno-unused-variable" + ]; + + doCheck = false; # Requires GPU + + postFixup = '' + patchelf $out/lib/*.so \ + --add-rpath ${aqlprofile}/lib \ + --add-needed libhsa-amd-aqlprofile64.so + + wrapProgram $out/bin/rocprofv3 --add-flags "--att-library-path ${ + lib.makeLibraryPath [ rocprof-trace-decoder ] + }" + ''; + + postInstall = '' + mkdir -p $dev/lib $dev/share/rocprofiler-sdk + mv $out/lib/cmake $dev/lib/ + mv $out/share/rocprofiler-sdk/{samples,tests} $dev/share/rocprofiler-sdk/ + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "ROCm GPU performance analysis SDK"; + homepage = "https://github.com/ROCm/rocprofiler-sdk"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocprofiler/default.nix b/pkgs/development/rocm-modules/10/rocprofiler/default.nix new file mode 100644 index 0000000000000..02500210e2d2b --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprofiler/default.nix @@ -0,0 +1,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.localGpuTargets or 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.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-systems"; + tag = "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_ + # 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 = lib.licenses.mit; # mitx11 + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocr-debug-agent/default.nix b/pkgs/development/rocm-modules/10/rocr-debug-agent/default.nix new file mode 100644 index 0000000000000..a153ff75e2847 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocr-debug-agent/default.nix @@ -0,0 +1,55 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + python3, + clr, + rocdbgapi, + elfutils, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocr-debug-agent"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocr_debug_agent"; + tag = "rocm-${finalAttrs.version}"; + hash = "sha256-w2Zg4kpuKy68DkVGsBTUsjRZoV/Y/Z3Q8s0oSIR3Ask="; + }; + + nativeBuildInputs = [ + cmake + clr + python3 # TODO: check for scripts that need patchShebangs in output + ]; + + buildInputs = [ + rocdbgapi + elfutils + ]; + + cmakeFlags = [ + "-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip" + "-DHIP_ROOT_DIR=${clr}" + "-DHIP_PATH=${clr}" + ]; + + # Weird install target + postInstall = '' + rm -rf $out/src + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "Library that provides some debugging functionality for ROCr"; + homepage = "https://github.com/ROCm/rocr_debug_agent"; + license = lib.licenses.ncsa; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocshmem/default.nix b/pkgs/development/rocm-modules/10/rocshmem/default.nix new file mode 100644 index 0000000000000..33c8f4cce5a46 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocshmem/default.nix @@ -0,0 +1,69 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + rocm-core, + rocm-runtime, + clr, + mpi, + useMpi ? true, + useReverseOffload ? useMpi, + buildExamples ? false, + gpuTargets ? (clr.localGpuTargets or [ ]), +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocshmem${clr.gpuArchSuffix}"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocSHMEM"; + tag = "rocm-${finalAttrs.version}"; + hash = "sha256-7TiUABwCVPvosoLdR8zN+QGiX+OD7iD+HKMLnGMmRYA="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + clr + ]; + + buildInputs = [ + rocm-runtime + ] + ++ lib.optionals useMpi [ + mpi + ]; + + cmakeFlags = [ + (lib.cmakeBool "CMAKE_POSITION_INDEPENDENT_CODE" true) + (lib.cmakeFeature "CMAKE_CXX_COMPILER" "hipcc") + (lib.cmakeFeature "ROCM_PATH" "${clr}") + (lib.cmakeFeature "ROCM_VERSION" rocm-core.ROCM_LIBPATCH_VERSION) + (lib.cmakeBool "USE_IPC" true) + (lib.cmakeBool "USE_RO" useReverseOffload) + (lib.cmakeBool "USE_SINGLE_NODE" (!useMpi)) + (lib.cmakeBool "USE_EXTERNAL_MPI" useMpi) + (lib.cmakeBool "BUILD_EXAMPLES" buildExamples) + (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") + (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") + (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") + ] + ++ lib.optionals (gpuTargets != [ ]) [ + (lib.cmakeFeature "GPU_TARGETS" (lib.concatStringsSep ";" gpuTargets)) + ]; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "The ROCm OpenSHMEM (rocSHMEM) runtime"; + homepage = "https://github.com/ROCm/rocSHMEM"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) From f7a6fe36c2e9f802eff42a31865709232834e073 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:53 -0700 Subject: [PATCH 23/79] rocmPackages_10: share rocprof-compute-viewer, mscclpp with rocmPackages rocprof-compute-viewer, mscclpp are unchanged between ROCm 7.2.4 and 10.1 (no 10.x upstream release, or versioned independently of ROCm), so the rocmPackages_10 scope calls the existing expression instead of copying it. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index fc71188cf36b6..6adebf4b7c681 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -82,8 +82,12 @@ let inherit (llvm) clang; }; + rocprof-compute-viewer = self.callPackage ../rocprof-compute-viewer { }; + roctracer = self.callPackage ./roctracer { }; + mscclpp = self.callPackage ../mscclpp { }; + half = self.callPackage ./half { }; # Even if config.rocmSupport is false we need rocmSupport true From 714d302a59ac40fee7211e2c10da6d6a497432e1 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:54 -0700 Subject: [PATCH 24/79] rocmPackages_10.aqlprofile: init at 10.1 Update the rocmPackages.aqlprofile copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/aqlprofile/default.nix | 6 +++--- pkgs/development/rocm-modules/10/default.nix | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/aqlprofile/default.nix b/pkgs/development/rocm-modules/10/aqlprofile/default.nix index 34b1d92f3d57f..84e13ff75271a 100644 --- a/pkgs/development/rocm-modules/10/aqlprofile/default.nix +++ b/pkgs/development/rocm-modules/10/aqlprofile/default.nix @@ -9,17 +9,17 @@ stdenv.mkDerivation (finalAttrs: { pname = "aqlprofile"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/aqlprofile" "shared" ]; - hash = "sha256-74HjB5Ughu17rSRx9mfCCsPJI4TVyXnT4aU7vIbm7ak="; + hash = "sha256-7yeEJoyShSCwy1MTCeArYBabh5qTVm5uZL8N74rvxPA="; }; sourceRoot = "${finalAttrs.src.name}/projects/aqlprofile"; diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 6adebf4b7c681..853eb103d4520 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -63,6 +63,8 @@ let inherit (self) rocmUpdateScript; }; + aqlprofile = self.callPackage ./aqlprofile { }; + rocm-docs-core = python3Packages.callPackage ../rocm-docs-core { }; hip-common = self.callPackage ./hip-common { }; From ccf1430f94cd469c525f1e99395a37fe87ffb6ba Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:54 -0700 Subject: [PATCH 25/79] rocmPackages_10.rocprof-trace-decoder: init at 0.2.2 Update the rocmPackages.rocprof-trace-decoder copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.rocprof-trace-decoder: 0.1.7 -> 0.2.2": Track the rocm-systems monorepo at the therock-10.1 tag (the project keeps its own 0.x version, so the tag cannot derive from finalAttrs.version). Drop both local patches: use-system-dependencies.patch is obsolete (upstream removed the json FetchContent and prefers system gtest) and fix-test-dependency.patch (PR #3800) is merged upstream. Disable the ATT integration tests, which need pyelftools and bundled fixtures. From "rocmPackages.rocprof-trace-decoder: take comgr and runtime from the scope": It took the top-level rocmPackages and used rocmPackages.rocm-comgr and rocmPackages.rocm-runtime, so the per-arch scopes (rocmPackages.gfx906, ...) and any other instance of the scope built it against the default set's libraries. Take them as scope arguments like every other package. The default rocmPackages.rocprof-trace-decoder derivation is unchanged. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 + .../10/rocprof-trace-decoder/default.nix | 25 +++--- .../fix-test-dependency.patch | 15 ---- .../use-system-dependencies.patch | 81 ------------------- 4 files changed, 14 insertions(+), 109 deletions(-) delete mode 100644 pkgs/development/rocm-modules/10/rocprof-trace-decoder/fix-test-dependency.patch delete mode 100644 pkgs/development/rocm-modules/10/rocprof-trace-decoder/use-system-dependencies.patch diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 853eb103d4520..a11712cb371a3 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -86,6 +86,8 @@ let rocprof-compute-viewer = self.callPackage ../rocprof-compute-viewer { }; + rocprof-trace-decoder = self.callPackage ./rocprof-trace-decoder { }; + roctracer = self.callPackage ./roctracer { }; mscclpp = self.callPackage ../mscclpp { }; diff --git a/pkgs/development/rocm-modules/10/rocprof-trace-decoder/default.nix b/pkgs/development/rocm-modules/10/rocprof-trace-decoder/default.nix index 3ab1bb6446886..77eaa6dc1e31d 100644 --- a/pkgs/development/rocm-modules/10/rocprof-trace-decoder/default.nix +++ b/pkgs/development/rocm-modules/10/rocprof-trace-decoder/default.nix @@ -2,7 +2,8 @@ lib, stdenv, fetchFromGitHub, - rocmPackages, + rocm-comgr, + rocm-runtime, cmake, python3, nlohmann_json, @@ -11,39 +12,37 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocprof-trace-decoder"; - version = "0.1.7"; + version = "0.2.2"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-systems"; - # No tags (yet?) - rev = "feeca99950c590e0b8228733405c4a1a10fa4773"; + # rocprof-trace-decoder keeps its own 0.x version, so the rocm-systems + # monorepo tag cannot be derived from finalAttrs.version like sibling packages. + rev = "therock-10.1"; sparseCheckout = [ "projects/rocprof-trace-decoder" "shared" ]; - hash = "sha256-aJhPiZf5380jj2IeCipgcTEQYogr5R19UnVwKRGnkxo="; + hash = "sha256-0cbkljtw/gZJwXPUpJuLXpQlXfR/MQgEGbLDsRdzpcw="; }; sourceRoot = "${finalAttrs.src.name}/projects/rocprof-trace-decoder"; - patches = [ - ./use-system-dependencies.patch - # https://github.com/ROCm/rocm-systems/pull/3800 - ./fix-test-dependency.patch - ]; - strictDeps = true; nativeBuildInputs = [ cmake ]; buildInputs = [ - rocmPackages.rocm-comgr - rocmPackages.rocm-runtime + rocm-comgr + rocm-runtime ]; cmakeFlags = [ (lib.cmakeBool "BUILD_TESTS" finalAttrs.finalPackage.doCheck) + # The ATT integration tests need the pyelftools python module + # and bundled trace-data fixtures; keep the unit tests, skip integration. + (lib.cmakeBool "BUILD_INTEGRATION_TESTS" false) ]; nativeCheckInputs = [ diff --git a/pkgs/development/rocm-modules/10/rocprof-trace-decoder/fix-test-dependency.patch b/pkgs/development/rocm-modules/10/rocprof-trace-decoder/fix-test-dependency.patch deleted file mode 100644 index 7278ec688094a..0000000000000 --- a/pkgs/development/rocm-modules/10/rocprof-trace-decoder/fix-test-dependency.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt -index a923cadce53..95a4d3a807f 100644 ---- a/test/CMakeLists.txt -+++ b/test/CMakeLists.txt -@@ -186,7 +186,9 @@ if(BUILD_INTEGRATION_TESTS) - WORKING_DIRECTORY - ${TEST_BIN_DIR} - FIXTURES_REQUIRED -- unpack_data) -+ unpack_data -+ DEPENDS -+ ${DATA}_execute) - endif() - endforeach(DATA) - endif() diff --git a/pkgs/development/rocm-modules/10/rocprof-trace-decoder/use-system-dependencies.patch b/pkgs/development/rocm-modules/10/rocprof-trace-decoder/use-system-dependencies.patch deleted file mode 100644 index 1f821a1110882..0000000000000 --- a/pkgs/development/rocm-modules/10/rocprof-trace-decoder/use-system-dependencies.patch +++ /dev/null @@ -1,81 +0,0 @@ -diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt -index a923cad..53b0f49 100644 ---- a/test/CMakeLists.txt -+++ b/test/CMakeLists.txt -@@ -34,13 +34,7 @@ if(DISABLE_COMGR) - endif() - - if(NOT APPLE AND BUILD_INTEGRATION_TESTS) -- # Add nlohmann JSON as an external dependency -- include(FetchContent) -- FetchContent_Declare( -- json -- GIT_REPOSITORY https://github.com/nlohmann/json.git -- GIT_TAG v3.11.3) -- FetchContent_MakeAvailable(json) -+ find_package(nlohmann_json REQUIRED) - - add_subdirectory(att-tool) - endif() -diff --git a/test/att-tool/CMakeLists.txt b/test/att-tool/CMakeLists.txt -index 208af16..acd161f 100644 ---- a/test/att-tool/CMakeLists.txt -+++ b/test/att-tool/CMakeLists.txt -@@ -1,7 +1,7 @@ - # - # ATT decoder wrapper library for use by the rocprofv3 tool - # --find_library(COMGR REQUIRED NAMES amd_comgr HINTS /opt/rocm/lib) -+find_library(COMGR REQUIRED NAMES amd_comgr) - - set(ATT_TOOL_SOURCE_FILES - waitcnt/analysis.cpp -@@ -19,8 +19,11 @@ set(ATT_TOOL_SOURCE_FILES - - set(DECODER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../source/) - --set(INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../include/ ${DECODER_SRC} ${CMAKE_CURRENT_SOURCE_DIR} ${json_SOURCE_DIR}/include /opt/rocm/include) --set(LINK_LIBS ${COMGR} pthread) -+set(INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../include/ ${DECODER_SRC} ${CMAKE_CURRENT_SOURCE_DIR}) -+find_path(COMGR_INCLUDE_DIR REQUIRED NAMES amd_comgr.h PATH_SUFFIXES amd_comgr) -+find_path(HSA_INCLUDE_DIR REQUIRED NAMES hsa/amd_hsa_elf.h) -+set(LINK_LIBS ${COMGR} pthread nlohmann_json::nlohmann_json) -+list(APPEND INCLUDE_DIRS ${COMGR_INCLUDE_DIR} ${HSA_INCLUDE_DIR}) - - # Sources re-globbed only for sanitizer builds - file(GLOB ATT_DECODER_V3_FILES -diff --git a/test/att-tool/sdk/disassembly.hpp b/test/att-tool/sdk/disassembly.hpp -index c054143..ec3d6d2 100644 ---- a/test/att-tool/sdk/disassembly.hpp -+++ b/test/att-tool/sdk/disassembly.hpp -@@ -22,7 +22,7 @@ - - #pragma once - --#include -+#include - #include - - #include -diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt -index 8adafc0..9501efe 100644 ---- a/test/unit/CMakeLists.txt -+++ b/test/unit/CMakeLists.txt -@@ -9,16 +9,7 @@ project(att-decoder-unit-tests LANGUAGES CXX) - set(CMAKE_CXX_STANDARD 17) - set(CMAKE_CXX_STANDARD_REQUIRED ON) - --# Fetch GoogleTest --include(FetchContent) --FetchContent_Declare( -- googletest -- GIT_REPOSITORY https://github.com/google/googletest.git -- GIT_TAG v1.14.0) --set(INSTALL_GTEST -- OFF -- CACHE BOOL "" FORCE) --FetchContent_MakeAvailable(googletest) -+find_package(GTest REQUIRED) - - enable_testing() - From d6929991aea7ee8e3dcf6645ec7683cafa9f1718 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:55 -0700 Subject: [PATCH 26/79] rocmPackages_10.rocdbgapi: init at 10.1 Update the rocmPackages.rocdbgapi copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.{rocdbgapi,rocr-debug-agent}: move to rocm-systems monorepo": ROCdbgapi and rocr_debug_agent moved into the rocm-systems monorepo in ROCm 10. Switch both to the sparse-checkout source (projects/ + shared) at the therock-10.1 tag. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ .../rocm-modules/10/rocdbgapi/default.nix | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index a11712cb371a3..76ea49641bb1a 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -90,6 +90,8 @@ let roctracer = self.callPackage ./roctracer { }; + rocdbgapi = self.callPackage ./rocdbgapi { }; + mscclpp = self.callPackage ../mscclpp { }; half = self.callPackage ./half { }; diff --git a/pkgs/development/rocm-modules/10/rocdbgapi/default.nix b/pkgs/development/rocm-modules/10/rocdbgapi/default.nix index 8cceaa35137b3..c0014ac9a3640 100644 --- a/pkgs/development/rocm-modules/10/rocdbgapi/default.nix +++ b/pkgs/development/rocm-modules/10/rocdbgapi/default.nix @@ -47,7 +47,7 @@ let in stdenv.mkDerivation (finalAttrs: { pname = "rocdbgapi"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -60,10 +60,16 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; - repo = "ROCdbgapi"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-KqvhwfIv8pbr8WbnfAKl71fg5yxbwYcpzZcGU9Htdkc="; + # ROCdbgapi lives in the rocm-systems monorepo since ROCm 10 + repo = "rocm-systems"; + tag = "therock-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocdbgapi" + "shared" + ]; + hash = "sha256-vadmzQL3Sqtbtf7vMKCN6jabBuxnugPHDJd2yDhVDTM="; }; + sourceRoot = "${finalAttrs.src.name}/projects/rocdbgapi"; nativeBuildInputs = [ cmake From 90c358a5797695248803cb14473677762ecf1abe Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:56 -0700 Subject: [PATCH 27/79] rocmPackages_10.rocgdb: init at 10.1 Update the rocmPackages.rocgdb copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.rocgdb: 7.2.4 -> 10.1.0". Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ pkgs/development/rocm-modules/10/rocgdb/default.nix | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 76ea49641bb1a..f10765a04559d 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -90,6 +90,8 @@ let roctracer = self.callPackage ./roctracer { }; + rocgdb = self.callPackage ./rocgdb { }; + rocdbgapi = self.callPackage ./rocdbgapi { }; mscclpp = self.callPackage ../mscclpp { }; diff --git a/pkgs/development/rocm-modules/10/rocgdb/default.nix b/pkgs/development/rocm-modules/10/rocgdb/default.nix index 918f624b673d2..4dbb291e5305f 100644 --- a/pkgs/development/rocm-modules/10/rocgdb/default.nix +++ b/pkgs/development/rocm-modules/10/rocgdb/default.nix @@ -23,13 +23,14 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocgdb"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "ROCgdb"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-oml/HLExnnjh7+axeWPZRWecpwK2BnzVOaGvXYhrxKs="; + # ROCgdb switched to the two-component therock-X.Y tag scheme in 10.0. + tag = "therock-${finalAttrs.version}"; + hash = "sha256-BenTuntdO+NUgzty0en2b7uaIvugISNU4rqxRG/Ka1w="; }; nativeBuildInputs = [ From 80a94c1165adadf5f601dbd449c6e3f1fdef3edd Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:56 -0700 Subject: [PATCH 28/79] rocmPackages_10.rocr-debug-agent: init at 10.1 Update the rocmPackages.rocr-debug-agent copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.{rocdbgapi,rocr-debug-agent}: move to rocm-systems monorepo": ROCdbgapi and rocr_debug_agent moved into the rocm-systems monorepo in ROCm 10. Switch both to the sparse-checkout source (projects/ + shared) at the therock-10.1 tag. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ .../rocm-modules/10/rocr-debug-agent/default.nix | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index f10765a04559d..03ea95c9224fc 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -94,6 +94,8 @@ let rocdbgapi = self.callPackage ./rocdbgapi { }; + rocr-debug-agent = self.callPackage ./rocr-debug-agent { }; + mscclpp = self.callPackage ../mscclpp { }; half = self.callPackage ./half { }; diff --git a/pkgs/development/rocm-modules/10/rocr-debug-agent/default.nix b/pkgs/development/rocm-modules/10/rocr-debug-agent/default.nix index a153ff75e2847..b134c42718a49 100644 --- a/pkgs/development/rocm-modules/10/rocr-debug-agent/default.nix +++ b/pkgs/development/rocm-modules/10/rocr-debug-agent/default.nix @@ -12,14 +12,20 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocr-debug-agent"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; - repo = "rocr_debug_agent"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-w2Zg4kpuKy68DkVGsBTUsjRZoV/Y/Z3Q8s0oSIR3Ask="; + # rocr_debug_agent lives in the rocm-systems monorepo since ROCm 10 + repo = "rocm-systems"; + tag = "therock-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocr-debug-agent" + "shared" + ]; + hash = "sha256-WpBG1ogF161EM3tgXnVGstyDBdCmTXQPUPnkZF1eF3A="; }; + sourceRoot = "${finalAttrs.src.name}/projects/rocr-debug-agent"; nativeBuildInputs = [ cmake From 6b5e088beca49b7c2d9940fc186f9ead4349fd09 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:57 -0700 Subject: [PATCH 29/79] rocmPackages_10.rocprofiler: init at 10.1 Update the rocmPackages.rocprofiler copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From the mass bump: - rocprofiler-register: drop 3 fetchpatches now upstream. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 4 ++++ pkgs/development/rocm-modules/10/rocprofiler/default.nix | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 03ea95c9224fc..d18d539f16a2a 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -80,6 +80,10 @@ let # hsakmt was merged into rocm-runtime hsakmt = self.rocm-runtime; + + rocprofiler = self.callPackage ./rocprofiler { + inherit (llvm) clang; + }; rocprofiler-register = self.callPackage ./rocprofiler-register { inherit (llvm) clang; }; diff --git a/pkgs/development/rocm-modules/10/rocprofiler/default.nix b/pkgs/development/rocm-modules/10/rocprofiler/default.nix index 02500210e2d2b..358a2467e7975 100644 --- a/pkgs/development/rocm-modules/10/rocprofiler/default.nix +++ b/pkgs/development/rocm-modules/10/rocprofiler/default.nix @@ -44,18 +44,18 @@ let in stdenv.mkDerivation (finalAttrs: { pname = "rocprofiler"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/rocprofiler" "shared" ]; fetchSubmodules = true; - hash = "sha256-Wo0pymD8LsrdczdIUEEVe5x2Id//KIFkh40kliAQgWo="; + hash = "sha256-vKs+2TpbxmHZNmQK0WDRRKohUTpu/Zkc1V1b8V+lExk="; }; sourceRoot = "${finalAttrs.src.name}/projects/rocprofiler"; From 29472b7330c6ac391e3f80cd14afb6c706d5d6fb Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:57 -0700 Subject: [PATCH 30/79] rocmPackages_10.rdc: init at 10.1 Update the rocmPackages.rdc copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.rdc: drop CXXFLAGS patch fixed upstream in therock-10.1": ROCm/rocm-systems#2423 was closed without merging, but therock-10.1 fixes the same problem: projects/rdc/CMakeLists.txt now appends to CMAKE_CXX_FLAGS instead of overwriting it. fix-cmake-cxxflags.patch no longer applies. The libcap pkg-config patch (#2424) is still needed and applies with offsets. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 + .../rocm-modules/10/rdc/default.nix | 10 +- .../10/rdc/fix-cmake-cxxflags.patch | 217 ------------------ 3 files changed, 6 insertions(+), 223 deletions(-) delete mode 100644 pkgs/development/rocm-modules/10/rdc/fix-cmake-cxxflags.patch diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index d18d539f16a2a..9f2264f660abc 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -65,6 +65,8 @@ let aqlprofile = self.callPackage ./aqlprofile { }; + rdc = self.callPackage ./rdc { }; + rocm-docs-core = python3Packages.callPackage ../rocm-docs-core { }; hip-common = self.callPackage ./hip-common { }; diff --git a/pkgs/development/rocm-modules/10/rdc/default.nix b/pkgs/development/rocm-modules/10/rdc/default.nix index 8c5debc4dec47..fe03b7f0510fd 100644 --- a/pkgs/development/rocm-modules/10/rdc/default.nix +++ b/pkgs/development/rocm-modules/10/rdc/default.nix @@ -49,7 +49,7 @@ let in stdenv.mkDerivation (finalAttrs: { pname = "rdc"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -64,19 +64,17 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/rdc" "shared" ]; - hash = "sha256-SmySauRxFnEQJVTjGYf4TpmQclTwZG2RZrk3u6ko5Qo="; + hash = "sha256-tcov375DXHX1L/HhACevulzBOhq7Gp08j8SDEuVgPYU="; }; sourceRoot = "${finalAttrs.src.name}/projects/rdc"; patches = [ - # https://github.com/ROCm/rocm-systems/pull/2423 - ./fix-cmake-cxxflags.patch - # https://github.com/ROCm/rocm-systems/pull/2424 + # Find libcap through pkg-config (https://github.com/ROCm/rocm-systems/pull/2424, closed) ./fix-libcap-pkgconfig.patch ]; diff --git a/pkgs/development/rocm-modules/10/rdc/fix-cmake-cxxflags.patch b/pkgs/development/rocm-modules/10/rdc/fix-cmake-cxxflags.patch deleted file mode 100644 index bf7f3dbb0eef4..0000000000000 --- a/pkgs/development/rocm-modules/10/rdc/fix-cmake-cxxflags.patch +++ /dev/null @@ -1,217 +0,0 @@ -From 92f25181dbf722cb749e445851580df4ea779299 Mon Sep 17 00:00:00 2001 -From: Luna Nova -Date: Sun, 21 Dec 2025 08:01:08 -0800 -Subject: [PATCH 1/2] fix(rdc): set CMAKE_CXX_FLAGS after project() to avoid - clobbering env - -CMAKE_CXX_FLAGS' initial value is set from $CXXFLAGS on project() call -so the previous location ignored CXXFLAGS from env or CMake toolchain -config. - -Ref: https://cmake.org/cmake/help/v4.2/variable/CMAKE_LANG_FLAGS_INIT.html -Fixes: 874a7b438f ("CMAKE - Fix build types") ---- - CMakeLists.txt | 48 +++++++++++++++++++------------------ - 1 file changed, 25 insertions(+), 23 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 907c9fbff42..8b386c7be3d 100755 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -55,29 +55,6 @@ set_property( - PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel" - ) - --# Set compile flags --set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64 -msse -msse2") --set(CMAKE_CXX_FLAGS_DEBUG -- "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -DDEBUG" -- CACHE STRING -- "Flags for Debug builds" --) --set(CMAKE_CXX_FLAGS_RELEASE -- "${CMAKE_CXX_FLAGS_RELEASE} -O2 -s -DNDEBUG" -- CACHE STRING -- "Flags for Release builds" --) --set(CMAKE_CXX_FLAGS_RELWITHDEBINFO -- "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG" -- CACHE STRING -- "Flags for RelWithDebInfo builds" --) --set(CMAKE_CXX_FLAGS_MINSIZEREL -- "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG" -- CACHE STRING -- "Flags for MinSizeRel builds" --) -- - set(CMAKE_MODULE_PATH - "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/" - CACHE INTERNAL -@@ -155,6 +132,31 @@ project(${RDC} VERSION "${VERSION_STRING}" HOMEPAGE_URL "https://github.com/Rade - # this must go after project() - include(GNUInstallDirs) - -+# NB: CMAKE__FLAGS are initialized from environment (CXXFLAGS et al.) -+# during project(). Setting them before project() discards env and toolchain -+# defaults. Cf. CMAKE__FLAGS_INIT for toolchain overrides. -+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64 -msse -msse2") -+set(CMAKE_CXX_FLAGS_DEBUG -+ "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -DDEBUG" -+ CACHE STRING -+ "Flags for Debug builds" -+) -+set(CMAKE_CXX_FLAGS_RELEASE -+ "${CMAKE_CXX_FLAGS_RELEASE} -O2 -s -DNDEBUG" -+ CACHE STRING -+ "Flags for Release builds" -+) -+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO -+ "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG" -+ CACHE STRING -+ "Flags for RelWithDebInfo builds" -+) -+set(CMAKE_CXX_FLAGS_MINSIZEREL -+ "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG" -+ CACHE STRING -+ "Flags for MinSizeRel builds" -+) -+ - set(COMMON_DIR "${CMAKE_CURRENT_SOURCE_DIR}/common") - - set(GRPC_ROOT_DEFAULT "/usr") - -From 0c8710c3570963b29c709b1cd1f78b15fd73a950 Mon Sep 17 00:00:00 2001 -From: Luna Nova -Date: Sun, 21 Dec 2025 08:13:04 -0800 -Subject: [PATCH 2/2] fix(rdc): don't reimplement CMake default build type flag - logic - -The previous approach was overly complicated and added nothing. CMake already defaults -similar flags for each of the default supported build types. -Additionally, the previous flags broke AArch64 as -m64 -msse are incompatible. -It's not necessary to explicitly set this with modern toolchains. - -Fixes: 874a7b438f ("CMAKE - Fix build types") -Fixes: bc7f01e992 ("Initial RDC commit") ---- - CMakeLists.txt | 25 +--------------------- - example/CMakeLists.txt | 26 ++--------------------- - tests/example/CMakeLists.txt | 24 +-------------------- - 3 files changed, 4 insertions(+), 71 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 8b386c7be3d..251fcddd653 100755 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -132,30 +132,7 @@ project(${RDC} VERSION "${VERSION_STRING}" HOMEPAGE_URL "https://github.com/Rade - # this must go after project() - include(GNUInstallDirs) - --# NB: CMAKE__FLAGS are initialized from environment (CXXFLAGS et al.) --# during project(). Setting them before project() discards env and toolchain --# defaults. Cf. CMAKE__FLAGS_INIT for toolchain overrides. --set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64 -msse -msse2") --set(CMAKE_CXX_FLAGS_DEBUG -- "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -DDEBUG" -- CACHE STRING -- "Flags for Debug builds" --) --set(CMAKE_CXX_FLAGS_RELEASE -- "${CMAKE_CXX_FLAGS_RELEASE} -O2 -s -DNDEBUG" -- CACHE STRING -- "Flags for Release builds" --) --set(CMAKE_CXX_FLAGS_RELWITHDEBINFO -- "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG" -- CACHE STRING -- "Flags for RelWithDebInfo builds" --) --set(CMAKE_CXX_FLAGS_MINSIZEREL -- "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG" -- CACHE STRING -- "Flags for MinSizeRel builds" --) -+add_compile_options(-Wall -Wextra) - - set(COMMON_DIR "${CMAKE_CURRENT_SOURCE_DIR}/common") - -diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt -index 378a2005818..7c51307ec38 100755 ---- a/example/CMakeLists.txt -+++ b/example/CMakeLists.txt -@@ -31,30 +31,6 @@ cmake_minimum_required(VERSION 3.15) - option(CMAKE_VERBOSE_MAKEFILE "Enable verbose output" ON) - option(CMAKE_EXPORT_COMPILE_COMMANDS "Export compile commands for linters and autocompleters" ON) - --# Set compile flags --set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64 -msse -msse2") --set(CMAKE_CXX_FLAGS_DEBUG -- "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -DDEBUG" -- CACHE STRING -- "Flags for Debug builds" --) --# note: no '-s' here unlike other CMakeLists.txt --set(CMAKE_CXX_FLAGS_RELEASE -- "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG" -- CACHE STRING -- "Flags for Release builds" --) --set(CMAKE_CXX_FLAGS_RELWITHDEBINFO -- "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG" -- CACHE STRING -- "Flags for RelWithDebInfo builds" --) --set(CMAKE_CXX_FLAGS_MINSIZEREL -- "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG" -- CACHE STRING -- "Flags for MinSizeRel builds" --) -- - set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard to use") - set(CMAKE_CXX_STANDARD_REQUIRED ON) - set(CMAKE_CXX_EXTENSIONS OFF) -@@ -66,6 +42,8 @@ endif() - - project(RDC_example) - -+add_compile_options(-Wall -Wextra) -+ - # provides cmake_print_variables(VAR) - include(CMakePrintHelpers) - -diff --git a/tests/example/CMakeLists.txt b/tests/example/CMakeLists.txt -index d5614f387bd..13c2f3857a1 100755 ---- a/tests/example/CMakeLists.txt -+++ b/tests/example/CMakeLists.txt -@@ -22,29 +22,7 @@ message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&") - message(" Cmake Example Lib ") - message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&") - --# Set compile flags --set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64 -msse -msse2") --set(CMAKE_CXX_FLAGS_DEBUG -- "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -DDEBUG" -- CACHE STRING -- "Flags for Debug builds" --) --# note: no '-s' here unlike other CMakeLists.txt --set(CMAKE_CXX_FLAGS_RELEASE -- "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG" -- CACHE STRING -- "Flags for Release builds" --) --set(CMAKE_CXX_FLAGS_RELWITHDEBINFO -- "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG" -- CACHE STRING -- "Flags for RelWithDebInfo builds" --) --set(CMAKE_CXX_FLAGS_MINSIZEREL -- "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG" -- CACHE STRING -- "Flags for MinSizeRel builds" --) -+add_compile_options(-Wall -Wextra) - - # Required Defines first: - From 6ea18ed121aac71690a7744f0c56c84905776dd8 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:58 -0700 Subject: [PATCH 31/79] rocmPackages_10.rccl: init at 10.1 Update the rocmPackages.rccl copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.rccl: monorepo source, rocm_smi -> amd_smi, drop mscclpp": rccl moved into the rocm-systems monorepo in ROCm 10. Switch to the sparse-checkout source and adapt: - rocm_smi -> amd_smi (CMakeLists find_package(amd_smi) gated on ROCM_VERSION >= 71100; SMI is dlopen'd at runtime). - Drop fix_hw_reg_hw_id_gt_gfx10.patch: its __trace_hwreg() target was removed when collTrace was restructured; the other hunk only touches tools/JitterBench (not built by default). - Drop the MSCCLPP integration (ENABLE_MSCCLPP / MSCCLPP_ROOT): upstream removed it from CMakeLists, so the separate mscclpp input is gone. Revised during the split review: Drop -DENABLE_MSCCL_KERNEL; 10.x no longer has the option. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ .../rocm-modules/10/rccl/default.nix | 29 +++++++--------- .../10/rccl/fix_hw_reg_hw_id_gt_gfx10.patch | 33 ------------------- 3 files changed, 14 insertions(+), 50 deletions(-) delete mode 100644 pkgs/development/rocm-modules/10/rccl/fix_hw_reg_hw_id_gt_gfx10.patch diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 9f2264f660abc..c129e332e4eed 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -104,6 +104,8 @@ let mscclpp = self.callPackage ../mscclpp { }; + rccl = self.callPackage ./rccl { }; + half = self.callPackage ./half { }; # Even if config.rocmSupport is false we need rocmSupport true diff --git a/pkgs/development/rocm-modules/10/rccl/default.nix b/pkgs/development/rocm-modules/10/rccl/default.nix index 1dbcd0c84945c..2269b178b9283 100644 --- a/pkgs/development/rocm-modules/10/rccl/default.nix +++ b/pkgs/development/rocm-modules/10/rccl/default.nix @@ -5,11 +5,10 @@ rocmUpdateScript, cmake, rocm-cmake, - rocm-smi, + amdsmi, rocm-core, pkg-config, clr, - mscclpp, perl, hipify, python3, @@ -40,7 +39,7 @@ in # infiniband ib_peer_mem support isn't in the mainline kernel but is carried by some distros stdenv.mkDerivation (finalAttrs: { pname = "rccl${clr.gpuArchSuffix}"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -51,15 +50,19 @@ stdenv.mkDerivation (finalAttrs: { patches = [ ./rccl-test-missing-iomanip.diff - ./fix_hw_reg_hw_id_gt_gfx10.patch ]; src = fetchFromGitHub { owner = "ROCm"; - repo = "rccl"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-A1IQYIDWqu3JLiPQ70G52s1/0ZweQxFlgMUH81qJWmU="; + repo = "rocm-systems"; + tag = "therock-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rccl" + "shared" + ]; + hash = "sha256-OkX15/P1wQ9E8QfAOklXvxmVw700kvIyi6CwdorqNhA="; }; + sourceRoot = "${finalAttrs.src.name}/projects/rccl"; requiredSystemFeatures = [ "big-parallel" ]; # Very resource intensive LTO @@ -75,13 +78,13 @@ stdenv.mkDerivation (finalAttrs: { ]; buildInputs = [ - rocm-smi + # Headers only; RCCL dlopens amd_smi at runtime. + amdsmi fmt gtest roctracer rocprofiler rocprofiler-register - mscclpp ] ++ lib.optionals buildTests [ chrpath @@ -95,10 +98,6 @@ stdenv.mkDerivation (finalAttrs: { "-DROCM_PATCH_VERSION=${rocm-core.ROCM_LIBPATCH_VERSION}" "-DROCM_VERSION=${rocm-core.ROCM_LIBPATCH_VERSION}" "-DBUILD_BFD=OFF" # Can't get it to detect bfd.h - "-DENABLE_MSCCL_KERNEL=ON" - # FIXME: this is still running a download because if(NOT mscclpp_nccl_FOUND) is commented out T_T - "-DENABLE_MSCCLPP=OFF" - #"-DMSCCLPP_ROOT=${mscclpp}" # Manually define CMAKE_INSTALL_ # See: https://github.com/NixOS/nixpkgs/pull/197838 "-DCMAKE_INSTALL_BINDIR=bin" @@ -121,10 +120,6 @@ stdenv.mkDerivation (finalAttrs: { env.LDFLAGS = "${san}"; postPatch = '' patchShebangs src tools - substituteInPlace CMakeLists.txt \ - --replace-fail '${"\${HOST_OS_ID}"}' '"ubuntu"' \ - --replace-fail 'target_include_directories(rccl PRIVATE ''${ROCM_SMI_INCLUDE_DIR})' \ - 'target_include_directories(rccl PRIVATE ''${ROCM_SMI_INCLUDE_DIRS})' ''; postInstall = diff --git a/pkgs/development/rocm-modules/10/rccl/fix_hw_reg_hw_id_gt_gfx10.patch b/pkgs/development/rocm-modules/10/rccl/fix_hw_reg_hw_id_gt_gfx10.patch deleted file mode 100644 index c69000814a8a6..0000000000000 --- a/pkgs/development/rocm-modules/10/rccl/fix_hw_reg_hw_id_gt_gfx10.patch +++ /dev/null @@ -1,33 +0,0 @@ -fix: __trace_hwreg should use HW_REG_HW_ID1 for all gfx10/11/12 -diff --git a/src/device/common.h b/src/device/common.h -index c6c61021..742885f4 100644 ---- a/src/device/common.h -+++ b/src/device/common.h -@@ -26,8 +26,9 @@ - { __atomic_store_n((DST), (SRC), __ATOMIC_SEQ_CST); } - #endif - --#if defined(__gfx1100__) || defined(__gfx1101__) || defined(__gfx1102__) || defined(__gfx1200__) || defined(__gfx1201__) --#define __trace_hwreg() -+#if defined(__GFX10__) || defined(__GFX11__) || defined(__GFX12__) -+#define __trace_hwreg() \ -+ asm volatile ("s_getreg_b32 %0, hwreg(HW_REG_HW_ID1)" : "=s" (collTrace->data_0)); - #else - #define __trace_hwreg() \ - asm volatile ("s_getreg_b32 %0, hwreg(HW_REG_HW_ID)" : "=s" (collTrace->data_0)); -diff --git a/tools/JitterBench/Common.hpp b/tools/JitterBench/Common.hpp -index bad12a1b..b59856a8 100644 ---- a/tools/JitterBench/Common.hpp -+++ b/tools/JitterBench/Common.hpp -@@ -43,9 +43,9 @@ THE SOFTWARE. - #endif - - // Macro for collecting HW_REG_HW_ID --#if defined(__gfx1100__) || defined(__gfx1101__) || defined(__gfx1102__) || defined(__NVCC__) -+#if defined(__GFX10__) || defined(__GFX11__) || defined(__GFX12__) - #define GetHwId(val) \ -- val = 0 -+ asm volatile ("s_getreg_b32 %0, hwreg(HW_REG_HW_ID1)" : "=s" (val)); - #else - #define GetHwId(val) \ - asm volatile ("s_getreg_b32 %0, hwreg(HW_REG_HW_ID)" : "=s" (val)); From e89558d595225db803b9baa7afb46bfccb767327 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:59 -0700 Subject: [PATCH 32/79] rocmPackages_10.rocprofiler-sdk: init at 10.1 Update the rocmPackages.rocprofiler-sdk copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.rocprofiler-sdk: drop patches upstreamed in therock-10.1": ROCm 10.1 merged the whole nixpkgs patch stack, so remove it: - 86ee7b2e / 36d9d33d / 94a4595a fetchpatches (system-libraries build, fmt memory header, amd_comgr linkage): present upstream. - 0001 (rename-consumer-test) and 0008 (stop-setting-warning-flags): only touched test CMakeLists; tests are off by default. - 0002 (missing STL headers), 0003 (amd-comgr dep), 0004 (find_package GLOBAL scoping): upstream. - 0005/0006/0007 (system elfio/otf2/json): the ROCPROFILER_BUILD_ELFIO/ OTF2/JSON options and their system-dependency branches are upstream (PR #2319 / #1243). - 0010 (fmt 12.2 format.h): upstream. The -DROCPROFILER_BUILD_{ELFIO,OTF2,JSON}=false cmakeFlags still drive those now-upstream options to use the system elfio/otf2/nlohmann_json. rocprofiler-sdk-tool now find_package(rocprof-trace-decoder REQUIRED)s at configure time, so add it as a build input. Revised during the split review: Drop the 0009 glog guard, the glog input and ROCPROFILER_BUILD_GLOG: the 10.1 SDK logs through Abseil (rocm-systems d80117889b3f is in therock-10.1), and the guard's glog symbol only resolved through rocprofiler-register. Add ompt-explicit-tool.patch: ompt_start_tool now declines unless a tool was requested through ROCP_TOOL_LIBRARIES (as rocprofv3 does) or rocprofiler_force_configure. Registering clients from libomp's initialisation dlopens every library defining rocprofiler_configure; with torch, libtorch_cpu (Kineto) is still loading, glibc reruns its pending constructors, and OpenBLAS reenters OpenMP initialisation, livelocking import. Clients found by symbol still register when the HIP runtime starts and only miss OMPT callbacks. This replaces the OMP_TOOL edit torch carried in PR 573885. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 1 + ...missing-CPackComponent-cmake-include.patch | 25 -- ...2-allow-using-system-yaml-dependency.patch | 68 ----- ...-allow-using-system-elfio-dependency.patch | 70 ----- ...4-allow-using-system-otf2-dependency.patch | 54 ---- ...5-allow-using-system-json-dependency.patch | 54 ---- .../0006-fix-amd-comgr-resolution.patch | 154 ----------- ...udes-and-api-changes-with-fmt-v12.2..patch | 260 ------------------ ...ilation-errors-from-missing-includes.patch | 93 ------- ...ocprofiler-sdk-guard-ompt-auto-start.patch | 50 ---- .../10/rocprofiler-sdk/default.nix | 97 +++---- .../rocprofiler-sdk/ompt-explicit-tool.patch | 76 +++++ 12 files changed, 109 insertions(+), 893 deletions(-) delete mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0001-fix-missing-CPackComponent-cmake-include.patch delete mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0002-allow-using-system-yaml-dependency.patch delete mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0003-allow-using-system-elfio-dependency.patch delete mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0004-allow-using-system-otf2-dependency.patch delete mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0005-allow-using-system-json-dependency.patch delete mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0006-fix-amd-comgr-resolution.patch delete mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0007-fix-missing-includes-and-api-changes-with-fmt-v12.2..patch delete mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0008-fix-compilation-errors-from-missing-includes.patch delete mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/0009-rocprofiler-sdk-guard-ompt-auto-start.patch create mode 100644 pkgs/development/rocm-modules/10/rocprofiler-sdk/ompt-explicit-tool.patch diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index c129e332e4eed..fc166698fcda2 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -89,6 +89,7 @@ let rocprofiler-register = self.callPackage ./rocprofiler-register { inherit (llvm) clang; }; + rocprofiler-sdk = self.callPackage ./rocprofiler-sdk { }; rocprof-compute-viewer = self.callPackage ../rocprof-compute-viewer { }; diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0001-fix-missing-CPackComponent-cmake-include.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0001-fix-missing-CPackComponent-cmake-include.patch deleted file mode 100644 index 1e65ac7a76ee5..0000000000000 --- a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0001-fix-missing-CPackComponent-cmake-include.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 5ae420cc204d0afb1ad388ddbceec237a4164569 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 17:28:05 +1100 -Subject: [PATCH 1/8] fix missing CPackComponent cmake include - ---- - cmake/rocprofiler_config_packaging.cmake | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/cmake/rocprofiler_config_packaging.cmake b/cmake/rocprofiler_config_packaging.cmake -index 84c2ecf230..55d9f58f38 100644 ---- a/cmake/rocprofiler_config_packaging.cmake -+++ b/cmake/rocprofiler_config_packaging.cmake -@@ -126,6 +126,8 @@ endif() - list(APPEND _DEB_PACKAGE_DEPENDS ${ROCPROFILER_CPACK_DEBIAN_PACKAGE_DEPENDS}) - list(APPEND _RPM_PACKAGE_REQUIRES ${ROCPROFILER_CPACK_RPM_PACKAGE_REQUIRES}) - -+include(CPackComponent) -+ - foreach(COMPONENT_GROUP ${ROCPROFILER_COMPONENT_GROUPS}) - set(_DEP "${COMPONENT_DEP_${COMPONENT_GROUP}}") - set(_NAME "${COMPONENT_NAME_${COMPONENT_GROUP}}") --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0002-allow-using-system-yaml-dependency.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0002-allow-using-system-yaml-dependency.patch deleted file mode 100644 index 3fa335a25eb9a..0000000000000 --- a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0002-allow-using-system-yaml-dependency.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 0477671140ffc3d1b50e1cca69f107b51112faa8 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 17:29:27 +1100 -Subject: [PATCH 2/8] allow using system yaml dependency - ---- - cmake/rocprofiler_options.cmake | 2 ++ - external/CMakeLists.txt | 29 +++++++++++++++++------------ - 2 files changed, 19 insertions(+), 12 deletions(-) - -diff --git a/cmake/rocprofiler_options.cmake b/cmake/rocprofiler_options.cmake -index 08d1032635..faee11049f 100644 ---- a/cmake/rocprofiler_options.cmake -+++ b/cmake/rocprofiler_options.cmake -@@ -65,6 +65,8 @@ rocprofiler_add_option(ROCPROFILER_BUILD_PYBIND11 - "Enable building pybind11 library internally" ON) - rocprofiler_add_option(ROCPROFILER_BUILD_GOTCHA - "Enable building gotcha library internally" ON) -+rocprofiler_add_option(ROCPROFILER_BUILD_YAML_CPP -+ "Enable building yaml-cpp library internally" ON) - if(ROCPROFILER_BUILD_TESTS) - rocprofiler_add_option( - ROCPROFILER_BUILD_GTEST -diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt -index 5bee3dc032..cab59c07bd 100644 ---- a/external/CMakeLists.txt -+++ b/external/CMakeLists.txt -@@ -131,20 +131,25 @@ if(NOT TARGET PTL::ptl-static) - add_subdirectory(ptl EXCLUDE_FROM_ALL) - endif() - --rocprofiler_checkout_git_submodule( -- RECURSIVE -- RELATIVE_PATH external/yaml-cpp -- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} -- REPO_URL https://github.com/jbeder/yaml-cpp.git -- REPO_BRANCH "master") -+if(ROCPROFILER_BUILD_YAML_CPP) -+ rocprofiler_checkout_git_submodule( -+ RECURSIVE -+ RELATIVE_PATH external/yaml-cpp -+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} -+ REPO_URL https://github.com/jbeder/yaml-cpp.git -+ REPO_BRANCH "master") - --add_subdirectory(yaml-cpp EXCLUDE_FROM_ALL) -+ add_subdirectory(yaml-cpp EXCLUDE_FROM_ALL) - --target_link_libraries(rocprofiler-sdk-yaml-cpp -- INTERFACE $) --target_include_directories( -- rocprofiler-sdk-yaml-cpp -- INTERFACE $) -+ target_link_libraries(rocprofiler-sdk-yaml-cpp -+ INTERFACE $) -+ target_include_directories( -+ rocprofiler-sdk-yaml-cpp -+ INTERFACE $) -+else() -+ find_package(yaml-cpp 0.8.0 REQUIRED) -+ target_link_libraries(rocprofiler-sdk-yaml-cpp INTERFACE yaml-cpp::yaml-cpp) -+endif() - - # checkout submodule if not already checked out or clone repo if no .gitmodules file - rocprofiler_checkout_git_submodule( --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0003-allow-using-system-elfio-dependency.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0003-allow-using-system-elfio-dependency.patch deleted file mode 100644 index 702f380edb420..0000000000000 --- a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0003-allow-using-system-elfio-dependency.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 27cec58fefe73c26ccca212ebbc002a0b9c1bfa5 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 17:29:50 +1100 -Subject: [PATCH 3/8] allow using system elfio dependency - ---- - cmake/rocprofiler_options.cmake | 2 ++ - external/CMakeLists.txt | 33 +++++++++++++++++++-------------- - 2 files changed, 21 insertions(+), 14 deletions(-) - -diff --git a/cmake/rocprofiler_options.cmake b/cmake/rocprofiler_options.cmake -index faee11049f..a09af6c2c9 100644 ---- a/cmake/rocprofiler_options.cmake -+++ b/cmake/rocprofiler_options.cmake -@@ -67,6 +67,8 @@ rocprofiler_add_option(ROCPROFILER_BUILD_GOTCHA - "Enable building gotcha library internally" ON) - rocprofiler_add_option(ROCPROFILER_BUILD_YAML_CPP - "Enable building yaml-cpp library internally" ON) -+rocprofiler_add_option(ROCPROFILER_BUILD_ELFIO -+ "Enable building ELFIO library internally" ON) - if(ROCPROFILER_BUILD_TESTS) - rocprofiler_add_option( - ROCPROFILER_BUILD_GTEST -diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt -index cab59c07bd..a75229edf3 100644 ---- a/external/CMakeLists.txt -+++ b/external/CMakeLists.txt -@@ -201,20 +201,25 @@ target_link_libraries( - INTERFACE $) - - # ELFIO --rocprofiler_checkout_git_submodule( -- RECURSIVE -- RELATIVE_PATH external/elfio -- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} -- REPO_URL https://github.com/serge1/ELFIO.git -- REPO_BRANCH "Release_3.12") -- --set(ELFIO_BUILD_EXAMPLES OFF) --set(ELFIO_BUILD_TESTS OFF) --add_subdirectory(elfio EXCLUDE_FROM_ALL) --if(TARGET rocprofiler-sdk-elfio) -- get_target_property(ELFIO_INCLUDE_DIR elfio::elfio INTERFACE_INCLUDE_DIRECTORIES) -- target_include_directories(rocprofiler-sdk-elfio SYSTEM -- INTERFACE ${ELFIO_INCLUDE_DIR}) -+if(ROCPROFILER_BUILD_ELFIO) -+ rocprofiler_checkout_git_submodule( -+ RECURSIVE -+ RELATIVE_PATH external/elfio -+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} -+ REPO_URL https://github.com/serge1/ELFIO.git -+ REPO_BRANCH "Release_3.12") -+ -+ set(ELFIO_BUILD_EXAMPLES OFF) -+ set(ELFIO_BUILD_TESTS OFF) -+ add_subdirectory(elfio EXCLUDE_FROM_ALL) -+ if(TARGET rocprofiler-sdk-elfio) -+ get_target_property(ELFIO_INCLUDE_DIR elfio::elfio INTERFACE_INCLUDE_DIRECTORIES) -+ target_include_directories(rocprofiler-sdk-elfio SYSTEM -+ INTERFACE ${ELFIO_INCLUDE_DIR}) -+ endif() -+else() -+ find_package(elfio REQUIRED GLOBAL) -+ target_link_libraries(rocprofiler-sdk-elfio INTERFACE elfio::elfio) - endif() - - # --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0004-allow-using-system-otf2-dependency.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0004-allow-using-system-otf2-dependency.patch deleted file mode 100644 index 61a2888f79f8c..0000000000000 --- a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0004-allow-using-system-otf2-dependency.patch +++ /dev/null @@ -1,54 +0,0 @@ -From d2c8a5872c8d2af1bc8c203ad75f7c1c83cfb919 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 17:30:13 +1100 -Subject: [PATCH 4/8] allow using system otf2 dependency - ---- - cmake/rocprofiler_options.cmake | 2 ++ - external/CMakeLists.txt | 17 +++++++++-------- - 2 files changed, 11 insertions(+), 8 deletions(-) - -diff --git a/cmake/rocprofiler_options.cmake b/cmake/rocprofiler_options.cmake -index a09af6c2c9..19e092df06 100644 ---- a/cmake/rocprofiler_options.cmake -+++ b/cmake/rocprofiler_options.cmake -@@ -69,6 +69,8 @@ rocprofiler_add_option(ROCPROFILER_BUILD_YAML_CPP - "Enable building yaml-cpp library internally" ON) - rocprofiler_add_option(ROCPROFILER_BUILD_ELFIO - "Enable building ELFIO library internally" ON) -+rocprofiler_add_option(ROCPROFILER_BUILD_OTF2 -+ "Enable building OTF2 library internally" ON) - if(ROCPROFILER_BUILD_TESTS) - rocprofiler_add_option( - ROCPROFILER_BUILD_GTEST -diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt -index a75229edf3..e1be3df85e 100644 ---- a/external/CMakeLists.txt -+++ b/external/CMakeLists.txt -@@ -225,14 +225,15 @@ endif() - # - # OTF2 - # --add_subdirectory(otf2) -- --rocprofiler_checkout_git_submodule( -- RECURSIVE -- RELATIVE_PATH external/json -- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} -- REPO_URL https://github.com/nlohmann/json.git -- REPO_BRANCH "develop") -+if(ROCPROFILER_BUILD_OTF2) -+ add_subdirectory(otf2) -+else() -+ find_package(PkgConfig REQUIRED) -+ pkg_check_modules(OTF2 REQUIRED IMPORTED_TARGET otf2) -+ add_library(otf2 INTERFACE) -+ add_library(otf2::otf2 ALIAS otf2) -+ target_link_libraries(otf2 INTERFACE PkgConfig::OTF2) -+endif() - - # - # JSON --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0005-allow-using-system-json-dependency.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0005-allow-using-system-json-dependency.patch deleted file mode 100644 index b6cb539682c45..0000000000000 --- a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0005-allow-using-system-json-dependency.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 3c42b2a8491b44fa58940fcd44b45c64f1b43cf1 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 17:30:36 +1100 -Subject: [PATCH 5/8] allow using system json dependency - ---- - cmake/rocprofiler_options.cmake | 2 ++ - external/CMakeLists.txt | 17 +++++++++++++++++ - 2 files changed, 19 insertions(+) - -diff --git a/cmake/rocprofiler_options.cmake b/cmake/rocprofiler_options.cmake -index 19e092df06..b7a7a6cbdd 100644 ---- a/cmake/rocprofiler_options.cmake -+++ b/cmake/rocprofiler_options.cmake -@@ -71,6 +71,8 @@ rocprofiler_add_option(ROCPROFILER_BUILD_ELFIO - "Enable building ELFIO library internally" ON) - rocprofiler_add_option(ROCPROFILER_BUILD_OTF2 - "Enable building OTF2 library internally" ON) -+rocprofiler_add_option(ROCPROFILER_BUILD_JSON -+ "Enable building JSON library internally" ON) - if(ROCPROFILER_BUILD_TESTS) - rocprofiler_add_option( - ROCPROFILER_BUILD_GTEST -diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt -index e1be3df85e..a282232f22 100644 ---- a/external/CMakeLists.txt -+++ b/external/CMakeLists.txt -@@ -243,6 +243,23 @@ target_include_directories( - rocprofiler-sdk-json SYSTEM - INTERFACE $) - -+if(ROCPROFILER_BUILD_JSON) -+ rocprofiler_checkout_git_submodule( -+ RECURSIVE -+ RELATIVE_PATH external/json -+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} -+ REPO_URL https://github.com/nlohmann/json.git -+ REPO_BRANCH "develop") -+ -+ add_subdirectory(json) -+ target_include_directories( -+ rocprofiler-sdk-json SYSTEM -+ INTERFACE $) -+else() -+ find_package(nlohmann_json REQUIRED GLOBAL) -+ target_link_libraries(rocprofiler-sdk-json INTERFACE nlohmann_json::nlohmann_json) -+endif() -+ - # - # SQLite3 - # --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0006-fix-amd-comgr-resolution.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0006-fix-amd-comgr-resolution.patch deleted file mode 100644 index 03103ec734619..0000000000000 --- a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0006-fix-amd-comgr-resolution.patch +++ /dev/null @@ -1,154 +0,0 @@ -From 9977c287e106d9c494546212a3544e238363e219 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 16:52:24 +1100 -Subject: [PATCH 6/8] fix amd-comgr resolution - ---- - .../lib/att-tool/waitcnt/tests/CMakeLists.txt | 1 + - source/lib/python/utilities.cmake | 3 ++- - .../counters/tests/CMakeLists.txt | 2 ++ - .../pc_sampling/parser/tests/CMakeLists.txt | 20 ++++++++++++++----- - .../lib/rocprofiler-sdk/tests/CMakeLists.txt | 2 ++ - .../thread_trace/tests/CMakeLists.txt | 1 + - 6 files changed, 23 insertions(+), 6 deletions(-) - -diff --git a/source/lib/att-tool/waitcnt/tests/CMakeLists.txt b/source/lib/att-tool/waitcnt/tests/CMakeLists.txt -index 8a13e80cbe..48b3debc93 100644 ---- a/source/lib/att-tool/waitcnt/tests/CMakeLists.txt -+++ b/source/lib/att-tool/waitcnt/tests/CMakeLists.txt -@@ -10,6 +10,7 @@ target_link_libraries( - rocprofiler-sdk::rocprofiler-sdk-common-library - rocprofiler-sdk::rocprofiler-sdk-glog - rocprofiler-sdk::rocprofiler-sdk-static-library -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr - GTest::gtest - GTest::gtest_main) - target_sources(att-decoder-waitcnt-test PRIVATE att_decoder_waitcnt_test.cpp) -diff --git a/source/lib/python/utilities.cmake b/source/lib/python/utilities.cmake -index 1bc9171a3e..21bc9cfb3d 100644 ---- a/source/lib/python/utilities.cmake -+++ b/source/lib/python/utilities.cmake -@@ -209,7 +209,8 @@ function(rocprofiler_rocpd_python_bindings _VERSION) - rocprofiler-sdk::rocprofiler-sdk-gotcha - rocprofiler-sdk::rocprofiler-sdk-dw - rocprofiler-sdk::rocprofiler-sdk-static-library -- rocprofiler-sdk::rocprofiler-sdk-rocpd-library) -+ rocprofiler-sdk::rocprofiler-sdk-rocpd-library -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr) - - # if "Development" is specified instead of "Development.Module", we need to link to - # python libraries -diff --git a/source/lib/rocprofiler-sdk/counters/tests/CMakeLists.txt b/source/lib/rocprofiler-sdk/counters/tests/CMakeLists.txt -index 5e0d73e0f0..38251a7acc 100644 ---- a/source/lib/rocprofiler-sdk/counters/tests/CMakeLists.txt -+++ b/source/lib/rocprofiler-sdk/counters/tests/CMakeLists.txt -@@ -51,6 +51,7 @@ target_sources( - target_link_libraries( - counter_test_constants - PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr - rocprofiler-sdk::rocprofiler-sdk-static-library - rocprofiler-sdk::rocprofiler-sdk-hip - rocprofiler-sdk::rocprofiler-sdk-hsa-runtime) -@@ -73,6 +74,7 @@ target_link_libraries( - rocprofiler-sdk::rocprofiler-sdk-hsa-runtime - rocprofiler-sdk::rocprofiler-sdk-hip - rocprofiler-sdk::rocprofiler-sdk-common-library -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr - rocprofiler-sdk::rocprofiler-sdk-static-library - GTest::gtest - GTest::gtest_main) -diff --git a/source/lib/rocprofiler-sdk/pc_sampling/parser/tests/CMakeLists.txt b/source/lib/rocprofiler-sdk/pc_sampling/parser/tests/CMakeLists.txt -index 1c512054d6..3bb64572e1 100644 ---- a/source/lib/rocprofiler-sdk/pc_sampling/parser/tests/CMakeLists.txt -+++ b/source/lib/rocprofiler-sdk/pc_sampling/parser/tests/CMakeLists.txt -@@ -30,7 +30,9 @@ target_include_directories(pcs_gfx9_test PRIVATE ${PCTEST_INCLUDE_DIR}) - target_link_libraries( - pcs_gfx9_test - PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library -- rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr -+ rocprofiler-sdk::rocprofiler-sdk-static-library -+ GTest::gtest - GTest::gtest_main) - - gtest_add_tests( -@@ -52,7 +54,9 @@ target_include_directories(pcs_id_test PRIVATE ${PCTEST_INCLUDE_DIR}) - target_link_libraries( - pcs_id_test - PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library -- rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr -+ rocprofiler-sdk::rocprofiler-sdk-static-library -+ GTest::gtest - GTest::gtest_main) - - gtest_add_tests( -@@ -75,7 +79,9 @@ target_include_directories(pcs_bench_test PRIVATE ${PCTEST_INCLUDE_DIR}) - target_link_libraries( - pcs_bench_test - PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library -- rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr -+ rocprofiler-sdk::rocprofiler-sdk-static-library -+ GTest::gtest - GTest::gtest_main) - - add_executable(pcs_thread_test) -@@ -88,7 +94,9 @@ target_include_directories(pcs_thread_test PRIVATE ${PCTEST_INCLUDE_DIR}) - target_link_libraries( - pcs_thread_test - PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library -- rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr -+ rocprofiler-sdk::rocprofiler-sdk-static-library -+ GTest::gtest - GTest::gtest_main) - - gtest_add_tests( -@@ -111,7 +119,9 @@ target_include_directories(pcs_gfx12_test PRIVATE ${PCTEST_INCLUDE_DIR}) - target_link_libraries( - pcs_gfx12_test - PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library -- rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr -+ rocprofiler-sdk::rocprofiler-sdk-static-library -+ GTest::gtest - GTest::gtest_main) - - gtest_add_tests( -diff --git a/source/lib/rocprofiler-sdk/tests/CMakeLists.txt b/source/lib/rocprofiler-sdk/tests/CMakeLists.txt -index d71aa7c297..70dfe3376d 100644 ---- a/source/lib/rocprofiler-sdk/tests/CMakeLists.txt -+++ b/source/lib/rocprofiler-sdk/tests/CMakeLists.txt -@@ -28,6 +28,7 @@ target_sources(rocprofiler-sdk-lib-tests PRIVATE ${rocprofiler_lib_sources} - target_link_libraries( - rocprofiler-sdk-lib-tests - PRIVATE rocprofiler-sdk::rocprofiler-sdk-static-library -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr - rocprofiler-sdk::rocprofiler-sdk-common-library - rocprofiler-sdk::counter-test-constants - rocprofiler-sdk::rocprofiler-sdk-hsa-runtime -@@ -59,6 +60,7 @@ target_sources(rocprofiler-sdk-lib-tests-shared PRIVATE ${rocprofiler_shared_lib - target_link_libraries( - rocprofiler-sdk-lib-tests-shared - PRIVATE rocprofiler-sdk::rocprofiler-sdk-shared-library -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr - rocprofiler-sdk::rocprofiler-sdk-common-library - rocprofiler-sdk::rocprofiler-sdk-hsa-runtime - rocprofiler-sdk::rocprofiler-sdk-drm -diff --git a/source/lib/rocprofiler-sdk/thread_trace/tests/CMakeLists.txt b/source/lib/rocprofiler-sdk/thread_trace/tests/CMakeLists.txt -index 62acae39fb..7e867ba0a7 100644 ---- a/source/lib/rocprofiler-sdk/thread_trace/tests/CMakeLists.txt -+++ b/source/lib/rocprofiler-sdk/thread_trace/tests/CMakeLists.txt -@@ -14,6 +14,7 @@ target_link_libraries( - rocprofiler-sdk::rocprofiler-sdk-glog - rocprofiler-sdk::rocprofiler-sdk-hsa-runtime - rocprofiler-sdk::rocprofiler-sdk-hip -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr - rocprofiler-sdk::rocprofiler-sdk-common-library - GTest::gtest - GTest::gtest_main --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0007-fix-missing-includes-and-api-changes-with-fmt-v12.2..patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0007-fix-missing-includes-and-api-changes-with-fmt-v12.2..patch deleted file mode 100644 index 970e2a89b67d4..0000000000000 --- a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0007-fix-missing-includes-and-api-changes-with-fmt-v12.2..patch +++ /dev/null @@ -1,260 +0,0 @@ -From eb68d5d6dcdb085dc3d8d18576fee7cf998f6512 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 16:59:59 +1100 -Subject: [PATCH 7/8] fix missing includes and api changes with fmt v12.2.0 - ---- - source/lib/common/logging.cpp | 1 + - source/lib/output/generateRocpd.cpp | 1 + - source/lib/output/generateStats.cpp | 1 + - source/lib/output/metadata.cpp | 1 - - source/lib/output/metadata.hpp | 2 +- - source/lib/output/sql/common.hpp | 1 + - source/lib/python/rocpd/libpyrocpd.cpp | 1 + - source/lib/python/rocpd/source/serialization/sql.cpp | 3 +++ - source/lib/python/rocpd/source/sql_generator.hpp | 3 +++ - source/lib/rocprofiler-sdk-tool/tool.cpp | 3 ++- - source/lib/rocprofiler-sdk/counters/tests/device_counting.cpp | 1 + - source/lib/rocprofiler-sdk/counters/tests/dimension.cpp | 1 + - source/lib/rocprofiler-sdk/hip/details/format.hpp | 4 ++-- - source/lib/rocprofiler-sdk/hsa/aql_packet.cpp | 2 +- - source/lib/rocprofiler-sdk/hsa/details/fmt.hpp | 3 +++ - source/lib/rocprofiler-sdk/ompt.cpp | 2 +- - .../pc_sampling/parser/pc_record_interface.cpp | 2 ++ - source/lib/tests/common/parse.cpp | 1 + - 18 files changed, 26 insertions(+), 7 deletions(-) - -diff --git a/source/lib/common/logging.cpp b/source/lib/common/logging.cpp -index 6c07322b06..24aecbc23d 100644 ---- a/source/lib/common/logging.cpp -+++ b/source/lib/common/logging.cpp -@@ -25,6 +25,7 @@ - #include "lib/common/filesystem.hpp" - - #include -+#include - #include - #include - -diff --git a/source/lib/output/generateRocpd.cpp b/source/lib/output/generateRocpd.cpp -index 564a9bd45f..65d9a5d7cf 100644 ---- a/source/lib/output/generateRocpd.cpp -+++ b/source/lib/output/generateRocpd.cpp -@@ -56,6 +56,7 @@ - #include - - #include -+#include - #include - #include - -diff --git a/source/lib/output/generateStats.cpp b/source/lib/output/generateStats.cpp -index 22c1a7f425..3860be129b 100644 ---- a/source/lib/output/generateStats.cpp -+++ b/source/lib/output/generateStats.cpp -@@ -33,6 +33,7 @@ - #include - - #include -+#include - - #include - #include -diff --git a/source/lib/output/metadata.cpp b/source/lib/output/metadata.cpp -index abe9e00b50..f68d46de5b 100644 ---- a/source/lib/output/metadata.cpp -+++ b/source/lib/output/metadata.cpp -@@ -41,7 +41,6 @@ - #include - #include - --#include - #include - - #include -diff --git a/source/lib/output/metadata.hpp b/source/lib/output/metadata.hpp -index 069401f962..a283896f29 100644 ---- a/source/lib/output/metadata.hpp -+++ b/source/lib/output/metadata.hpp -@@ -45,7 +45,7 @@ - #include - #include - --#include -+#include - - #include - #include -diff --git a/source/lib/output/sql/common.hpp b/source/lib/output/sql/common.hpp -index 40fb8df9a8..97f96e06c4 100644 ---- a/source/lib/output/sql/common.hpp -+++ b/source/lib/output/sql/common.hpp -@@ -29,6 +29,7 @@ - #include "lib/common/units.hpp" - - #include -+#include - #include - - #include -diff --git a/source/lib/python/rocpd/libpyrocpd.cpp b/source/lib/python/rocpd/libpyrocpd.cpp -index 009afd694b..8ad4eb3458 100644 ---- a/source/lib/python/rocpd/libpyrocpd.cpp -+++ b/source/lib/python/rocpd/libpyrocpd.cpp -@@ -55,6 +55,7 @@ - #include - - #include -+#include - #include - #include - #include -diff --git a/source/lib/python/rocpd/source/serialization/sql.cpp b/source/lib/python/rocpd/source/serialization/sql.cpp -index d10e878be5..9192abc45b 100644 ---- a/source/lib/python/rocpd/source/serialization/sql.cpp -+++ b/source/lib/python/rocpd/source/serialization/sql.cpp -@@ -23,6 +23,9 @@ - #include "lib/python/rocpd/source/serialization/sql.hpp" - #include "lib/output/sql/common.hpp" - -+#include -+#include -+ - namespace cereal - { - SQLite3InputArchive::SQLite3InputArchive(sqlite3* conn, -diff --git a/source/lib/python/rocpd/source/sql_generator.hpp b/source/lib/python/rocpd/source/sql_generator.hpp -index 6284857afb..881ad23a72 100644 ---- a/source/lib/python/rocpd/source/sql_generator.hpp -+++ b/source/lib/python/rocpd/source/sql_generator.hpp -@@ -38,6 +38,9 @@ - #include - #include - -+#include -+#include -+ - namespace rocpd - { - namespace tool = ::rocprofiler::tool; -diff --git a/source/lib/rocprofiler-sdk-tool/tool.cpp b/source/lib/rocprofiler-sdk-tool/tool.cpp -index 7b03fa3eb8..6ddb2274e5 100644 ---- a/source/lib/rocprofiler-sdk-tool/tool.cpp -+++ b/source/lib/rocprofiler-sdk-tool/tool.cpp -@@ -78,7 +78,8 @@ - #include - #include - --#include -+#include -+#include - - #include - #include -diff --git a/source/lib/rocprofiler-sdk/counters/tests/device_counting.cpp b/source/lib/rocprofiler-sdk/counters/tests/device_counting.cpp -index 9587b219f3..d82a6ec40b 100644 ---- a/source/lib/rocprofiler-sdk/counters/tests/device_counting.cpp -+++ b/source/lib/rocprofiler-sdk/counters/tests/device_counting.cpp -@@ -39,6 +39,7 @@ - #include - - #include -+#include - #include - #include - #include -diff --git a/source/lib/rocprofiler-sdk/counters/tests/dimension.cpp b/source/lib/rocprofiler-sdk/counters/tests/dimension.cpp -index 387c167bd0..22fcda9bf7 100644 ---- a/source/lib/rocprofiler-sdk/counters/tests/dimension.cpp -+++ b/source/lib/rocprofiler-sdk/counters/tests/dimension.cpp -@@ -39,6 +39,7 @@ - #include - - #include -+#include - #include - #include - #include -diff --git a/source/lib/rocprofiler-sdk/hip/details/format.hpp b/source/lib/rocprofiler-sdk/hip/details/format.hpp -index f65cf016a6..46f734d65d 100644 ---- a/source/lib/rocprofiler-sdk/hip/details/format.hpp -+++ b/source/lib/rocprofiler-sdk/hip/details/format.hpp -@@ -31,8 +31,8 @@ - #include - #include - --#include "fmt/core.h" --#include "fmt/ranges.h" -+#include -+#include - - #define ROCP_SDK_HIP_FORMATTER(TYPE, ...) \ - template <> \ -diff --git a/source/lib/rocprofiler-sdk/hsa/aql_packet.cpp b/source/lib/rocprofiler-sdk/hsa/aql_packet.cpp -index f1c0c3a56e..389a182e9d 100644 ---- a/source/lib/rocprofiler-sdk/hsa/aql_packet.cpp -+++ b/source/lib/rocprofiler-sdk/hsa/aql_packet.cpp -@@ -21,7 +21,7 @@ - // THE SOFTWARE. - - #include "lib/rocprofiler-sdk/hsa/aql_packet.hpp" --#include -+#include - #include - #include - #include "lib/common/logging.hpp" -diff --git a/source/lib/rocprofiler-sdk/hsa/details/fmt.hpp b/source/lib/rocprofiler-sdk/hsa/details/fmt.hpp -index c136a2739c..f0d7d9e94f 100644 ---- a/source/lib/rocprofiler-sdk/hsa/details/fmt.hpp -+++ b/source/lib/rocprofiler-sdk/hsa/details/fmt.hpp -@@ -22,6 +22,9 @@ - - #include "lib/rocprofiler-sdk/hsa/queue.hpp" - -+#include -+#include -+ - namespace fmt - { - template <> -diff --git a/source/lib/rocprofiler-sdk/ompt.cpp b/source/lib/rocprofiler-sdk/ompt.cpp -index a9ccc571c8..0d7166465a 100644 ---- a/source/lib/rocprofiler-sdk/ompt.cpp -+++ b/source/lib/rocprofiler-sdk/ompt.cpp -@@ -31,7 +31,7 @@ - #include - #include - --#include -+#include - #include - #include - -diff --git a/source/lib/rocprofiler-sdk/pc_sampling/parser/pc_record_interface.cpp b/source/lib/rocprofiler-sdk/pc_sampling/parser/pc_record_interface.cpp -index 8d418df50e..a4163529c1 100644 ---- a/source/lib/rocprofiler-sdk/pc_sampling/parser/pc_record_interface.cpp -+++ b/source/lib/rocprofiler-sdk/pc_sampling/parser/pc_record_interface.cpp -@@ -24,6 +24,8 @@ - - #include "lib/common/utility.hpp" - -+#include -+ - template <> - uint64_t - PCSamplingParserContext::alloc( -diff --git a/source/lib/tests/common/parse.cpp b/source/lib/tests/common/parse.cpp -index 5e3b63c85f..ccfc0912bc 100644 ---- a/source/lib/tests/common/parse.cpp -+++ b/source/lib/tests/common/parse.cpp -@@ -23,6 +23,7 @@ - #include - - #include -+#include - #include - - #include --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0008-fix-compilation-errors-from-missing-includes.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0008-fix-compilation-errors-from-missing-includes.patch deleted file mode 100644 index ab694273ab2c2..0000000000000 --- a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0008-fix-compilation-errors-from-missing-includes.patch +++ /dev/null @@ -1,93 +0,0 @@ -From 3346d7d75513445c19f04a9e972216522752e469 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 17:00:20 +1100 -Subject: [PATCH 8/8] fix compilation errors from missing includes - ---- - source/lib/att-tool/att_lib_wrapper.hpp | 2 ++ - source/lib/att-tool/wave.hpp | 1 + - source/lib/rocprofiler-sdk-rocpd/sql.cpp | 1 + - source/lib/rocprofiler-sdk/counters/metrics.cpp | 1 + - source/lib/rocprofiler-sdk/counters/metrics.hpp | 1 + - source/lib/rocprofiler-sdk/tests/status.cpp | 1 + - 6 files changed, 7 insertions(+) - -diff --git a/source/lib/att-tool/att_lib_wrapper.hpp b/source/lib/att-tool/att_lib_wrapper.hpp -index e7e58c5991..7dcd000a43 100644 ---- a/source/lib/att-tool/att_lib_wrapper.hpp -+++ b/source/lib/att-tool/att_lib_wrapper.hpp -@@ -28,9 +28,11 @@ - #include - - #include -+#include - #include - #include - #include -+#include - #include - - namespace rocprofiler -diff --git a/source/lib/att-tool/wave.hpp b/source/lib/att-tool/wave.hpp -index 1a7b1adda6..65686d8ea3 100644 ---- a/source/lib/att-tool/wave.hpp -+++ b/source/lib/att-tool/wave.hpp -@@ -29,6 +29,7 @@ - #include "waitcnt/analysis.hpp" - #include "wstates.hpp" - -+#include - #include - #include - #include -diff --git a/source/lib/rocprofiler-sdk-rocpd/sql.cpp b/source/lib/rocprofiler-sdk-rocpd/sql.cpp -index b052ec51c3..7e8742686e 100644 ---- a/source/lib/rocprofiler-sdk-rocpd/sql.cpp -+++ b/source/lib/rocprofiler-sdk-rocpd/sql.cpp -@@ -39,6 +39,7 @@ - #include - - #include -+#include - #include - #include - -diff --git a/source/lib/rocprofiler-sdk/counters/metrics.cpp b/source/lib/rocprofiler-sdk/counters/metrics.cpp -index 201ae4fd25..4780a0ba31 100644 ---- a/source/lib/rocprofiler-sdk/counters/metrics.cpp -+++ b/source/lib/rocprofiler-sdk/counters/metrics.cpp -@@ -45,6 +45,7 @@ - #include // for dladdr - #include - #include -+#include - #include - #include - -diff --git a/source/lib/rocprofiler-sdk/counters/metrics.hpp b/source/lib/rocprofiler-sdk/counters/metrics.hpp -index 7915bc8805..a893c2c9b3 100644 ---- a/source/lib/rocprofiler-sdk/counters/metrics.hpp -+++ b/source/lib/rocprofiler-sdk/counters/metrics.hpp -@@ -35,6 +35,7 @@ - #include - #include - #include -+#include - - namespace rocprofiler - { -diff --git a/source/lib/rocprofiler-sdk/tests/status.cpp b/source/lib/rocprofiler-sdk/tests/status.cpp -index a5a492101d..b01f511b99 100644 ---- a/source/lib/rocprofiler-sdk/tests/status.cpp -+++ b/source/lib/rocprofiler-sdk/tests/status.cpp -@@ -25,6 +25,7 @@ - - #include - -+#include - #include - - TEST(rocprofiler_lib, error_string) --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0009-rocprofiler-sdk-guard-ompt-auto-start.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/0009-rocprofiler-sdk-guard-ompt-auto-start.patch deleted file mode 100644 index 147d79483318e..0000000000000 --- a/pkgs/development/rocm-modules/10/rocprofiler-sdk/0009-rocprofiler-sdk-guard-ompt-auto-start.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 502d2df0ddd84f0f2fa718b9a02ee0f01f36dac1 Mon Sep 17 00:00:00 2001 -From: Luna Nova -Date: Tue, 2 Jun 2026 01:31:05 -0700 -Subject: [PATCH] [rocprofiler-sdk] don't auto-start OMPT tool before glog is - initialized - -The OpenMP runtime resolves its weak ompt_start_tool to the strong symbol we -export and calls it during OpenMP init. That can fire from an unrelated -library's constructor (observed: OpenBLAS calling omp_get_num_places) while -librocprofiler-sdk is still being dlopen'd. init_logging() then dereferences -glog's gflags FLAGS_vmodule, whose backing pointer is still null until glog's -static initializers run, and the process segfaults on `import torch`. - -The init order is not reliably fixable from here: a dependency cycle among the -ROCm libraries makes the loader run our constructors before libglog's, so a -flag set by our own constructor does not imply glog is ready. Instead gate the -tool start on glog itself, by testing whether gflags has populated FLAGS_vmodule -yet; reading the raw pointer is safe even before construction. It is read via an -asm label because the gflags header only exposes it as a reference, which the -compiler assumes is never null. Declining (nullptr) when glog is not yet ready -is a valid OMPT "no tool" response; deliberate profiling (rocprofv3 preloads the -tool early, before such constructors) is unaffected. ---- - source/lib/rocprofiler-sdk/ompt.cpp | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/source/lib/rocprofiler-sdk/ompt.cpp b/source/lib/rocprofiler-sdk/ompt.cpp -index a9ccc57..3231087 100644 ---- a/source/lib/rocprofiler-sdk/ompt.cpp -+++ b/source/lib/rocprofiler-sdk/ompt.cpp -@@ -199,6 +199,8 @@ finalize_ompt() - } // namespace ompt - } // namespace rocprofiler - -+extern void* const rocprofiler_glog_vmodule_flag asm("_ZN3fLS13FLAGS_vmoduleB5cxx11E"); -+ - extern "C" { - - rocprofiler_status_t -@@ -245,6 +247,8 @@ ompt_start_tool(unsigned int omp_version, const char* runtime_version) ROCPROFIL - ompt_start_tool_result_t* - ompt_start_tool(unsigned int omp_version, const char* runtime_version) - { -+ if(rocprofiler_glog_vmodule_flag == nullptr) return nullptr; -+ - ::rocprofiler::registration::init_logging(); - ::rocprofiler::registration::initialize(); - return rocprofiler_ompt_start_tool(omp_version, runtime_version); --- -2.54.0 diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/default.nix b/pkgs/development/rocm-modules/10/rocprofiler-sdk/default.nix index a93c5e93c4e3e..6da6fe8b92773 100644 --- a/pkgs/development/rocm-modules/10/rocprofiler-sdk/default.nix +++ b/pkgs/development/rocm-modules/10/rocprofiler-sdk/default.nix @@ -25,9 +25,7 @@ xz, numactl, fmt, - glog, gtest, - fetchpatch, yaml-cpp, elfio, nlohmann_json, @@ -46,7 +44,7 @@ # rocprofiler-sdk is the home of rocprofv3 stdenv.mkDerivation (finalAttrs: { pname = "rocprofiler-sdk"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -56,8 +54,8 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-7XCxu917Mgp3SQAKlTWj3ympgwOYW3aJFcOv/GhPk1c="; + tag = "therock-${finalAttrs.version}"; + hash = "sha256-UmYHC+87XIW+Z4WVd7k0MQ9baTvFlq/SgCt9Foy1mPI="; fetchSubmodules = true; sparseCheckout = [ "projects/rocprofiler-sdk" @@ -82,6 +80,9 @@ stdenv.mkDerivation (finalAttrs: { rocm-runtime rocprofiler-register aqlprofile + # rocprofiler-sdk-tool does find_package(rocprof-trace-decoder REQUIRED) at + # configure time for the ATT quick-scan feature. + rocprof-trace-decoder rocm-comgr libdrm elfutils @@ -92,7 +93,6 @@ stdenv.mkDerivation (finalAttrs: { xz numactl fmt - glog gtest yaml-cpp elfio @@ -102,70 +102,40 @@ stdenv.mkDerivation (finalAttrs: { ]; patches = [ - (fetchpatch { - # Fix missing amd_comgr linkage in pc-sampling integration test - url = "https://github.com/ROCm/rocm-systems/commit/94a4595a5d02bc066f7a32e1b2134a99a5231213.patch"; - hash = "sha256-86Fx0bKL0pvXTwVN8QJL+yzCbMYkmMaKzcU4PYcW6ig="; - relative = "projects/rocprofiler-sdk"; - }) - ] - ++ [ - # Just the missing CPackComponent reference sourced from this commit: - # https://github.com/ROCm/rocm-systems/commit/86ee7b2eb2273adaf1181ef9a6b2091465c6f0c7 - ./0001-fix-missing-CPackComponent-cmake-include.patch - ] - ++ [ - # Can be removed when a release contains the changes found in this pr: - # https://github.com/ROCm/rocm-systems/pull/4721 - ./0002-allow-using-system-yaml-dependency.patch - ./0003-allow-using-system-elfio-dependency.patch - ./0004-allow-using-system-otf2-dependency.patch - ./0005-allow-using-system-json-dependency.patch - ./0006-fix-amd-comgr-resolution.patch - ] - ++ [ - # Sourced from several commits that address issues with fmt, dropping conflicting changes no longer needed to build - # https://github.com/ROCm/rocm-systems/commit/36d9d33d90879bfbd406498011070ebd929a56b1 - # https://github.com/ROCm/rocm-systems/commit/e2f588592ecfb0653ed5b3078753186325adf70a - # https://github.com/ROCm/rocm-systems/commit/86ee7b2eb2273adaf1181ef9a6b2091465c6f0c7 (just the fmt changes) - ./0007-fix-missing-includes-and-api-changes-with-fmt-v12.2..patch - ] - ++ [ - # One new import failure added to source commit: - # https://github.com/ROCm/rocm-systems/pull/4721/changes/f7f24a54cbe55425fbefc87c7a3d0f4c85224948 - # which is also part of https://github.com/ROCm/rocm-systems/pull/4721 - ./0008-fix-compilation-errors-from-missing-includes.patch - ] - ++ [ - # Prevent a segfault on `import torch` (and other consumers that link - # librocprofiler-sdk for tracing) when OpenMP auto-discovers our - # ompt_start_tool before glog is initialized. Upstream incidentally fixes - # this by dropping glog in rocm-systems d80117889b3f - # "[rocprofiler-sdk] Migrate from glog to Abseil Logging (#4668)", which - # is too invasive (40 files + new abseil submodule) to backport. - ./0009-rocprofiler-sdk-guard-ompt-auto-start.patch + ./ompt-explicit-tool.patch ]; postPatch = '' - # NixOS' ROCm distribution does not support libomptarget yet - substituteInPlace samples/CMakeLists.txt \ - --replace-fail 'add_subdirectory(openmp_target)' '# add_subdirectory(openmp_target)' - substituteInPlace tests/CMakeLists.txt \ - --replace-fail 'add_subdirectory(openmp-tools)' '# add_subdirectory(openmp-tools)' - substituteInPlace tests/bin/CMakeLists.txt \ - --replace-fail 'add_subdirectory(openmp)' '# add_subdirectory(openmp)' - - # This requires building perfetto's trace-processor-shell via a weird external script - substituteInPlace tests/CMakeLists.txt \ - --replace-fail 'add_subdirectory(pytest-packages)' "" - - patchShebangs source/libexec/rocprofiler-sdk/rocprofiler-sdk-launch-compiler/rocprofiler-sdk-launch-compiler.sh + # NixOS' ROCm distribution does not support libomptarget yet + substituteInPlace samples/CMakeLists.txt \ + --replace-fail 'add_subdirectory(openmp_target)' '# add_subdirectory(openmp_target)' + substituteInPlace tests/CMakeLists.txt \ + --replace-fail 'add_subdirectory(openmp-tools)' '# add_subdirectory(openmp-tools)' + substituteInPlace tests/bin/CMakeLists.txt \ + --replace-fail 'add_subdirectory(openmp)' '# add_subdirectory(openmp)' + + # This requires building perfetto's trace-processor-shell via a weird external script + substituteInPlace tests/CMakeLists.txt \ + --replace-fail 'add_subdirectory(pytest-packages)' "" + + # The sources have bare system includes (`` in the output/sql + + # python-binding sources, `` in the vendored aqlprofile) + # that assume a distro-style /usr/include. nixpkgs keeps those headers in the + # packages' dev outputs, and the rocm-toolchain clang used here + # (-DCMAKE_CXX_COMPILER=clang++, unwrapped) ignores NIX_CFLAGS_COMPILE, so add + # them as a real CMake -isystem at the top of the tree. (A global + # -DCMAKE_CXX_FLAGS instead would clobber abseil's C++-standard detection.) + substituteInPlace CMakeLists.txt \ + --replace-fail 'add_subdirectory(external)' \ + 'include_directories(SYSTEM ${lib.getDev sqlite}/include ${lib.getDev libdrm}/include) + add_subdirectory(external)' + + patchShebangs source/libexec/rocprofiler-sdk/rocprofiler-sdk-launch-compiler/rocprofiler-sdk-launch-compiler.sh ''; cmakeFlags = [ (lib.cmakeBool "ROCPROFILER_BUILD_GHC_FS" false) (lib.cmakeBool "ROCPROFILER_BUILD_FMT" false) - (lib.cmakeBool "ROCPROFILER_BUILD_GLOG" false) (lib.cmakeBool "ROCPROFILER_BUILD_GTEST" false) (lib.cmakeBool "ROCPROFILER_BUILD_PYBIND11" false) (lib.cmakeBool "ROCPROFILER_BUILD_YAML_CPP" false) @@ -192,9 +162,6 @@ stdenv.mkDerivation (finalAttrs: { # building tests or samples. (lib.cmakeFeature "GPU_TARGETS" (lib.concatStringsSep ";" gpuTargets)) ]; - cxxCMakeFlags = [ - "-Wno-unused-variable" - ]; doCheck = false; # Requires GPU diff --git a/pkgs/development/rocm-modules/10/rocprofiler-sdk/ompt-explicit-tool.patch b/pkgs/development/rocm-modules/10/rocprofiler-sdk/ompt-explicit-tool.patch new file mode 100644 index 0000000000000..75f57e30e6e47 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprofiler-sdk/ompt-explicit-tool.patch @@ -0,0 +1,76 @@ +Subject: [PATCH] Avoid unsolicited OMPT initialization + +OpenMP calls ompt_start_tool from its own initialization, which can run +inside a library constructor. Registering clients from there dlopens every +library that defines rocprofiler_configure; if one of them is still being +loaded (PyTorch's libtorch_cpu, for Kineto), glibc reruns pending +constructors and OpenBLAS reenters OpenMP initialization, which livelocks +on its init lock. Decline the tool unless one was requested through +ROCP_TOOL_LIBRARIES (as rocprofv3 does) or rocprofiler_force_configure. +Clients found by symbol still register when the HIP runtime starts; they +only miss OMPT callbacks. + +OpenMP queries ompt_start_tool only once, at startup, so attaching a +profiler to an already running process cannot enable OMPT tracing; the +other services are unaffected. + +--- a/source/lib/rocprofiler-sdk/ompt.cpp ++++ b/source/lib/rocprofiler-sdk/ompt.cpp +@@ -265,6 +265,9 @@ ompt_start_tool(unsigned int omp_version, const char* runtime_version) ROCPROFIL + ompt_start_tool_result_t* + ompt_start_tool(unsigned int omp_version, const char* runtime_version) + { ++ // Registering clients during OpenMP startup can reenter it (see above). ++ if(!::rocprofiler::registration::is_tool_requested()) return nullptr; ++ + ::rocprofiler::registration::init_logging(); + ::rocprofiler::registration::initialize(); + return rocprofiler_ompt_start_tool(omp_version, runtime_version); +--- a/source/lib/rocprofiler-sdk/registration.cpp ++++ b/source/lib/rocprofiler-sdk/registration.cpp +@@ -86,6 +86,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -1039,6 +1040,16 @@ get_client_offset() + return _v; + } + ++static std::atomic forced_configure_requested{false}; ++ ++bool ++is_tool_requested() ++{ ++ if(forced_configure_requested.load(std::memory_order_acquire)) return true; ++ const auto* tools = secure_getenv("ROCP_TOOL_LIBRARIES"); ++ return tools && *tools; ++} ++ + int + get_init_status() + { +@@ -1235,6 +1246,8 @@ rocprofiler_force_configure(rocprofiler_configure_func_t configure_func) + + if(rocprofiler::registration::get_fini_status() != 0) return ROCPROFILER_STATUS_ERROR_FINALIZED; + ++ rocprofiler::registration::forced_configure_requested.store(true, std::memory_order_release); ++ + ROCP_INFO << "forcing rocprofiler configuration"; + + auto* forced_configs = rocprofiler::registration::get_forced_configures(); +--- a/source/lib/rocprofiler-sdk/registration.hpp ++++ b/source/lib/rocprofiler-sdk/registration.hpp +@@ -49,6 +49,9 @@ namespace registration + void + init_logging(); + ++bool ++is_tool_requested(); ++ + // initialize the clients + void + initialize(); From e01bc52f9be9e141650ddd589330650a7d3d5fbb Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:18:59 -0700 Subject: [PATCH 33/79] rocmPackages_10.rocshmem: init at 10.1 Update the rocmPackages.rocshmem copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.rocshmem: move to rocm-systems monorepo, fix device bitcode": rocSHMEM moved into the rocm-systems monorepo in ROCm 10. Switch to the sparse-checkout source and fix its device-bitcode build: cmake/DeviceBitcode.cmake compiles device-side .bc with a manual clang command whose -I list omits the HSA headers (the host librocshmem.a gets them via the hsa-runtime64 link interface), so the bitcode build failed with "'hsa/hsa.h' file not found". Add rocm-runtime's include dir to the bitcode flags. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ .../rocm-modules/10/rocshmem/default.nix | 23 +++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index fc166698fcda2..ca6fa75dbb7ff 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -107,6 +107,8 @@ let rccl = self.callPackage ./rccl { }; + rocshmem = self.callPackage ./rocshmem { }; + half = self.callPackage ./half { }; # Even if config.rocmSupport is false we need rocmSupport true diff --git a/pkgs/development/rocm-modules/10/rocshmem/default.nix b/pkgs/development/rocm-modules/10/rocshmem/default.nix index 33c8f4cce5a46..c18d6c77da492 100644 --- a/pkgs/development/rocm-modules/10/rocshmem/default.nix +++ b/pkgs/development/rocm-modules/10/rocshmem/default.nix @@ -17,14 +17,20 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocshmem${clr.gpuArchSuffix}"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; - repo = "rocSHMEM"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-7TiUABwCVPvosoLdR8zN+QGiX+OD7iD+HKMLnGMmRYA="; + # rocSHMEM lives in the rocm-systems monorepo since ROCm 10 + repo = "rocm-systems"; + tag = "therock-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocshmem" + "shared" + ]; + hash = "sha256-uVUHYyJbaE5vauN1mczLf7rYNxRSD93eJDIDbzbYzHs="; }; + sourceRoot = "${finalAttrs.src.name}/projects/rocshmem"; nativeBuildInputs = [ cmake @@ -39,6 +45,15 @@ stdenv.mkDerivation (finalAttrs: { mpi ]; + # The device bitcode command does not see the HSA headers the host target gets. + postPatch = '' + substituteInPlace cmake/DeviceBitcode.cmake \ + --replace-fail \ + '-Xclang -mcode-object-version=none' \ + '-Xclang -mcode-object-version=none + -I${rocm-runtime}/include' + ''; + cmakeFlags = [ (lib.cmakeBool "CMAKE_POSITION_INDEPENDENT_CODE" true) (lib.cmakeFeature "CMAKE_CXX_COMPILER" "hipcc") From 191f83c9e0a5d91c52033fd6420b73105fd547d7 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:02 -0700 Subject: [PATCH 34/79] rocmPackages_10: copy rocPRIM, rocRAND, rocFFT from rocmPackages Verbatim copies of the rocmPackages (ROCm 7.2.4) expressions for rocprim, rocthrust, hipcub, rocrand, hiprand, rocfft, hipfft, not yet part of the rocmPackages_10 scope. The following commits update each one to ROCm 10.1, so their diffs read against 7.2.4. Assisted-by: Claude Code (claude-opus-5-5) --- .../rocm-modules/10/hipcub/default.nix | 100 +++++++++++ .../rocm-modules/10/hipfft/default.nix | 121 +++++++++++++ .../rocm-modules/10/hiprand/default.nix | 78 ++++++++ .../rocm-modules/10/rocfft/default.nix | 170 ++++++++++++++++++ .../10/rocfft/log-every-n-aot-jobs.patch | 35 ++++ .../rocm-modules/10/rocprim/default.nix | 97 ++++++++++ .../rocm-modules/10/rocrand/default.nix | 98 ++++++++++ .../rocm-modules/10/rocthrust/default.nix | 93 ++++++++++ 8 files changed, 792 insertions(+) create mode 100644 pkgs/development/rocm-modules/10/hipcub/default.nix create mode 100644 pkgs/development/rocm-modules/10/hipfft/default.nix create mode 100644 pkgs/development/rocm-modules/10/hiprand/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocfft/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocfft/log-every-n-aot-jobs.patch create mode 100644 pkgs/development/rocm-modules/10/rocprim/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocrand/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocthrust/default.nix diff --git a/pkgs/development/rocm-modules/10/hipcub/default.nix b/pkgs/development/rocm-modules/10/hipcub/default.nix new file mode 100644 index 0000000000000..a775d81509a1e --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipcub/default.nix @@ -0,0 +1,100 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + rocprim, + clr, + gtest, + gbenchmark, + buildTests ? false, + buildBenchmarks ? false, + gpuTargets ? clr.localGpuTargets or [ ], +}: + +# CUB can also be used as a backend instead of rocPRIM. +stdenv.mkDerivation (finalAttrs: { + pname = "hipcub"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildTests [ + "test" + ] + ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/hipcub" + "shared" + ]; + hash = "sha256-geO6LS1osKAlmVRtiZ6keqFHsJccyB7pRZdWPEkue2M="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/hipcub"; + + nativeBuildInputs = [ + cmake + rocm-cmake + clr + ]; + + buildInputs = [ + rocprim + ] + ++ lib.optionals buildTests [ + gtest + ] + ++ lib.optionals buildBenchmarks [ + gbenchmark + ]; + + cmakeFlags = [ + "-DHIP_ROOT_DIR=${clr}" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] + ++ lib.optionals (gpuTargets != [ ]) [ + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ] + ++ lib.optionals buildTests [ + "-DBUILD_TEST=ON" + ] + ++ lib.optionals buildBenchmarks [ + "-DBUILD_BENCHMARK=ON" + ]; + + postInstall = + lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/test_* $test/bin + '' + + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/benchmark_* $benchmark/bin + '' + + lib.optionalString (buildTests || buildBenchmarks) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "Thin wrapper library on top of rocPRIM or CUB"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipcub"; + license = lib.licenses.bsd3; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/hipfft/default.nix b/pkgs/development/rocm-modules/10/hipfft/default.nix new file mode 100644 index 0000000000000..62c98375d029a --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipfft/default.nix @@ -0,0 +1,121 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + clr, + rocfft, + gtest, + boost, + fftw, + fftwFloat, + openmp, + buildTests ? false, + buildBenchmarks ? false, + buildSamples ? false, + gpuTargets ? clr.localGpuTargets or [ ], +}: + +# Can also use cuFFT +stdenv.mkDerivation (finalAttrs: { + pname = "hipfft"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildTests [ + "test" + ] + ++ lib.optionals buildBenchmarks [ + "benchmark" + ] + ++ lib.optionals buildSamples [ + "sample" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/hipfft" + "shared" + ]; + fetchSubmodules = true; + hash = "sha256-EtxZuxBPx6trTN9iC7uri2+UR0Eolp919Ry4U1PEqNA="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/hipfft"; + + nativeBuildInputs = [ + clr + cmake + rocm-cmake + ]; + + buildInputs = [ + rocfft + ] + ++ lib.optionals (buildTests || buildBenchmarks || buildSamples) [ + gtest + boost + fftw + fftwFloat + openmp + ]; + + cmakeFlags = [ + "-DCMAKE_C_COMPILER=hipcc" + "-DCMAKE_CXX_COMPILER=hipcc" + "-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip" + "-DHIP_ROOT_DIR=${clr}" + "-DHIP_PATH=${clr}" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] + ++ lib.optionals (gpuTargets != [ ]) [ + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ] + ++ lib.optionals buildTests [ + "-DBUILD_CLIENTS_TESTS=ON" + ] + ++ lib.optionals buildBenchmarks [ + "-DBUILD_CLIENTS_RIDER=ON" + ] + ++ lib.optionals buildSamples [ + "-DBUILD_CLIENTS_SAMPLES=ON" + ]; + + postInstall = + lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/hipfft-test $test/bin + '' + + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/hipfft-rider $benchmark/bin + '' + + lib.optionalString buildSamples '' + mkdir -p $sample/bin + mv clients/staging/hipfft_* $sample/bin + patchelf $sample/bin/hipfft_* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" + '' + + lib.optionalString (buildTests || buildBenchmarks) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "FFT marshalling library"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipfft"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/hiprand/default.nix b/pkgs/development/rocm-modules/10/hiprand/default.nix new file mode 100644 index 0000000000000..5e0fd0812ada3 --- /dev/null +++ b/pkgs/development/rocm-modules/10/hiprand/default.nix @@ -0,0 +1,78 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + clr, + rocrand, + gtest, + buildTests ? false, + gpuTargets ? clr.localGpuTargets or [ ], +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "hiprand"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildTests [ + "test" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/hiprand" + "shared" + ]; + hash = "sha256-bjcwjN1dNukhoDAbiSpATlK6dtAwM8bOJTe3IjhdwwY="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/hiprand"; + + nativeBuildInputs = [ + cmake + rocm-cmake + clr + ]; + + buildInputs = [ rocrand ] ++ (lib.optionals buildTests [ gtest ]); + + cmakeFlags = [ + "-DHIP_ROOT_DIR=${clr}" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] + ++ lib.optionals (gpuTargets != [ ]) [ + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ] + ++ lib.optionals buildTests [ + "-DBUILD_TEST=ON" + ]; + + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/test_* $test/bin + rm -r $out/bin/hipRAND + # Fail if bin/ isn't actually empty + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "HIP wrapper for rocRAND and cuRAND"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hiprand"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocfft/default.nix b/pkgs/development/rocm-modules/10/rocfft/default.nix new file mode 100644 index 0000000000000..c48529ac5a831 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocfft/default.nix @@ -0,0 +1,170 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + clr, + python3, + rocm-cmake, + sqlite, + boost, + fftw, + fftwFloat, + gtest, + openmp, + rocrand, + hiprand, + gpuTargets ? clr.localGpuTargets or clr.gpuTargets, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocfft${clr.gpuArchSuffix}"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocfft" + "shared" + ]; + hash = "sha256-RjWMzLX0nBA8ClweJ8YgRTn+Nzt/VUkOoSw3jMQ3IWg="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rocfft"; + + nativeBuildInputs = [ + cmake + clr + python3 + rocm-cmake + ]; + + buildInputs = [ + sqlite + hiprand + ]; + + patches = [ + # Fixes build timeout due to no log output during rocfft_aot step + ./log-every-n-aot-jobs.patch + ]; + + cmakeFlags = [ + "-DSQLITE_USE_SYSTEM_PACKAGE=ON" + "-DHIP_PLATFORM=amd" + "-DBUILD_CLIENTS=OFF" + "-DBUILD_SHARED_LIBS=ON" + "-DUSE_HIPRAND=ON" + "-DROCFFT_KERNEL_CACHE_ENABLE=ON" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] + ++ lib.optionals (gpuTargets != [ ]) [ + "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ]; + + passthru = { + test = stdenv.mkDerivation { + pname = "${finalAttrs.pname}-test"; + inherit (finalAttrs) version src; + + sourceRoot = "${finalAttrs.src.name}/projects/rocfft/clients/tests"; + + nativeBuildInputs = [ + cmake + clr + rocm-cmake + ]; + + buildInputs = [ + boost + fftw + fftwFloat + finalAttrs.finalPackage + gtest + openmp + rocrand + hiprand + ]; + + postInstall = '' + rm -r "$out/lib/fftw" + rmdir "$out/lib" + ''; + }; + + benchmark = stdenv.mkDerivation { + pname = "${finalAttrs.pname}-benchmark"; + inherit (finalAttrs) version src; + + sourceRoot = "${finalAttrs.src.name}/projects/rocfft/clients/rider"; + + nativeBuildInputs = [ + cmake + clr + rocm-cmake + ]; + + buildInputs = [ + boost + finalAttrs.finalPackage + openmp + (python3.withPackages ( + ps: with ps; [ + pandas + scipy + ] + )) + rocrand + ]; + + postInstall = '' + cp -a ../../../scripts/perf "$out/bin" + ''; + }; + + samples = stdenv.mkDerivation { + pname = "${finalAttrs.pname}-samples"; + inherit (finalAttrs) version src; + + sourceRoot = "${finalAttrs.src.name}/projects/rocfft/clients/samples"; + + nativeBuildInputs = [ + cmake + clr + rocm-cmake + ]; + + buildInputs = [ + boost + finalAttrs.finalPackage + openmp + rocrand + ]; + + installPhase = '' + runHook preInstall + mkdir "$out" + cp -a bin "$out" + runHook postInstall + ''; + }; + + updateScript = rocmUpdateScript { inherit finalAttrs; }; + }; + + requiredSystemFeatures = [ "big-parallel" ]; + + meta = { + description = "FFT implementation for ROCm"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocfft"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocfft/log-every-n-aot-jobs.patch b/pkgs/development/rocm-modules/10/rocfft/log-every-n-aot-jobs.patch new file mode 100644 index 0000000000000..266f495d3e7c0 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocfft/log-every-n-aot-jobs.patch @@ -0,0 +1,35 @@ +diff --git a/library/src/rocfft_aot_helper.cpp b/library/src/rocfft_aot_helper.cpp +index f0a889f4..452eb37f 100644 +--- a/library/src/rocfft_aot_helper.cpp ++++ b/library/src/rocfft_aot_helper.cpp +@@ -771,26 +771,22 @@ int main(int argc, char** argv) + for(size_t i = 0; i < NUM_THREADS; ++i) + { + threads.emplace_back([&queue, &gpu_archs]() { ++ int compile_count = 0; + while(true) + { + auto item = queue.pop(); + if(item.kernel_name.empty()) + break; + ++ if(++compile_count % 16 == 0) ++ std::cerr << "rocfft_aot_helper processing " << item.kernel_name << std::endl << std::flush; + for(const auto& gpu_arch : gpu_archs) + { +- if(item.sol_arch_name.empty()) ++ if(item.sol_arch_name.empty() || gpu_arch.find(item.sol_arch_name) != std::string::npos) + { + RTCCache::cached_compile( + item.kernel_name, gpu_arch, item.generate_src, generator_sum()); + } +- else if(gpu_arch.find(item.sol_arch_name) != std::string::npos) +- { +- // std::cout << "arch: " << gpu_arch +- // << ", solution-kernel: " << item.kernel_name << std::endl; +- RTCCache::cached_compile( +- item.kernel_name, gpu_arch, item.generate_src, generator_sum()); +- } + } + } + }); diff --git a/pkgs/development/rocm-modules/10/rocprim/default.nix b/pkgs/development/rocm-modules/10/rocprim/default.nix new file mode 100644 index 0000000000000..577cbfb862014 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocprim/default.nix @@ -0,0 +1,97 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + clr, + gtest, + gbenchmark, + buildTests ? false, + buildBenchmarks ? false, + gpuTargets ? clr.localGpuTargets or [ ], +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocprim"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildTests [ + "test" + ] + ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocprim" + "shared" + ]; + hash = "sha256-e0mZ27OXyblcnXQGv2ex/CvWx9smw6nBbHZIijj7lP8="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rocprim"; + + nativeBuildInputs = [ + cmake + rocm-cmake + clr + ]; + + buildInputs = + lib.optionals buildTests [ + gtest + ] + ++ lib.optionals buildBenchmarks [ + gbenchmark + ]; + + cmakeFlags = [ + "-DHIP_CXX_COMPILER=amdclang++" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] + ++ lib.optionals (gpuTargets != [ ]) [ + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ] + ++ lib.optionals buildTests [ + "-DBUILD_TEST=ON" + ] + ++ lib.optionals buildBenchmarks [ + "-DBUILD_BENCHMARK=ON" + ]; + + postInstall = + lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/test_* $test/bin + mv $out/bin/rocprim $test/bin + '' + + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/benchmark_* $benchmark/bin + '' + + lib.optionalString (buildTests || buildBenchmarks) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "ROCm parallel primitives"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocprim"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocrand/default.nix b/pkgs/development/rocm-modules/10/rocrand/default.nix new file mode 100644 index 0000000000000..cefff33fafd63 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocrand/default.nix @@ -0,0 +1,98 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + clr, + gtest, + gbenchmark, + buildTests ? false, + buildBenchmarks ? false, + gpuTargets ? clr.localGpuTargets or [ ], +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocrand${clr.gpuArchSuffix}"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildTests [ + "test" + ] + ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocrand" + "shared" + ]; + hash = "sha256-tl++h7LSEXf0jWe007+RIRwYHdB6TKPDpzipj1Emew8="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rocrand"; + + nativeBuildInputs = [ + cmake + rocm-cmake + clr + ]; + + buildInputs = + lib.optionals buildTests [ + gtest + ] + ++ lib.optionals buildBenchmarks [ + gbenchmark + ]; + + cmakeFlags = [ + "-DHIP_ROOT_DIR=${clr}" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] + ++ lib.optionals (gpuTargets != [ ]) [ + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ] + ++ lib.optionals buildTests [ + "-DBUILD_TEST=ON" + ] + ++ lib.optionals buildBenchmarks [ + "-DBUILD_BENCHMARK=ON" + ]; + + postInstall = + lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/test_* $test/bin + '' + + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/benchmark_* $benchmark/bin + '' + + lib.optionalString (buildTests || buildBenchmarks) '' + rm -r $out/bin/rocRAND + # Fail if bin/ isn't actually empty + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "Generate pseudo-random and quasi-random numbers"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocrand"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocthrust/default.nix b/pkgs/development/rocm-modules/10/rocthrust/default.nix new file mode 100644 index 0000000000000..653498cb85653 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocthrust/default.nix @@ -0,0 +1,93 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + rocprim, + clr, + gtest, + buildTests ? false, + buildBenchmarks ? false, + gpuTargets ? clr.localGpuTargets or [ ], +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocthrust"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildTests [ + "test" + ] + ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocthrust" + "shared" + ]; + hash = "sha256-wHEgpmBZCYtvp+OyebrRyfoFz3WQyKWfHPrdzQVL8lY="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rocthrust"; + + nativeBuildInputs = [ + cmake + rocm-cmake + rocprim + clr + ]; + + buildInputs = lib.optionals buildTests [ + gtest + ]; + + cmakeFlags = [ + "-DHIP_ROOT_DIR=${clr}" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] + ++ lib.optionals (gpuTargets != [ ]) [ + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ] + ++ lib.optionals buildTests [ + "-DBUILD_TEST=ON" + ] + ++ lib.optionals buildBenchmarks [ + "-DBUILD_BENCHMARKS=ON" + ]; + + postInstall = + lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/{test_*,*.hip} $test/bin + '' + + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/benchmark_* $benchmark/bin + '' + + lib.optionalString (buildTests || buildBenchmarks) '' + rm -rf $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "ROCm parallel algorithm library"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocthrust"; + license = lib.licenses.asl20; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) From 4408c26d9afe8b355ae8d95c69f0e0adf800f69f Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:02 -0700 Subject: [PATCH 35/79] rocmPackages_10.rocprim: init at 10.1 Update the rocmPackages.rocprim copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ pkgs/development/rocm-modules/10/rocprim/default.nix | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index ca6fa75dbb7ff..833cc3a3535f2 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -103,6 +103,8 @@ let rocr-debug-agent = self.callPackage ./rocr-debug-agent { }; + rocprim = self.callPackage ./rocprim { }; + mscclpp = self.callPackage ../mscclpp { }; rccl = self.callPackage ./rccl { }; diff --git a/pkgs/development/rocm-modules/10/rocprim/default.nix b/pkgs/development/rocm-modules/10/rocprim/default.nix index 577cbfb862014..07bf5ac9dcd27 100644 --- a/pkgs/development/rocm-modules/10/rocprim/default.nix +++ b/pkgs/development/rocm-modules/10/rocprim/default.nix @@ -15,7 +15,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocprim"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -30,12 +30,12 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/rocprim" "shared" ]; - hash = "sha256-e0mZ27OXyblcnXQGv2ex/CvWx9smw6nBbHZIijj7lP8="; + hash = "sha256-ObSLanTmi2Utv7kWM7hjnVzmNU2e4P23SB3+7Z3qO0o="; }; sourceRoot = "${finalAttrs.src.name}/projects/rocprim"; From cbd6bbe43fa6e3feb62f3dee21169262f2fbff90 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:03 -0700 Subject: [PATCH 36/79] rocmPackages_10.rocthrust: init at 10.1 Update the rocmPackages.rocthrust copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ pkgs/development/rocm-modules/10/rocthrust/default.nix | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 833cc3a3535f2..42dbd21ab6a58 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -105,6 +105,8 @@ let rocprim = self.callPackage ./rocprim { }; + rocthrust = self.callPackage ./rocthrust { }; + mscclpp = self.callPackage ../mscclpp { }; rccl = self.callPackage ./rccl { }; diff --git a/pkgs/development/rocm-modules/10/rocthrust/default.nix b/pkgs/development/rocm-modules/10/rocthrust/default.nix index 653498cb85653..8e3febeddccc5 100644 --- a/pkgs/development/rocm-modules/10/rocthrust/default.nix +++ b/pkgs/development/rocm-modules/10/rocthrust/default.nix @@ -15,7 +15,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocthrust"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -30,12 +30,12 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/rocthrust" "shared" ]; - hash = "sha256-wHEgpmBZCYtvp+OyebrRyfoFz3WQyKWfHPrdzQVL8lY="; + hash = "sha256-VYIOMrJj+6fxuV3SkntYnPnCsyqAvLERlxrQQ5qzYJA="; }; sourceRoot = "${finalAttrs.src.name}/projects/rocthrust"; From 5962e8c86f67496f40b0d06a1c045abb0937727c Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:04 -0700 Subject: [PATCH 37/79] rocmPackages_10.hipcub: init at 10.1 Update the rocmPackages.hipcub copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ pkgs/development/rocm-modules/10/hipcub/default.nix | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 42dbd21ab6a58..9c5f6626b7193 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -113,6 +113,8 @@ let rocshmem = self.callPackage ./rocshmem { }; + hipcub = self.callPackage ./hipcub { }; + half = self.callPackage ./half { }; # Even if config.rocmSupport is false we need rocmSupport true diff --git a/pkgs/development/rocm-modules/10/hipcub/default.nix b/pkgs/development/rocm-modules/10/hipcub/default.nix index a775d81509a1e..257a52b65508c 100644 --- a/pkgs/development/rocm-modules/10/hipcub/default.nix +++ b/pkgs/development/rocm-modules/10/hipcub/default.nix @@ -17,7 +17,7 @@ # CUB can also be used as a backend instead of rocPRIM. stdenv.mkDerivation (finalAttrs: { pname = "hipcub"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -32,12 +32,12 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/hipcub" "shared" ]; - hash = "sha256-geO6LS1osKAlmVRtiZ6keqFHsJccyB7pRZdWPEkue2M="; + hash = "sha256-66uC/CxNSXoHWo9uSbrYfqZkchr7zHVLrwbsfZoYtUQ="; }; sourceRoot = "${finalAttrs.src.name}/projects/hipcub"; From 0386a8b31a6d9f3530d81ed03861491934f96253 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:04 -0700 Subject: [PATCH 38/79] rocmPackages_10.rocrand: init at 10.1 Update the rocmPackages.rocrand copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ pkgs/development/rocm-modules/10/rocrand/default.nix | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 9c5f6626b7193..9c26f7c00d758 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -107,6 +107,8 @@ let rocthrust = self.callPackage ./rocthrust { }; + rocrand = self.callPackage ./rocrand { }; + mscclpp = self.callPackage ../mscclpp { }; rccl = self.callPackage ./rccl { }; diff --git a/pkgs/development/rocm-modules/10/rocrand/default.nix b/pkgs/development/rocm-modules/10/rocrand/default.nix index cefff33fafd63..412b24ff7ce18 100644 --- a/pkgs/development/rocm-modules/10/rocrand/default.nix +++ b/pkgs/development/rocm-modules/10/rocrand/default.nix @@ -15,7 +15,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocrand${clr.gpuArchSuffix}"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -30,12 +30,12 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/rocrand" "shared" ]; - hash = "sha256-tl++h7LSEXf0jWe007+RIRwYHdB6TKPDpzipj1Emew8="; + hash = "sha256-vBNKXBOfBi+f9VaxZWaka/phgidi/lGOow+aSjBpy+4="; }; sourceRoot = "${finalAttrs.src.name}/projects/rocrand"; From 3fda76a3f3f4773d3cf429e272e4fcb5d31fa9c3 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:05 -0700 Subject: [PATCH 39/79] rocmPackages_10.hiprand: init at 10.1 Update the rocmPackages.hiprand copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ pkgs/development/rocm-modules/10/hiprand/default.nix | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 9c26f7c00d758..6474b4cb96668 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -109,6 +109,8 @@ let rocrand = self.callPackage ./rocrand { }; + hiprand = self.callPackage ./hiprand { }; + mscclpp = self.callPackage ../mscclpp { }; rccl = self.callPackage ./rccl { }; diff --git a/pkgs/development/rocm-modules/10/hiprand/default.nix b/pkgs/development/rocm-modules/10/hiprand/default.nix index 5e0fd0812ada3..663cd52383aa2 100644 --- a/pkgs/development/rocm-modules/10/hiprand/default.nix +++ b/pkgs/development/rocm-modules/10/hiprand/default.nix @@ -14,7 +14,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "hiprand"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -26,12 +26,12 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/hiprand" "shared" ]; - hash = "sha256-bjcwjN1dNukhoDAbiSpATlK6dtAwM8bOJTe3IjhdwwY="; + hash = "sha256-ocVmceoelvCbg95F+z02wbSi+M/Wm4nFolrlpqKIhlk="; }; sourceRoot = "${finalAttrs.src.name}/projects/hiprand"; From d7b9cf24d295995c1312417fa327c4e140674ef3 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:05 -0700 Subject: [PATCH 40/79] rocmPackages_10.rocfft: init at 10.1 Update the rocmPackages.rocfft copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From the mass bump: - rocfft: rebase log-every-n-aot-jobs.patch onto the 10.1 source. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ .../rocm-modules/10/rocfft/default.nix | 6 ++-- .../10/rocfft/log-every-n-aot-jobs.patch | 32 ++++++------------- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 6474b4cb96668..cddfb9078d170 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -111,6 +111,8 @@ let hiprand = self.callPackage ./hiprand { }; + rocfft = self.callPackage ./rocfft { }; + mscclpp = self.callPackage ../mscclpp { }; rccl = self.callPackage ./rccl { }; diff --git a/pkgs/development/rocm-modules/10/rocfft/default.nix b/pkgs/development/rocm-modules/10/rocfft/default.nix index c48529ac5a831..53ab3ae97693a 100644 --- a/pkgs/development/rocm-modules/10/rocfft/default.nix +++ b/pkgs/development/rocm-modules/10/rocfft/default.nix @@ -20,17 +20,17 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocfft${clr.gpuArchSuffix}"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/rocfft" "shared" ]; - hash = "sha256-RjWMzLX0nBA8ClweJ8YgRTn+Nzt/VUkOoSw3jMQ3IWg="; + hash = "sha256-N7bqrYrrYg9p6YnG7UcvOL7qYDPD/XwKUj7Jco57/oY="; }; sourceRoot = "${finalAttrs.src.name}/projects/rocfft"; diff --git a/pkgs/development/rocm-modules/10/rocfft/log-every-n-aot-jobs.patch b/pkgs/development/rocm-modules/10/rocfft/log-every-n-aot-jobs.patch index 266f495d3e7c0..6b366860f5c40 100644 --- a/pkgs/development/rocm-modules/10/rocfft/log-every-n-aot-jobs.patch +++ b/pkgs/development/rocm-modules/10/rocfft/log-every-n-aot-jobs.patch @@ -1,11 +1,10 @@ diff --git a/library/src/rocfft_aot_helper.cpp b/library/src/rocfft_aot_helper.cpp -index f0a889f4..452eb37f 100644 ---- a/library/src/rocfft_aot_helper.cpp -+++ b/library/src/rocfft_aot_helper.cpp -@@ -771,26 +771,22 @@ int main(int argc, char** argv) +--- a/library/src/rocfft_aot_helper.cpp 2026-09-23 08:37:25.278407528 -0700 ++++ b/library/src/rocfft_aot_helper.cpp 2026-09-23 08:37:25.298619033 -0700 +@@ -786,12 +786,19 @@ for(size_t i = 0; i < NUM_THREADS; ++i) { - threads.emplace_back([&queue, &gpu_archs]() { + threads.emplace_back([&queue, &gpu_archs, &rtc_helper]() { + int compile_count = 0; while(true) { @@ -13,23 +12,12 @@ index f0a889f4..452eb37f 100644 if(item.kernel_name.empty()) break; ++ // Emit periodic progress so the Nix builder does not time out on the ++ // long, otherwise-silent ahead-of-time kernel compile step. + if(++compile_count % 16 == 0) -+ std::cerr << "rocfft_aot_helper processing " << item.kernel_name << std::endl << std::flush; ++ std::cerr << "rocfft_aot_helper processing " << item.kernel_name ++ << std::endl ++ << std::flush; for(const auto& gpu_arch : gpu_archs) { -- if(item.sol_arch_name.empty()) -+ if(item.sol_arch_name.empty() || gpu_arch.find(item.sol_arch_name) != std::string::npos) - { - RTCCache::cached_compile( - item.kernel_name, gpu_arch, item.generate_src, generator_sum()); - } -- else if(gpu_arch.find(item.sol_arch_name) != std::string::npos) -- { -- // std::cout << "arch: " << gpu_arch -- // << ", solution-kernel: " << item.kernel_name << std::endl; -- RTCCache::cached_compile( -- item.kernel_name, gpu_arch, item.generate_src, generator_sum()); -- } - } - } - }); + if(item.sol_arch_name.empty()) From fe3f688c4806c72e00f060d4db75a5bb181261bd Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:06 -0700 Subject: [PATCH 41/79] rocmPackages_10.hipfft: init at 10.1 Update the rocmPackages.hipfft copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ pkgs/development/rocm-modules/10/hipfft/default.nix | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index cddfb9078d170..759abf2f33081 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -121,6 +121,8 @@ let hipcub = self.callPackage ./hipcub { }; + hipfft = self.callPackage ./hipfft { }; + half = self.callPackage ./half { }; # Even if config.rocmSupport is false we need rocmSupport true diff --git a/pkgs/development/rocm-modules/10/hipfft/default.nix b/pkgs/development/rocm-modules/10/hipfft/default.nix index 62c98375d029a..0d7d6b75b0786 100644 --- a/pkgs/development/rocm-modules/10/hipfft/default.nix +++ b/pkgs/development/rocm-modules/10/hipfft/default.nix @@ -21,7 +21,7 @@ # Can also use cuFFT stdenv.mkDerivation (finalAttrs: { pname = "hipfft"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -39,13 +39,13 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/hipfft" "shared" ]; fetchSubmodules = true; - hash = "sha256-EtxZuxBPx6trTN9iC7uri2+UR0Eolp919Ry4U1PEqNA="; + hash = "sha256-QTcdNpA/xEH99DZ6rlhMGWUVpc0aitve4lKlhNiF0OM="; }; sourceRoot = "${finalAttrs.src.name}/projects/hipfft"; From 6d11f2b0d63ff31f11df2735a6e50d09641604aa Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:07 -0700 Subject: [PATCH 42/79] rocmPackages_10: copy hipBLASLt from rocmPackages Verbatim copies of the rocmPackages (ROCm 7.2.4) expressions for hipblas-common, hipblaslt, not yet part of the rocmPackages_10 scope. The following commits update each one to ROCm 10.1, so their diffs read against 7.2.4. Assisted-by: Claude Code (claude-opus-5-5) --- .../10/hipblas-common/default.nix | 43 + .../10/hipblaslt/Tensile-interning.patch | 181 ++++ .../TensileCreateLibrary-refactor.patch | 849 ++++++++++++++++++ .../rocm-modules/10/hipblaslt/default.nix | 256 ++++++ .../messagepack-compression-support.patch | 56 ++ .../parallel-buildSourceCodeObjectFile.diff | 12 + 6 files changed, 1397 insertions(+) create mode 100644 pkgs/development/rocm-modules/10/hipblas-common/default.nix create mode 100644 pkgs/development/rocm-modules/10/hipblaslt/Tensile-interning.patch create mode 100644 pkgs/development/rocm-modules/10/hipblaslt/TensileCreateLibrary-refactor.patch create mode 100644 pkgs/development/rocm-modules/10/hipblaslt/default.nix create mode 100644 pkgs/development/rocm-modules/10/hipblaslt/messagepack-compression-support.patch create mode 100644 pkgs/development/rocm-modules/10/hipblaslt/parallel-buildSourceCodeObjectFile.diff diff --git a/pkgs/development/rocm-modules/10/hipblas-common/default.nix b/pkgs/development/rocm-modules/10/hipblas-common/default.nix new file mode 100644 index 0000000000000..6ddc7c8e258a5 --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipblas-common/default.nix @@ -0,0 +1,43 @@ +{ + lib, + stdenv, + cmake, + fetchFromGitHub, + rocm-cmake, + rocmUpdateScript, +}: +stdenv.mkDerivation (finalAttrs: { + pname = "hipblas-common"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/hipblas-common" + "shared" + ]; + hash = "sha256-83LgS4I1fMSaNtWdVFf1qhYRMT7a9jVzO3XpUzEipXg="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/hipblas-common"; + + nativeBuildInputs = [ + cmake + ]; + + buildInputs = [ + rocm-cmake + ]; + + strictDeps = true; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + meta = { + description = "Common files shared by hipBLAS and hipBLASLt"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipblas-common"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/hipblaslt/Tensile-interning.patch b/pkgs/development/rocm-modules/10/hipblaslt/Tensile-interning.patch new file mode 100644 index 0000000000000..acf44437520db --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipblaslt/Tensile-interning.patch @@ -0,0 +1,181 @@ +diff --git a/tensilelite/Tensile/Common/Utilities.py b/tensilelite/Tensile/Common/Utilities.py +index 0a9d9db5b3..cb9779eaac 100644 +--- a/tensilelite/Tensile/Common/Utilities.py ++++ b/tensilelite/Tensile/Common/Utilities.py +@@ -24,6 +24,7 @@ + + import functools + import math ++import operator + import os + import sys + import time +@@ -269,8 +270,20 @@ def state(obj): + + + def state_key_ordering(cls): +- def tup(obj): +- return tuple([getattr(obj, k) for k in cls.StateKeys]) ++ # Use operator.attrgetter for efficiency if __slots__ is defined ++ if hasattr(cls, '__slots__'): ++ # attrgetter is faster for slotted classes ++ getter = operator.attrgetter(*cls.StateKeys) ++ if len(cls.StateKeys) == 1: ++ # attrgetter returns scalar for single key, we need tuple ++ def tup(obj): ++ return (getter(obj),) ++ else: ++ tup = getter ++ else: ++ # Fallback for regular classes ++ def tup(obj): ++ return tuple([getattr(obj, k) for k in cls.StateKeys]) + + def lt(a, b): + return tup(a) < tup(b) +diff --git a/tensilelite/Tensile/Contractions.py b/tensilelite/Tensile/Contractions.py +index c0d4e851b1..3f2c2e98c6 100644 +--- a/tensilelite/Tensile/Contractions.py ++++ b/tensilelite/Tensile/Contractions.py +@@ -37,9 +37,60 @@ from Tensile.Toolchain.Component import Assembler + from math import ceil + + MIN_K_FOR_GSU = 32 ++ ++# Interning helpers to reduce memory usage by reusing identical objects ++_free_index_cache = {} ++def intern_free_index(isA, i=None, c=None, d=None, a=None, b=None): ++ key = (isA, i, c, d, a, b) ++ if key not in _free_index_cache: ++ obj = FreeIndex(isA, i, c, d) ++ obj.a = a ++ if b is not None: ++ obj.b = b ++ _free_index_cache[key] = obj ++ return _free_index_cache[key] ++ ++_batch_index_cache = {} ++def intern_batch_index(a=None, b=None, c=None, d=None): ++ key = (a, b, c, d) ++ if key not in _batch_index_cache: ++ obj = BatchIndex(c=c, d=d) ++ obj.a = a ++ obj.b = b ++ _batch_index_cache[key] = obj ++ return _batch_index_cache[key] ++ ++_bound_index_cache = {} ++def intern_bound_index(a=None, b=None, aMirror=False, bMirror=False): ++ key = (a, b, aMirror, bMirror) ++ if key not in _bound_index_cache: ++ obj = BoundIndex(aMirror=aMirror, bMirror=bMirror) ++ obj.a = a ++ obj.b = b ++ _bound_index_cache[key] = obj ++ return _bound_index_cache[key] ++ ++_size_mapping_cache = {} ++def intern_size_mapping(size_mapping): ++ """Intern a SizeMapping instance to reduce redundancy.""" ++ # Build hashable key from StateKeys, converting lists to tuples ++ key_parts = [] ++ for attr in size_mapping.StateKeys: ++ val = getattr(size_mapping, attr) ++ # Convert lists to tuples for hashing ++ if isinstance(val, list): ++ val = tuple(val) ++ key_parts.append(val) ++ key = tuple(key_parts) ++ ++ if key not in _size_mapping_cache: ++ _size_mapping_cache[key] = size_mapping ++ return _size_mapping_cache[key] ++ + @state_key_ordering + class FreeIndex: + StateKeys = ['isA', 'i', 'c', 'd'] ++ __slots__ = ['isA', 'i', 'c', 'd', 'a', 'b'] + + def __init__(self, isA, i=None, c=None, d=None): + self.isA = isA +@@ -50,6 +101,7 @@ class FreeIndex: + @state_key_ordering + class BatchIndex: + StateKeys = ['a', 'b', 'c', 'd'] ++ __slots__ = ['a', 'b', 'c', 'd'] + def __init__(self, a=None, b=None, c=None, d=None): + self.a = a + self.b = b +@@ -59,6 +111,7 @@ class BatchIndex: + @state_key_ordering + class BoundIndex: + StateKeys = ['a', 'b', 'aMirror', 'bMirror'] ++ __slots__ = ['a', 'b', 'aMirror', 'bMirror'] + def __init__(self, a=None, b=None, aMirror=False, bMirror=False): + self.a = a + self.b = b +@@ -107,6 +160,23 @@ class ProblemType: + for ib, ic in enumerate(d['IndexAssignmentsB']): + indices[ic].b = ib + ++ # Now intern all indices with their final state (including .a and .b) ++ for i, idx in enumerate(indices): ++ if isinstance(idx, FreeIndex): ++ indices[i] = intern_free_index(idx.isA, idx.i, idx.c, idx.d, ++ getattr(idx, 'a', None), getattr(idx, 'b', None)) ++ elif isinstance(idx, BatchIndex): ++ indices[i] = intern_batch_index(getattr(idx, 'a', None), getattr(idx, 'b', None), ++ idx.c, idx.d) ++ elif isinstance(idx, BoundIndex): ++ indices[i] = intern_bound_index(getattr(idx, 'a', None), getattr(idx, 'b', None), ++ idx.aMirror, idx.bMirror) ++ ++ # Update the lists with interned versions ++ freeIndices = [idx for idx in indices if isinstance(idx, FreeIndex)] ++ batchIndices = [idx for idx in indices if isinstance(idx, BatchIndex)] ++ boundIndices = [idx for idx in indices if isinstance(idx, BoundIndex)] ++ + for idx in indices: + assert idx is not None + idxState = state(idx) +@@ -596,6 +666,7 @@ class SizeMapping: + 'nonTemporalA', + 'nonTemporalB', + ] ++ __slots__ = StateKeys + + @classmethod + def FromOriginalState(cls, d): +@@ -751,7 +822,7 @@ class Solution: + info = cls.ReadOriginalInfo(d) + rv.libraryLogicIndex = int(info.get("SolutionIndex", -1)) + +- rv.sizeMapping = SizeMapping.FromOriginalState(d) ++ rv.sizeMapping = intern_size_mapping(SizeMapping.FromOriginalState(d)) + + rv.internalArgsSupport = InternalArgsSupport.FromOriginalState(d) + +diff --git a/tensilelite/Tensile/TensileCreateLibrary/Run.py b/tensilelite/Tensile/TensileCreateLibrary/Run.py +index 730b6b1fff..b0068563a0 100644 +--- a/tensilelite/Tensile/TensileCreateLibrary/Run.py ++++ b/tensilelite/Tensile/TensileCreateLibrary/Run.py +@@ -104,7 +104,6 @@ class KernelCodeGenResult(NamedTuple): + src: str + header: Optional[str] + name: str +- targetObjFilename: str + isa: IsaVersion + wavefrontSize: int + cuoccupancy: int +@@ -127,10 +126,9 @@ def processKernelSource(kernelWriterAssembly, data, splitGSU, kernel) -> KernelC + asmFilename = getKernelFileBase(splitGSU, kernel) + err, src = kernelWriter.getSourceFileString(kernel) + header = kernelWriter.getHeaderFileString(kernel) +- objFilename = kernel._state.get("codeObjectFile", None) + pgr = int(kernel["PrefetchGlobalRead"]) + return KernelCodeGenResult( +- err, src, header, asmFilename, objFilename, tuple(kernel["ISA"]), \ ++ err, src, header, asmFilename, tuple(kernel["ISA"]), \ + kernel["WavefrontSize"], kernel["CUOccupancy"], \ + pgr, kernel["MathClocksUnrolledLoop"] + ) diff --git a/pkgs/development/rocm-modules/10/hipblaslt/TensileCreateLibrary-refactor.patch b/pkgs/development/rocm-modules/10/hipblaslt/TensileCreateLibrary-refactor.patch new file mode 100644 index 0000000000000..1accf91426f46 --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipblaslt/TensileCreateLibrary-refactor.patch @@ -0,0 +1,849 @@ +diff --git a/tensilelite/Tensile/Common/Parallel.py b/tensilelite/Tensile/Common/Parallel.py +index 1a2bf9e119..f46100c7b8 100644 +--- a/tensilelite/Tensile/Common/Parallel.py ++++ b/tensilelite/Tensile/Common/Parallel.py +@@ -22,43 +22,58 @@ + # + ################################################################################ + +-import concurrent.futures +-import itertools ++import multiprocessing + import os ++import re + import sys + import time +- +-from joblib import Parallel, delayed ++from functools import partial ++from typing import Any, Callable + + from .Utilities import tqdm + + +-def joblibParallelSupportsGenerator(): +- import joblib +- from packaging.version import Version ++def get_inherited_job_limit() -> int: ++ # 1. Check CMAKE_BUILD_PARALLEL_LEVEL (CMake 3.12+) ++ if 'CMAKE_BUILD_PARALLEL_LEVEL' in os.environ: ++ try: ++ return int(os.environ['CMAKE_BUILD_PARALLEL_LEVEL']) ++ except ValueError: ++ pass + +- joblibVer = joblib.__version__ +- return Version(joblibVer) >= Version("1.4.0") ++ # 2. Parse MAKEFLAGS for -jN ++ makeflags = os.environ.get('MAKEFLAGS', '') ++ match = re.search(r'-j\s*(\d+)', makeflags) ++ if match: ++ return int(match.group(1)) + ++ return -1 + +-def CPUThreadCount(enable=True): +- from .GlobalParameters import globalParameters + ++def CPUThreadCount(enable=True): + if not enable: + return 1 +- else: ++ from .GlobalParameters import globalParameters ++ ++ # Priority order: ++ # 1. Inherited from build system (CMAKE_BUILD_PARALLEL_LEVEL or MAKEFLAGS) ++ # 2. Explicit --jobs flag ++ # 3. Auto-detect ++ inherited_limit = get_inherited_job_limit() ++ cpuThreads = inherited_limit if inherited_limit > 0 else globalParameters["CpuThreads"] ++ ++ if cpuThreads < 1: + if os.name == "nt": +- # Windows supports at most 61 workers because the scheduler uses +- # WaitForMultipleObjects directly, which has the limit (the limit +- # is actually 64, but some handles are needed for accounting). +- cpu_count = min(os.cpu_count(), 61) ++ cpuThreads = os.cpu_count() + else: +- cpu_count = len(os.sched_getaffinity(0)) +- cpuThreads = globalParameters["CpuThreads"] +- if cpuThreads == -1: +- return cpu_count ++ cpuThreads = len(os.sched_getaffinity(0)) + +- return min(cpu_count, cpuThreads) ++ if os.name == "nt": ++ # Windows supports at most 61 workers because the scheduler uses ++ # WaitForMultipleObjects directly, which has the limit (the limit ++ # is actually 64, but some handles are needed for accounting). ++ cpuThreads = min(cpuThreads, 61) ++ return max(1, cpuThreads) + + + def pcallWithGlobalParamsMultiArg(f, args, newGlobalParameters): +@@ -71,19 +86,22 @@ def pcallWithGlobalParamsSingleArg(f, arg, newGlobalParameters): + return f(arg) + + +-def apply_print_exception(item, *args): +- # print(item, args) ++def OverwriteGlobalParameters(newGlobalParameters): ++ from . import GlobalParameters ++ ++ GlobalParameters.globalParameters.clear() ++ GlobalParameters.globalParameters.update(newGlobalParameters) ++ ++ ++def worker_function(args, function, multiArg): ++ """Worker function that executes in the pool process.""" + try: +- if len(args) > 0: +- func = item +- args = args[0] +- return func(*args) ++ if multiArg: ++ return function(*args) + else: +- func, item = item +- return func(item) ++ return function(args) + except Exception: + import traceback +- + traceback.print_exc() + raise + finally: +@@ -98,154 +116,121 @@ def OverwriteGlobalParameters(newGlobalParameters): + GlobalParameters.globalParameters.update(newGlobalParameters) + + +-def ProcessingPool(enable=True, maxTasksPerChild=None): +- import multiprocessing +- import multiprocessing.dummy +- +- threadCount = CPUThreadCount() +- +- if (not enable) or threadCount <= 1: +- return multiprocessing.dummy.Pool(1) +- +- if multiprocessing.get_start_method() == "spawn": +- from . import GlobalParameters +- +- return multiprocessing.Pool( +- threadCount, +- initializer=OverwriteGlobalParameters, +- maxtasksperchild=maxTasksPerChild, +- initargs=(GlobalParameters.globalParameters,), +- ) +- else: +- return multiprocessing.Pool(threadCount, maxtasksperchild=maxTasksPerChild) ++def progress_logger(iterable, total, message, min_log_interval=5.0): ++ """ ++ Generator that wraps an iterable and logs progress with time-based throttling. + ++ Only logs progress if at least min_log_interval seconds have passed since last log. ++ Only prints completion message if task took >= min_log_interval seconds. + +-def ParallelMap(function, objects, message="", enable=True, method=None, maxTasksPerChild=None): ++ Yields (index, item) tuples. + """ +- Generally equivalent to list(map(function, objects)), possibly executing in parallel. +- +- message: A message describing the operation to be performed. +- enable: May be set to false to disable parallelism. +- method: A function which can fetch the mapping function from a processing pool object. +- Leave blank to use .map(), other possiblities: +- - `lambda x: x.starmap` - useful if `function` takes multiple parameters. +- - `lambda x: x.imap` - lazy evaluation +- - `lambda x: x.imap_unordered` - lazy evaluation, does not preserve order of return value. +- """ +- from .GlobalParameters import globalParameters ++ start_time = time.time() ++ last_log_time = start_time ++ log_interval = 1 + (total // 100) + +- threadCount = CPUThreadCount(enable) +- pool = ProcessingPool(enable, maxTasksPerChild) +- +- if threadCount <= 1 and globalParameters["ShowProgressBar"]: +- # Provide a progress bar for single-threaded operation. +- # This works for method=None, and for starmap. +- mapFunc = map +- if method is not None: +- # itertools provides starmap which can fill in for pool.starmap. It provides imap on Python 2.7. +- # If this works, we will use it, otherwise we will fallback to the "dummy" pool for single threaded +- # operation. +- try: +- mapFunc = method(itertools) +- except NameError: +- mapFunc = None +- +- if mapFunc is not None: +- return list(mapFunc(function, tqdm(objects, message))) +- +- mapFunc = pool.map +- if method: +- mapFunc = method(pool) +- +- objects = zip(itertools.repeat(function), objects) +- function = apply_print_exception +- +- countMessage = "" +- try: +- countMessage = " for {} tasks".format(len(objects)) +- except TypeError: +- pass ++ for idx, item in enumerate(iterable): ++ if idx % log_interval == 0: ++ current_time = time.time() ++ if (current_time - last_log_time) >= min_log_interval: ++ print(f"{message}\t{idx+1: 5d}/{total: 5d}") ++ last_log_time = current_time ++ yield idx, item + +- if message != "": +- message += ": " ++ elapsed = time.time() - start_time ++ final_idx = idx + 1 if 'idx' in locals() else 0 + +- print("{0}Launching {1} threads{2}...".format(message, threadCount, countMessage)) +- sys.stdout.flush() +- currentTime = time.time() +- rv = mapFunc(function, objects) +- totalTime = time.time() - currentTime +- print("{0}Done. ({1:.1f} secs elapsed)".format(message, totalTime)) +- sys.stdout.flush() +- pool.close() +- return rv ++ if elapsed >= min_log_interval or last_log_time > start_time: ++ print(f"{message} done in {elapsed:.1f}s!\t{final_idx: 5d}/{total: 5d}") + + +-def ParallelMapReturnAsGenerator(function, objects, message="", enable=True, multiArg=True): +- from .GlobalParameters import globalParameters ++def imap_with_progress(pool, func, iterable, total, message, chunksize): ++ results = [] ++ for _, result in progress_logger(pool.imap(func, iterable, chunksize=chunksize), total, message): ++ results.append(result) ++ return results + +- threadCount = CPUThreadCount(enable) +- print("{0}Launching {1} threads...".format(message, threadCount)) + +- if threadCount <= 1 and globalParameters["ShowProgressBar"]: +- # Provide a progress bar for single-threaded operation. +- callFunc = lambda args: function(*args) if multiArg else lambda args: function(args) +- return [callFunc(args) for args in tqdm(objects, message)] ++def _ParallelMap_generator(worker, objects, objLen, message, chunksize, threadCount, globalParameters, maxtasksperchild): ++ # separate fn because yield makes the entire fn a generator even if unreachable ++ ctx = multiprocessing.get_context('forkserver' if os.name != 'nt' else 'spawn') + +- with concurrent.futures.ProcessPoolExecutor(max_workers=threadCount) as executor: +- resultFutures = (executor.submit(function, *arg if multiArg else arg) for arg in objects) +- for result in concurrent.futures.as_completed(resultFutures): +- yield result.result() ++ with ctx.Pool(processes=threadCount, maxtasksperchild=maxtasksperchild, ++ initializer=OverwriteGlobalParameters, initargs=(globalParameters,)) as pool: ++ for _, result in progress_logger(pool.imap_unordered(worker, objects, chunksize=chunksize), objLen, message): ++ yield result + + + def ParallelMap2( +- function, objects, message="", enable=True, multiArg=True, return_as="list", procs=None ++ function: Callable, ++ objects: Any, ++ message: str = "", ++ enable: bool = True, ++ multiArg: bool = True, ++ minChunkSize: int = 1, ++ maxWorkers: int = -1, ++ maxtasksperchild: int = 1024, ++ return_as: str = "list" + ): ++ """Executes a function over a list of objects in parallel or sequentially. ++ ++ This function is generally equivalent to ``list(map(function, objects))``. However, it provides ++ additional functionality to run in parallel, depending on the 'enable' flag and available CPU ++ threads. ++ ++ Args: ++ function: The function to apply to each item in 'objects'. If 'multiArg' is True, 'function' ++ should accept multiple arguments. ++ objects: An iterable of objects to be processed by 'function'. If 'multiArg' is True, each ++ item in 'objects' should be an iterable of arguments for 'function'. ++ message: Optional; a message describing the operation. Default is an empty string. ++ enable: Optional; if False, disables parallel execution and runs sequentially. Default is True. ++ multiArg: Optional; if True, treats each item in 'objects' as multiple arguments for ++ 'function'. Default is True. ++ return_as: Optional; "list" (default) or "generator_unordered" for streaming results ++ ++ Returns: ++ A list or generator containing the results of applying **function** to each item in **objects**. + """ +- Generally equivalent to list(map(function, objects)), possibly executing in parallel. ++ from .GlobalParameters import globalParameters + +- message: A message describing the operation to be performed. +- enable: May be set to false to disable parallelism. +- multiArg: True if objects represent multiple arguments +- (differentiates multi args vs single collection arg) +- """ +- if return_as in ("generator", "generator_unordered") and not joblibParallelSupportsGenerator(): +- return ParallelMapReturnAsGenerator(function, objects, message, enable, multiArg) ++ threadCount = CPUThreadCount(enable) + +- from .GlobalParameters import globalParameters ++ if not hasattr(objects, "__len__"): ++ objects = list(objects) + +- threadCount = procs if procs else CPUThreadCount(enable) ++ objLen = len(objects) ++ if objLen == 0: ++ return [] if return_as == "list" else iter([]) + +- threadCount = CPUThreadCount(enable) ++ f = (lambda x: function(*x)) if multiArg else function ++ if objLen == 1: ++ print(f"{message}: (1 task)") ++ result = [f(x) for x in objects] ++ return result if return_as == "list" else iter(result) + +- if threadCount <= 1 and globalParameters["ShowProgressBar"]: +- # Provide a progress bar for single-threaded operation. +- return [function(*args) if multiArg else function(args) for args in tqdm(objects, message)] ++ extra_message = ( ++ f": {threadCount} thread(s)" + f", {objLen} tasks" ++ if objLen ++ else "" ++ ) + +- countMessage = "" +- try: +- countMessage = " for {} tasks".format(len(objects)) +- except TypeError: +- pass +- +- if message != "": +- message += ": " +- print("{0}Launching {1} threads{2}...".format(message, threadCount, countMessage)) +- sys.stdout.flush() +- currentTime = time.time() +- +- pcall = pcallWithGlobalParamsMultiArg if multiArg else pcallWithGlobalParamsSingleArg +- pargs = zip(objects, itertools.repeat(globalParameters)) +- +- if joblibParallelSupportsGenerator(): +- rv = Parallel(n_jobs=threadCount, timeout=99999, return_as=return_as)( +- delayed(pcall)(function, a, params) for a, params in pargs +- ) ++ print(f"ParallelMap {message}{extra_message}") ++ ++ if threadCount <= 1: ++ result = [f(x) for x in objects] ++ return result if return_as == "list" else iter(result) ++ ++ if maxWorkers > 0: ++ threadCount = min(maxWorkers, threadCount) ++ ++ chunksize = max(minChunkSize, objLen // 2000) ++ worker = partial(worker_function, function=function, multiArg=multiArg) ++ if return_as == "generator_unordered": ++ # yield results as they complete without buffering ++ return _ParallelMap_generator(worker, objects, objLen, message, chunksize, threadCount, globalParameters, maxtasksperchild) + else: +- rv = Parallel(n_jobs=threadCount, timeout=99999)( +- delayed(pcall)(function, a, params) for a, params in pargs +- ) +- +- totalTime = time.time() - currentTime +- print("{0}Done. ({1:.1f} secs elapsed)".format(message, totalTime)) +- sys.stdout.flush() +- return rv ++ ctx = multiprocessing.get_context('forkserver' if os.name != 'nt' else 'spawn') ++ with ctx.Pool(processes=threadCount, maxtasksperchild=maxtasksperchild, ++ initializer=OverwriteGlobalParameters, initargs=(globalParameters,)) as pool: ++ return list(imap_with_progress(pool, worker, objects, objLen, message, chunksize)) +diff --git a/tensilelite/Tensile/CustomKernels.py b/tensilelite/Tensile/CustomKernels.py +index ffceb636f5..127b3386a1 100644 +--- a/tensilelite/Tensile/CustomKernels.py ++++ b/tensilelite/Tensile/CustomKernels.py +@@ -24,7 +24,9 @@ + + from . import CUSTOM_KERNEL_PATH + from Tensile.Common.ValidParameters import checkParametersAreValid, validParameters, newMIValidParameters ++from Tensile.CustomYamlLoader import DEFAULT_YAML_LOADER + ++from functools import lru_cache + import yaml + + import os +@@ -58,10 +60,13 @@ def getCustomKernelConfigAndAssembly(name, directory=CUSTOM_KERNEL_PATH): + + return (config, assembly) + ++# getCustomKernelConfig will get called repeatedly on the same file ++# 20x logic loading speedup for aquavanjaram_Cijk_Ailk_Bljk_F8NH_HHS_BH_Bias_HAS_SAB_SAV_freesize_custom_GSUs ++@lru_cache + def readCustomKernelConfig(name, directory=CUSTOM_KERNEL_PATH): + rawConfig, _ = getCustomKernelConfigAndAssembly(name, directory) + try: +- return yaml.safe_load(rawConfig)["custom.config"] ++ return yaml.load(rawConfig, Loader=DEFAULT_YAML_LOADER)["custom.config"] + except yaml.scanner.ScannerError as e: + raise RuntimeError("Failed to read configuration for custom kernel: {0}\nDetails:\n{1}".format(name, e)) + +diff --git a/tensilelite/Tensile/CustomYamlLoader.py b/tensilelite/Tensile/CustomYamlLoader.py +index e03f456fbe..ed7510f2ce 100644 +--- a/tensilelite/Tensile/CustomYamlLoader.py ++++ b/tensilelite/Tensile/CustomYamlLoader.py +@@ -1,6 +1,7 @@ + # Copyright © Advanced Micro Devices, Inc., or its affiliates. + # SPDX-License-Identifier: MIT + ++import sys + import yaml + from pathlib import Path + +@@ -70,7 +71,7 @@ def parse_scalar(loader: yaml.Loader): + elif is_float(value_lower): + return float(value_lower) + +- return value ++ return sys.intern(value) + + def load_yaml_stream(yaml_path: Path, loader_type: yaml.Loader): + with open(yaml_path, 'r') as f: +diff --git a/tensilelite/Tensile/TensileCreateLibrary/Run.py b/tensilelite/Tensile/TensileCreateLibrary/Run.py +index 22d19851a3..348068b3bf 100644 +--- a/tensilelite/Tensile/TensileCreateLibrary/Run.py ++++ b/tensilelite/Tensile/TensileCreateLibrary/Run.py +@@ -26,8 +26,10 @@ import rocisa + + import functools + import glob ++import gc + import itertools + import os ++import resource + import shutil + from pathlib import Path + from timeit import default_timer as timer +@@ -78,6 +80,25 @@ from Tensile.Utilities.Decorators.Timing import timing + from .ParseArguments import parseArguments + + ++def getMemoryUsage(): ++ """Get peak and current memory usage in MB.""" ++ rusage = resource.getrusage(resource.RUSAGE_SELF) ++ peak_memory_mb = rusage.ru_maxrss / 1024 # KB to MB on Linux ++ ++ # Get current memory from /proc/self/status ++ current_memory_mb = 0 ++ try: ++ with open('/proc/self/status') as f: ++ for line in f: ++ if line.startswith('VmRSS:'): ++ current_memory_mb = int(line.split()[1]) / 1024 # KB to MB ++ break ++ except: ++ current_memory_mb = peak_memory_mb # Fallback ++ ++ return (peak_memory_mb, current_memory_mb) ++ ++ + class KernelCodeGenResult(NamedTuple): + err: int + src: str +@@ -115,6 +136,29 @@ def processKernelSource(kernelWriterAssembly, data, outOptions, splitGSU, kernel + ) + + ++def processAndAssembleKernelTCL(kernelWriterAssembly, rocisa_data, outOptions, splitGSU, kernel, assemblyTmpPath, assembler): ++ """ ++ Pipeline function for TCL mode that: ++ 1. Generates kernel source ++ 2. Writes .s file to disk ++ 3. Assembles to .o file ++ 4. Deletes .s file ++ """ ++ result = processKernelSource(kernelWriterAssembly, rocisa_data, outOptions, splitGSU, kernel) ++ return writeAndAssembleKernel(result, assemblyTmpPath, assembler) ++ ++ ++def writeMasterSolutionLibrary(name_lib_tuple, newLibraryDir, splitGSU, libraryFormat): ++ """ ++ Write a master solution library to disk. ++ Module-level function to support multiprocessing. ++ """ ++ name, lib = name_lib_tuple ++ filename = os.path.join(newLibraryDir, name) ++ lib.applyNaming(splitGSU) ++ LibraryIO.write(filename, state(lib), libraryFormat) ++ ++ + def removeInvalidSolutionsAndKernels(results, kernels, solutions, errorTolerant, printLevel: bool, splitGSU: bool): + removeKernels = [] + removeKernelNames = [] +@@ -189,6 +233,24 @@ def writeAssembly(asmPath: Union[Path, str], result: KernelCodeGenResult): + return path, isa, wfsize, minResult + + ++def writeAndAssembleKernel(result: KernelCodeGenResult, asmPath: Union[Path, str], assembler): ++ """Write assembly file and immediately assemble it to .o file""" ++ if result.err: ++ printExit(f"Failed to build kernel {result.name} because it has error code {result.err}") ++ ++ path = Path(asmPath) / f"{result.name}.s" ++ with open(path, "w", encoding="utf-8") as f: ++ f.write(result.src) ++ ++ # Assemble .s -> .o ++ assembler(isaToGfx(result.isa), result.wavefrontSize, str(path), str(path.with_suffix(".o"))) ++ ++ # Delete assembly file immediately to save disk space ++ path.unlink() ++ ++ return KernelMinResult(result.err, result.cuoccupancy, result.pgr, result.mathclk) ++ ++ + def writeHelpers( + outputPath, kernelHelperObjs, KERNEL_HELPER_FILENAME_CPP, KERNEL_HELPER_FILENAME_H + ): +@@ -272,14 +334,15 @@ def writeSolutionsAndKernels( + numAsmKernels = len(asmKernels) + numKernels = len(asmKernels) + assert numKernels == numAsmKernels, "Only assembly kernels are supported in TensileLite" +- asmIter = zip( +- itertools.repeat(kernelWriterAssembly), +- itertools.repeat(rocisa.rocIsa.getInstance().getData()), +- itertools.repeat(outOptions), +- itertools.repeat(splitGSU), +- asmKernels ++ ++ processKernelFn = functools.partial( ++ processKernelSource, ++ kernelWriterAssembly=kernelWriterAssembly, ++ data=rocisa.rocIsa.getInstance().getData(), ++ outOptions=outOptions, ++ splitGSU=splitGSU + ) +- asmResults = ParallelMap2(processKernelSource, asmIter, "Generating assembly kernels", return_as="list") ++ asmResults = ParallelMap2(processKernelFn, asmKernels, "Generating assembly kernels", return_as="list", multiArg=False) + removeInvalidSolutionsAndKernels( + asmResults, asmKernels, solutions, errorTolerant, getVerbosity(), splitGSU + ) +@@ -287,19 +350,21 @@ def writeSolutionsAndKernels( + asmResults, asmKernels, solutions, splitGSU + ) + +- def assemble(ret): +- p, isa, wavefrontsize, _ = ret +- asmToolchain.assembler(isaToGfx(isa), wavefrontsize, str(p), str(p.with_suffix(".o"))) +- +- unaryWriteAssembly = functools.partial(writeAssembly, assemblyTmpPath) +- compose = lambda *F: functools.reduce(lambda f, g: lambda x: f(g(x)), F) ++ # Use functools.partial to bind assemblyTmpPath and assembler ++ writeAndAssembleFn = functools.partial( ++ writeAndAssembleKernel, ++ asmPath=assemblyTmpPath, ++ assembler=asmToolchain.assembler ++ ) + ret = ParallelMap2( +- compose(assemble, unaryWriteAssembly), ++ writeAndAssembleFn, + asmResults, + "Writing assembly kernels", + return_as="list", + multiArg=False, + ) ++ del asmResults ++ gc.collect() + + writeHelpers(outputPath, kernelHelperObjs, KERNEL_HELPER_FILENAME_CPP, KERNEL_HELPER_FILENAME_H) + srcKernelFile = Path(outputPath) / "Kernels.cpp" +@@ -376,40 +441,35 @@ def writeSolutionsAndKernelsTCL( + + uniqueAsmKernels = [k for k in asmKernels if not k.duplicate] + +- def assemble(ret, removeTemporaries: bool): +- asmPath, isa, wavefrontsize, result = ret +- asmToolchain.assembler(isaToGfx(isa), wavefrontsize, str(asmPath), str(asmPath.with_suffix(".o"))) +- if removeTemporaries: +- asmPath.unlink() +- return result +- +- unaryAssemble = functools.partial(assemble, removeTemporaries=removeTemporaries) +- + outOptions = rocisa.rocIsa.getInstance().getOutputOptions() + outOptions.outputNoComment = not disableAsmComments + +- unaryProcessKernelSource = functools.partial( +- processKernelSource, ++ processKernelFn = functools.partial( ++ processAndAssembleKernelTCL, + kernelWriterAssembly, + rocisa.rocIsa.getInstance().getData(), + outOptions, + splitGSU, ++ assemblyTmpPath=assemblyTmpPath, ++ assembler=asmToolchain.assembler + ) + +- unaryWriteAssembly = functools.partial(writeAssembly, assemblyTmpPath) +- compose = lambda *F: functools.reduce(lambda f, g: lambda x: f(g(x)), F) +- ret = ParallelMap2( +- compose(unaryAssemble, unaryWriteAssembly, unaryProcessKernelSource), ++ results = ParallelMap2( ++ processKernelFn, + uniqueAsmKernels, + "Generating assembly kernels", + multiArg=False, + return_as="list" + ) ++ del processKernelFn ++ gc.collect() ++ + passPostKernelInfoToSolution( +- ret, uniqueAsmKernels, solutions, splitGSU ++ results, uniqueAsmKernels, solutions, splitGSU + ) +- # result.src is very large so let garbage collector know to clean up +- del ret ++ del results ++ gc.collect() ++ + buildAssemblyCodeObjectFiles( + asmToolchain.linker, + asmToolchain.bundler, +@@ -508,6 +568,15 @@ def generateKernelHelperObjects(solutions: List[Solution], cxxCompiler: str, isa + return sorted(khos, key=sortByEnum, reverse=True) # Ensure that we write Enum kernel helpers are first in list + + ++def libraryIter(lib: MasterSolutionLibrary): ++ if len(lib.solutions): ++ for i, s in enumerate(lib.solutions.items()): ++ yield (i, *s) ++ else: ++ for _, lazyLib in lib.lazyLibraries.items(): ++ yield from libraryIter(lazyLib) ++ ++ + @timing + def generateLogicDataAndSolutions(logicFiles, args, assembler: Assembler, isaInfoMap): + +@@ -523,26 +592,23 @@ def generateLogicDataAndSolutions(logicFiles, args, assembler: Assembler, isaInf + printSolutionRejectionReason = True + printIndexAssignmentInfo = False + +- fIter = zip( +- logicFiles, +- itertools.repeat(assembler), +- itertools.repeat(splitGSU), +- itertools.repeat(printSolutionRejectionReason), +- itertools.repeat(printIndexAssignmentInfo), +- itertools.repeat(isaInfoMap), +- itertools.repeat(args["LazyLibraryLoading"]), ++ parseLogicFn = functools.partial( ++ LibraryIO.parseLibraryLogicFile, ++ assembler=assembler, ++ splitGSU=splitGSU, ++ printSolutionRejectionReason=printSolutionRejectionReason, ++ printIndexAssignmentInfo=printIndexAssignmentInfo, ++ isaInfoMap=isaInfoMap, ++ lazyLibraryLoading=args["LazyLibraryLoading"] + ) + +- def libraryIter(lib: MasterSolutionLibrary): +- if len(lib.solutions): +- for i, s in enumerate(lib.solutions.items()): +- yield (i, *s) +- else: +- for _, lazyLib in lib.lazyLibraries.items(): +- yield from libraryIter(lazyLib) +- + for library in ParallelMap2( +- LibraryIO.parseLibraryLogicFile, fIter, "Loading Logics...", return_as="generator_unordered" ++ parseLogicFn, logicFiles, "Loading Logics...", ++ return_as="generator_unordered", ++ minChunkSize=24, ++ maxWorkers=32, ++ maxtasksperchild=1, ++ multiArg=False, + ): + _, architectureName, _, _, _, newLibrary = library + +@@ -554,6 +620,9 @@ def generateLogicDataAndSolutions(logicFiles, args, assembler: Assembler, isaInf + else: + masterLibraries[architectureName] = newLibrary + masterLibraries[architectureName].version = args["CodeObjectVersion"] ++ del library, newLibrary ++ ++ gc.collect() + + # Sort masterLibraries to make global soln index values deterministic + solnReIndex = 0 +@@ -751,6 +820,9 @@ def run(): + ) + stop_wsk = timer() + print(f"Time to generate kernels (s): {(stop_wsk-start_wsk):3.2f}") ++ numKernelHelperObjs = len(kernelHelperObjs) ++ del kernelWriterAssembly, kernelHelperObjs ++ gc.collect() + + archs = [ # is this really different than the other archs above? + isaToGfx(arch) +@@ -768,13 +840,10 @@ def run(): + if kName not in solDict: + solDict["%s"%kName] = kernel + +- def writeMsl(name, lib): +- filename = os.path.join(newLibraryDir, name) +- lib.applyNaming(splitGSU) +- LibraryIO.write(filename, state(lib), arguments["LibraryFormat"]) +- + filename = os.path.join(newLibraryDir, "TensileLiteLibrary_lazy_Mapping") + LibraryIO.write(filename, libraryMapping, "msgpack") ++ del libraryMapping ++ gc.collect() + + start_msl = timer() + for archName, newMasterLibrary in masterLibraries.items(): +@@ -791,12 +860,22 @@ def run(): + kName = getKeyNoInternalArgs(s.originalSolution, splitGSU) + s.sizeMapping.CUOccupancy = solDict["%s"%kName]["CUOccupancy"] + +- ParallelMap2(writeMsl, ++ writeFn = functools.partial( ++ writeMasterSolutionLibrary, ++ newLibraryDir=newLibraryDir, ++ splitGSU=splitGSU, ++ libraryFormat=arguments["LibraryFormat"] ++ ) ++ ++ ParallelMap2(writeFn, + newMasterLibrary.lazyLibraries.items(), + "Writing master solution libraries", ++ multiArg=False, + return_as="list") + stop_msl = timer() + print(f"Time to write master solution libraries (s): {(stop_msl-start_msl):3.2f}") ++ del masterLibraries, solutions, kernels, solDict ++ gc.collect() + + if not arguments["KeepBuildTmp"]: + buildTmp = Path(arguments["OutputPath"]).parent / "library" / "build_tmp" +@@ -813,8 +892,11 @@ def run(): + print("") + + stop = timer() ++ peak_memory_mb, current_memory_mb = getMemoryUsage() + + print(f"Total time (s): {(stop-start):3.2f}") + print(f"Total kernels processed: {numKernels}") + print(f"Kernels processed per second: {(numKernels/(stop-start)):3.2f}") +- print(f"KernelHelperObjs: {len(kernelHelperObjs)}") ++ print(f"KernelHelperObjs: {numKernelHelperObjs}") ++ print(f"Peak memory usage (MB): {peak_memory_mb:,.1f}") ++ print(f"Current memory usage (MB): {current_memory_mb:,.1f}") +diff --git a/tensilelite/Tensile/TensileMergeLibrary.py b/tensilelite/Tensile/TensileMergeLibrary.py +index e33c617b6f..ba163e9918 100644 +--- a/tensilelite/Tensile/TensileMergeLibrary.py ++++ b/tensilelite/Tensile/TensileMergeLibrary.py +@@ -303,8 +303,7 @@ def avoidRegressions(originalDir, incrementalDir, outputPath, forceMerge, noEff= + logicsFiles[origFile] = origFile + logicsFiles[incFile] = incFile + +- iters = zip(logicsFiles.keys()) +- logicsList = ParallelMap2(loadData, iters, "Loading Logics...", return_as="list") ++ logicsList = ParallelMap2(loadData, logicsFiles.keys(), "Loading Logics...", return_as="list", multiArg=False) + logicsDict = {} + for i, _ in enumerate(logicsList): + logicsDict[logicsList[i][0]] = logicsList[i][1] +diff --git a/tensilelite/Tensile/TensileUpdateLibrary.py b/tensilelite/Tensile/TensileUpdateLibrary.py +index 5ff265d0ed..c1803a6349 100644 +--- a/tensilelite/Tensile/TensileUpdateLibrary.py ++++ b/tensilelite/Tensile/TensileUpdateLibrary.py +@@ -26,7 +26,7 @@ from . import LibraryIO + from .Tensile import addCommonArguments, argUpdatedGlobalParameters + + from .Common import assignGlobalParameters, print1, restoreDefaultGlobalParameters, HR, \ +- globalParameters, architectureMap, ensurePath, ParallelMap, __version__ ++ globalParameters, architectureMap, ensurePath, ParallelMap2, __version__ + + import argparse + import copy +@@ -149,7 +149,7 @@ def TensileUpdateLibrary(userArgs): + for logicFile in logicFiles: + print("# %s" % logicFile) + fIter = zip(logicFiles, itertools.repeat(args.logic_path), itertools.repeat(outputPath)) +- libraries = ParallelMap(UpdateLogic, fIter, "Updating logic files", method=lambda x: x.starmap) ++ libraries = ParallelMap2(UpdateLogic, fIter, "Updating logic files", multiArg=True, return_as="list") + + + def main(): +diff --git a/tensilelite/Tensile/Toolchain/Assembly.py b/tensilelite/Tensile/Toolchain/Assembly.py +index a8b91e8d62..265e1d532c 100644 +--- a/tensilelite/Tensile/Toolchain/Assembly.py ++++ b/tensilelite/Tensile/Toolchain/Assembly.py +@@ -30,7 +30,7 @@ import subprocess + from pathlib import Path + from typing import List, Union, NamedTuple + +-from Tensile.Common import print2 ++from Tensile.Common import print1, print2 + from Tensile.Common.Architectures import isaToGfx + from ..SolutionStructs import Solution + +@@ -92,8 +92,26 @@ def buildAssemblyCodeObjectFiles( + if coName: + coFileMap[asmDir / (coName + extCoRaw)].add(str(asmDir / (kernel["BaseName"] + extObj))) + ++ # Build reference count map for .o files to handle shared object files ++ # (.o files from kernels marked .duplicate in TensileCreateLibrary) ++ objFileRefCount = collections.Counter() ++ for coFileRaw, objFiles in coFileMap.items(): ++ for objFile in objFiles: ++ objFileRefCount[objFile] += 1 ++ ++ sharedObjFiles = {objFile: count for objFile, count in objFileRefCount.items() if count > 1} ++ if sharedObjFiles: ++ print1(f"Found {len(sharedObjFiles)} .o files shared across multiple code objects:") ++ + for coFileRaw, objFiles in coFileMap.items(): + linker(objFiles, str(coFileRaw)) ++ ++ # Delete .o files after linking once usage count reaches 0 ++ for objFile in objFiles: ++ objFileRefCount[objFile] -= 1 ++ if objFileRefCount[objFile] == 0: ++ Path(objFile).unlink() ++ + coFile = destDir / coFileRaw.name.replace(extCoRaw, extCo) + if compress: + bundler.compress(str(coFileRaw), str(coFile), gfx) +diff --git a/tensilelite/Tensile/Toolchain/Component.py b/tensilelite/Tensile/Toolchain/Component.py +index 67fa35e2d8..dde83af4c3 100644 +--- a/tensilelite/Tensile/Toolchain/Component.py ++++ b/tensilelite/Tensile/Toolchain/Component.py +@@ -355,6 +355,7 @@ class Linker(Component): + when invoking the linker, LLVM allows the provision of arguments via a "response file" + Reference: https://llvm.org/docs/CommandLine.html#response-files + """ ++ # FIXME: this prevents threading as clang_args.txt is overwritten + with open(Path.cwd() / "clang_args.txt", "wt") as file: + file.write(" ".join(srcPaths).replace('\\', '\\\\') if os_name == "nt" else " ".join(srcPaths)) + return [*(self.default_args), "-o", destPath, "@clang_args.txt"] +diff --git a/tensilelite/requirements.txt b/tensilelite/requirements.txt +index 60c4c11445..5c8fd66a88 100644 +--- a/tensilelite/requirements.txt ++++ b/tensilelite/requirements.txt +@@ -2,8 +2,6 @@ dataclasses; python_version == '3.6' + packaging + pyyaml + msgpack +-joblib>=1.4.0; python_version >= '3.8' +-joblib>=1.1.1; python_version < '3.8' + simplejson + ujson + orjson diff --git a/pkgs/development/rocm-modules/10/hipblaslt/default.nix b/pkgs/development/rocm-modules/10/hipblaslt/default.nix new file mode 100644 index 0000000000000..d24759510a5c3 --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipblaslt/default.nix @@ -0,0 +1,256 @@ +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + rocm-cmake, + rocm-smi, + pkg-config, + clr, + gfortran, + gtest, + boost, + llvm, + msgpack-cxx, + amd-blis, + libxml2, + python3, + python3Packages, + openmp, + hipblas-common, + lapack-reference, + ncurses, + ninja, + libffi, + jemalloc, + zlib, + zstd, + rocmUpdateScript, + buildTests ? false, + buildSamples ? false, + # hipblaslt supports only devices with MFMA or WMMA + gpuTargets ? (clr.localGpuTargets or clr.gpuTargets), +}: + +let + # hipblaslt is extremely particular about what it will build with + # so intersect with a known supported list and use only those + supportedTargets = ( + lib.lists.intersectLists gpuTargets [ + "gfx908" + "gfx90a" + "gfx942" + "gfx950" + "gfx1100" + "gfx1101" + "gfx1150" + "gfx1151" + "gfx1200" + "gfx1201" + ] + ); + supportsTargetArches = supportedTargets != [ ]; + py = python3.withPackages (ps: [ + ps.pyyaml + ps.setuptools + ps.packaging + ps.nanobind + ps.msgpack + ]); + # workaround: build for one working target if no targets are supported + # a few CXX files are still build for the device + gpuTargets' = + if supportsTargetArches then (lib.concatStringsSep ";" supportedTargets) else "gfx1200"; + compiler = "amdclang++"; + # no-switch due to spammy warnings on some cases with fixme messages + # FIXME(LunNova@): cmake files need patched to include this properly or + # maybe we improve the toolchain to use config files + assemble a sysroot + # so system wide include assumptions work + cFlags = "-Wno-switch -fopenmp -I${lib.getDev zstd}/include -I${amd-blis}/include/blis/ -I${lib.getDev msgpack-cxx}/include"; +in +stdenv.mkDerivation (finalAttrs: { + pname = "hipblaslt${clr.gpuArchSuffix}"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + hash = "sha256-+xMmPKb32NP9U35dHCXfXWwa6exfiL5TezfXERVDfe4="; + sparseCheckout = [ + "projects/hipblaslt" + "shared" + ]; + # Compress the 5ish GiB of yaml files so this .src is under output size limit + postFetch = '' + find $out -name '*.yaml' -path '*/Tensile/Logic/*' -exec ${lib.getExe zstd} --rm {} \; + ''; + }; + sourceRoot = "${finalAttrs.src.name}/projects/hipblaslt"; + env.CXX = compiler; + env.CFLAGS = cFlags; + env.CXXFLAGS = cFlags; + env.ROCM_PATH = "${clr}"; + env.TENSILE_ROCM_ASSEMBLER_PATH = lib.getExe' clr "amdclang++"; + env.TENSILE_GEN_ASSEMBLY_TOOLCHAIN = lib.getExe' clr "amdclang++"; + env.LD_PRELOAD = "${jemalloc}/lib/libjemalloc.so"; + env.MALLOC_CONF = "background_thread:true,metadata_thp:auto,dirty_decay_ms:10000,muzzy_decay_ms:10000"; + requiredSystemFeatures = [ "big-parallel" ]; + + __structuredAttrs = true; + strictDeps = true; + + outputs = [ + "out" + # benchmarks are non-optional + "benchmark" + ] + ++ lib.optionals buildTests [ + "test" + ] + ++ lib.optionals buildSamples [ + "sample" + ]; + + patches = [ + # Upstream issue requesting properly specifying + # parallel-jobs for these invocations + # https://github.com/ROCm/rocm-libraries/issues/1242 + ./parallel-buildSourceCodeObjectFile.diff + # Support loading zstd compressed .dat files, required to keep output under + # hydra size limit + ./messagepack-compression-support.patch + # [hipblaslt] Refactor Parallel.py to drop joblib, massively reduce peak disk space usage + # https://github.com/ROCm/rocm-libraries/pull/2073 + ./TensileCreateLibrary-refactor.patch + ./Tensile-interning.patch + ]; + + preConfigure = '' + find . -name '*.yaml.zst' -path '*/Tensile/Logic/*' -exec zstd -d --rm {} \; + ''; + + postPatch = '' + # git isn't needed and we have no .git + substituteInPlace cmake/dependencies.cmake \ + --replace-fail "find_package(Git REQUIRED)" "" + substituteInPlace CMakeLists.txt \ + --replace-fail " LANGUAGES CXX" " LANGUAGES CXX C ASM" + ''; + + doCheck = false; + doInstallCheck = true; + + nativeBuildInputs = [ + cmake + rocm-cmake + py + clr + gfortran + pkg-config + ninja + rocm-smi + zstd + ]; + + buildInputs = [ + llvm.llvm + clr + rocm-cmake + hipblas-common + amd-blis + rocm-smi + openmp + libffi + ncurses + lapack-reference + + # Tensile deps - not optional, building without tensile isn't actually supported + msgpack-cxx + libxml2 + python3Packages.msgpack + zlib + zstd + ] + ++ lib.optionals buildTests [ + gtest + ]; + + cmakeFlags = [ + (lib.cmakeFeature "Boost_INCLUDE_DIR" "${lib.getDev boost}/include") # msgpack FindBoost fails to find boost + (lib.cmakeFeature "GPU_TARGETS" gpuTargets') + (lib.cmakeBool "BUILD_TESTING" buildTests) + (lib.cmakeBool "HIPBLASLT_ENABLE_BLIS" true) + (lib.cmakeBool "HIPBLASLT_BUILD_TESTING" buildTests) + (lib.cmakeBool "HIPBLASLT_ENABLE_SAMPLES" buildSamples) + (lib.cmakeBool "HIPBLASLT_ENABLE_DEVICE" supportsTargetArches) + # FIXME: Enable for ROCm 7.x + (lib.cmakeBool "HIPBLASLT_ENABLE_ROCROLLER" false) + "-DCMAKE_C_COMPILER=amdclang" + "-DCMAKE_HIP_COMPILER=${compiler}" + "-DCMAKE_CXX_COMPILER=${compiler}" + "-DROCM_FOUND=ON" # hipblaslt tries to download rocm-cmake if this isn't set + "-DBLIS_ROOT=${amd-blis}" + "-DBLIS_LIB=${amd-blis}/lib/libblis-mt.so" + "-DBLIS_INCLUDE_DIR=${amd-blis}/include/blis/" + "-DBLA_PREFER_PKGCONFIG=ON" + "-DFETCHCONTENT_SOURCE_DIR_NANOBIND=${python3Packages.nanobind.src}" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + "-DHIPBLASLT_ENABLE_MARKER=Off" + ]; + + postInstall = + # Compress msgpack .dat files to stay under hydra output size limit + # Relies on messagepack-compression-support.patch + '' + for file in $out/lib/hipblaslt/library/*.dat; do + zstd -19 --long -f "$file" -o "$file.tmp" && mv "$file.tmp" "$file" + done + '' + # Move binaries to appropriate outputs and delete leftover /bin + + '' + mkdir -p $benchmark/bin + mv $out/bin/hipblaslt-{api-overhead,bench*} $out/bin/*.yaml $out/bin/*.py $benchmark/bin + ${lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/hipblas-test $test/bin + ''} + ${lib.optionalString buildSamples '' + mkdir -p $sample/bin + mv $out/bin/example-* $sample/bin + ''} + rmdir $out/bin + ''; + + installCheckPhase = + # Verify compression worked and .dat files aren't huge + '' + runHook preInstallCheck + find "$out" -type f -name "*.dat" -size "+2M" -exec sh -c ' + echo "ERROR: oversized .dat file, check for issues with install compression: {}" >&2 + exit 1 + ' {} \; + echo "Verified .dat files in $out are not huge" + runHook postInstallCheck + ''; + + # If this is false there are no kernels in the output lib + # supporting the target device + # so if it's an optional dep it's best to not depend on it + # Some packages like torch need hipblaslt to compile + # and are fine ignoring it at runtime if it's not supported + # so we have to support building an empty hipblaslt + passthru.supportsTargetArches = supportsTargetArches; + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + meta = { + description = "Library that provides general matrix-matrix operations with a flexible API"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipblaslt"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/hipblaslt/messagepack-compression-support.patch b/pkgs/development/rocm-modules/10/hipblaslt/messagepack-compression-support.patch new file mode 100644 index 0000000000000..ace6b2b728ad2 --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipblaslt/messagepack-compression-support.patch @@ -0,0 +1,56 @@ +diff --git a/Tensile/Source/lib/source/msgpack/MessagePack.cpp b/Tensile/Source/lib/source/msgpack/MessagePack.cpp +index de97929c..dbc397e0 100644 +--- a/tensilelite/src/msgpack/MessagePack.cpp ++++ b/tensilelite/src/msgpack/MessagePack.cpp +@@ -28,6 +28,8 @@ + + #include + ++#include ++ + #include + + namespace Tensile +@@ -86,6 +88,34 @@ namespace Tensile + return nullptr; + } + ++ // Check if the file is zstd compressed ++ char magic[4]; ++ in.read(magic, 4); ++ bool isCompressed = (in.gcount() == 4 && magic[0] == '\x28' && magic[1] == '\xB5' && magic[2] == '\x2F' && magic[3] == '\xFD'); ++ // Reset file pointer to the beginning ++ in.seekg(0, std::ios::beg); ++ ++ if (isCompressed) { ++ // Decompress zstd file ++ std::vector compressedData((std::istreambuf_iterator(in)), std::istreambuf_iterator()); ++ ++ size_t decompressedSize = ZSTD_getFrameContentSize(compressedData.data(), compressedData.size()); ++ if (decompressedSize == ZSTD_CONTENTSIZE_ERROR || decompressedSize == ZSTD_CONTENTSIZE_UNKNOWN) { ++ if(Debug::Instance().printDataInit()) ++ std::cout << "Error: Unable to determine decompressed size for " << filename << std::endl; ++ return false; ++ } ++ ++ std::vector decompressedData(decompressedSize); ++ size_t dSize = ZSTD_decompress(decompressedData.data(), decompressedSize, compressedData.data(), compressedData.size()); ++ if (ZSTD_isError(dSize)) { ++ if(Debug::Instance().printDataInit()) ++ std::cout << "Error: ZSTD decompression failed for " << filename << std::endl; ++ return false; ++ } ++ ++ msgpack::unpack(result, decompressedData.data(), dSize); ++ } else { + msgpack::unpacker unp; + bool finished_parsing; + constexpr size_t buffer_size = 1 << 19; +@@ -109,6 +139,7 @@ namespace Tensile + + return nullptr; + } ++ } + } + catch(std::runtime_error const& exc) + { diff --git a/pkgs/development/rocm-modules/10/hipblaslt/parallel-buildSourceCodeObjectFile.diff b/pkgs/development/rocm-modules/10/hipblaslt/parallel-buildSourceCodeObjectFile.diff new file mode 100644 index 0000000000000..019e7a6123b16 --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipblaslt/parallel-buildSourceCodeObjectFile.diff @@ -0,0 +1,12 @@ +diff --git a/tensilelite/Tensile/Toolchain/Source.py b/tensilelite/Tensile/Toolchain/Source.py +index c9862e6c..dfa5ba40 100644 +--- a/tensilelite/Tensile/Toolchain/Source.py ++++ b/tensilelite/Tensile/Toolchain/Source.py +@@ -102,6 +102,7 @@ def buildSourceCodeObjectFiles( + coPaths= [] + + objPath = str(tmpObjDir / objFilename) ++ compiler.default_args += ["-parallel-jobs=8"] + compiler(str(includeDir), cmdlineArchs, str(kernelPath), objPath) + + for target in bundler.targets(objPath): From 083faab01b9af356d0713ce076dc8a5313cb4fae Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:07 -0700 Subject: [PATCH 43/79] rocmPackages_10.hipblas-common: init at 10.1 Update the rocmPackages.hipblas-common copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ pkgs/development/rocm-modules/10/hipblas-common/default.nix | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 759abf2f33081..2b5214bc6e4e0 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -123,6 +123,8 @@ let hipfft = self.callPackage ./hipfft { }; + hipblas-common = self.callPackage ./hipblas-common { }; + half = self.callPackage ./half { }; # Even if config.rocmSupport is false we need rocmSupport true diff --git a/pkgs/development/rocm-modules/10/hipblas-common/default.nix b/pkgs/development/rocm-modules/10/hipblas-common/default.nix index 6ddc7c8e258a5..620be6f63942f 100644 --- a/pkgs/development/rocm-modules/10/hipblas-common/default.nix +++ b/pkgs/development/rocm-modules/10/hipblas-common/default.nix @@ -8,17 +8,17 @@ }: stdenv.mkDerivation (finalAttrs: { pname = "hipblas-common"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/hipblas-common" "shared" ]; - hash = "sha256-83LgS4I1fMSaNtWdVFf1qhYRMT7a9jVzO3XpUzEipXg="; + hash = "sha256-2sUJqcy/LSfKOvY1IBzlxmbKZImMxf6YGA+qQml8DLc="; }; sourceRoot = "${finalAttrs.src.name}/projects/hipblas-common"; From 6c84a785a3fa06073c93f913e300f8cbfc858267 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:08 -0700 Subject: [PATCH 44/79] rocmPackages_10.hipblaslt: init at 10.1 Update the rocmPackages.hipblaslt copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.hipblaslt: 1.4.1 (stinkytofu, amd_smi, nanobind)": hipBLASLt 1.4.1 needs shared/stinkytofu sources (rocisa compiles its .cpp unconditionally), switches rocm_smi -> amd_smi, renames the MSGPACK/LLVM enables to HIPBLASLT_ENABLE_YAML, and FetchContents nanobind when absent. Add the sources/inputs and rebase messagepack-compression-support.patch. Drop the Tensile-interning and TensileCreateLibrary-refactor tensilelite patches: they no longer apply to the reorganised tree; joblib is supplied via the python env instead. Rebase parallel-buildSourceCodeObjectFile (ROCm/rocm-libraries#1242 is still open) onto the new Toolchain/Component.py, adding -parallel-jobs=8 once to the HIP compiler's default args rather than appending it on every buildSourceCodeObjectFiles call. tensilelite's new HelperKernelCache defaults to $HOME/.tensile, so disable it. Set CMAKE_SUPPRESS_REGENERATION so cmake >= 4.4 does not re-run configure mid-build and lose the FetchContent nanobind_add_module. Revised during the split review: Add tensile-memory.patch, adapting the memory protections of the ROCm 7 Tensile patches to the new pipeline: worker count bounded by NIX_BUILD_CORES/MAKEFLAGS, interned YAML strings, compact post-assembly results. Refresh the MessagePack compression patch. Drop the stinkytofu clang-tidy workaround (upstream now guards it with ENABLE_CLANG_TIDY) and the redundant HOME override. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 + .../10/hipblaslt/Tensile-interning.patch | 181 ---- .../TensileCreateLibrary-refactor.patch | 849 ------------------ .../rocm-modules/10/hipblaslt/default.nix | 40 +- .../messagepack-compression-support.patch | 22 +- .../parallel-buildSourceCodeObjectFile.diff | 23 +- .../10/hipblaslt/tensile-memory.patch | 92 ++ 7 files changed, 141 insertions(+), 1068 deletions(-) delete mode 100644 pkgs/development/rocm-modules/10/hipblaslt/Tensile-interning.patch delete mode 100644 pkgs/development/rocm-modules/10/hipblaslt/TensileCreateLibrary-refactor.patch create mode 100644 pkgs/development/rocm-modules/10/hipblaslt/tensile-memory.patch diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 2b5214bc6e4e0..f5412ffe47754 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -125,6 +125,8 @@ let hipblas-common = self.callPackage ./hipblas-common { }; + hipblaslt = self.callPackage ./hipblaslt { }; + half = self.callPackage ./half { }; # Even if config.rocmSupport is false we need rocmSupport true diff --git a/pkgs/development/rocm-modules/10/hipblaslt/Tensile-interning.patch b/pkgs/development/rocm-modules/10/hipblaslt/Tensile-interning.patch deleted file mode 100644 index acf44437520db..0000000000000 --- a/pkgs/development/rocm-modules/10/hipblaslt/Tensile-interning.patch +++ /dev/null @@ -1,181 +0,0 @@ -diff --git a/tensilelite/Tensile/Common/Utilities.py b/tensilelite/Tensile/Common/Utilities.py -index 0a9d9db5b3..cb9779eaac 100644 ---- a/tensilelite/Tensile/Common/Utilities.py -+++ b/tensilelite/Tensile/Common/Utilities.py -@@ -24,6 +24,7 @@ - - import functools - import math -+import operator - import os - import sys - import time -@@ -269,8 +270,20 @@ def state(obj): - - - def state_key_ordering(cls): -- def tup(obj): -- return tuple([getattr(obj, k) for k in cls.StateKeys]) -+ # Use operator.attrgetter for efficiency if __slots__ is defined -+ if hasattr(cls, '__slots__'): -+ # attrgetter is faster for slotted classes -+ getter = operator.attrgetter(*cls.StateKeys) -+ if len(cls.StateKeys) == 1: -+ # attrgetter returns scalar for single key, we need tuple -+ def tup(obj): -+ return (getter(obj),) -+ else: -+ tup = getter -+ else: -+ # Fallback for regular classes -+ def tup(obj): -+ return tuple([getattr(obj, k) for k in cls.StateKeys]) - - def lt(a, b): - return tup(a) < tup(b) -diff --git a/tensilelite/Tensile/Contractions.py b/tensilelite/Tensile/Contractions.py -index c0d4e851b1..3f2c2e98c6 100644 ---- a/tensilelite/Tensile/Contractions.py -+++ b/tensilelite/Tensile/Contractions.py -@@ -37,9 +37,60 @@ from Tensile.Toolchain.Component import Assembler - from math import ceil - - MIN_K_FOR_GSU = 32 -+ -+# Interning helpers to reduce memory usage by reusing identical objects -+_free_index_cache = {} -+def intern_free_index(isA, i=None, c=None, d=None, a=None, b=None): -+ key = (isA, i, c, d, a, b) -+ if key not in _free_index_cache: -+ obj = FreeIndex(isA, i, c, d) -+ obj.a = a -+ if b is not None: -+ obj.b = b -+ _free_index_cache[key] = obj -+ return _free_index_cache[key] -+ -+_batch_index_cache = {} -+def intern_batch_index(a=None, b=None, c=None, d=None): -+ key = (a, b, c, d) -+ if key not in _batch_index_cache: -+ obj = BatchIndex(c=c, d=d) -+ obj.a = a -+ obj.b = b -+ _batch_index_cache[key] = obj -+ return _batch_index_cache[key] -+ -+_bound_index_cache = {} -+def intern_bound_index(a=None, b=None, aMirror=False, bMirror=False): -+ key = (a, b, aMirror, bMirror) -+ if key not in _bound_index_cache: -+ obj = BoundIndex(aMirror=aMirror, bMirror=bMirror) -+ obj.a = a -+ obj.b = b -+ _bound_index_cache[key] = obj -+ return _bound_index_cache[key] -+ -+_size_mapping_cache = {} -+def intern_size_mapping(size_mapping): -+ """Intern a SizeMapping instance to reduce redundancy.""" -+ # Build hashable key from StateKeys, converting lists to tuples -+ key_parts = [] -+ for attr in size_mapping.StateKeys: -+ val = getattr(size_mapping, attr) -+ # Convert lists to tuples for hashing -+ if isinstance(val, list): -+ val = tuple(val) -+ key_parts.append(val) -+ key = tuple(key_parts) -+ -+ if key not in _size_mapping_cache: -+ _size_mapping_cache[key] = size_mapping -+ return _size_mapping_cache[key] -+ - @state_key_ordering - class FreeIndex: - StateKeys = ['isA', 'i', 'c', 'd'] -+ __slots__ = ['isA', 'i', 'c', 'd', 'a', 'b'] - - def __init__(self, isA, i=None, c=None, d=None): - self.isA = isA -@@ -50,6 +101,7 @@ class FreeIndex: - @state_key_ordering - class BatchIndex: - StateKeys = ['a', 'b', 'c', 'd'] -+ __slots__ = ['a', 'b', 'c', 'd'] - def __init__(self, a=None, b=None, c=None, d=None): - self.a = a - self.b = b -@@ -59,6 +111,7 @@ class BatchIndex: - @state_key_ordering - class BoundIndex: - StateKeys = ['a', 'b', 'aMirror', 'bMirror'] -+ __slots__ = ['a', 'b', 'aMirror', 'bMirror'] - def __init__(self, a=None, b=None, aMirror=False, bMirror=False): - self.a = a - self.b = b -@@ -107,6 +160,23 @@ class ProblemType: - for ib, ic in enumerate(d['IndexAssignmentsB']): - indices[ic].b = ib - -+ # Now intern all indices with their final state (including .a and .b) -+ for i, idx in enumerate(indices): -+ if isinstance(idx, FreeIndex): -+ indices[i] = intern_free_index(idx.isA, idx.i, idx.c, idx.d, -+ getattr(idx, 'a', None), getattr(idx, 'b', None)) -+ elif isinstance(idx, BatchIndex): -+ indices[i] = intern_batch_index(getattr(idx, 'a', None), getattr(idx, 'b', None), -+ idx.c, idx.d) -+ elif isinstance(idx, BoundIndex): -+ indices[i] = intern_bound_index(getattr(idx, 'a', None), getattr(idx, 'b', None), -+ idx.aMirror, idx.bMirror) -+ -+ # Update the lists with interned versions -+ freeIndices = [idx for idx in indices if isinstance(idx, FreeIndex)] -+ batchIndices = [idx for idx in indices if isinstance(idx, BatchIndex)] -+ boundIndices = [idx for idx in indices if isinstance(idx, BoundIndex)] -+ - for idx in indices: - assert idx is not None - idxState = state(idx) -@@ -596,6 +666,7 @@ class SizeMapping: - 'nonTemporalA', - 'nonTemporalB', - ] -+ __slots__ = StateKeys - - @classmethod - def FromOriginalState(cls, d): -@@ -751,7 +822,7 @@ class Solution: - info = cls.ReadOriginalInfo(d) - rv.libraryLogicIndex = int(info.get("SolutionIndex", -1)) - -- rv.sizeMapping = SizeMapping.FromOriginalState(d) -+ rv.sizeMapping = intern_size_mapping(SizeMapping.FromOriginalState(d)) - - rv.internalArgsSupport = InternalArgsSupport.FromOriginalState(d) - -diff --git a/tensilelite/Tensile/TensileCreateLibrary/Run.py b/tensilelite/Tensile/TensileCreateLibrary/Run.py -index 730b6b1fff..b0068563a0 100644 ---- a/tensilelite/Tensile/TensileCreateLibrary/Run.py -+++ b/tensilelite/Tensile/TensileCreateLibrary/Run.py -@@ -104,7 +104,6 @@ class KernelCodeGenResult(NamedTuple): - src: str - header: Optional[str] - name: str -- targetObjFilename: str - isa: IsaVersion - wavefrontSize: int - cuoccupancy: int -@@ -127,10 +126,9 @@ def processKernelSource(kernelWriterAssembly, data, splitGSU, kernel) -> KernelC - asmFilename = getKernelFileBase(splitGSU, kernel) - err, src = kernelWriter.getSourceFileString(kernel) - header = kernelWriter.getHeaderFileString(kernel) -- objFilename = kernel._state.get("codeObjectFile", None) - pgr = int(kernel["PrefetchGlobalRead"]) - return KernelCodeGenResult( -- err, src, header, asmFilename, objFilename, tuple(kernel["ISA"]), \ -+ err, src, header, asmFilename, tuple(kernel["ISA"]), \ - kernel["WavefrontSize"], kernel["CUOccupancy"], \ - pgr, kernel["MathClocksUnrolledLoop"] - ) diff --git a/pkgs/development/rocm-modules/10/hipblaslt/TensileCreateLibrary-refactor.patch b/pkgs/development/rocm-modules/10/hipblaslt/TensileCreateLibrary-refactor.patch deleted file mode 100644 index 1accf91426f46..0000000000000 --- a/pkgs/development/rocm-modules/10/hipblaslt/TensileCreateLibrary-refactor.patch +++ /dev/null @@ -1,849 +0,0 @@ -diff --git a/tensilelite/Tensile/Common/Parallel.py b/tensilelite/Tensile/Common/Parallel.py -index 1a2bf9e119..f46100c7b8 100644 ---- a/tensilelite/Tensile/Common/Parallel.py -+++ b/tensilelite/Tensile/Common/Parallel.py -@@ -22,43 +22,58 @@ - # - ################################################################################ - --import concurrent.futures --import itertools -+import multiprocessing - import os -+import re - import sys - import time -- --from joblib import Parallel, delayed -+from functools import partial -+from typing import Any, Callable - - from .Utilities import tqdm - - --def joblibParallelSupportsGenerator(): -- import joblib -- from packaging.version import Version -+def get_inherited_job_limit() -> int: -+ # 1. Check CMAKE_BUILD_PARALLEL_LEVEL (CMake 3.12+) -+ if 'CMAKE_BUILD_PARALLEL_LEVEL' in os.environ: -+ try: -+ return int(os.environ['CMAKE_BUILD_PARALLEL_LEVEL']) -+ except ValueError: -+ pass - -- joblibVer = joblib.__version__ -- return Version(joblibVer) >= Version("1.4.0") -+ # 2. Parse MAKEFLAGS for -jN -+ makeflags = os.environ.get('MAKEFLAGS', '') -+ match = re.search(r'-j\s*(\d+)', makeflags) -+ if match: -+ return int(match.group(1)) - -+ return -1 - --def CPUThreadCount(enable=True): -- from .GlobalParameters import globalParameters - -+def CPUThreadCount(enable=True): - if not enable: - return 1 -- else: -+ from .GlobalParameters import globalParameters -+ -+ # Priority order: -+ # 1. Inherited from build system (CMAKE_BUILD_PARALLEL_LEVEL or MAKEFLAGS) -+ # 2. Explicit --jobs flag -+ # 3. Auto-detect -+ inherited_limit = get_inherited_job_limit() -+ cpuThreads = inherited_limit if inherited_limit > 0 else globalParameters["CpuThreads"] -+ -+ if cpuThreads < 1: - if os.name == "nt": -- # Windows supports at most 61 workers because the scheduler uses -- # WaitForMultipleObjects directly, which has the limit (the limit -- # is actually 64, but some handles are needed for accounting). -- cpu_count = min(os.cpu_count(), 61) -+ cpuThreads = os.cpu_count() - else: -- cpu_count = len(os.sched_getaffinity(0)) -- cpuThreads = globalParameters["CpuThreads"] -- if cpuThreads == -1: -- return cpu_count -+ cpuThreads = len(os.sched_getaffinity(0)) - -- return min(cpu_count, cpuThreads) -+ if os.name == "nt": -+ # Windows supports at most 61 workers because the scheduler uses -+ # WaitForMultipleObjects directly, which has the limit (the limit -+ # is actually 64, but some handles are needed for accounting). -+ cpuThreads = min(cpuThreads, 61) -+ return max(1, cpuThreads) - - - def pcallWithGlobalParamsMultiArg(f, args, newGlobalParameters): -@@ -71,19 +86,22 @@ def pcallWithGlobalParamsSingleArg(f, arg, newGlobalParameters): - return f(arg) - - --def apply_print_exception(item, *args): -- # print(item, args) -+def OverwriteGlobalParameters(newGlobalParameters): -+ from . import GlobalParameters -+ -+ GlobalParameters.globalParameters.clear() -+ GlobalParameters.globalParameters.update(newGlobalParameters) -+ -+ -+def worker_function(args, function, multiArg): -+ """Worker function that executes in the pool process.""" - try: -- if len(args) > 0: -- func = item -- args = args[0] -- return func(*args) -+ if multiArg: -+ return function(*args) - else: -- func, item = item -- return func(item) -+ return function(args) - except Exception: - import traceback -- - traceback.print_exc() - raise - finally: -@@ -98,154 +116,121 @@ def OverwriteGlobalParameters(newGlobalParameters): - GlobalParameters.globalParameters.update(newGlobalParameters) - - --def ProcessingPool(enable=True, maxTasksPerChild=None): -- import multiprocessing -- import multiprocessing.dummy -- -- threadCount = CPUThreadCount() -- -- if (not enable) or threadCount <= 1: -- return multiprocessing.dummy.Pool(1) -- -- if multiprocessing.get_start_method() == "spawn": -- from . import GlobalParameters -- -- return multiprocessing.Pool( -- threadCount, -- initializer=OverwriteGlobalParameters, -- maxtasksperchild=maxTasksPerChild, -- initargs=(GlobalParameters.globalParameters,), -- ) -- else: -- return multiprocessing.Pool(threadCount, maxtasksperchild=maxTasksPerChild) -+def progress_logger(iterable, total, message, min_log_interval=5.0): -+ """ -+ Generator that wraps an iterable and logs progress with time-based throttling. - -+ Only logs progress if at least min_log_interval seconds have passed since last log. -+ Only prints completion message if task took >= min_log_interval seconds. - --def ParallelMap(function, objects, message="", enable=True, method=None, maxTasksPerChild=None): -+ Yields (index, item) tuples. - """ -- Generally equivalent to list(map(function, objects)), possibly executing in parallel. -- -- message: A message describing the operation to be performed. -- enable: May be set to false to disable parallelism. -- method: A function which can fetch the mapping function from a processing pool object. -- Leave blank to use .map(), other possiblities: -- - `lambda x: x.starmap` - useful if `function` takes multiple parameters. -- - `lambda x: x.imap` - lazy evaluation -- - `lambda x: x.imap_unordered` - lazy evaluation, does not preserve order of return value. -- """ -- from .GlobalParameters import globalParameters -+ start_time = time.time() -+ last_log_time = start_time -+ log_interval = 1 + (total // 100) - -- threadCount = CPUThreadCount(enable) -- pool = ProcessingPool(enable, maxTasksPerChild) -- -- if threadCount <= 1 and globalParameters["ShowProgressBar"]: -- # Provide a progress bar for single-threaded operation. -- # This works for method=None, and for starmap. -- mapFunc = map -- if method is not None: -- # itertools provides starmap which can fill in for pool.starmap. It provides imap on Python 2.7. -- # If this works, we will use it, otherwise we will fallback to the "dummy" pool for single threaded -- # operation. -- try: -- mapFunc = method(itertools) -- except NameError: -- mapFunc = None -- -- if mapFunc is not None: -- return list(mapFunc(function, tqdm(objects, message))) -- -- mapFunc = pool.map -- if method: -- mapFunc = method(pool) -- -- objects = zip(itertools.repeat(function), objects) -- function = apply_print_exception -- -- countMessage = "" -- try: -- countMessage = " for {} tasks".format(len(objects)) -- except TypeError: -- pass -+ for idx, item in enumerate(iterable): -+ if idx % log_interval == 0: -+ current_time = time.time() -+ if (current_time - last_log_time) >= min_log_interval: -+ print(f"{message}\t{idx+1: 5d}/{total: 5d}") -+ last_log_time = current_time -+ yield idx, item - -- if message != "": -- message += ": " -+ elapsed = time.time() - start_time -+ final_idx = idx + 1 if 'idx' in locals() else 0 - -- print("{0}Launching {1} threads{2}...".format(message, threadCount, countMessage)) -- sys.stdout.flush() -- currentTime = time.time() -- rv = mapFunc(function, objects) -- totalTime = time.time() - currentTime -- print("{0}Done. ({1:.1f} secs elapsed)".format(message, totalTime)) -- sys.stdout.flush() -- pool.close() -- return rv -+ if elapsed >= min_log_interval or last_log_time > start_time: -+ print(f"{message} done in {elapsed:.1f}s!\t{final_idx: 5d}/{total: 5d}") - - --def ParallelMapReturnAsGenerator(function, objects, message="", enable=True, multiArg=True): -- from .GlobalParameters import globalParameters -+def imap_with_progress(pool, func, iterable, total, message, chunksize): -+ results = [] -+ for _, result in progress_logger(pool.imap(func, iterable, chunksize=chunksize), total, message): -+ results.append(result) -+ return results - -- threadCount = CPUThreadCount(enable) -- print("{0}Launching {1} threads...".format(message, threadCount)) - -- if threadCount <= 1 and globalParameters["ShowProgressBar"]: -- # Provide a progress bar for single-threaded operation. -- callFunc = lambda args: function(*args) if multiArg else lambda args: function(args) -- return [callFunc(args) for args in tqdm(objects, message)] -+def _ParallelMap_generator(worker, objects, objLen, message, chunksize, threadCount, globalParameters, maxtasksperchild): -+ # separate fn because yield makes the entire fn a generator even if unreachable -+ ctx = multiprocessing.get_context('forkserver' if os.name != 'nt' else 'spawn') - -- with concurrent.futures.ProcessPoolExecutor(max_workers=threadCount) as executor: -- resultFutures = (executor.submit(function, *arg if multiArg else arg) for arg in objects) -- for result in concurrent.futures.as_completed(resultFutures): -- yield result.result() -+ with ctx.Pool(processes=threadCount, maxtasksperchild=maxtasksperchild, -+ initializer=OverwriteGlobalParameters, initargs=(globalParameters,)) as pool: -+ for _, result in progress_logger(pool.imap_unordered(worker, objects, chunksize=chunksize), objLen, message): -+ yield result - - - def ParallelMap2( -- function, objects, message="", enable=True, multiArg=True, return_as="list", procs=None -+ function: Callable, -+ objects: Any, -+ message: str = "", -+ enable: bool = True, -+ multiArg: bool = True, -+ minChunkSize: int = 1, -+ maxWorkers: int = -1, -+ maxtasksperchild: int = 1024, -+ return_as: str = "list" - ): -+ """Executes a function over a list of objects in parallel or sequentially. -+ -+ This function is generally equivalent to ``list(map(function, objects))``. However, it provides -+ additional functionality to run in parallel, depending on the 'enable' flag and available CPU -+ threads. -+ -+ Args: -+ function: The function to apply to each item in 'objects'. If 'multiArg' is True, 'function' -+ should accept multiple arguments. -+ objects: An iterable of objects to be processed by 'function'. If 'multiArg' is True, each -+ item in 'objects' should be an iterable of arguments for 'function'. -+ message: Optional; a message describing the operation. Default is an empty string. -+ enable: Optional; if False, disables parallel execution and runs sequentially. Default is True. -+ multiArg: Optional; if True, treats each item in 'objects' as multiple arguments for -+ 'function'. Default is True. -+ return_as: Optional; "list" (default) or "generator_unordered" for streaming results -+ -+ Returns: -+ A list or generator containing the results of applying **function** to each item in **objects**. - """ -- Generally equivalent to list(map(function, objects)), possibly executing in parallel. -+ from .GlobalParameters import globalParameters - -- message: A message describing the operation to be performed. -- enable: May be set to false to disable parallelism. -- multiArg: True if objects represent multiple arguments -- (differentiates multi args vs single collection arg) -- """ -- if return_as in ("generator", "generator_unordered") and not joblibParallelSupportsGenerator(): -- return ParallelMapReturnAsGenerator(function, objects, message, enable, multiArg) -+ threadCount = CPUThreadCount(enable) - -- from .GlobalParameters import globalParameters -+ if not hasattr(objects, "__len__"): -+ objects = list(objects) - -- threadCount = procs if procs else CPUThreadCount(enable) -+ objLen = len(objects) -+ if objLen == 0: -+ return [] if return_as == "list" else iter([]) - -- threadCount = CPUThreadCount(enable) -+ f = (lambda x: function(*x)) if multiArg else function -+ if objLen == 1: -+ print(f"{message}: (1 task)") -+ result = [f(x) for x in objects] -+ return result if return_as == "list" else iter(result) - -- if threadCount <= 1 and globalParameters["ShowProgressBar"]: -- # Provide a progress bar for single-threaded operation. -- return [function(*args) if multiArg else function(args) for args in tqdm(objects, message)] -+ extra_message = ( -+ f": {threadCount} thread(s)" + f", {objLen} tasks" -+ if objLen -+ else "" -+ ) - -- countMessage = "" -- try: -- countMessage = " for {} tasks".format(len(objects)) -- except TypeError: -- pass -- -- if message != "": -- message += ": " -- print("{0}Launching {1} threads{2}...".format(message, threadCount, countMessage)) -- sys.stdout.flush() -- currentTime = time.time() -- -- pcall = pcallWithGlobalParamsMultiArg if multiArg else pcallWithGlobalParamsSingleArg -- pargs = zip(objects, itertools.repeat(globalParameters)) -- -- if joblibParallelSupportsGenerator(): -- rv = Parallel(n_jobs=threadCount, timeout=99999, return_as=return_as)( -- delayed(pcall)(function, a, params) for a, params in pargs -- ) -+ print(f"ParallelMap {message}{extra_message}") -+ -+ if threadCount <= 1: -+ result = [f(x) for x in objects] -+ return result if return_as == "list" else iter(result) -+ -+ if maxWorkers > 0: -+ threadCount = min(maxWorkers, threadCount) -+ -+ chunksize = max(minChunkSize, objLen // 2000) -+ worker = partial(worker_function, function=function, multiArg=multiArg) -+ if return_as == "generator_unordered": -+ # yield results as they complete without buffering -+ return _ParallelMap_generator(worker, objects, objLen, message, chunksize, threadCount, globalParameters, maxtasksperchild) - else: -- rv = Parallel(n_jobs=threadCount, timeout=99999)( -- delayed(pcall)(function, a, params) for a, params in pargs -- ) -- -- totalTime = time.time() - currentTime -- print("{0}Done. ({1:.1f} secs elapsed)".format(message, totalTime)) -- sys.stdout.flush() -- return rv -+ ctx = multiprocessing.get_context('forkserver' if os.name != 'nt' else 'spawn') -+ with ctx.Pool(processes=threadCount, maxtasksperchild=maxtasksperchild, -+ initializer=OverwriteGlobalParameters, initargs=(globalParameters,)) as pool: -+ return list(imap_with_progress(pool, worker, objects, objLen, message, chunksize)) -diff --git a/tensilelite/Tensile/CustomKernels.py b/tensilelite/Tensile/CustomKernels.py -index ffceb636f5..127b3386a1 100644 ---- a/tensilelite/Tensile/CustomKernels.py -+++ b/tensilelite/Tensile/CustomKernels.py -@@ -24,7 +24,9 @@ - - from . import CUSTOM_KERNEL_PATH - from Tensile.Common.ValidParameters import checkParametersAreValid, validParameters, newMIValidParameters -+from Tensile.CustomYamlLoader import DEFAULT_YAML_LOADER - -+from functools import lru_cache - import yaml - - import os -@@ -58,10 +60,13 @@ def getCustomKernelConfigAndAssembly(name, directory=CUSTOM_KERNEL_PATH): - - return (config, assembly) - -+# getCustomKernelConfig will get called repeatedly on the same file -+# 20x logic loading speedup for aquavanjaram_Cijk_Ailk_Bljk_F8NH_HHS_BH_Bias_HAS_SAB_SAV_freesize_custom_GSUs -+@lru_cache - def readCustomKernelConfig(name, directory=CUSTOM_KERNEL_PATH): - rawConfig, _ = getCustomKernelConfigAndAssembly(name, directory) - try: -- return yaml.safe_load(rawConfig)["custom.config"] -+ return yaml.load(rawConfig, Loader=DEFAULT_YAML_LOADER)["custom.config"] - except yaml.scanner.ScannerError as e: - raise RuntimeError("Failed to read configuration for custom kernel: {0}\nDetails:\n{1}".format(name, e)) - -diff --git a/tensilelite/Tensile/CustomYamlLoader.py b/tensilelite/Tensile/CustomYamlLoader.py -index e03f456fbe..ed7510f2ce 100644 ---- a/tensilelite/Tensile/CustomYamlLoader.py -+++ b/tensilelite/Tensile/CustomYamlLoader.py -@@ -1,6 +1,7 @@ - # Copyright © Advanced Micro Devices, Inc., or its affiliates. - # SPDX-License-Identifier: MIT - -+import sys - import yaml - from pathlib import Path - -@@ -70,7 +71,7 @@ def parse_scalar(loader: yaml.Loader): - elif is_float(value_lower): - return float(value_lower) - -- return value -+ return sys.intern(value) - - def load_yaml_stream(yaml_path: Path, loader_type: yaml.Loader): - with open(yaml_path, 'r') as f: -diff --git a/tensilelite/Tensile/TensileCreateLibrary/Run.py b/tensilelite/Tensile/TensileCreateLibrary/Run.py -index 22d19851a3..348068b3bf 100644 ---- a/tensilelite/Tensile/TensileCreateLibrary/Run.py -+++ b/tensilelite/Tensile/TensileCreateLibrary/Run.py -@@ -26,8 +26,10 @@ import rocisa - - import functools - import glob -+import gc - import itertools - import os -+import resource - import shutil - from pathlib import Path - from timeit import default_timer as timer -@@ -78,6 +80,25 @@ from Tensile.Utilities.Decorators.Timing import timing - from .ParseArguments import parseArguments - - -+def getMemoryUsage(): -+ """Get peak and current memory usage in MB.""" -+ rusage = resource.getrusage(resource.RUSAGE_SELF) -+ peak_memory_mb = rusage.ru_maxrss / 1024 # KB to MB on Linux -+ -+ # Get current memory from /proc/self/status -+ current_memory_mb = 0 -+ try: -+ with open('/proc/self/status') as f: -+ for line in f: -+ if line.startswith('VmRSS:'): -+ current_memory_mb = int(line.split()[1]) / 1024 # KB to MB -+ break -+ except: -+ current_memory_mb = peak_memory_mb # Fallback -+ -+ return (peak_memory_mb, current_memory_mb) -+ -+ - class KernelCodeGenResult(NamedTuple): - err: int - src: str -@@ -115,6 +136,29 @@ def processKernelSource(kernelWriterAssembly, data, outOptions, splitGSU, kernel - ) - - -+def processAndAssembleKernelTCL(kernelWriterAssembly, rocisa_data, outOptions, splitGSU, kernel, assemblyTmpPath, assembler): -+ """ -+ Pipeline function for TCL mode that: -+ 1. Generates kernel source -+ 2. Writes .s file to disk -+ 3. Assembles to .o file -+ 4. Deletes .s file -+ """ -+ result = processKernelSource(kernelWriterAssembly, rocisa_data, outOptions, splitGSU, kernel) -+ return writeAndAssembleKernel(result, assemblyTmpPath, assembler) -+ -+ -+def writeMasterSolutionLibrary(name_lib_tuple, newLibraryDir, splitGSU, libraryFormat): -+ """ -+ Write a master solution library to disk. -+ Module-level function to support multiprocessing. -+ """ -+ name, lib = name_lib_tuple -+ filename = os.path.join(newLibraryDir, name) -+ lib.applyNaming(splitGSU) -+ LibraryIO.write(filename, state(lib), libraryFormat) -+ -+ - def removeInvalidSolutionsAndKernels(results, kernels, solutions, errorTolerant, printLevel: bool, splitGSU: bool): - removeKernels = [] - removeKernelNames = [] -@@ -189,6 +233,24 @@ def writeAssembly(asmPath: Union[Path, str], result: KernelCodeGenResult): - return path, isa, wfsize, minResult - - -+def writeAndAssembleKernel(result: KernelCodeGenResult, asmPath: Union[Path, str], assembler): -+ """Write assembly file and immediately assemble it to .o file""" -+ if result.err: -+ printExit(f"Failed to build kernel {result.name} because it has error code {result.err}") -+ -+ path = Path(asmPath) / f"{result.name}.s" -+ with open(path, "w", encoding="utf-8") as f: -+ f.write(result.src) -+ -+ # Assemble .s -> .o -+ assembler(isaToGfx(result.isa), result.wavefrontSize, str(path), str(path.with_suffix(".o"))) -+ -+ # Delete assembly file immediately to save disk space -+ path.unlink() -+ -+ return KernelMinResult(result.err, result.cuoccupancy, result.pgr, result.mathclk) -+ -+ - def writeHelpers( - outputPath, kernelHelperObjs, KERNEL_HELPER_FILENAME_CPP, KERNEL_HELPER_FILENAME_H - ): -@@ -272,14 +334,15 @@ def writeSolutionsAndKernels( - numAsmKernels = len(asmKernels) - numKernels = len(asmKernels) - assert numKernels == numAsmKernels, "Only assembly kernels are supported in TensileLite" -- asmIter = zip( -- itertools.repeat(kernelWriterAssembly), -- itertools.repeat(rocisa.rocIsa.getInstance().getData()), -- itertools.repeat(outOptions), -- itertools.repeat(splitGSU), -- asmKernels -+ -+ processKernelFn = functools.partial( -+ processKernelSource, -+ kernelWriterAssembly=kernelWriterAssembly, -+ data=rocisa.rocIsa.getInstance().getData(), -+ outOptions=outOptions, -+ splitGSU=splitGSU - ) -- asmResults = ParallelMap2(processKernelSource, asmIter, "Generating assembly kernels", return_as="list") -+ asmResults = ParallelMap2(processKernelFn, asmKernels, "Generating assembly kernels", return_as="list", multiArg=False) - removeInvalidSolutionsAndKernels( - asmResults, asmKernels, solutions, errorTolerant, getVerbosity(), splitGSU - ) -@@ -287,19 +350,21 @@ def writeSolutionsAndKernels( - asmResults, asmKernels, solutions, splitGSU - ) - -- def assemble(ret): -- p, isa, wavefrontsize, _ = ret -- asmToolchain.assembler(isaToGfx(isa), wavefrontsize, str(p), str(p.with_suffix(".o"))) -- -- unaryWriteAssembly = functools.partial(writeAssembly, assemblyTmpPath) -- compose = lambda *F: functools.reduce(lambda f, g: lambda x: f(g(x)), F) -+ # Use functools.partial to bind assemblyTmpPath and assembler -+ writeAndAssembleFn = functools.partial( -+ writeAndAssembleKernel, -+ asmPath=assemblyTmpPath, -+ assembler=asmToolchain.assembler -+ ) - ret = ParallelMap2( -- compose(assemble, unaryWriteAssembly), -+ writeAndAssembleFn, - asmResults, - "Writing assembly kernels", - return_as="list", - multiArg=False, - ) -+ del asmResults -+ gc.collect() - - writeHelpers(outputPath, kernelHelperObjs, KERNEL_HELPER_FILENAME_CPP, KERNEL_HELPER_FILENAME_H) - srcKernelFile = Path(outputPath) / "Kernels.cpp" -@@ -376,40 +441,35 @@ def writeSolutionsAndKernelsTCL( - - uniqueAsmKernels = [k for k in asmKernels if not k.duplicate] - -- def assemble(ret, removeTemporaries: bool): -- asmPath, isa, wavefrontsize, result = ret -- asmToolchain.assembler(isaToGfx(isa), wavefrontsize, str(asmPath), str(asmPath.with_suffix(".o"))) -- if removeTemporaries: -- asmPath.unlink() -- return result -- -- unaryAssemble = functools.partial(assemble, removeTemporaries=removeTemporaries) -- - outOptions = rocisa.rocIsa.getInstance().getOutputOptions() - outOptions.outputNoComment = not disableAsmComments - -- unaryProcessKernelSource = functools.partial( -- processKernelSource, -+ processKernelFn = functools.partial( -+ processAndAssembleKernelTCL, - kernelWriterAssembly, - rocisa.rocIsa.getInstance().getData(), - outOptions, - splitGSU, -+ assemblyTmpPath=assemblyTmpPath, -+ assembler=asmToolchain.assembler - ) - -- unaryWriteAssembly = functools.partial(writeAssembly, assemblyTmpPath) -- compose = lambda *F: functools.reduce(lambda f, g: lambda x: f(g(x)), F) -- ret = ParallelMap2( -- compose(unaryAssemble, unaryWriteAssembly, unaryProcessKernelSource), -+ results = ParallelMap2( -+ processKernelFn, - uniqueAsmKernels, - "Generating assembly kernels", - multiArg=False, - return_as="list" - ) -+ del processKernelFn -+ gc.collect() -+ - passPostKernelInfoToSolution( -- ret, uniqueAsmKernels, solutions, splitGSU -+ results, uniqueAsmKernels, solutions, splitGSU - ) -- # result.src is very large so let garbage collector know to clean up -- del ret -+ del results -+ gc.collect() -+ - buildAssemblyCodeObjectFiles( - asmToolchain.linker, - asmToolchain.bundler, -@@ -508,6 +568,15 @@ def generateKernelHelperObjects(solutions: List[Solution], cxxCompiler: str, isa - return sorted(khos, key=sortByEnum, reverse=True) # Ensure that we write Enum kernel helpers are first in list - - -+def libraryIter(lib: MasterSolutionLibrary): -+ if len(lib.solutions): -+ for i, s in enumerate(lib.solutions.items()): -+ yield (i, *s) -+ else: -+ for _, lazyLib in lib.lazyLibraries.items(): -+ yield from libraryIter(lazyLib) -+ -+ - @timing - def generateLogicDataAndSolutions(logicFiles, args, assembler: Assembler, isaInfoMap): - -@@ -523,26 +592,23 @@ def generateLogicDataAndSolutions(logicFiles, args, assembler: Assembler, isaInf - printSolutionRejectionReason = True - printIndexAssignmentInfo = False - -- fIter = zip( -- logicFiles, -- itertools.repeat(assembler), -- itertools.repeat(splitGSU), -- itertools.repeat(printSolutionRejectionReason), -- itertools.repeat(printIndexAssignmentInfo), -- itertools.repeat(isaInfoMap), -- itertools.repeat(args["LazyLibraryLoading"]), -+ parseLogicFn = functools.partial( -+ LibraryIO.parseLibraryLogicFile, -+ assembler=assembler, -+ splitGSU=splitGSU, -+ printSolutionRejectionReason=printSolutionRejectionReason, -+ printIndexAssignmentInfo=printIndexAssignmentInfo, -+ isaInfoMap=isaInfoMap, -+ lazyLibraryLoading=args["LazyLibraryLoading"] - ) - -- def libraryIter(lib: MasterSolutionLibrary): -- if len(lib.solutions): -- for i, s in enumerate(lib.solutions.items()): -- yield (i, *s) -- else: -- for _, lazyLib in lib.lazyLibraries.items(): -- yield from libraryIter(lazyLib) -- - for library in ParallelMap2( -- LibraryIO.parseLibraryLogicFile, fIter, "Loading Logics...", return_as="generator_unordered" -+ parseLogicFn, logicFiles, "Loading Logics...", -+ return_as="generator_unordered", -+ minChunkSize=24, -+ maxWorkers=32, -+ maxtasksperchild=1, -+ multiArg=False, - ): - _, architectureName, _, _, _, newLibrary = library - -@@ -554,6 +620,9 @@ def generateLogicDataAndSolutions(logicFiles, args, assembler: Assembler, isaInf - else: - masterLibraries[architectureName] = newLibrary - masterLibraries[architectureName].version = args["CodeObjectVersion"] -+ del library, newLibrary -+ -+ gc.collect() - - # Sort masterLibraries to make global soln index values deterministic - solnReIndex = 0 -@@ -751,6 +820,9 @@ def run(): - ) - stop_wsk = timer() - print(f"Time to generate kernels (s): {(stop_wsk-start_wsk):3.2f}") -+ numKernelHelperObjs = len(kernelHelperObjs) -+ del kernelWriterAssembly, kernelHelperObjs -+ gc.collect() - - archs = [ # is this really different than the other archs above? - isaToGfx(arch) -@@ -768,13 +840,10 @@ def run(): - if kName not in solDict: - solDict["%s"%kName] = kernel - -- def writeMsl(name, lib): -- filename = os.path.join(newLibraryDir, name) -- lib.applyNaming(splitGSU) -- LibraryIO.write(filename, state(lib), arguments["LibraryFormat"]) -- - filename = os.path.join(newLibraryDir, "TensileLiteLibrary_lazy_Mapping") - LibraryIO.write(filename, libraryMapping, "msgpack") -+ del libraryMapping -+ gc.collect() - - start_msl = timer() - for archName, newMasterLibrary in masterLibraries.items(): -@@ -791,12 +860,22 @@ def run(): - kName = getKeyNoInternalArgs(s.originalSolution, splitGSU) - s.sizeMapping.CUOccupancy = solDict["%s"%kName]["CUOccupancy"] - -- ParallelMap2(writeMsl, -+ writeFn = functools.partial( -+ writeMasterSolutionLibrary, -+ newLibraryDir=newLibraryDir, -+ splitGSU=splitGSU, -+ libraryFormat=arguments["LibraryFormat"] -+ ) -+ -+ ParallelMap2(writeFn, - newMasterLibrary.lazyLibraries.items(), - "Writing master solution libraries", -+ multiArg=False, - return_as="list") - stop_msl = timer() - print(f"Time to write master solution libraries (s): {(stop_msl-start_msl):3.2f}") -+ del masterLibraries, solutions, kernels, solDict -+ gc.collect() - - if not arguments["KeepBuildTmp"]: - buildTmp = Path(arguments["OutputPath"]).parent / "library" / "build_tmp" -@@ -813,8 +892,11 @@ def run(): - print("") - - stop = timer() -+ peak_memory_mb, current_memory_mb = getMemoryUsage() - - print(f"Total time (s): {(stop-start):3.2f}") - print(f"Total kernels processed: {numKernels}") - print(f"Kernels processed per second: {(numKernels/(stop-start)):3.2f}") -- print(f"KernelHelperObjs: {len(kernelHelperObjs)}") -+ print(f"KernelHelperObjs: {numKernelHelperObjs}") -+ print(f"Peak memory usage (MB): {peak_memory_mb:,.1f}") -+ print(f"Current memory usage (MB): {current_memory_mb:,.1f}") -diff --git a/tensilelite/Tensile/TensileMergeLibrary.py b/tensilelite/Tensile/TensileMergeLibrary.py -index e33c617b6f..ba163e9918 100644 ---- a/tensilelite/Tensile/TensileMergeLibrary.py -+++ b/tensilelite/Tensile/TensileMergeLibrary.py -@@ -303,8 +303,7 @@ def avoidRegressions(originalDir, incrementalDir, outputPath, forceMerge, noEff= - logicsFiles[origFile] = origFile - logicsFiles[incFile] = incFile - -- iters = zip(logicsFiles.keys()) -- logicsList = ParallelMap2(loadData, iters, "Loading Logics...", return_as="list") -+ logicsList = ParallelMap2(loadData, logicsFiles.keys(), "Loading Logics...", return_as="list", multiArg=False) - logicsDict = {} - for i, _ in enumerate(logicsList): - logicsDict[logicsList[i][0]] = logicsList[i][1] -diff --git a/tensilelite/Tensile/TensileUpdateLibrary.py b/tensilelite/Tensile/TensileUpdateLibrary.py -index 5ff265d0ed..c1803a6349 100644 ---- a/tensilelite/Tensile/TensileUpdateLibrary.py -+++ b/tensilelite/Tensile/TensileUpdateLibrary.py -@@ -26,7 +26,7 @@ from . import LibraryIO - from .Tensile import addCommonArguments, argUpdatedGlobalParameters - - from .Common import assignGlobalParameters, print1, restoreDefaultGlobalParameters, HR, \ -- globalParameters, architectureMap, ensurePath, ParallelMap, __version__ -+ globalParameters, architectureMap, ensurePath, ParallelMap2, __version__ - - import argparse - import copy -@@ -149,7 +149,7 @@ def TensileUpdateLibrary(userArgs): - for logicFile in logicFiles: - print("# %s" % logicFile) - fIter = zip(logicFiles, itertools.repeat(args.logic_path), itertools.repeat(outputPath)) -- libraries = ParallelMap(UpdateLogic, fIter, "Updating logic files", method=lambda x: x.starmap) -+ libraries = ParallelMap2(UpdateLogic, fIter, "Updating logic files", multiArg=True, return_as="list") - - - def main(): -diff --git a/tensilelite/Tensile/Toolchain/Assembly.py b/tensilelite/Tensile/Toolchain/Assembly.py -index a8b91e8d62..265e1d532c 100644 ---- a/tensilelite/Tensile/Toolchain/Assembly.py -+++ b/tensilelite/Tensile/Toolchain/Assembly.py -@@ -30,7 +30,7 @@ import subprocess - from pathlib import Path - from typing import List, Union, NamedTuple - --from Tensile.Common import print2 -+from Tensile.Common import print1, print2 - from Tensile.Common.Architectures import isaToGfx - from ..SolutionStructs import Solution - -@@ -92,8 +92,26 @@ def buildAssemblyCodeObjectFiles( - if coName: - coFileMap[asmDir / (coName + extCoRaw)].add(str(asmDir / (kernel["BaseName"] + extObj))) - -+ # Build reference count map for .o files to handle shared object files -+ # (.o files from kernels marked .duplicate in TensileCreateLibrary) -+ objFileRefCount = collections.Counter() -+ for coFileRaw, objFiles in coFileMap.items(): -+ for objFile in objFiles: -+ objFileRefCount[objFile] += 1 -+ -+ sharedObjFiles = {objFile: count for objFile, count in objFileRefCount.items() if count > 1} -+ if sharedObjFiles: -+ print1(f"Found {len(sharedObjFiles)} .o files shared across multiple code objects:") -+ - for coFileRaw, objFiles in coFileMap.items(): - linker(objFiles, str(coFileRaw)) -+ -+ # Delete .o files after linking once usage count reaches 0 -+ for objFile in objFiles: -+ objFileRefCount[objFile] -= 1 -+ if objFileRefCount[objFile] == 0: -+ Path(objFile).unlink() -+ - coFile = destDir / coFileRaw.name.replace(extCoRaw, extCo) - if compress: - bundler.compress(str(coFileRaw), str(coFile), gfx) -diff --git a/tensilelite/Tensile/Toolchain/Component.py b/tensilelite/Tensile/Toolchain/Component.py -index 67fa35e2d8..dde83af4c3 100644 ---- a/tensilelite/Tensile/Toolchain/Component.py -+++ b/tensilelite/Tensile/Toolchain/Component.py -@@ -355,6 +355,7 @@ class Linker(Component): - when invoking the linker, LLVM allows the provision of arguments via a "response file" - Reference: https://llvm.org/docs/CommandLine.html#response-files - """ -+ # FIXME: this prevents threading as clang_args.txt is overwritten - with open(Path.cwd() / "clang_args.txt", "wt") as file: - file.write(" ".join(srcPaths).replace('\\', '\\\\') if os_name == "nt" else " ".join(srcPaths)) - return [*(self.default_args), "-o", destPath, "@clang_args.txt"] -diff --git a/tensilelite/requirements.txt b/tensilelite/requirements.txt -index 60c4c11445..5c8fd66a88 100644 ---- a/tensilelite/requirements.txt -+++ b/tensilelite/requirements.txt -@@ -2,8 +2,6 @@ dataclasses; python_version == '3.6' - packaging - pyyaml - msgpack --joblib>=1.4.0; python_version >= '3.8' --joblib>=1.1.1; python_version < '3.8' - simplejson - ujson - orjson diff --git a/pkgs/development/rocm-modules/10/hipblaslt/default.nix b/pkgs/development/rocm-modules/10/hipblaslt/default.nix index d24759510a5c3..1dc5962ec0698 100644 --- a/pkgs/development/rocm-modules/10/hipblaslt/default.nix +++ b/pkgs/development/rocm-modules/10/hipblaslt/default.nix @@ -4,7 +4,7 @@ fetchFromGitHub, cmake, rocm-cmake, - rocm-smi, + amdsmi, pkg-config, clr, gfortran, @@ -56,6 +56,8 @@ let ps.packaging ps.nanobind ps.msgpack + # tensilelite imports joblib (Parallel.py) and lists it in requirements.txt. + ps.joblib ]); # workaround: build for one working target if no targets are supported # a few CXX files are still build for the device @@ -70,13 +72,13 @@ let in stdenv.mkDerivation (finalAttrs: { pname = "hipblaslt${clr.gpuArchSuffix}"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-+xMmPKb32NP9U35dHCXfXWwa6exfiL5TezfXERVDfe4="; + tag = "therock-${finalAttrs.version}"; + hash = "sha256-FOwC+eG8dYgiktogDrUZhtKbKl9iNFvnGXSt0Uj02lQ="; sparseCheckout = [ "projects/hipblaslt" "shared" @@ -95,6 +97,9 @@ stdenv.mkDerivation (finalAttrs: { env.TENSILE_GEN_ASSEMBLY_TOOLCHAIN = lib.getExe' clr "amdclang++"; env.LD_PRELOAD = "${jemalloc}/lib/libjemalloc.so"; env.MALLOC_CONF = "background_thread:true,metadata_thp:auto,dirty_decay_ms:10000,muzzy_decay_ms:10000"; + # tensilelite caches helper-kernel code objects in $HOME/.tensile, which is + # unwritable in the sandbox, and a cache across builds is useless under Nix. + env.TENSILE_DISABLE_HELPER_CACHE = "1"; requiredSystemFeatures = [ "big-parallel" ]; __structuredAttrs = true; @@ -117,13 +122,10 @@ stdenv.mkDerivation (finalAttrs: { # parallel-jobs for these invocations # https://github.com/ROCm/rocm-libraries/issues/1242 ./parallel-buildSourceCodeObjectFile.diff + ./tensile-memory.patch # Support loading zstd compressed .dat files, required to keep output under # hydra size limit ./messagepack-compression-support.patch - # [hipblaslt] Refactor Parallel.py to drop joblib, massively reduce peak disk space usage - # https://github.com/ROCm/rocm-libraries/pull/2073 - ./TensileCreateLibrary-refactor.patch - ./Tensile-interning.patch ]; preConfigure = '' @@ -131,11 +133,15 @@ stdenv.mkDerivation (finalAttrs: { ''; postPatch = '' - # git isn't needed and we have no .git - substituteInPlace cmake/dependencies.cmake \ + # origami needs Git only for a rocm-cmake FetchContent fallback we never take. + substituteInPlace ../../shared/origami/cmake/dependencies.cmake \ --replace-fail "find_package(Git REQUIRED)" "" - substituteInPlace CMakeLists.txt \ - --replace-fail " LANGUAGES CXX" " LANGUAGES CXX C ASM" + + + + # For messagepack-compression-support.patch; amdclang ignores NIX_LDFLAGS. + echo 'target_link_libraries(tensilelite-host PRIVATE ${lib.getLib zstd}/lib/libzstd.so)' \ + >> tensilelite/src/msgpack/CMakeLists.txt ''; doCheck = false; @@ -149,7 +155,7 @@ stdenv.mkDerivation (finalAttrs: { gfortran pkg-config ninja - rocm-smi + amdsmi zstd ]; @@ -159,7 +165,7 @@ stdenv.mkDerivation (finalAttrs: { rocm-cmake hipblas-common amd-blis - rocm-smi + amdsmi openmp libffi ncurses @@ -195,6 +201,9 @@ stdenv.mkDerivation (finalAttrs: { "-DBLIS_INCLUDE_DIR=${amd-blis}/include/blis/" "-DBLA_PREFER_PKGCONFIG=ON" "-DFETCHCONTENT_SOURCE_DIR_NANOBIND=${python3Packages.nanobind.src}" + # Tensile codegen writes into a CONFIGURE_DEPENDS glob; the mid-build re-run + # of cmake >= 4.4 then loses nanobind_add_module. + (lib.cmakeBool "CMAKE_SUPPRESS_REGENERATION" true) # Manually define CMAKE_INSTALL_ # See: https://github.com/NixOS/nixpkgs/pull/197838 "-DCMAKE_INSTALL_BINDIR=bin" @@ -214,7 +223,6 @@ stdenv.mkDerivation (finalAttrs: { # Move binaries to appropriate outputs and delete leftover /bin + '' mkdir -p $benchmark/bin - mv $out/bin/hipblaslt-{api-overhead,bench*} $out/bin/*.yaml $out/bin/*.py $benchmark/bin ${lib.optionalString buildTests '' mkdir -p $test/bin mv $out/bin/hipblas-test $test/bin @@ -223,6 +231,8 @@ stdenv.mkDerivation (finalAttrs: { mkdir -p $sample/bin mv $out/bin/example-* $sample/bin ''} + # Everything else in bin/ is a benchmark tool. + mv $out/bin/* $benchmark/bin rmdir $out/bin ''; diff --git a/pkgs/development/rocm-modules/10/hipblaslt/messagepack-compression-support.patch b/pkgs/development/rocm-modules/10/hipblaslt/messagepack-compression-support.patch index ace6b2b728ad2..bf14f9711c9c8 100644 --- a/pkgs/development/rocm-modules/10/hipblaslt/messagepack-compression-support.patch +++ b/pkgs/development/rocm-modules/10/hipblaslt/messagepack-compression-support.patch @@ -1,18 +1,16 @@ -diff --git a/Tensile/Source/lib/source/msgpack/MessagePack.cpp b/Tensile/Source/lib/source/msgpack/MessagePack.cpp -index de97929c..dbc397e0 100644 --- a/tensilelite/src/msgpack/MessagePack.cpp +++ b/tensilelite/src/msgpack/MessagePack.cpp -@@ -28,6 +28,8 @@ +@@ -27,6 +27,8 @@ + #include #include - -+#include + - #include ++#include - namespace Tensile -@@ -86,6 +88,34 @@ namespace Tensile - return nullptr; + #include + #include +@@ -245,6 +247,34 @@ + return false; } + // Check if the file is zstd compressed @@ -46,11 +44,11 @@ index de97929c..dbc397e0 100644 msgpack::unpacker unp; bool finished_parsing; constexpr size_t buffer_size = 1 << 19; -@@ -109,6 +139,7 @@ namespace Tensile +@@ -278,6 +308,7 @@ - return nullptr; + return false; } + } } - catch(std::runtime_error const& exc) + catch(std::exception const& exc) { diff --git a/pkgs/development/rocm-modules/10/hipblaslt/parallel-buildSourceCodeObjectFile.diff b/pkgs/development/rocm-modules/10/hipblaslt/parallel-buildSourceCodeObjectFile.diff index 019e7a6123b16..0aed828b1178a 100644 --- a/pkgs/development/rocm-modules/10/hipblaslt/parallel-buildSourceCodeObjectFile.diff +++ b/pkgs/development/rocm-modules/10/hipblaslt/parallel-buildSourceCodeObjectFile.diff @@ -1,12 +1,13 @@ -diff --git a/tensilelite/Tensile/Toolchain/Source.py b/tensilelite/Tensile/Toolchain/Source.py -index c9862e6c..dfa5ba40 100644 ---- a/tensilelite/Tensile/Toolchain/Source.py -+++ b/tensilelite/Tensile/Toolchain/Source.py -@@ -102,6 +102,7 @@ def buildSourceCodeObjectFiles( - coPaths= [] +diff --git a/tensilelite/Tensile/Toolchain/Component.py b/tensilelite/Tensile/Toolchain/Component.py +--- a/tensilelite/Tensile/Toolchain/Component.py ++++ b/tensilelite/Tensile/Toolchain/Component.py +@@ -219,6 +219,9 @@ + "-x", "hip", "-O3", + "-Xoffload-linker", f"--build-id={build_id_kind}", + "-std=c++17", ++ # Parallelise the per-arch device compiles of each invocation. ++ # https://github.com/ROCm/rocm-libraries/issues/1242 ++ "-parallel-jobs=8", + ] - objPath = str(tmpObjDir / objFilename) -+ compiler.default_args += ["-parallel-jobs=8"] - compiler(str(includeDir), cmdlineArchs, str(kernelPath), objPath) - - for target in bundler.targets(objPath): + if asan_build: diff --git a/pkgs/development/rocm-modules/10/hipblaslt/tensile-memory.patch b/pkgs/development/rocm-modules/10/hipblaslt/tensile-memory.patch new file mode 100644 index 0000000000000..d38c111717707 --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipblaslt/tensile-memory.patch @@ -0,0 +1,92 @@ +Subject: [PATCH] Limit Tensile workers and retain only kernel metadata + +Adapt the memory protections from the ROCm 7 Tensile patches to the new +pipeline. Honor build-system worker limits, intern immutable YAML strings, +and release generated assembly after it has been written and assembled. +Keep SizeMapping objects separate: passPostKernelInfoToLibrary mutates them. + +--- a/tensilelite/Tensile/Common/Parallel.py ++++ b/tensilelite/Tensile/Common/Parallel.py +@@ -25,6 +25,7 @@ + import concurrent.futures + import itertools + import os ++import re + import sys + import time + +@@ -46,19 +47,24 @@ + + if not enable: + return 1 +- else: +- if os.name == "nt": +- # Windows supports at most 61 workers because the scheduler uses +- # WaitForMultipleObjects directly, which has the limit (the limit +- # is actually 64, but some handles are needed for accounting). +- cpu_count = min(os.cpu_count(), 61) +- else: +- cpu_count = len(os.sched_getaffinity(0)) +- cpuThreads = globalParameters["CpuThreads"] +- if cpuThreads == -1: +- return cpu_count +- +- return min(cpu_count, cpuThreads) ++ cpu_count = os.cpu_count() if os.name == "nt" else len(os.sched_getaffinity(0)) ++ if os.name == "nt": ++ cpu_count = min(cpu_count, 61) ++ limits = [cpu_count] ++ configured = globalParameters["CpuThreads"] ++ if configured > 0: ++ limits.append(configured) ++ for name in ("CMAKE_BUILD_PARALLEL_LEVEL", "NIX_BUILD_CORES"): ++ try: ++ limit = int(os.environ.get(name, "")) ++ except ValueError: ++ continue ++ if limit > 0: ++ limits.append(limit) ++ match = re.search(r"(?:^|\s)-j\s*(\d+)(?:\s|$)", os.environ.get("MAKEFLAGS", "")) ++ if match and int(match[1]) > 0: ++ limits.append(int(match[1])) ++ return max(1, min(limits)) + + + def pcallWithGlobalParamsMultiArg(f, args, newGlobalParameters): +--- a/tensilelite/Tensile/CustomYamlLoader.py ++++ b/tensilelite/Tensile/CustomYamlLoader.py +@@ -1,6 +1,7 @@ + # Copyright © Advanced Micro Devices, Inc., or its affiliates. + # SPDX-License-Identifier: MIT + ++import sys + import yaml + from pathlib import Path + from typing import List +@@ -73,7 +74,7 @@ + elif is_float(value_lower): + return float(value_lower) + +- return value ++ return sys.intern(value) + + def load_yaml_stream(yaml_path: Path, loader_type: yaml.Loader): + with open(yaml_path, 'r') as f: +--- a/tensilelite/Tensile/TensileCreateLibrary/Run.py ++++ b/tensilelite/Tensile/TensileCreateLibrary/Run.py +@@ -672,8 +672,13 @@ + def composed_function(kernel): + processed_kernel = unaryProcessKernelSource(kernel) + written_kernel = unaryWriteAssembly(processed_kernel) +- assembled_kernel = assemble(written_kernel) +- return processed_kernel ++ assemble(written_kernel) ++ return KernelMinResult( ++ processed_kernel.err, ++ processed_kernel.cuoccupancy, ++ processed_kernel.pgr, ++ processed_kernel.mathclk, ++ ) + return composed_function + + results = ParallelMap2( From b043375fbbc6c898b8bb127c7bb30d478fa62944 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:09 -0700 Subject: [PATCH 45/79] rocmPackages_10: copy Tensile and rocBLAS from rocmPackages Verbatim copies of the rocmPackages (ROCm 7.2.4) expressions for tensile, rocblas, not yet part of the rocmPackages_10 scope. The following commits update each one to ROCm 10.1, so their diffs read against 7.2.4. Assisted-by: Claude Code (claude-opus-5-5) --- .../rocm-modules/10/rocblas/default.nix | 208 ++++++++++++++++++ .../10/rocblas/hiplaslt-unstable-compat.patch | 99 +++++++++ .../rocm-modules/10/tensile/default.nix | 96 ++++++++ ...ensile-create-library-dont-copy-twice.diff | 20 ++ .../tensile-solutionstructs-perf-fix.diff | 48 ++++ 5 files changed, 471 insertions(+) create mode 100644 pkgs/development/rocm-modules/10/rocblas/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocblas/hiplaslt-unstable-compat.patch create mode 100644 pkgs/development/rocm-modules/10/tensile/default.nix create mode 100644 pkgs/development/rocm-modules/10/tensile/tensile-create-library-dont-copy-twice.diff create mode 100644 pkgs/development/rocm-modules/10/tensile/tensile-solutionstructs-perf-fix.diff diff --git a/pkgs/development/rocm-modules/10/rocblas/default.nix b/pkgs/development/rocm-modules/10/rocblas/default.nix new file mode 100644 index 0000000000000..0e9d0485a2c6b --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocblas/default.nix @@ -0,0 +1,208 @@ +{ + lib, + stdenv, + fetchFromGitHub, + fetchpatch, + rocmUpdateScript, + cmake, + rocm-cmake, + clr, + diffutils, + python3, + tensile, + boost, + msgpack-cxx, + libxml2, + gtest, + gfortran, + openmp, + gitMinimal, + amd-blis, + zstd, + roctracer, + hipblas-common, + hipblaslt, + python3Packages, + rocm-smi, + pkg-config, + removeReferencesTo, + buildTensile ? true, + buildTests ? true, + buildBenchmarks ? true, + tensileSepArch ? true, + tensileLazyLib ? true, + withHipBlasLt ? true, + gpuTargets ? (clr.localGpuTargets or clr.gpuTargets), +}: + +let + gpuTargets' = lib.concatStringsSep ";" gpuTargets; +in +stdenv.mkDerivation (finalAttrs: { + pname = "rocblas${clr.gpuArchSuffix}"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocblas" + "shared" + ]; + hash = "sha256-wrjcr2ASSF+bk5atjvKfIYSbg+vevo/a2W2ca9Nft/4="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rocblas"; + + outputs = [ "out" ] ++ lib.optional buildBenchmarks "benchmark" ++ lib.optional buildTests "test"; + + nativeBuildInputs = [ + cmake + # no ninja, it buffers console output and nix times out long periods of no output + rocm-cmake + clr + gitMinimal + pkg-config + removeReferencesTo + ] + ++ lib.optionals buildTensile [ + tensile + ]; + + buildInputs = [ + python3 + hipblas-common + roctracer + openmp + amd-blis + ] + ++ lib.optionals withHipBlasLt [ + hipblaslt + ] + ++ lib.optionals buildTensile [ + zstd + msgpack-cxx + libxml2 + python3Packages.msgpack + python3Packages.zstandard + ] + ++ lib.optionals (buildTests || buildBenchmarks) [ + gtest + gfortran + rocm-smi + ] + ++ lib.optionals (buildTensile || buildTests || buildBenchmarks) [ + python3Packages.pyyaml + ]; + + env.CXXFLAGS = "-fopenmp -I${lib.getDev boost}/include -I${hipblas-common}/include -I${roctracer}/include"; + # Fails to link tests with undefined symbol: cblas_* + env.LDFLAGS = + "-Wl,--as-needed -lzstd" + lib.optionalString (buildTests || buildBenchmarks) " -lcblas"; + env.TENSILE_ROCM_ASSEMBLER_PATH = "${stdenv.cc}/bin/clang++"; + + cmakeFlags = [ + (lib.cmakeFeature "Boost_INCLUDE_DIR" "${lib.getDev boost}/include") # msgpack FindBoost fails to find boost + (lib.cmakeFeature "CMAKE_EXECUTE_PROCESS_COMMAND_ECHO" "STDERR") + (lib.cmakeFeature "CMAKE_Fortran_COMPILER" "${lib.getBin gfortran}/bin/gfortran") + (lib.cmakeFeature "CMAKE_Fortran_COMPILER_AR" "${lib.getBin gfortran}/bin/ar") + (lib.cmakeFeature "CMAKE_Fortran_COMPILER_RANLIB" "${lib.getBin gfortran}/bin/ranlib") + (lib.cmakeFeature "python" "python3") + (lib.cmakeFeature "SUPPORTED_TARGETS" gpuTargets') + (lib.cmakeFeature "AMDGPU_TARGETS" gpuTargets') + (lib.cmakeFeature "GPU_TARGETS" gpuTargets') + (lib.cmakeBool "BUILD_WITH_TENSILE" buildTensile) + (lib.cmakeBool "ROCM_SYMLINK_LIBS" false) + (lib.cmakeFeature "ROCBLAS_TENSILE_LIBRARY_DIR" "lib/rocblas") + (lib.cmakeBool "BUILD_WITH_HIPBLASLT" withHipBlasLt) + (lib.cmakeBool "BUILD_CLIENTS_TESTS" buildTests) + (lib.cmakeBool "BUILD_CLIENTS_BENCHMARKS" buildBenchmarks) + (lib.cmakeBool "BUILD_CLIENTS_SAMPLES" buildBenchmarks) + (lib.cmakeBool "BUILD_OFFLOAD_COMPRESS" true) + # # Temporarily set variables to work around upstream CMakeLists issue + # # Can be removed once https://github.com/ROCm/rocm-cmake/issues/121 is fixed + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + "-DCMAKE_INSTALL_LIBDIR=lib" + ] + ++ lib.optionals buildTensile [ + "-DCPACK_SET_DESTDIR=OFF" + "-DLINK_BLIS=ON" + "-DBLAS_LIBRARY=${amd-blis}/lib/libblis-mt.so" + "-DBLIS_INCLUDE_DIR=${amd-blis}/include/blis/" + "-DBLA_PREFER_PKGCONFIG=ON" + "-DTensile_CODE_OBJECT_VERSION=default" + "-DTensile_LOGIC=asm_full" + "-DTensile_LIBRARY_FORMAT=msgpack" + (lib.cmakeBool "BUILD_WITH_PIP" false) + (lib.cmakeBool "Tensile_SEPARATE_ARCHITECTURES" tensileSepArch) + (lib.cmakeBool "Tensile_LAZY_LIBRARY_LOADING" tensileLazyLib) + ]; + + patches = [ + (fetchpatch { + name = "Extend-rocBLAS-HIP-ISA-compatibility.patch"; + url = "https://github.com/GZGavinZhao/rocm-libraries/commit/49f21f3cfe7eb4b8ac724eef81fa2cae97a3c22e.patch"; + hash = "sha256-vAVVpTwt49lGHu2YopR1X68v5LwFOjUYuSC4ucBpFGg="; + relative = "projects/rocblas"; + }) + ]; + + # Pass $NIX_BUILD_CORES to Tensile + postPatch = '' + substituteInPlace cmake/build-options.cmake \ + --replace-fail 'Tensile_CPU_THREADS ""' 'Tensile_CPU_THREADS "$ENV{NIX_BUILD_CORES}"' + '' + # Workaround: libblis detection uses broken absolute paths + # TODO: upstream a proper fix + + '' + substituteInPlace clients/CMakeLists.txt \ + --replace-fail "if ( NOT WIN32 )" "if(OFF)" \ + --replace-fail "else() # WIN32" "elseif(OFF)" + '' + # Fixes sh: line 1: /usr/bin/diff: No such file or directory + # /build/source/clients/gtest/../include/testing_logging.hpp:1117: Failure + + lib.optionalString buildTests '' + substituteInPlace clients/include/testing_logging.hpp \ + --replace-fail "/usr/bin/diff" "${lib.getExe' diffutils "diff"}" + ''; + + postInstall = + # tensile isn't needed at runtime and pulls in ~400MB of python deps + '' + remove-references-to -t ${tensile} \ + "$out/lib/librocblas.so."* + '' + + lib.optionalString buildBenchmarks '' + moveToOutput "bin/*-tune" "$benchmark" + moveToOutput "bin/*-bench" "$benchmark" + moveToOutput "bin/*example*" "$benchmark" + cp "$out/bin/"*.{yaml,txt} "$benchmark/bin" + '' + + lib.optionalString buildTests '' + moveToOutput "bin/*test*" "$test" + cp "$out/bin/"*.{yaml,txt} "$test/bin" + '' + + '' + if [ -d $out/bin ]; then + rm $out/bin/*.{yaml,txt} || true + rmdir $out/bin + fi + ''; + + passthru = { + amdgpu_targets = gpuTargets'; + updateScript = rocmUpdateScript { inherit finalAttrs; }; + }; + + enableParallelBuilding = true; + requiredSystemFeatures = [ "big-parallel" ]; + + meta = { + description = "BLAS implementation for ROCm platform"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocblas"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocblas/hiplaslt-unstable-compat.patch b/pkgs/development/rocm-modules/10/rocblas/hiplaslt-unstable-compat.patch new file mode 100644 index 0000000000000..4d8c885c8d398 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocblas/hiplaslt-unstable-compat.patch @@ -0,0 +1,99 @@ +diff --git a/library/src/hipblaslt_host.cpp b/library/src/hipblaslt_host.cpp +index 8080070c..97d5216e 100644 +--- a/library/src/hipblaslt_host.cpp ++++ b/library/src/hipblaslt_host.cpp +@@ -155,22 +155,22 @@ namespace + hipblaslt_compute_type); + + hipblaslt_ext::GemmProblemType problemType; +- problemType.op_a = (hipblasOperation_t)prob.trans_a; +- problemType.op_b = (hipblasOperation_t)prob.trans_b; +- problemType.type_a = hipblaslt_datatype; +- problemType.type_b = hipblaslt_datatype; +- problemType.type_c = hipblaslt_datatype; +- problemType.type_d = hipblaslt_datatype; +- problemType.type_compute = hipblaslt_compute_type; ++ problemType.setOpA((hipblasOperation_t)prob.trans_a); ++ problemType.setOpB((hipblasOperation_t)prob.trans_b); ++ problemType.setTypeA(hipblaslt_datatype); ++ problemType.setTypeB(hipblaslt_datatype); ++ problemType.setTypeC(hipblaslt_datatype); ++ problemType.setTypeD(hipblaslt_datatype); ++ problemType.setTypeCompute(hipblaslt_compute_type); + + hipblaslt_ext::GemmEpilogue epilogue; + hipblaslt_ext::GemmInputs inputs; +- inputs.a = (void*)(prob.A + prob.buffer_offset_a); +- inputs.b = (void*)(prob.B + prob.buffer_offset_b); +- inputs.c = (void*)(prob.C + prob.buffer_offset_c); +- inputs.d = (void*)(prob.D + prob.buffer_offset_d); +- inputs.alpha = (void*)prob.alpha; +- inputs.beta = (void*)prob.beta; ++ inputs.setA((void*)(prob.A + prob.buffer_offset_a)); ++ inputs.setB((void*)(prob.B + prob.buffer_offset_b)); ++ inputs.setC((void*)(prob.C + prob.buffer_offset_c)); ++ inputs.setD((void*)(prob.D + prob.buffer_offset_d)); ++ inputs.setAlpha((void*)prob.alpha); ++ inputs.setBeta((void*)prob.beta); + + gemm.setProblem(prob.m, + prob.n, +@@ -214,13 +214,13 @@ namespace + hipblaslt_compute_type); + + hipblaslt_ext::GemmProblemType problemType; +- problemType.op_a = (hipblasOperation_t)prob.trans_a; +- problemType.op_b = (hipblasOperation_t)prob.trans_b; +- problemType.type_a = hipblaslt_datatype; +- problemType.type_b = hipblaslt_datatype; +- problemType.type_c = hipblaslt_datatype; +- problemType.type_d = hipblaslt_datatype; +- problemType.type_compute = hipblaslt_compute_type; ++ problemType.setOpA((hipblasOperation_t)prob.trans_a); ++ problemType.setOpB((hipblasOperation_t)prob.trans_b); ++ problemType.setTypeA(hipblaslt_datatype); ++ problemType.setTypeB(hipblaslt_datatype); ++ problemType.setTypeC(hipblaslt_datatype); ++ problemType.setTypeD(hipblaslt_datatype); ++ problemType.setTypeCompute(hipblaslt_compute_type); + + std::vector Ms(prob.batch_count); + std::vector Ns(prob.batch_count); +@@ -251,12 +251,12 @@ namespace + stridecs[batch] = prob.batch_stride_c; + strideds[batch] = prob.batch_stride_d; + batch_counts[batch] = 1; +- inputs[batch].a = (void*)(prob.batch_A[batch] + prob.buffer_offset_a); +- inputs[batch].b = (void*)(prob.batch_B[batch] + prob.buffer_offset_b); +- inputs[batch].c = (void*)(prob.batch_C[batch] + prob.buffer_offset_c); +- inputs[batch].d = (void*)(prob.batch_D[batch] + prob.buffer_offset_d); +- inputs[batch].alpha = (void*)prob.alpha; +- inputs[batch].beta = (void*)prob.beta; ++ inputs[batch].setA((void*)(prob.batch_A[batch] + prob.buffer_offset_a)); ++ inputs[batch].setB((void*)(prob.batch_B[batch] + prob.buffer_offset_b)); ++ inputs[batch].setC((void*)(prob.batch_C[batch] + prob.buffer_offset_c)); ++ inputs[batch].setD((void*)(prob.batch_D[batch] + prob.buffer_offset_d)); ++ inputs[batch].setAlpha((void*)prob.alpha); ++ inputs[batch].setBeta((void*)prob.beta); + } + + gemm.setProblem(Ms, +diff --git a/library/src/tensile_host.cpp b/library/src/tensile_host.cpp +index 1b1289f3..ed463725 100644 +--- a/library/src/tensile_host.cpp ++++ b/library/src/tensile_host.cpp +@@ -271,14 +271,6 @@ namespace + { + return Tensile::LazyLoadingInit::gfx90a; + } +- else if(deviceString.find("gfx940") != std::string::npos) +- { +- return Tensile::LazyLoadingInit::gfx940; +- } +- else if(deviceString.find("gfx941") != std::string::npos) +- { +- return Tensile::LazyLoadingInit::gfx941; +- } + else if(deviceString.find("gfx942") != std::string::npos) + { + return Tensile::LazyLoadingInit::gfx942; diff --git a/pkgs/development/rocm-modules/10/tensile/default.nix b/pkgs/development/rocm-modules/10/tensile/default.nix new file mode 100644 index 0000000000000..ee84ccc4eabe0 --- /dev/null +++ b/pkgs/development/rocm-modules/10/tensile/default.nix @@ -0,0 +1,96 @@ +{ + lib, + fetchFromGitHub, + fetchpatch, + rocmUpdateScript, + buildPythonPackage, + pytestCheckHook, + setuptools, + distro, + pyyaml, + msgpack, + pandas, + joblib, + filelock, + clr, + rich, +}: + +buildPythonPackage (finalAttrs: { + pname = "tensile"; + version = "7.2.4"; + pyproject = true; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "shared/tensile" + "shared" + ]; + hash = "sha256-sYudPiEPGeZLmf6+3XfQDZqRXiKgRsGPucApzYwlGV8="; + }; + sourceRoot = "${finalAttrs.src.name}/shared/tensile"; + + # TODO: It should be possible to run asm caps test ONCE for all supported arches + # We currently disable the test because it's slow and runs each time tensile launches + postPatch = '' + substituteInPlace Tensile/Common.py \ + --replace-fail 'if globalParameters["AssemblerPath"] is not None:' "if False:" + # Add an assert that the fallback 9,0,0 is supported before setting the kernel to it + # If it's not detected as supported we have an issue with compiler paths or the compiler is broken + # and it's better to stop immediately + substituteInPlace Tensile/KernelWriter.py \ + --replace-fail '= (9,0,0)' '= (9,0,0);assert(globalParameters["AsmCaps"][(9,0,0)]["SupportedISA"])' + find . -type f -iname "*.sh" -exec chmod +x {} \; + patchShebangs Tensile + ''; + + buildInputs = [ setuptools ]; + + propagatedBuildInputs = [ + pyyaml + msgpack + pandas + joblib + distro + rich + ]; + + patches = [ + ./tensile-solutionstructs-perf-fix.diff + ./tensile-create-library-dont-copy-twice.diff + (fetchpatch { + # [PATCH] Extend Tensile HIP ISA compatibility + hash = "sha256-ZHXNYSeLkhhNDaIfdqQm68Pxmh1shUL7mAVmh8/I6Xk="; + url = "https://github.com/GZGavinZhao/rocm-libraries/commit/1f7135dfc0cdb175c8f0e5eb71b2d24699942873.patch"; + relative = "shared/tensile"; + }) + ]; + + doCheck = false; # Too many errors, not sure how to set this up properly + + nativeCheckInputs = [ + pytestCheckHook + filelock + clr + ]; + + env = { + dontCheckPythonMetadata = true; + ROCM_PATH = "${clr}"; + }; + + pythonImportsCheck = [ "Tensile" ]; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "GEMMs and tensor contractions"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/shared/tensile"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/tensile/tensile-create-library-dont-copy-twice.diff b/pkgs/development/rocm-modules/10/tensile/tensile-create-library-dont-copy-twice.diff new file mode 100644 index 0000000000000..2b680241d9e4e --- /dev/null +++ b/pkgs/development/rocm-modules/10/tensile/tensile-create-library-dont-copy-twice.diff @@ -0,0 +1,20 @@ +diff --git a/Tensile/TensileCreateLibrary.py b/Tensile/TensileCreateLibrary.py +index a1644606..c6ca2882 100644 +--- a/Tensile/TensileCreateLibrary.py ++++ b/Tensile/TensileCreateLibrary.py +@@ -852,9 +852,14 @@ def copyStaticFiles(outputPath=None): + "KernelHeader.h", + ] + ++ import filecmp + for fileName in libraryStaticFiles: + # copy file +- shutil.copy(os.path.join(globalParameters["SourcePath"], fileName), outputPath) ++ # no need to copy twice if it has already been copied ++ src = os.path.join(globalParameters["SourcePath"], fileName) ++ dst = os.path.join(outputPath, os.path.basename(src)) ++ if not os.path.isfile(dst) or not filecmp.cmp(src, dst): ++ shutil.copyfile(src, dst) + + return libraryStaticFiles + diff --git a/pkgs/development/rocm-modules/10/tensile/tensile-solutionstructs-perf-fix.diff b/pkgs/development/rocm-modules/10/tensile/tensile-solutionstructs-perf-fix.diff new file mode 100644 index 0000000000000..7157238042ece --- /dev/null +++ b/pkgs/development/rocm-modules/10/tensile/tensile-solutionstructs-perf-fix.diff @@ -0,0 +1,48 @@ +diff --git a/Tensile/SolutionStructs.py b/Tensile/SolutionStructs.py +index f663c6f1..17bcf897 100644 +--- a/Tensile/SolutionStructs.py ++++ b/Tensile/SolutionStructs.py +@@ -4828,24 +4828,26 @@ class Solution(collections.abc.Mapping): + # create a dictionary of lists of parameter values + @staticmethod + def getSerialNaming(objs): ++ valid_params = sorted(validParameters.keys()) + data = {} +- for objIdx in range(0, len(objs)): +- obj = objs[objIdx] +- for paramName in sorted(obj.keys()): +- if paramName in list(validParameters.keys()): +- paramValue = obj[paramName] +- if paramName in data: +- if paramValue not in data[paramName]: +- data[paramName].append(paramValue) +- else: +- data[paramName] = [ paramValue ] +- maxObjs = 1 +- for paramName in data: +- if not isinstance(data[paramName][0],dict): +- data[paramName] = sorted(data[paramName]) +- maxObjs *= len(data[paramName]) +- numDigits = len(str(maxObjs)) +- return [ data, numDigits ] ++ ++ objs = [getattr(obj, "_state", obj) for obj in objs] ++ ++ for param in valid_params: ++ d = [] ++ for obj in objs: ++ if param in obj: ++ v = obj[param] ++ if v not in d: ++ d.append(v) ++ if len(d): ++ if not isinstance(d[0], dict): d.sort() ++ data[param] = d ++ ++ # Calculate max objects using prod() from math module ++ max_objs = math.prod(len(values) for values in data.values()) ++ num_digits = len(str(max_objs)) ++ return data, num_digits + + ######################################## + # Get Name Serial \ No newline at end of file From baf7dc93ec61b01701be61409f8ee02439999f2d Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:10 -0700 Subject: [PATCH 46/79] rocmPackages_10.tensile: init at 10.1 Update the rocmPackages.tensile copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 7 +++++++ pkgs/development/rocm-modules/10/tensile/default.nix | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index f5412ffe47754..4ed29774a59a5 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -123,6 +123,13 @@ let hipfft = self.callPackage ./hipfft { }; + tensile = pyPackages.callPackage ./tensile { + inherit (self) + rocmUpdateScript + clr + ; + }; + hipblas-common = self.callPackage ./hipblas-common { }; hipblaslt = self.callPackage ./hipblaslt { }; diff --git a/pkgs/development/rocm-modules/10/tensile/default.nix b/pkgs/development/rocm-modules/10/tensile/default.nix index ee84ccc4eabe0..313729dee02df 100644 --- a/pkgs/development/rocm-modules/10/tensile/default.nix +++ b/pkgs/development/rocm-modules/10/tensile/default.nix @@ -18,18 +18,18 @@ buildPythonPackage (finalAttrs: { pname = "tensile"; - version = "7.2.4"; + version = "10.1"; pyproject = true; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "shared/tensile" "shared" ]; - hash = "sha256-sYudPiEPGeZLmf6+3XfQDZqRXiKgRsGPucApzYwlGV8="; + hash = "sha256-OJPndaRrXoWsqrEFYRRhU8qnivb1zLigFQ2McWqMMDk="; }; sourceRoot = "${finalAttrs.src.name}/shared/tensile"; From c0ec6f6d68393b0be04cdfc4ca62624150c6ffa5 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:10 -0700 Subject: [PATCH 47/79] rocmPackages_10.rocblas: init at 10.1 Update the rocmPackages.rocblas copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.rocblas: split Tensile kernels into per-arch shards": Introduce a per-architecture Tensile "shard" split for rocBLAS: base.nix is the raw single-/multi-arch builder (the former default.nix), and default.nix now assembles one joined output from per-arch shards. For a multi-arch build the host librocblas.so + headers + cmake are built once for the head arch, and every other arch's self-contained lib/rocblas/library// Tensile directory is built as a separate minimal shard and merged in postInstall. rocBLAS builds Tensile with SEPARATE_ARCHITECTURES + LAZY_LIBRARY_LOADING, so in a shared build the kernels are not linked into librocblas.so; each per-arch dir is loaded by path at runtime, making the join a plain per-arch-dir merge with no relink. Single-arch scopes (e.g. rocmPackages.gfx906.*) have no tail archs and return the base build verbatim, so their derivation stays byte-identical to before the split. The merge strips the shard store path that Tensile bakes into a per-arch code object's ELF metadata (remove-references-to). That reference is not load-bearing -- the unsplit multi-arch build self-references $out in the same spot and runs fine -- and disallowedReferences guards against a regression. Validated on a gfx1102 (Radeon Pro W7500): a [gfx906-head, gfx1102-shard] join runs a correct rocBLAS SGEMM on the gfx1102 hardware, loading the merged gfx1102 Tensile directory from the joined output. From "rocmPackages.rocblas: 7.2.4 -> 10.1.0": - Clients switched rocm_smi -> amd_smi (find_package(amd_smi CONFIG REQUIRED)); add amdsmi for the test/benchmark builds. - Drop the GZGavinZhao "Extend rocBLAS HIP ISA compatibility" patch: library/src/handle.cpp now has explicit Processor::gfx906/gfx90c cases, so with gfx906 in gpuTargets Tensile builds real gfx906 kernels. - Give cblas an explicit -L. rocBLAS compiles with the unwrapped rocm-toolchain clang, so buildInput lib dirs are not injected into the clang-linker-wrapper host-link path. With LLVM 24 the rocm-cmake rocm_check_target_ids probe (run before find_package(BLAS)) does a full --hip-link, and CMake seeds CMAKE_EXE_LINKER_FLAGS from $LDFLAGS, so a bare `-lcblas` makes that probe fail, emptying the supported-target list and aborting with "Unsupported target". Add amd-blis's libdir. - Drop the testing_logging.hpp /usr/bin/diff substitution; the source no longer shells out to it. - ROCm 10 installs a bin/rocblas/ CTest scaffolding dir alongside the client yaml/txt, so remove the whole bin/ tree from the library output. Revised during the split review: Forward package overrides to base.nix and read the effective settings from its passthru. Shard only builds whose Tensile libraries are separate-architecture and lazily loaded; use the base build otherwise. Omit -lzstd and the Tensile reference removal when Tensile is disabled. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 6 + .../rocm-modules/10/rocblas/base.nix | 212 ++++++++++++++ .../rocm-modules/10/rocblas/default.nix | 277 ++++++------------ 3 files changed, 300 insertions(+), 195 deletions(-) create mode 100644 pkgs/development/rocm-modules/10/rocblas/base.nix diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 4ed29774a59a5..3154983f16e31 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -130,6 +130,12 @@ let ; }; + # rocblas_base is the raw per-arch builder (marked broken, like + # composable_kernel_base); rocblas (default.nix) assembles the per-arch + # Tensile shards into one joined output (see rocblas/default.nix). + rocblas_base = self.callPackage ./rocblas/base.nix { }; + rocblas = self.callPackage ./rocblas { }; + hipblas-common = self.callPackage ./hipblas-common { }; hipblaslt = self.callPackage ./hipblaslt { }; diff --git a/pkgs/development/rocm-modules/10/rocblas/base.nix b/pkgs/development/rocm-modules/10/rocblas/base.nix new file mode 100644 index 0000000000000..478616b76bab0 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocblas/base.nix @@ -0,0 +1,212 @@ +{ + lib, + stdenv, + fetchFromGitHub, + fetchpatch, + rocmUpdateScript, + cmake, + rocm-cmake, + clr, + python3, + tensile, + boost, + msgpack-cxx, + libxml2, + gtest, + gfortran, + openmp, + gitMinimal, + amd-blis, + zstd, + roctracer, + hipblas-common, + hipblaslt, + python3Packages, + amdsmi, + pkg-config, + removeReferencesTo, + buildTensile ? true, + buildTests ? true, + buildBenchmarks ? true, + tensileSepArch ? true, + tensileLazyLib ? true, + withHipBlasLt ? true, + gpuTargets ? (clr.localGpuTargets or clr.gpuTargets), +}: + +let + gpuTargets' = lib.concatStringsSep ";" gpuTargets; +in +stdenv.mkDerivation (finalAttrs: { + pname = "rocblas${clr.gpuArchSuffix}"; + version = "10.1"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + rev = "therock-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocblas" + "shared" + ]; + hash = "sha256-G6vo78dbgP02zQJKsAuFPoncy2rsGkenZWrfvj4mD8M="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rocblas"; + + outputs = [ "out" ] ++ lib.optional buildBenchmarks "benchmark" ++ lib.optional buildTests "test"; + + nativeBuildInputs = [ + cmake + # no ninja, it buffers console output and nix times out long periods of no output + rocm-cmake + clr + gitMinimal + pkg-config + removeReferencesTo + ] + ++ lib.optionals buildTensile [ + tensile + ]; + + buildInputs = [ + python3 + hipblas-common + roctracer + openmp + amd-blis + ] + ++ lib.optionals withHipBlasLt [ + hipblaslt + ] + ++ lib.optionals buildTensile [ + zstd + msgpack-cxx + libxml2 + python3Packages.msgpack + python3Packages.zstandard + ] + ++ lib.optionals (buildTests || buildBenchmarks) [ + gtest + gfortran + # clients/CMakeLists.txt: find_package(amd_smi CONFIG REQUIRED) + amdsmi + ] + ++ lib.optionals (buildTensile || buildTests || buildBenchmarks) [ + python3Packages.pyyaml + ]; + + env.CXXFLAGS = "-fopenmp -I${lib.getDev boost}/include -I${hipblas-common}/include -I${roctracer}/include"; + # Fails to link tests with undefined symbol: cblas_* (cblas comes from amd-blis). + # cblas needs an explicit -L: rocBLAS compiles with the unwrapped rocm-toolchain + # clang, so buildInput lib dirs are not injected into the clang-linker-wrapper + # host-link path the way the nixpkgs cc-wrapper would. With LLVM 24 the rocm-cmake + # `rocm_check_target_ids` probe (run before find_package(BLAS)) does a full + # `--hip-link`, and CMake seeds CMAKE_EXE_LINKER_FLAGS from $LDFLAGS, so a bare + # `-lcblas` makes that probe's link fail ("unable to find library -lcblas"), which + # empties the supported-target list and aborts with "Unsupported target ". + # Only builds with tests/benchmarks hit this; the Tensile shards build with them off. + env.LDFLAGS = + "-Wl,--as-needed" + + lib.optionalString buildTensile " -lzstd" + + lib.optionalString (buildTests || buildBenchmarks) " -L${amd-blis}/lib -lcblas"; + env.TENSILE_ROCM_ASSEMBLER_PATH = "${stdenv.cc}/bin/clang++"; + + cmakeFlags = [ + (lib.cmakeFeature "Boost_INCLUDE_DIR" "${lib.getDev boost}/include") # msgpack FindBoost fails to find boost + (lib.cmakeFeature "CMAKE_EXECUTE_PROCESS_COMMAND_ECHO" "STDERR") + (lib.cmakeFeature "CMAKE_Fortran_COMPILER" "${lib.getBin gfortran}/bin/gfortran") + (lib.cmakeFeature "CMAKE_Fortran_COMPILER_AR" "${lib.getBin gfortran}/bin/ar") + (lib.cmakeFeature "CMAKE_Fortran_COMPILER_RANLIB" "${lib.getBin gfortran}/bin/ranlib") + (lib.cmakeFeature "python" "python3") + (lib.cmakeFeature "SUPPORTED_TARGETS" gpuTargets') + (lib.cmakeFeature "AMDGPU_TARGETS" gpuTargets') + (lib.cmakeFeature "GPU_TARGETS" gpuTargets') + (lib.cmakeBool "BUILD_WITH_TENSILE" buildTensile) + (lib.cmakeBool "ROCM_SYMLINK_LIBS" false) + (lib.cmakeFeature "ROCBLAS_TENSILE_LIBRARY_DIR" "lib/rocblas") + (lib.cmakeBool "BUILD_WITH_HIPBLASLT" withHipBlasLt) + (lib.cmakeBool "BUILD_CLIENTS_TESTS" buildTests) + (lib.cmakeBool "BUILD_CLIENTS_BENCHMARKS" buildBenchmarks) + (lib.cmakeBool "BUILD_CLIENTS_SAMPLES" buildBenchmarks) + (lib.cmakeBool "BUILD_OFFLOAD_COMPRESS" true) + # # Temporarily set variables to work around upstream CMakeLists issue + # # Can be removed once https://github.com/ROCm/rocm-cmake/issues/121 is fixed + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + "-DCMAKE_INSTALL_LIBDIR=lib" + ] + ++ lib.optionals buildTensile [ + "-DCPACK_SET_DESTDIR=OFF" + "-DLINK_BLIS=ON" + "-DBLAS_LIBRARY=${amd-blis}/lib/libblis-mt.so" + "-DBLIS_INCLUDE_DIR=${amd-blis}/include/blis/" + "-DBLA_PREFER_PKGCONFIG=ON" + "-DTensile_CODE_OBJECT_VERSION=default" + "-DTensile_LOGIC=asm_full" + "-DTensile_LIBRARY_FORMAT=msgpack" + (lib.cmakeBool "BUILD_WITH_PIP" false) + (lib.cmakeBool "Tensile_SEPARATE_ARCHITECTURES" tensileSepArch) + (lib.cmakeBool "Tensile_LAZY_LIBRARY_LOADING" tensileLazyLib) + ]; + + # Pass $NIX_BUILD_CORES to Tensile + postPatch = '' + substituteInPlace cmake/build-options.cmake \ + --replace-fail 'Tensile_CPU_THREADS ""' 'Tensile_CPU_THREADS "$ENV{NIX_BUILD_CORES}"' + '' + # Workaround: libblis detection uses broken absolute paths + # TODO: upstream a proper fix + + '' + substituteInPlace clients/CMakeLists.txt \ + --replace-fail "if ( NOT WIN32 )" "if(OFF)" \ + --replace-fail "else() # WIN32" "elseif(OFF)" + ''; + + postInstall = + # Tensile is only needed while generating kernels. + lib.optionalString buildTensile '' + remove-references-to -t ${tensile} \ + "$out/lib/librocblas.so."* + '' + + lib.optionalString buildBenchmarks '' + moveToOutput "bin/*-tune" "$benchmark" + moveToOutput "bin/*-bench" "$benchmark" + moveToOutput "bin/*example*" "$benchmark" + cp "$out/bin/"*.{yaml,txt} "$benchmark/bin" + '' + + lib.optionalString buildTests '' + moveToOutput "bin/*test*" "$test" + cp "$out/bin/"*.{yaml,txt} "$test/bin" + '' + + '' + # The rocBLAS library output keeps no bin/ (clients live in $test / + # $benchmark). ROCm 10 also installs a bin/rocblas/ CTest scaffolding dir + # alongside the client yaml/txt, so remove the whole bin/ tree rather than + # rmdir'ing (which fails on the non-empty directory). + rm -rf $out/bin + ''; + + passthru = { + # Read by ./default.nix to decide whether the build can be sharded. + inherit + buildTensile + tensileSepArch + tensileLazyLib + gpuTargets + ; + amdgpu_targets = gpuTargets'; + updateScript = rocmUpdateScript { inherit finalAttrs; }; + }; + + enableParallelBuilding = true; + requiredSystemFeatures = [ "big-parallel" ]; + + meta = { + description = "BLAS implementation for ROCm platform"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocblas"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + broken = true; # this base package shouldn't be built directly + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocblas/default.nix b/pkgs/development/rocm-modules/10/rocblas/default.nix index 0e9d0485a2c6b..bd731d100bcc7 100644 --- a/pkgs/development/rocm-modules/10/rocblas/default.nix +++ b/pkgs/development/rocm-modules/10/rocblas/default.nix @@ -1,208 +1,95 @@ +# One Tensile shard per GPU architecture. With separate architectures and lazy +# loading, librocblas.so opens lib/rocblas/library// at runtime, so the +# shards join by directory merge. Other layouts use ./base.nix directly. { lib, - stdenv, - fetchFromGitHub, - fetchpatch, - rocmUpdateScript, - cmake, - rocm-cmake, clr, - diffutils, - python3, - tensile, - boost, - msgpack-cxx, - libxml2, - gtest, - gfortran, - openmp, - gitMinimal, - amd-blis, - zstd, - roctracer, - hipblas-common, - hipblaslt, - python3Packages, - rocm-smi, - pkg-config, - removeReferencesTo, - buildTensile ? true, - buildTests ? true, - buildBenchmarks ? true, - tensileSepArch ? true, - tensileLazyLib ? true, - withHipBlasLt ? true, - gpuTargets ? (clr.localGpuTargets or clr.gpuTargets), -}: + rocblas_base, + ... +}@args: let - gpuTargets' = lib.concatStringsSep ";" gpuTargets; -in -stdenv.mkDerivation (finalAttrs: { - pname = "rocblas${clr.gpuArchSuffix}"; - version = "7.2.4"; + base = rocblas_base.override ( + builtins.removeAttrs args [ + "lib" + "clr" + "rocblas_base" + ] + ); + inherit (base.passthru) + buildTensile + tensileSepArch + tensileLazyLib + gpuTargets + ; + archList = gpuTargets; + headArch = lib.head archList; + tailArchs = lib.drop 1 archList; + shardTensile = buildTensile && tensileSepArch && tensileLazyLib && lib.length archList > 1; - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/rocblas" - "shared" - ]; - hash = "sha256-wrjcr2ASSF+bk5atjvKfIYSbg+vevo/a2W2ca9Nft/4="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rocblas"; + # One architecture's lazy Tensile library; everything else is dropped. + mkTensileShard = + arch: + (base.override { + gpuTargets = [ arch ]; + buildTests = false; + buildBenchmarks = false; + }).overrideAttrs + (old: { + pname = "rocblas-tensile-${arch}"; + meta = (unbreak old).meta; + outputs = [ "out" ]; + doCheck = false; + postInstall = (old.postInstall or "") + '' + keep="$(mktemp -d)" + cp -r "$out/lib/rocblas/library" "$keep/library" + rm -rf "$out"/* + mkdir -p "$out/lib/rocblas" + mv "$keep/library" "$out/lib/rocblas/library" + rm -rf "$keep" + ''; + }); - outputs = [ "out" ] ++ lib.optional buildBenchmarks "benchmark" ++ lib.optional buildTests "test"; + tensileShards = map mkTensileShard tailArchs; - nativeBuildInputs = [ - cmake - # no ninja, it buffers console output and nix times out long periods of no output - rocm-cmake - clr - gitMinimal - pkg-config - removeReferencesTo - ] - ++ lib.optionals buildTensile [ - tensile - ]; + # The base is hidden from Hydra; the configured public builds are usable. + unbreak = old: { + meta = old.meta // { + broken = false; + }; + }; +in - buildInputs = [ - python3 - hipblas-common - roctracer - openmp - amd-blis - ] - ++ lib.optionals withHipBlasLt [ - hipblaslt - ] - ++ lib.optionals buildTensile [ - zstd - msgpack-cxx - libxml2 - python3Packages.msgpack - python3Packages.zstandard - ] - ++ lib.optionals (buildTests || buildBenchmarks) [ - gtest - gfortran - rocm-smi - ] - ++ lib.optionals (buildTensile || buildTests || buildBenchmarks) [ - python3Packages.pyyaml - ]; +# Other Tensile layouts cannot be merged by copying architecture directories. +if !shardTensile then + base.overrideAttrs unbreak +else + (base.override { + gpuTargets = [ headArch ]; + }).overrideAttrs + (old: { + pname = "rocblas${clr.gpuArchSuffix}"; + meta = (unbreak old).meta; - env.CXXFLAGS = "-fopenmp -I${lib.getDev boost}/include -I${hipblas-common}/include -I${roctracer}/include"; - # Fails to link tests with undefined symbol: cblas_* - env.LDFLAGS = - "-Wl,--as-needed -lzstd" + lib.optionalString (buildTests || buildBenchmarks) " -lcblas"; - env.TENSILE_ROCM_ASSEMBLER_PATH = "${stdenv.cc}/bin/clang++"; + inherit tensileShards; + disallowedReferences = tensileShards; - cmakeFlags = [ - (lib.cmakeFeature "Boost_INCLUDE_DIR" "${lib.getDev boost}/include") # msgpack FindBoost fails to find boost - (lib.cmakeFeature "CMAKE_EXECUTE_PROCESS_COMMAND_ECHO" "STDERR") - (lib.cmakeFeature "CMAKE_Fortran_COMPILER" "${lib.getBin gfortran}/bin/gfortran") - (lib.cmakeFeature "CMAKE_Fortran_COMPILER_AR" "${lib.getBin gfortran}/bin/ar") - (lib.cmakeFeature "CMAKE_Fortran_COMPILER_RANLIB" "${lib.getBin gfortran}/bin/ranlib") - (lib.cmakeFeature "python" "python3") - (lib.cmakeFeature "SUPPORTED_TARGETS" gpuTargets') - (lib.cmakeFeature "AMDGPU_TARGETS" gpuTargets') - (lib.cmakeFeature "GPU_TARGETS" gpuTargets') - (lib.cmakeBool "BUILD_WITH_TENSILE" buildTensile) - (lib.cmakeBool "ROCM_SYMLINK_LIBS" false) - (lib.cmakeFeature "ROCBLAS_TENSILE_LIBRARY_DIR" "lib/rocblas") - (lib.cmakeBool "BUILD_WITH_HIPBLASLT" withHipBlasLt) - (lib.cmakeBool "BUILD_CLIENTS_TESTS" buildTests) - (lib.cmakeBool "BUILD_CLIENTS_BENCHMARKS" buildBenchmarks) - (lib.cmakeBool "BUILD_CLIENTS_SAMPLES" buildBenchmarks) - (lib.cmakeBool "BUILD_OFFLOAD_COMPRESS" true) - # # Temporarily set variables to work around upstream CMakeLists issue - # # Can be removed once https://github.com/ROCm/rocm-cmake/issues/121 is fixed - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - "-DCMAKE_INSTALL_LIBDIR=lib" - ] - ++ lib.optionals buildTensile [ - "-DCPACK_SET_DESTDIR=OFF" - "-DLINK_BLIS=ON" - "-DBLAS_LIBRARY=${amd-blis}/lib/libblis-mt.so" - "-DBLIS_INCLUDE_DIR=${amd-blis}/include/blis/" - "-DBLA_PREFER_PKGCONFIG=ON" - "-DTensile_CODE_OBJECT_VERSION=default" - "-DTensile_LOGIC=asm_full" - "-DTensile_LIBRARY_FORMAT=msgpack" - (lib.cmakeBool "BUILD_WITH_PIP" false) - (lib.cmakeBool "Tensile_SEPARATE_ARCHITECTURES" tensileSepArch) - (lib.cmakeBool "Tensile_LAZY_LIBRARY_LOADING" tensileLazyLib) - ]; + # Merge the shard directories, then strip the shard store path that Tensile + # embeds in one code object's ELF metadata per architecture. It is not + # load-bearing (the unsplit build embeds its own $out in the same place), + # and remove-references-to keeps the ELF layout. disallowedReferences + # keeps the private shards out of consumers' closures. + postInstall = (old.postInstall or "") + '' + for shard in $tensileShards; do + cp -r --no-preserve=mode "$shard/lib/rocblas/library/"* "$out/lib/rocblas/library/" + done + for shard in $tensileShards; do + find "$out/lib/rocblas/library" -type f -exec remove-references-to -t "$shard" {} + + done + ''; - patches = [ - (fetchpatch { - name = "Extend-rocBLAS-HIP-ISA-compatibility.patch"; - url = "https://github.com/GZGavinZhao/rocm-libraries/commit/49f21f3cfe7eb4b8ac724eef81fa2cae97a3c22e.patch"; - hash = "sha256-vAVVpTwt49lGHu2YopR1X68v5LwFOjUYuSC4ucBpFGg="; - relative = "projects/rocblas"; + passthru = (old.passthru or { }) // { + amdgpu_targets = lib.concatStringsSep ";" archList; + inherit tensileShards; + }; }) - ]; - - # Pass $NIX_BUILD_CORES to Tensile - postPatch = '' - substituteInPlace cmake/build-options.cmake \ - --replace-fail 'Tensile_CPU_THREADS ""' 'Tensile_CPU_THREADS "$ENV{NIX_BUILD_CORES}"' - '' - # Workaround: libblis detection uses broken absolute paths - # TODO: upstream a proper fix - + '' - substituteInPlace clients/CMakeLists.txt \ - --replace-fail "if ( NOT WIN32 )" "if(OFF)" \ - --replace-fail "else() # WIN32" "elseif(OFF)" - '' - # Fixes sh: line 1: /usr/bin/diff: No such file or directory - # /build/source/clients/gtest/../include/testing_logging.hpp:1117: Failure - + lib.optionalString buildTests '' - substituteInPlace clients/include/testing_logging.hpp \ - --replace-fail "/usr/bin/diff" "${lib.getExe' diffutils "diff"}" - ''; - - postInstall = - # tensile isn't needed at runtime and pulls in ~400MB of python deps - '' - remove-references-to -t ${tensile} \ - "$out/lib/librocblas.so."* - '' - + lib.optionalString buildBenchmarks '' - moveToOutput "bin/*-tune" "$benchmark" - moveToOutput "bin/*-bench" "$benchmark" - moveToOutput "bin/*example*" "$benchmark" - cp "$out/bin/"*.{yaml,txt} "$benchmark/bin" - '' - + lib.optionalString buildTests '' - moveToOutput "bin/*test*" "$test" - cp "$out/bin/"*.{yaml,txt} "$test/bin" - '' - + '' - if [ -d $out/bin ]; then - rm $out/bin/*.{yaml,txt} || true - rmdir $out/bin - fi - ''; - - passthru = { - amdgpu_targets = gpuTargets'; - updateScript = rocmUpdateScript { inherit finalAttrs; }; - }; - - enableParallelBuilding = true; - requiredSystemFeatures = [ "big-parallel" ]; - - meta = { - description = "BLAS implementation for ROCm platform"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocblas"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) From 40280b90d9f678f3fe90bcef5d14e79a8d197e26 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:13 -0700 Subject: [PATCH 48/79] rocmPackages_10: copy sparse, solvers, rocALUTION, rocWMMA, hipfort Verbatim copies of the rocmPackages (ROCm 7.2.4) expressions for rocsparse, hipsparse, rocsolver, hipblas, hipsolver, rocalution, rocwmma, hipfort, hipsparselt, not yet part of the rocmPackages_10 scope. The following commits update each one to ROCm 10.1, so their diffs read against 7.2.4. Assisted-by: Claude Code (claude-opus-5-5) --- .../rocm-modules/10/hipblas/default.nix | 132 +++++++++++ .../rocm-modules/10/hipfort/default.nix | 70 ++++++ .../rocm-modules/10/hipsolver/default.nix | 117 +++++++++ .../rocm-modules/10/hipsparse/default.nix | 148 ++++++++++++ .../rocm-modules/10/hipsparselt/default.nix | 123 ++++++++++ .../rocm-modules/10/rocalution/default.nix | 122 ++++++++++ .../rocm-modules/10/rocsolver/default.nix | 135 +++++++++++ .../rocm-modules/10/rocsparse/default.nix | 159 +++++++++++++ .../rocm-modules/10/rocsparse/deps.nix | 223 ++++++++++++++++++ .../rocwmma/0000-dont-fetch-googletest.patch | 35 +++ .../rocm-modules/10/rocwmma/default.nix | 116 +++++++++ 11 files changed, 1380 insertions(+) create mode 100644 pkgs/development/rocm-modules/10/hipblas/default.nix create mode 100644 pkgs/development/rocm-modules/10/hipfort/default.nix create mode 100644 pkgs/development/rocm-modules/10/hipsolver/default.nix create mode 100644 pkgs/development/rocm-modules/10/hipsparse/default.nix create mode 100644 pkgs/development/rocm-modules/10/hipsparselt/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocalution/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocsolver/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocsparse/default.nix create mode 100644 pkgs/development/rocm-modules/10/rocsparse/deps.nix create mode 100644 pkgs/development/rocm-modules/10/rocwmma/0000-dont-fetch-googletest.patch create mode 100644 pkgs/development/rocm-modules/10/rocwmma/default.nix diff --git a/pkgs/development/rocm-modules/10/hipblas/default.nix b/pkgs/development/rocm-modules/10/hipblas/default.nix new file mode 100644 index 0000000000000..af6c620211805 --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipblas/default.nix @@ -0,0 +1,132 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + clr, + gfortran, + hipblas-common, + rocblas, + rocsolver, + rocsparse, + rocprim, + gtest, + lapack-reference, + buildTests ? false, + buildBenchmarks ? false, + buildSamples ? false, + # for passthru.tests + hipblas, +}: + +# Can also use cuBLAS +stdenv.mkDerivation (finalAttrs: { + pname = "hipblas"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildTests [ + "test" + ] + ++ lib.optionals buildBenchmarks [ + "benchmark" + ] + ++ lib.optionals buildSamples [ + "sample" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/hipblas" + "shared" + ]; + hash = "sha256-1+aNDotV5liHBnGddmWtaKYCcsWPxQD3AoEubnghV0M="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/hipblas"; + + postPatch = '' + substituteInPlace library/CMakeLists.txt \ + --replace-fail "find_package(Git REQUIRED)" "" + ''; + + nativeBuildInputs = [ + cmake + rocm-cmake + clr + gfortran + ]; + + propagatedBuildInputs = [ hipblas-common ]; + + buildInputs = [ + rocblas + rocprim + rocsparse + rocsolver + ] + ++ lib.optionals buildTests [ + gtest + ] + ++ lib.optionals (buildTests || buildBenchmarks) [ + lapack-reference + ]; + + cmakeFlags = [ + "-DCMAKE_CXX_COMPILER=${lib.getExe' clr "amdclang++"}" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + "-DBUILD_WITH_SOLVER=ON" + "-DAMDGPU_TARGETS=${rocblas.amdgpu_targets}" + ] + ++ lib.optionals buildTests [ + "-DBUILD_CLIENTS_TESTS=ON" + ] + ++ lib.optionals buildBenchmarks [ + "-DBUILD_CLIENTS_BENCHMARKS=ON" + ] + ++ lib.optionals buildSamples [ + "-DBUILD_CLIENTS_SAMPLES=ON" + ]; + + postInstall = + lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/hipblas-test $test/bin + '' + + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/hipblas-bench $benchmark/bin + '' + + lib.optionalString buildSamples '' + mkdir -p $sample/bin + mv $out/bin/example-* $sample/bin + '' + + lib.optionalString (buildTests || buildBenchmarks || buildSamples) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + passthru.tests.hipblas-tested = hipblas.override { + buildTests = true; + buildBenchmarks = true; + buildSamples = true; + }; + + meta = { + description = "ROCm BLAS marshalling library"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipblas"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/hipfort/default.nix b/pkgs/development/rocm-modules/10/hipfort/default.nix new file mode 100644 index 0000000000000..72519db7b0458 --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipfort/default.nix @@ -0,0 +1,70 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + gfortran, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "hipfort"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "hipfort"; + tag = "rocm-${finalAttrs.version}"; + hash = "sha256-XaB4jauCN41tgD1YHHA2td/yckwfMBemBe/iL0SCxQo="; + }; + + __structuredAttrs = true; + strictDeps = true; + + nativeBuildInputs = [ + cmake + gfortran + ]; + + buildInputs = [ + rocm-cmake + ]; + + cmakeFlags = [ + (lib.cmakeFeature "HIPFORT_COMPILER" "${gfortran}/bin/gfortran") + (lib.cmakeFeature "HIPFORT_AR" "${gfortran.cc}/bin/gcc-ar") + (lib.cmakeFeature "HIPFORT_RANLIB" "${gfortran.cc}/bin/gcc-ranlib") + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") + (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") + (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") + ]; + + postPatch = '' + patchShebangs bin + + substituteInPlace bin/hipfc bin/mymcpu \ + --replace-fail "/bin/cat" "cat" + + substituteInPlace bin/CMakeLists.txt \ + --replace-fail "/bin/mkdir" "mkdir" \ + --replace-fail "/bin/cp" "cp" \ + --replace-fail "/bin/sed" "sed" \ + --replace-fail "/bin/chmod" "chmod" \ + --replace-fail "/bin/ln" "ln" + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "Fortran interfaces for ROCm libraries"; + homepage = "https://github.com/ROCm/hipfort"; + changelog = "https://github.com/ROCm/hipfort/releases/tag/${finalAttrs.src.tag}"; + license = lib.licenses.mit; # mitx11 + mainProgram = "hipfc"; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/hipsolver/default.nix b/pkgs/development/rocm-modules/10/hipsolver/default.nix new file mode 100644 index 0000000000000..c0f548bf7d1e9 --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipsolver/default.nix @@ -0,0 +1,117 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + clr, + gfortran, + rocblas, + rocsolver, + rocsparse, + suitesparse, + gtest, + lapack-reference, + buildTests ? false, + buildBenchmarks ? false, + buildSamples ? false, +}: + +# Can also use cuSOLVER +stdenv.mkDerivation (finalAttrs: { + pname = "hipsolver"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildTests [ + "test" + ] + ++ lib.optionals buildBenchmarks [ + "benchmark" + ] + ++ lib.optionals buildSamples [ + "sample" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/hipsolver" + "shared" + ]; + hash = "sha256-ts5wuXHoBFZ1WMAk8Ir5cucP75G0SMOWmn3FEH04ZEQ="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/hipsolver"; + + nativeBuildInputs = [ + cmake + rocm-cmake + clr + gfortran + ]; + + buildInputs = [ + rocblas + rocsolver + rocsparse + suitesparse + ] + ++ lib.optionals buildTests [ + gtest + ] + ++ lib.optionals (buildTests || buildBenchmarks) [ + lapack-reference + ]; + + cmakeFlags = [ + "-DCMAKE_CXX_COMPILER=hipcc" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + "-DBUILD_WITH_SPARSE=OFF" # FIXME: broken - can't find suitesparse/cholmod, looks fixed in master + ] + ++ lib.optionals buildTests [ + "-DBUILD_CLIENTS_TESTS=ON" + ] + ++ lib.optionals buildBenchmarks [ + "-DBUILD_CLIENTS_BENCHMARKS=ON" + ] + ++ lib.optionals buildSamples [ + "-DBUILD_CLIENTS_SAMPLES=ON" + ]; + + postInstall = + lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/hipsolver-test $test/bin + '' + + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/hipsolver-bench $benchmark/bin + '' + + lib.optionalString buildSamples '' + mkdir -p $sample/bin + mv clients/staging/example-* $sample/bin + patchelf $sample/bin/example-* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" + '' + + lib.optionalString (buildTests || buildBenchmarks) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "ROCm SOLVER marshalling library"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipsolver"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/hipsparse/default.nix b/pkgs/development/rocm-modules/10/hipsparse/default.nix new file mode 100644 index 0000000000000..7057fb8ceb5b0 --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipsparse/default.nix @@ -0,0 +1,148 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + rocsparse, + clr, + gfortran, + gtest, + openmp, + buildTests ? false, + buildBenchmarks ? false, + buildSamples ? false, + gpuTargets ? clr.localGpuTargets or [ ], +}: + +# This can also use cuSPARSE as a backend instead of rocSPARSE +stdenv.mkDerivation (finalAttrs: { + pname = "hipsparse"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildTests [ + "test" + ] + ++ lib.optionals buildSamples [ + "sample" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/hipsparse" + "shared" + ]; + hash = "sha256-E1chG+giFtf02fjutoV4yM2XvrQKjgXRSvxs0NBBkvI="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/hipsparse"; + + nativeBuildInputs = [ + cmake + rocm-cmake + clr + gfortran + ]; + + buildInputs = [ + rocsparse + ] + ++ lib.optionals (buildTests || buildBenchmarks) [ + gtest + ] + ++ lib.optionals (buildTests || buildSamples) [ + openmp + ]; + + cmakeFlags = [ + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + (lib.cmakeBool "BUILD_CLIENTS_TESTS" buildTests) + (lib.cmakeBool "BUILD_CLIENTS_BENCHMARKS" buildBenchmarks) + (lib.cmakeBool "BUILD_CLIENTS_SAMPLES" buildSamples) + ] + ++ lib.optionals (gpuTargets != [ ]) [ + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ]; + + # We have to manually generate the matrices + # CMAKE_MATRICES_DIR seems to be reset in clients/tests/CMakeLists.txt + postPatch = lib.optionalString buildTests '' + mkdir -p matrices + + ln -s ${rocsparse.passthru.matrices.matrix-01}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-02}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-03}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-04}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-05}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-06}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-07}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-08}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-09}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-10}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-11}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-12}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-13}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-14}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-15}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-16}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-17}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-18}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-19}/*.mtx matrices + + # Not used by the original cmake, causes an error + rm matrices/*_b.mtx + + echo "deps/convert.cpp -> deps/mtx2csr" + hipcc deps/convert.cpp -O3 -o deps/mtx2csr + + for mat in $(ls -1 matrices | cut -d "." -f 1); do + echo "mtx2csr: $mat.mtx -> $mat.bin" + deps/mtx2csr matrices/$mat.mtx matrices/$mat.bin + unlink matrices/$mat.mtx + done + + substituteInPlace clients/tests/CMakeLists.txt \ + --replace "\''${PROJECT_BINARY_DIR}/matrices" "/build/source/matrices" + ''; + + postInstall = + lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/hipsparse-test $test/bin + mv /build/source/matrices $test + rmdir $out/bin + '' + + lib.optionalString buildSamples '' + mkdir -p $sample/bin + mv clients/staging/example_* $sample/bin + patchelf --set-rpath $out/lib:${ + lib.makeLibraryPath ( + finalAttrs.buildInputs + ++ [ + clr + gfortran.cc + ] + ) + } $sample/bin/example_* + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "ROCm SPARSE marshalling library"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipsparse"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/hipsparselt/default.nix b/pkgs/development/rocm-modules/10/hipsparselt/default.nix new file mode 100644 index 0000000000000..9cd7c710a6d6c --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipsparselt/default.nix @@ -0,0 +1,123 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + ninja, + git, + pkg-config, + rocm-cmake, + rocm-smi, + clr, + hipsparse, + openmp, + llvm, + msgpack-cxx, + libxml2, + zlib, + zstd, + python3, + python3Packages, + # hipsparselt only supports gfx942/gfx950 + gpuTargets ? (clr.localGpuTargets or clr.gpuTargets), +}: + +let + supportedTargets = ( + lib.lists.intersectLists gpuTargets [ + "gfx942" + "gfx950" + ] + ); + supportsTargetArches = supportedTargets != [ ]; + py = python3.withPackages (ps: [ + ps.pyyaml + ps.setuptools + ps.packaging + ps.nanobind + ps.msgpack + ps.joblib + ]); + compiler = "amdclang++"; +in +stdenv.mkDerivation (finalAttrs: { + pname = "hipsparselt${clr.gpuArchSuffix}"; + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + hash = "sha256-Al/0yZPn/wqtBFQU1FcGoSquDMObk6HQ3D5sSh5biHg="; + sparseCheckout = [ + "projects/hipsparselt" + "projects/hipblaslt/tensilelite" + "projects/hipblaslt/cmake" + "projects/hipblaslt/device-library" + "shared/origami" + ]; + }; + sourceRoot = "${finalAttrs.src.name}/projects/hipsparselt"; + + env.CXX = compiler; + env.ROCM_PATH = "${clr}"; + env.TENSILE_ROCM_ASSEMBLER_PATH = lib.getExe' clr "amdclang++"; + env.TENSILE_GEN_ASSEMBLY_TOOLCHAIN = lib.getExe' clr "amdclang++"; + requiredSystemFeatures = [ "big-parallel" ]; + + __structuredAttrs = true; + strictDeps = true; + + nativeBuildInputs = [ + cmake + ninja + git + pkg-config + rocm-cmake + rocm-smi + py + clr + ]; + + buildInputs = [ + llvm.llvm + clr + rocm-cmake + hipsparse + openmp + msgpack-cxx + libxml2 + python3Packages.msgpack + zlib + zstd + ]; + + cmakeFlags = [ + (lib.cmakeFeature "GPU_TARGETS" (lib.concatStringsSep ";" supportedTargets)) + (lib.cmakeBool "HIPSPARSELT_ENABLE_DEVICE" supportsTargetArches) + (lib.cmakeBool "HIPSPARSELT_ENABLE_CLIENT" false) + (lib.cmakeBool "HIPSPARSELT_BUILD_TESTING" false) + (lib.cmakeBool "HIPSPARSELT_ENABLE_MARKER" false) + (lib.cmakeBool "HIPBLASLT_ENABLE_ROCROLLER" false) + (lib.cmakeBool "HIPBLASLT_ENABLE_MARKER" false) + (lib.cmakeFeature "CMAKE_C_COMPILER" "amdclang") + (lib.cmakeFeature "CMAKE_HIP_COMPILER" compiler) + (lib.cmakeFeature "CMAKE_CXX_COMPILER" compiler) + (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_NANOBIND" "${python3Packages.nanobind.src}") + (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") + (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") + (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") + ]; + + passthru.supportsTargetArches = supportsTargetArches; + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "ROCm hipSPARSELt - a SPARSE marshalling library"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipsparselt"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocalution/default.nix b/pkgs/development/rocm-modules/10/rocalution/default.nix new file mode 100644 index 0000000000000..8fd50e6fc589b --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocalution/default.nix @@ -0,0 +1,122 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + rocblas, + rocsparse, + rocprim, + rocrand, + clr, + pkg-config, + openmp, + openmpi, + gtest, + buildTests ? false, + buildBenchmarks ? false, + buildSamples ? false, + gpuTargets ? clr.localGpuTargets or [ ], # gpuTargets = [ "gfx803" "gfx900:xnack-" "gfx906:xnack-" ... ] +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocalution"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildTests [ + "test" + ] + ++ lib.optionals buildBenchmarks [ + "benchmark" + ] + ++ lib.optionals buildSamples [ + "sample" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocALUTION"; + tag = "rocm-${finalAttrs.version}"; + hash = "sha256-yPM26e8tGNpPScIriAPRb+6OZfdpX4PgE0E9bmc3FkU="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + clr + pkg-config + ]; + + buildInputs = [ + rocblas + rocsparse + rocprim + rocrand + openmp + openmpi + ] + ++ lib.optionals buildTests [ + gtest + ]; + + cmakeFlags = [ + "-DROCM_PATH=${clr}" + "-DHIP_ROOT_DIR=${clr}" + "-DSUPPORT_HIP=ON" + "-DSUPPORT_OMP=ON" + "-DSUPPORT_MPI=ON" + "-DBUILD_CLIENTS_SAMPLES=${if buildSamples then "ON" else "OFF"}" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] + ++ lib.optionals (gpuTargets != [ ]) [ + "-DAMDGPU_TARGETS=${lib.strings.concatStringsSep ";" gpuTargets}" + "-DGPU_TARGETS=${lib.strings.concatStringsSep ";" gpuTargets}" + ] + ++ lib.optionals buildTests [ + "-DBUILD_CLIENTS_TESTS=ON" + ] + ++ lib.optionals buildBenchmarks [ + "-DBUILD_CLIENTS_BENCHMARKS=ON" + ]; + + postInstall = + lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/rocalution-test $test/bin + '' + + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/rocalution-bench $benchmark/bin + '' + + lib.optionalString buildSamples '' + mkdir -p $sample/bin + mv clients/staging/* $sample/bin + rm $sample/bin/rocalution-test || true + rm $sample/bin/rocalution-bench || true + + patchelf --set-rpath \ + $out/lib:${lib.makeLibraryPath (finalAttrs.buildInputs ++ [ clr ])} \ + $sample/bin/* + '' + + lib.optionalString (buildTests || buildBenchmarks) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "Iterative sparse solvers for ROCm"; + homepage = "https://github.com/ROCm/rocALUTION"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocsolver/default.nix b/pkgs/development/rocm-modules/10/rocsolver/default.nix new file mode 100644 index 0000000000000..a70d06e30efc7 --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocsolver/default.nix @@ -0,0 +1,135 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + rocblas, + rocprim, + rocsparse, + clr, + fmt, + gtest, + gfortran, + lapack-reference, + buildTests ? false, + buildBenchmarks ? false, + gpuTargets ? ( + clr.localGpuTargets or [ + "gfx900" + "gfx906" + "gfx908" + "gfx90a" + "gfx942" + "gfx1010" + "gfx1030" + "gfx1100" + "gfx1101" + "gfx1102" + "gfx1150" + "gfx1151" + "gfx1200" + "gfx1201" + ] + ), +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocsolver${clr.gpuArchSuffix}"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildTests [ + "test" + ] + ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocsolver" + "shared" + ]; + hash = "sha256-n+Y8RheA0UYeSfpvOw5zfwe4VAW5hsKjlCXtBceGhf0="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rocsolver"; + + nativeBuildInputs = [ + cmake + # no ninja, it buffers console output and nix times out long periods of no output + rocm-cmake + clr + ] + ++ lib.optionals (buildTests || buildBenchmarks) [ + gfortran + ]; + + buildInputs = [ + # FIXME: rocblas and rocsolver can't build in parallel + # but rocsolver doesn't need rocblas' offload builds at build time + # could we build against a rocblas-minimal? + rocblas + rocprim + rocsparse + fmt + ] + ++ lib.optionals buildTests [ + gtest + ] + ++ lib.optionals (buildTests || buildBenchmarks) [ + lapack-reference + ]; + + cmakeFlags = [ + "-DHIP_CLANG_NUM_PARALLEL_JOBS=4" + "-DCMAKE_VERBOSE_MAKEFILE=ON" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] + ++ lib.optionals (gpuTargets != [ ]) [ + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ] + ++ lib.optionals buildTests [ + "-DBUILD_CLIENTS_TESTS=ON" + ] + ++ lib.optionals buildBenchmarks [ + "-DBUILD_CLIENTS_BENCHMARKS=ON" + ]; + + postInstall = + lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/rocsolver-test $test/bin + '' + + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/rocsolver-bench $benchmark/bin + '' + + lib.optionalString (buildTests || buildBenchmarks) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + requiredSystemFeatures = [ "big-parallel" ]; + + meta = { + description = "ROCm LAPACK implementation"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocsolver"; + license = lib.licenses.bsd2; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + timeout = 14400; # 4 hours + maxSilent = 14400; # 4 hours + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocsparse/default.nix b/pkgs/development/rocm-modules/10/rocsparse/default.nix new file mode 100644 index 0000000000000..db7b0b156850a --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocsparse/default.nix @@ -0,0 +1,159 @@ +{ + lib, + stdenv, + fetchFromGitHub, + fetchzip, + rocmUpdateScript, + cmake, + rocm-cmake, + rocprim, + rocblas, + clr, + gfortran, + gtest, + boost, + python3Packages, + buildTests ? false, + buildBenchmarks ? false, # Seems to depend on tests + gpuTargets ? clr.localGpuTargets or clr.gpuTargets, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocsparse${clr.gpuArchSuffix}"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals (buildTests || buildBenchmarks) [ + "test" + ] + ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocsparse" + "shared" + ]; + hash = "sha256-hkfBTcLig39al2w8zFTSQQnouaou9wlD6VlvIyFTNMg="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rocsparse"; + + nativeBuildInputs = [ + cmake + # no ninja, it buffers console output and nix times out long periods of no output + rocm-cmake + clr + gfortran + ]; + + buildInputs = [ + rocprim + rocblas + ] + ++ lib.optionals (buildTests || buildBenchmarks) [ + gtest + boost + python3Packages.python + python3Packages.pyyaml + ]; + + cmakeFlags = [ + "-DCMAKE_CXX_COMPILER=amdclang++" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] + ++ lib.optionals (gpuTargets != [ ]) [ + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ] + ++ lib.optionals (buildTests || buildBenchmarks) [ + "-DBUILD_CLIENTS_TESTS=ON" + "-DCMAKE_MATRICES_DIR=/build/source/matrices" + "-Dpython=python3" + ] + ++ lib.optionals buildBenchmarks [ + "-DBUILD_CLIENTS_BENCHMARKS=ON" + ]; + + # We have to manually generate the matrices + postPatch = lib.optionalString (buildTests || buildBenchmarks) '' + mkdir -p matrices + + ln -s ${finalAttrs.passthru.matrices.matrix-01}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-02}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-03}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-04}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-05}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-06}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-07}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-08}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-09}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-10}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-11}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-12}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-13}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-14}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-15}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-16}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-17}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-18}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-19}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-20}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-21}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-22}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-23}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-24}/*.mtx matrices + + # Not used by the original cmake, causes an error + rm matrices/*_b.mtx + + echo "deps/convert.cpp -> deps/mtx2csr" + hipcc deps/convert.cpp -O3 -o deps/mtx2csr + + for mat in $(ls -1 matrices | cut -d "." -f 1); do + echo "mtx2csr: $mat.mtx -> $mat.csr" + deps/mtx2csr matrices/$mat.mtx matrices/$mat.csr + unlink matrices/$mat.mtx + done + ''; + + postInstall = + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + cp -a $out/bin/* $benchmark/bin + rm $benchmark/bin/rocsparse-test + '' + + lib.optionalString (buildTests || buildBenchmarks) '' + mkdir -p $test/bin + mv $out/bin/* $test/bin + rm $test/bin/rocsparse-bench || true + mv /build/source/matrices $test + rmdir $out/bin + ''; + + passthru = { + matrices = import ./deps.nix { + inherit fetchzip; + mirror1 = "https://sparse.tamu.edu/MM"; + mirror2 = "https://www.cise.ufl.edu/research/sparse/MM"; + }; + + updateScript = rocmUpdateScript { inherit finalAttrs; }; + }; + + meta = { + description = "ROCm SPARSE implementation"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocsparse"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/rocsparse/deps.nix b/pkgs/development/rocm-modules/10/rocsparse/deps.nix new file mode 100644 index 0000000000000..00096ca4bf7ba --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocsparse/deps.nix @@ -0,0 +1,223 @@ +{ + fetchzip, + mirror1, + mirror2, +}: + +{ + matrix-01 = fetchzip { + hash = "sha256-AHur5ZIDZTFRrO2GV0ieXrffq4KUiGWiZ59pv0fUtEQ="; + + urls = [ + "${mirror1}/SNAP/amazon0312.tar.gz" + "${mirror2}/SNAP/amazon0312.tar.gz" + ]; + }; + + matrix-02 = fetchzip { + hash = "sha256-0rSxaN4lQcdaCLsvlgicG70FXUxXeERPiEmQ4MzbRdE="; + + urls = [ + "${mirror1}/Muite/Chebyshev4.tar.gz" + "${mirror2}/Muite/Chebyshev4.tar.gz" + ]; + }; + + matrix-03 = fetchzip { + hash = "sha256-hDzDWDUnHEyFedX/tMNq83ZH8uWyM4xtZYUUAD3rizo="; + + urls = [ + "${mirror1}/FEMLAB/sme3Dc.tar.gz" + "${mirror2}/FEMLAB/sme3Dc.tar.gz" + ]; + }; + + matrix-04 = fetchzip { + hash = "sha256-GmN2yOt/MoX01rKe05aTyB3ypUP4YbQGOITZ0BqPmC0="; + + urls = [ + "${mirror1}/Williams/webbase-1M.tar.gz" + "${mirror2}/Williams/webbase-1M.tar.gz" + ]; + }; + + matrix-05 = fetchzip { + hash = "sha256-gQNjfVyWzNM9RwImJGhkhahRmZz74LzDs1oijL7mI7k="; + + urls = [ + "${mirror1}/Williams/mac_econ_fwd500.tar.gz" + "${mirror2}/Williams/mac_econ_fwd500.tar.gz" + ]; + }; + + matrix-06 = fetchzip { + hash = "sha256-87cdZjntNcTuz5BtO59irhcuRbPllWSbhCEX3Td02qc="; + + urls = [ + "${mirror1}/Williams/mc2depi.tar.gz" + "${mirror2}/Williams/mc2depi.tar.gz" + ]; + }; + + matrix-07 = fetchzip { + hash = "sha256-WRamuJX3D8Tm+k0q67RjUDG3DeNAxhKiaPkk5afY5eU="; + + urls = [ + "${mirror1}/Bova/rma10.tar.gz" + "${mirror2}/Bova/rma10.tar.gz" + ]; + }; + + matrix-08 = fetchzip { + hash = "sha256-5dhkm293Mc3lzakKxHy5W5XIn4Rw+gihVh7gyrjEHXo="; + + urls = [ + "${mirror1}/JGD_BIBD/bibd_22_8.tar.gz" + "${mirror2}/JGD_BIBD/bibd_22_8.tar.gz" + ]; + }; + + matrix-09 = fetchzip { + hash = "sha256-czjLWCjXAjZCk5TGYHaEkwSAzQu3TQ3QyB6eNKR4G88="; + + urls = [ + "${mirror1}/Hamm/scircuit.tar.gz" + "${mirror2}/Hamm/scircuit.tar.gz" + ]; + }; + + matrix-10 = fetchzip { + hash = "sha256-bYuLnJViAIcIejAkh69/bsNAVIDU4wfTLtD+nmHd6FM="; + + urls = [ + "${mirror1}/Sandia/ASIC_320k.tar.gz" + "${mirror2}/Sandia/ASIC_320k.tar.gz" + ]; + }; + + matrix-11 = fetchzip { + hash = "sha256-aDwn8P1khYjo2Agbq5m9ZBInJUxf/knJNvyptt0fak0="; + + urls = [ + "${mirror1}/GHS_psdef/bmwcra_1.tar.gz" + "${mirror2}/GHS_psdef/bmwcra_1.tar.gz" + ]; + }; + + matrix-12 = fetchzip { + hash = "sha256-8OJqA/byhlAZd869TPUzZFdsOiwOoRGfKyhM+RMjXoY="; + + urls = [ + "${mirror1}/HB/nos1.tar.gz" + "${mirror2}/HB/nos1.tar.gz" + ]; + }; + + matrix-13 = fetchzip { + hash = "sha256-FS0rKqmg+uHwsM/yGfQLBdd7LH/rUrdutkNGBD/Mh1I="; + + urls = [ + "${mirror1}/HB/nos2.tar.gz" + "${mirror2}/HB/nos2.tar.gz" + ]; + }; + + matrix-14 = fetchzip { + hash = "sha256-DANnlrNJikrI7Pst9vRedtbuxepyHmCIu2yhltc4Qcs="; + + urls = [ + "${mirror1}/HB/nos3.tar.gz" + "${mirror2}/HB/nos3.tar.gz" + ]; + }; + + matrix-15 = fetchzip { + hash = "sha256-21mUgqjWGUfYgiWwSrKh9vH8Vdt3xzcefmqYNYRpxiY="; + + urls = [ + "${mirror1}/HB/nos4.tar.gz" + "${mirror2}/HB/nos4.tar.gz" + ]; + }; + + matrix-16 = fetchzip { + hash = "sha256-FOuXvGqBBFNkVS6cexmkluret54hCfCOdK+DOZllE4c="; + + urls = [ + "${mirror1}/HB/nos5.tar.gz" + "${mirror2}/HB/nos5.tar.gz" + ]; + }; + + matrix-17 = fetchzip { + hash = "sha256-+7NI1rA/qQxYPpjXKHvAaCZ+LSaAJ4xuJvMRMBEUYxg="; + + urls = [ + "${mirror1}/HB/nos6.tar.gz" + "${mirror2}/HB/nos6.tar.gz" + ]; + }; + + matrix-18 = fetchzip { + hash = "sha256-q3NxJjbwGGcFiQ9nhWfUKgZmdVwCfPmgQoqy0AqOsNc="; + + urls = [ + "${mirror1}/HB/nos7.tar.gz" + "${mirror2}/HB/nos7.tar.gz" + ]; + }; + + matrix-19 = fetchzip { + hash = "sha256-0GAN6qmVfD+tprIigzuUUUwm5KVhkN9X65wMEvFltDY="; + + urls = [ + "${mirror1}/DNVS/shipsec1.tar.gz" + "${mirror2}/DNVS/shipsec1.tar.gz" + ]; + }; + + matrix-20 = fetchzip { + hash = "sha256-f28Du/Urxsiq5NkRmRO10Zz9vvGRjEchquzHzbZpZ7U="; + + urls = [ + "${mirror1}/Cote/mplate.tar.gz" + "${mirror2}/Cote/mplate.tar.gz" + ]; + }; + + matrix-21 = fetchzip { + hash = "sha256-O+Wy0NfCU1hVUOfNR1dJpvDHLBwwa301IRJDrQJnhak="; + + urls = [ + "${mirror1}/Bai/qc2534.tar.gz" + "${mirror2}/Bai/qc2534.tar.gz" + ]; + }; + + matrix-22 = fetchzip { + hash = "sha256-oxMnt8U5Cf1ILWcBdU6W9jdSMMm+U6bIVl8nm3n3+OA="; + + urls = [ + "${mirror1}/Chevron/Chevron2.tar.gz" + "${mirror2}/Chevron/Chevron2.tar.gz" + ]; + }; + + matrix-23 = fetchzip { + hash = "sha256-MFD9BxFI/3IS7yatW121BAI04fbqrXpgYDT5UKjeKcU="; + + urls = [ + "${mirror1}/Chevron/Chevron3.tar.gz" + "${mirror2}/Chevron/Chevron3.tar.gz" + ]; + }; + + matrix-24 = fetchzip { + hash = "sha256-ikS8O51pe1nt3BNyhvfvqCbVL0+bg/da9bqGqeBDkTg="; + + urls = [ + "${mirror1}/Chevron/Chevron4.tar.gz" + "${mirror2}/Chevron/Chevron4.tar.gz" + ]; + }; +} diff --git a/pkgs/development/rocm-modules/10/rocwmma/0000-dont-fetch-googletest.patch b/pkgs/development/rocm-modules/10/rocwmma/0000-dont-fetch-googletest.patch new file mode 100644 index 0000000000000..fa47a3c42249b --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocwmma/0000-dont-fetch-googletest.patch @@ -0,0 +1,35 @@ +diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt +index 0d00883..86ce282 100644 +--- a/test/CMakeLists.txt ++++ b/test/CMakeLists.txt +@@ -30,30 +30,6 @@ cmake_dependent_option( ROCWMMA_BUILD_VALIDATION_TESTS "Build validation tests" + cmake_dependent_option( ROCWMMA_BUILD_BENCHMARK_TESTS "Build benchmarking tests" OFF "ROCWMMA_BUILD_TESTS" OFF ) + cmake_dependent_option( ROCWMMA_BUILD_EXTENDED_TESTS "Build extended test parameter coverage" OFF "ROCWMMA_BUILD_TESTS" OFF ) + +-# Test/benchmark requires additional dependencies +-include( FetchContent ) +- +-FetchContent_Declare( +- googletest +- GIT_REPOSITORY https://github.com/google/googletest.git +- GIT_TAG release-1.12.1 +-) +-FetchContent_GetProperties(googletest) +-if(NOT googletest_POPULATED) +- +- # Fetch the content using default details +- FetchContent_Populate(googletest) +- # Save the shared libs setting, then force to static libs +- set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS}) +- set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build SHARED libraries" FORCE) +- +- # Add gtest targets as static libs +- add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) +- +- # Restore shared libs setting +- set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD} CACHE INTERNAL "Build SHARED libraries" FORCE) +-endif() +- + set(ROCWMMA_TEST_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) + set(ROCWMMA_COMMON_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hip_device.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rocwmma_gtest_main.cpp) diff --git a/pkgs/development/rocm-modules/10/rocwmma/default.nix b/pkgs/development/rocm-modules/10/rocwmma/default.nix new file mode 100644 index 0000000000000..454cced2a0fdd --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocwmma/default.nix @@ -0,0 +1,116 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + rocm-smi, + clr, + openmp, + gtest, + rocblas, + buildTests ? false, # Will likely fail building because wavefront shifts are not supported for certain archs + buildExtendedTests ? false, + buildBenchmarks ? false, + buildSamples ? false, + gpuTargets ? clr.localGpuTargets or [ ], +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocwmma"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals (buildTests || buildBenchmarks) [ + "test" + ] + ++ lib.optionals buildBenchmarks [ + "benchmark" + ] + ++ lib.optionals buildSamples [ + "sample" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocwmma" + "shared" + ]; + hash = "sha256-eoF8a7zknpgvDOSDzolOrdtszUJ5tC7Ur2sRShiQEO0="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/rocwmma"; + + patches = lib.optionals (buildTests || buildBenchmarks) [ + ./0000-dont-fetch-googletest.patch + ]; + + nativeBuildInputs = [ + cmake + rocm-cmake + clr + ]; + + buildInputs = [ + openmp + ] + ++ lib.optionals (buildTests || buildBenchmarks) [ + rocm-smi + gtest + rocblas + ]; + + cmakeFlags = [ + "-DROCWMMA_BUILD_TESTS=${if buildTests || buildBenchmarks then "ON" else "OFF"}" + "-DROCWMMA_BUILD_SAMPLES=${if buildSamples then "ON" else "OFF"}" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] + ++ lib.optionals (gpuTargets != [ ]) [ + "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ] + ++ lib.optionals buildExtendedTests [ + "-DROCWMMA_BUILD_EXTENDED_TESTS=ON" + ] + ++ lib.optionals buildBenchmarks [ + "-DROCWMMA_BUILD_BENCHMARK_TESTS=ON" + "-DROCWMMA_BENCHMARK_WITH_ROCBLAS=ON" + ]; + + postInstall = + lib.optionalString (buildTests || buildBenchmarks) '' + mkdir -p $test/bin + mv $out/bin/{*_test,*-validate} $test/bin + '' + + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/*-bench $benchmark/bin + '' + + lib.optionalString buildSamples '' + mkdir -p $sample/bin + mv $out/bin/sgemmv $sample/bin + mv $out/bin/simple_gemm $sample/bin + mv $out/bin/simple_dlrm $sample/bin + '' + + lib.optionalString (buildTests || buildBenchmarks || buildSamples) '' + rm -rf $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "Mixed precision matrix multiplication and accumulation"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocwmma"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) From 9e03b9b4e2f31b4eb5157c73b640120045b79f8f Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:14 -0700 Subject: [PATCH 49/79] rocmPackages_10.rocsparse: init at 10.1 Update the rocmPackages.rocsparse copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. Source/version bump only. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ pkgs/development/rocm-modules/10/rocsparse/default.nix | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 3154983f16e31..568f502b69f2c 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -105,6 +105,8 @@ let rocprim = self.callPackage ./rocprim { }; + rocsparse = self.callPackage ./rocsparse { }; + rocthrust = self.callPackage ./rocthrust { }; rocrand = self.callPackage ./rocrand { }; diff --git a/pkgs/development/rocm-modules/10/rocsparse/default.nix b/pkgs/development/rocm-modules/10/rocsparse/default.nix index db7b0b156850a..a25210f1c7883 100644 --- a/pkgs/development/rocm-modules/10/rocsparse/default.nix +++ b/pkgs/development/rocm-modules/10/rocsparse/default.nix @@ -20,7 +20,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocsparse${clr.gpuArchSuffix}"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -35,12 +35,12 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/rocsparse" "shared" ]; - hash = "sha256-hkfBTcLig39al2w8zFTSQQnouaou9wlD6VlvIyFTNMg="; + hash = "sha256-CdUH85q4ZwZh+1OwzOMvLhE0LSwkAl4RzBSjhY1xuGo="; }; sourceRoot = "${finalAttrs.src.name}/projects/rocsparse"; From 10bc4fe214a5a02650557869710c9ce3a3be745e Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:14 -0700 Subject: [PATCH 50/79] rocmPackages_10.hipsparse: init at 10.1 Update the rocmPackages.hipsparse copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From the mass bump: - hipblas, hipsparse: new find_package(Python3 REQUIRED) -> add python3. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ pkgs/development/rocm-modules/10/hipsparse/default.nix | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 568f502b69f2c..62e738541711e 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -123,6 +123,8 @@ let hipcub = self.callPackage ./hipcub { }; + hipsparse = self.callPackage ./hipsparse { }; + hipfft = self.callPackage ./hipfft { }; tensile = pyPackages.callPackage ./tensile { diff --git a/pkgs/development/rocm-modules/10/hipsparse/default.nix b/pkgs/development/rocm-modules/10/hipsparse/default.nix index 7057fb8ceb5b0..c26c9b742c8d5 100644 --- a/pkgs/development/rocm-modules/10/hipsparse/default.nix +++ b/pkgs/development/rocm-modules/10/hipsparse/default.nix @@ -5,6 +5,7 @@ rocmUpdateScript, cmake, rocm-cmake, + python3, rocsparse, clr, gfortran, @@ -19,7 +20,7 @@ # This can also use cuSPARSE as a backend instead of rocSPARSE stdenv.mkDerivation (finalAttrs: { pname = "hipsparse"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -34,18 +35,20 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/hipsparse" "shared" ]; - hash = "sha256-E1chG+giFtf02fjutoV4yM2XvrQKjgXRSvxs0NBBkvI="; + hash = "sha256-kvDzX1SnvumRgj+Va+zFPbU93dZttIE/ovL4BPG2Xi0="; }; sourceRoot = "${finalAttrs.src.name}/projects/hipsparse"; nativeBuildInputs = [ cmake rocm-cmake + # CMakeLists.txt does find_package(Python3 REQUIRED) + python3 clr gfortran ]; From df9c71a953befc9ed75fa2154add0cb1baaf9230 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:15 -0700 Subject: [PATCH 51/79] rocmPackages_10.rocsolver: init at 10.1 Update the rocmPackages.rocsolver copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.{hipsolver,rocsolver}: link openblas-backed LAPACK": ROCm 10 hipSOLVER/rocSOLVER link a CPU-side BLAS/LAPACK. Upstream defaults to git-clone+build a static OpenBLAS at configure (blocked in the sandbox), so set HIPSOLVER_INTERNAL_LAPACK_BUILD=OFF and provide the openblas-backed 'blas'/'lapack' wrappers (LP64). Deliberately NOT lapack-reference: its libblas.so.3 carries ILP64 (_64_) symbols that collide with numpy's openblas in one process (e.g. 'import torch' -> undefined symbol cherk_64_). Discover LAPACK in CMake MODULE mode, since the openblas wrappers ship no LAPACKConfig.cmake. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ .../rocm-modules/10/rocsolver/default.nix | 14 +++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 62e738541711e..827b01578b639 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -140,6 +140,8 @@ let rocblas_base = self.callPackage ./rocblas/base.nix { }; rocblas = self.callPackage ./rocblas { }; + rocsolver = self.callPackage ./rocsolver { }; + hipblas-common = self.callPackage ./hipblas-common { }; hipblaslt = self.callPackage ./hipblaslt { }; diff --git a/pkgs/development/rocm-modules/10/rocsolver/default.nix b/pkgs/development/rocm-modules/10/rocsolver/default.nix index a70d06e30efc7..d9c3a00ad3392 100644 --- a/pkgs/development/rocm-modules/10/rocsolver/default.nix +++ b/pkgs/development/rocm-modules/10/rocsolver/default.nix @@ -12,7 +12,8 @@ fmt, gtest, gfortran, - lapack-reference, + blas, + lapack, buildTests ? false, buildBenchmarks ? false, gpuTargets ? ( @@ -37,7 +38,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocsolver${clr.gpuArchSuffix}"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -52,12 +53,12 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/rocsolver" "shared" ]; - hash = "sha256-n+Y8RheA0UYeSfpvOw5zfwe4VAW5hsKjlCXtBceGhf0="; + hash = "sha256-hqCOQ5frigvHc21MBnjPJff6pQNm+JjzelwO8NR9dXo="; }; sourceRoot = "${finalAttrs.src.name}/projects/rocsolver"; @@ -84,7 +85,10 @@ stdenv.mkDerivation (finalAttrs: { gtest ] ++ lib.optionals (buildTests || buildBenchmarks) [ - lapack-reference + # openblas-backed wrappers, not lapack-reference (avoids the ILP64 libblas.so.3 + # soname collision — see hipsolver). + blas + lapack ]; cmakeFlags = [ From 4424ea1ce89ab95d64457749b26423c8dd6e57b9 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:16 -0700 Subject: [PATCH 52/79] rocmPackages_10.hipblas: init at 10.1 Update the rocmPackages.hipblas copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From the mass bump: - hipblas, hipsparse: new find_package(Python3 REQUIRED) -> add python3. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ pkgs/development/rocm-modules/10/hipblas/default.nix | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 827b01578b639..636d8fd1935db 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -144,6 +144,8 @@ let hipblas-common = self.callPackage ./hipblas-common { }; + hipblas = self.callPackage ./hipblas { }; + hipblaslt = self.callPackage ./hipblaslt { }; half = self.callPackage ./half { }; diff --git a/pkgs/development/rocm-modules/10/hipblas/default.nix b/pkgs/development/rocm-modules/10/hipblas/default.nix index af6c620211805..0915099dddba8 100644 --- a/pkgs/development/rocm-modules/10/hipblas/default.nix +++ b/pkgs/development/rocm-modules/10/hipblas/default.nix @@ -5,6 +5,7 @@ rocmUpdateScript, cmake, rocm-cmake, + python3, clr, gfortran, hipblas-common, @@ -24,7 +25,7 @@ # Can also use cuBLAS stdenv.mkDerivation (finalAttrs: { pname = "hipblas"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -42,12 +43,12 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/hipblas" "shared" ]; - hash = "sha256-1+aNDotV5liHBnGddmWtaKYCcsWPxQD3AoEubnghV0M="; + hash = "sha256-VUM+5qu8VK6fUbKPCVMm0PtmuZhJZYfEI6aKJEV9Vwg="; }; sourceRoot = "${finalAttrs.src.name}/projects/hipblas"; @@ -59,6 +60,8 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ cmake rocm-cmake + # CMakeLists.txt does find_package(Python3 REQUIRED) + python3 clr gfortran ]; From 9b39b486a5ec0e092303e51ab07163b0a05c8611 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:16 -0700 Subject: [PATCH 53/79] rocmPackages_10.hipsolver: init at 10.1 Update the rocmPackages.hipsolver copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.{hipsolver,rocsolver}: link openblas-backed LAPACK": ROCm 10 hipSOLVER/rocSOLVER link a CPU-side BLAS/LAPACK. Upstream defaults to git-clone+build a static OpenBLAS at configure (blocked in the sandbox), so set HIPSOLVER_INTERNAL_LAPACK_BUILD=OFF and provide the openblas-backed 'blas'/'lapack' wrappers (LP64). Deliberately NOT lapack-reference: its libblas.so.3 carries ILP64 (_64_) symbols that collide with numpy's openblas in one process (e.g. 'import torch' -> undefined symbol cherk_64_). Discover LAPACK in CMake MODULE mode, since the openblas wrappers ship no LAPACKConfig.cmake. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ .../rocm-modules/10/hipsolver/default.nix | 20 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 636d8fd1935db..440c12459bacb 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -142,6 +142,8 @@ let rocsolver = self.callPackage ./rocsolver { }; + hipsolver = self.callPackage ./hipsolver { }; + hipblas-common = self.callPackage ./hipblas-common { }; hipblas = self.callPackage ./hipblas { }; diff --git a/pkgs/development/rocm-modules/10/hipsolver/default.nix b/pkgs/development/rocm-modules/10/hipsolver/default.nix index c0f548bf7d1e9..cfc00ed7b406a 100644 --- a/pkgs/development/rocm-modules/10/hipsolver/default.nix +++ b/pkgs/development/rocm-modules/10/hipsolver/default.nix @@ -12,7 +12,8 @@ rocsparse, suitesparse, gtest, - lapack-reference, + blas, + lapack, buildTests ? false, buildBenchmarks ? false, buildSamples ? false, @@ -21,7 +22,7 @@ # Can also use cuSOLVER stdenv.mkDerivation (finalAttrs: { pname = "hipsolver"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -39,12 +40,12 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/hipsolver" "shared" ]; - hash = "sha256-ts5wuXHoBFZ1WMAk8Ir5cucP75G0SMOWmn3FEH04ZEQ="; + hash = "sha256-Djncqth/JEH1ko0iVvx3WdvK2UeK/Ywuwca9y4q2Xvg="; }; sourceRoot = "${finalAttrs.src.name}/projects/hipsolver"; @@ -60,12 +61,13 @@ stdenv.mkDerivation (finalAttrs: { rocsolver rocsparse suitesparse + # CPU LAPACK for geev. Not lapack-reference: its ILP64 libblas.so.3 breaks + # `import torch` ("undefined symbol: cherk_64_"). + blas + lapack ] ++ lib.optionals buildTests [ gtest - ] - ++ lib.optionals (buildTests || buildBenchmarks) [ - lapack-reference ]; cmakeFlags = [ @@ -76,6 +78,10 @@ stdenv.mkDerivation (finalAttrs: { "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_INCLUDEDIR=include" "-DBUILD_WITH_SPARSE=OFF" # FIXME: broken - can't find suitesparse/cholmod, looks fixed in master + # Don't clone and build OpenBLAS at configure time. + "-DHIPSOLVER_INTERNAL_LAPACK_BUILD=OFF" + # The openblas-backed wrappers ship no LAPACKConfig.cmake. + "-DHIPSOLVER_FIND_PACKAGE_LAPACK_CONFIG=OFF" ] ++ lib.optionals buildTests [ "-DBUILD_CLIENTS_TESTS=ON" From 07f20883f5f18bdc8629e1d2a569648e122c6404 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:17 -0700 Subject: [PATCH 54/79] rocmPackages_10.rocalution: init at 10.1 Update the rocmPackages.rocalution copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From the mass bump: - rocalution, rpp: moved into the rocm-libraries monorepo (sparse Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ .../rocm-modules/10/rocalution/default.nix | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 440c12459bacb..64a17f94a5bc8 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -142,6 +142,8 @@ let rocsolver = self.callPackage ./rocsolver { }; + rocalution = self.callPackage ./rocalution { }; + hipsolver = self.callPackage ./hipsolver { }; hipblas-common = self.callPackage ./hipblas-common { }; diff --git a/pkgs/development/rocm-modules/10/rocalution/default.nix b/pkgs/development/rocm-modules/10/rocalution/default.nix index 8fd50e6fc589b..a08359d89b146 100644 --- a/pkgs/development/rocm-modules/10/rocalution/default.nix +++ b/pkgs/development/rocm-modules/10/rocalution/default.nix @@ -22,7 +22,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocalution"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -39,10 +39,16 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; - repo = "rocALUTION"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-yPM26e8tGNpPScIriAPRb+6OZfdpX4PgE0E9bmc3FkU="; + # rocALUTION moved into the rocm-libraries monorepo during the TheRock 7.x series + repo = "rocm-libraries"; + tag = "therock-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rocalution" + "shared" + ]; + hash = "sha256-peElY9WF9GbITUkeUwW0Ys8UYrUeXQ3Go7uWYGvMZBY="; }; + sourceRoot = "${finalAttrs.src.name}/projects/rocalution"; nativeBuildInputs = [ cmake From 998367b9b3d6f881c2160cffdbbab7e504cf1038 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:17 -0700 Subject: [PATCH 55/79] rocmPackages_10.rocwmma: init at 10.1 Update the rocmPackages.rocwmma copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.rocwmma: rocm_smi -> amd_smi, system googletest": ROCm 10 rocWMMA's benchmark tests find_package(amd_smi) (was rocm_smi) and replaced the hardcoded FetchContent(googletest) with a ROCWMMA_USE_SYSTEM_GOOGLETEST option. Switch to amdsmi, enable the system-gtest option, and drop the obsolete 0000-dont-fetch-googletest.patch. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ .../rocwmma/0000-dont-fetch-googletest.patch | 35 ------------------- .../rocm-modules/10/rocwmma/default.nix | 19 +++++----- 3 files changed, 12 insertions(+), 44 deletions(-) delete mode 100644 pkgs/development/rocm-modules/10/rocwmma/0000-dont-fetch-googletest.patch diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 64a17f94a5bc8..1238c93ec6ddd 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -142,6 +142,8 @@ let rocsolver = self.callPackage ./rocsolver { }; + rocwmma = self.callPackage ./rocwmma { }; + rocalution = self.callPackage ./rocalution { }; hipsolver = self.callPackage ./hipsolver { }; diff --git a/pkgs/development/rocm-modules/10/rocwmma/0000-dont-fetch-googletest.patch b/pkgs/development/rocm-modules/10/rocwmma/0000-dont-fetch-googletest.patch deleted file mode 100644 index fa47a3c42249b..0000000000000 --- a/pkgs/development/rocm-modules/10/rocwmma/0000-dont-fetch-googletest.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt -index 0d00883..86ce282 100644 ---- a/test/CMakeLists.txt -+++ b/test/CMakeLists.txt -@@ -30,30 +30,6 @@ cmake_dependent_option( ROCWMMA_BUILD_VALIDATION_TESTS "Build validation tests" - cmake_dependent_option( ROCWMMA_BUILD_BENCHMARK_TESTS "Build benchmarking tests" OFF "ROCWMMA_BUILD_TESTS" OFF ) - cmake_dependent_option( ROCWMMA_BUILD_EXTENDED_TESTS "Build extended test parameter coverage" OFF "ROCWMMA_BUILD_TESTS" OFF ) - --# Test/benchmark requires additional dependencies --include( FetchContent ) -- --FetchContent_Declare( -- googletest -- GIT_REPOSITORY https://github.com/google/googletest.git -- GIT_TAG release-1.12.1 --) --FetchContent_GetProperties(googletest) --if(NOT googletest_POPULATED) -- -- # Fetch the content using default details -- FetchContent_Populate(googletest) -- # Save the shared libs setting, then force to static libs -- set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS}) -- set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build SHARED libraries" FORCE) -- -- # Add gtest targets as static libs -- add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) -- -- # Restore shared libs setting -- set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD} CACHE INTERNAL "Build SHARED libraries" FORCE) --endif() -- - set(ROCWMMA_TEST_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) - set(ROCWMMA_COMMON_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hip_device.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rocwmma_gtest_main.cpp) diff --git a/pkgs/development/rocm-modules/10/rocwmma/default.nix b/pkgs/development/rocm-modules/10/rocwmma/default.nix index 454cced2a0fdd..bf9c553de5115 100644 --- a/pkgs/development/rocm-modules/10/rocwmma/default.nix +++ b/pkgs/development/rocm-modules/10/rocwmma/default.nix @@ -5,7 +5,7 @@ rocmUpdateScript, cmake, rocm-cmake, - rocm-smi, + amdsmi, clr, openmp, gtest, @@ -19,7 +19,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocwmma"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -37,19 +37,15 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/rocwmma" "shared" ]; - hash = "sha256-eoF8a7zknpgvDOSDzolOrdtszUJ5tC7Ur2sRShiQEO0="; + hash = "sha256-RvhZH4VVJLpj9ThF3MuvUPsAC7Y4BBTdIAReq7NyX3A="; }; sourceRoot = "${finalAttrs.src.name}/projects/rocwmma"; - patches = lib.optionals (buildTests || buildBenchmarks) [ - ./0000-dont-fetch-googletest.patch - ]; - nativeBuildInputs = [ cmake rocm-cmake @@ -60,7 +56,8 @@ stdenv.mkDerivation (finalAttrs: { openmp ] ++ lib.optionals (buildTests || buildBenchmarks) [ - rocm-smi + # rocWMMA's benchmark tests do find_package(amd_smi) + amdsmi gtest rocblas ]; @@ -74,6 +71,10 @@ stdenv.mkDerivation (finalAttrs: { "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_INCLUDEDIR=include" ] + ++ lib.optionals (buildTests || buildBenchmarks) [ + # Use nixpkgs gtest instead of the upstream FetchContent googletest download + "-DROCWMMA_USE_SYSTEM_GOOGLETEST=ON" + ] ++ lib.optionals (gpuTargets != [ ]) [ "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" ] From f2fe03b7459193df490c64912612ce5b9f8e51d4 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:18 -0700 Subject: [PATCH 56/79] rocmPackages_10.hipfort: init at 10.1.0 Update the rocmPackages.hipfort copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.hipfort: 7.2.4 -> 10.1.0": hipfort keeps the three-component rocm-X.Y.Z tag scheme (rocm-10.1.0), so it is not derived from the therock-X.Y monorepo tags like the rest of the set. hipfort 10.x dropped the bin/ wrapper scripts (hipfc, mymcpu) entirely and is now a pure Fortran interface library, so the obsolete bin/ postPatch and meta.mainProgram are removed. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ .../rocm-modules/10/hipfort/default.nix | 19 ++----------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 1238c93ec6ddd..0cbb030a9d7a4 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -125,6 +125,8 @@ let hipsparse = self.callPackage ./hipsparse { }; + hipfort = self.callPackage ./hipfort { }; + hipfft = self.callPackage ./hipfft { }; tensile = pyPackages.callPackage ./tensile { diff --git a/pkgs/development/rocm-modules/10/hipfort/default.nix b/pkgs/development/rocm-modules/10/hipfort/default.nix index 72519db7b0458..c8430de356c89 100644 --- a/pkgs/development/rocm-modules/10/hipfort/default.nix +++ b/pkgs/development/rocm-modules/10/hipfort/default.nix @@ -10,13 +10,13 @@ stdenv.mkDerivation (finalAttrs: { pname = "hipfort"; - version = "7.2.4"; + version = "10.1.0"; src = fetchFromGitHub { owner = "ROCm"; repo = "hipfort"; tag = "rocm-${finalAttrs.version}"; - hash = "sha256-XaB4jauCN41tgD1YHHA2td/yckwfMBemBe/iL0SCxQo="; + hash = "sha256-/Q/wVXkJJjDSsqVRSdtMPyOw72SRDawxnyv4BY0be8g="; }; __structuredAttrs = true; @@ -42,20 +42,6 @@ stdenv.mkDerivation (finalAttrs: { (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") ]; - postPatch = '' - patchShebangs bin - - substituteInPlace bin/hipfc bin/mymcpu \ - --replace-fail "/bin/cat" "cat" - - substituteInPlace bin/CMakeLists.txt \ - --replace-fail "/bin/mkdir" "mkdir" \ - --replace-fail "/bin/cp" "cp" \ - --replace-fail "/bin/sed" "sed" \ - --replace-fail "/bin/chmod" "chmod" \ - --replace-fail "/bin/ln" "ln" - ''; - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; meta = { @@ -63,7 +49,6 @@ stdenv.mkDerivation (finalAttrs: { homepage = "https://github.com/ROCm/hipfort"; changelog = "https://github.com/ROCm/hipfort/releases/tag/${finalAttrs.src.tag}"; license = lib.licenses.mit; # mitx11 - mainProgram = "hipfc"; teams = [ lib.teams.rocm ]; platforms = lib.platforms.linux; }; From 3988705038b6ec26ec88862e1d4567e8cc1b5117 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:19 -0700 Subject: [PATCH 57/79] rocmPackages_10.hipsparselt: init at 10.1 Update the rocmPackages.hipsparselt copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.hipsparselt: add hipblaslt device-library/stinkytofu sources": ROCm 10 hipsparselt configures hipBLASLt's CMakeLists (for rocisa), which needs library/include/hipblaslt-version.h.in and add_subdirectory's shared/stinkytofu. Extend the sparse checkout. Revised during the split review: Drop the stinkytofu clang-tidy workaround: therock-10.1 guards its include(ClangTidy) with ENABLE_CLANG_TIDY. Drop the HOME override; disabling the helper cache is enough, as hipBLASLt shows. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 ++ .../rocm-modules/10/hipsparselt/default.nix | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 0cbb030a9d7a4..709e07e947f7e 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -156,6 +156,8 @@ let hipblaslt = self.callPackage ./hipblaslt { }; + hipsparselt = self.callPackage ./hipsparselt { }; + half = self.callPackage ./half { }; # Even if config.rocmSupport is false we need rocmSupport true diff --git a/pkgs/development/rocm-modules/10/hipsparselt/default.nix b/pkgs/development/rocm-modules/10/hipsparselt/default.nix index 9cd7c710a6d6c..297f261ce9557 100644 --- a/pkgs/development/rocm-modules/10/hipsparselt/default.nix +++ b/pkgs/development/rocm-modules/10/hipsparselt/default.nix @@ -43,19 +43,23 @@ let in stdenv.mkDerivation (finalAttrs: { pname = "hipsparselt${clr.gpuArchSuffix}"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-Al/0yZPn/wqtBFQU1FcGoSquDMObk6HQ3D5sSh5biHg="; + tag = "therock-${finalAttrs.version}"; + hash = "sha256-pJvsJv007YCXR4YiOq3qFWlcDFoGxwKovNSk0Mjxnes="; sparseCheckout = [ "projects/hipsparselt" "projects/hipblaslt/tensilelite" "projects/hipblaslt/cmake" "projects/hipblaslt/device-library" + # hipBLASLt's CMakeLists, configured for rocisa, needs hipblaslt-version.h.in. + "projects/hipblaslt/library/include" "shared/origami" + # rocisa (tensilelite/rocisa/CMakeLists.txt) add_subdirectory's stinkytofu + "shared/stinkytofu" ]; }; sourceRoot = "${finalAttrs.src.name}/projects/hipsparselt"; @@ -64,6 +68,9 @@ stdenv.mkDerivation (finalAttrs: { env.ROCM_PATH = "${clr}"; env.TENSILE_ROCM_ASSEMBLER_PATH = lib.getExe' clr "amdclang++"; env.TENSILE_GEN_ASSEMBLY_TOOLCHAIN = lib.getExe' clr "amdclang++"; + # The tensilelite helper cache defaults to the unwritable $HOME/.tensile. + env.TENSILE_DISABLE_HELPER_CACHE = "1"; + requiredSystemFeatures = [ "big-parallel" ]; __structuredAttrs = true; From d6f447471dc335a46c4bb9f243badfd15fe27e02 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:19 -0700 Subject: [PATCH 58/79] rocmPackages_10: copy composable_kernel from rocmPackages Verbatim copies of the rocmPackages (ROCm 7.2.4) expressions for composable_kernel, not yet part of the rocmPackages_10 scope. The following commits update each one to ROCm 10.1, so their diffs read against 7.2.4. Assisted-by: Claude Code (claude-opus-5-5) --- .../10/composable_kernel/base.nix | 205 +++++++++++ .../10/composable_kernel/ck4inductor.nix | 44 +++ .../10/composable_kernel/default.nix | 319 ++++++++++++++++++ .../fix-empty-offload-targets.diff | 23 ++ 4 files changed, 591 insertions(+) create mode 100644 pkgs/development/rocm-modules/10/composable_kernel/base.nix create mode 100644 pkgs/development/rocm-modules/10/composable_kernel/ck4inductor.nix create mode 100644 pkgs/development/rocm-modules/10/composable_kernel/default.nix create mode 100644 pkgs/development/rocm-modules/10/composable_kernel/fix-empty-offload-targets.diff diff --git a/pkgs/development/rocm-modules/10/composable_kernel/base.nix b/pkgs/development/rocm-modules/10/composable_kernel/base.nix new file mode 100644 index 0000000000000..ef7304291ed4c --- /dev/null +++ b/pkgs/development/rocm-modules/10/composable_kernel/base.nix @@ -0,0 +1,205 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + clr, + rocminfo, + python3, + hipify, + gitMinimal, + gtest, + jemalloc, + zstd, + buildTests ? false, + buildExamples ? false, + # limits prebuilt kernel selection to those needed for MIOPEN (currently "*conv*") + # Other kernels can still be used if treating CK as a header only library + # and building specific instances, as done with ck4inductor/torch + miOpenReqLibsOnly ? true, + withDeprecatedKernels ? false, + gpuTargets ? ( + clr.localGpuTargets or [ + "gfx900" + "gfx906" + "gfx908" + "gfx90a" + "gfx942" + "gfx950" + "gfx10-3-generic" + "gfx11-generic" + "gfx12-generic" + ] + ), +}: +let + projectRoot = "projects/composablekernel"; +in +stdenv.mkDerivation (finalAttrs: { + preBuild = '' + echo "This derivation isn't intended to be built directly and only exists to be overridden and built in chunks"; + exit 1 + ''; + + pname = "composable_kernel_base"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildTests [ + "test" + ] + ++ lib.optionals buildExamples [ + "example" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + projectRoot + "shared" + ]; + hash = "sha256-Zs6wwPmys1kUlgDD4XzKKw273nH/Ur3HtuYxJjvjDs0="; + }; + sourceRoot = "${finalAttrs.src.name}/${projectRoot}"; + + nativeBuildInputs = [ + # Deliberately not using ninja + # because we're jankily composing build outputs from multiple drvs + # ninja won't believe they're up to date + gitMinimal + cmake + rocminfo + clr + hipify + zstd + python3 + ]; + + buildInputs = [ + rocm-cmake + clr + zstd + ]; + + strictDeps = true; + enableParallelBuilding = true; + env.ROCM_PATH = clr; + # Speed up build by ~7% with jemalloc (template torture test workload means allocation heavy clang invocations) + env.LD_PRELOAD = "${jemalloc}/lib/libjemalloc.so"; + env.MALLOC_CONF = "background_thread:true,metadata_thp:auto,dirty_decay_ms:10000,muzzy_decay_ms:10000"; + + cmakeFlags = [ + (lib.cmakeBool "MIOPEN_REQ_LIBS_ONLY" miOpenReqLibsOnly) + (lib.cmakeBool "BUILD_MHA_LIB" (!miOpenReqLibsOnly)) + (lib.cmakeBool "DISABLE_DL_KERNELS" true) + (lib.cmakeBool "DISABLE_DPP_KERNELS" true) + (lib.cmakeBool "CK_TIME_KERNEL" false) + "-DCMAKE_MODULE_PATH=${clr}/hip/cmake" + "-DCMAKE_POLICY_DEFAULT_CMP0069=NEW" + "-DDL_KERNELS=OFF" + # CK_USE_CODEGEN Required for migraphx which uses device_gemm_multiple_d.hpp + # but migraphx requires an incompatible fork of CK and fails anyway + # "-DCK_USE_CODEGEN=ON" + # It might be worth skipping fp64 in future with this: + # "-DDTYPES=fp32;fp16;fp8;bf16;int8" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + "-DBUILD_DEV=OFF" + "-DBUILD_MHA_LIB=ON" + "-DROCM_PATH=${clr}" + "-DENABLE_CLANG_CPP_CHECKS=OFF" + "-DCMAKE_HIP_COMPILER_ROCM_ROOT=${clr}" + + # FP8 can build for 908/90a but very slow build + # and produces unusably slow kernels that are huge + "-DCK_USE_FP8_ON_UNSUPPORTED_ARCH=OFF" + ] + ++ lib.optionals (gpuTargets != [ ]) [ + # We intentionally set GPU_ARCHS and not AMD/GPU_TARGETS + # per readme this is required if archs are dissimilar + # In rocm-6.3.x not setting any arch flag worked + # but setting dissimilar arches always failed + "-DGPU_ARCHS=${lib.concatStringsSep ";" gpuTargets}" + ] + ++ lib.optionals buildTests [ + "-DGOOGLETEST_DIR=${gtest.src}" # Custom linker names + ]; + + patches = [ + # Hacky fix for failure for some targets when all targets are selected out + # for a non-optional at link time kernel + ./fix-empty-offload-targets.diff + ]; + + postPatch = + # Reduce configure time by preventing thousands of clang-tidy targets being added + # We will never call them + # Never build profiler + '' + substituteInPlace library/src/utility/CMakeLists.txt library/src/tensor_operation_instance/gpu/CMakeLists.txt \ + --replace-fail clang_tidy_check '#clang_tidy_check' + substituteInPlace CMakeLists.txt \ + --replace-fail "add_subdirectory(profiler)" "" + substituteInPlace cmake/EnableCompilerWarnings.cmake \ + --replace-fail "-Werror" "" + '' + + lib.optionalString (!withDeprecatedKernels) '' + substituteInPlace include/ck/ck.hpp \ + --replace-fail "CK_BUILD_DEPRECATED 1" "CK_BUILD_DEPRECATED 0" + '' + # Optionally remove tests + + lib.optionalString (!buildTests) '' + substituteInPlace CMakeLists.txt \ + --replace-fail "add_subdirectory(test)" "" + substituteInPlace codegen/CMakeLists.txt \ + --replace-fail "include(ROCMTest)" "" + '' + # Optionally remove examples + + lib.optionalString (!buildExamples) '' + substituteInPlace CMakeLists.txt \ + --replace-fail "add_subdirectory(example)" "" + ''; + + postInstall = + lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/test_* $test/bin + '' + + lib.optionalString buildExamples '' + mkdir -p $example/bin + mv $out/bin/example_* $example/bin + ''; + + passthru = { + inherit gpuTargets miOpenReqLibsOnly; + composable_kernel_src = "${finalAttrs.src}/${projectRoot}"; + + updateScript = rocmUpdateScript { inherit finalAttrs; }; + anyGfx9Target = lib.lists.any (lib.strings.hasPrefix "gfx9") gpuTargets; + anyMfmaTarget = + (lib.lists.intersectLists gpuTargets [ + "gfx908" + "gfx90a" + "gfx942" + "gfx950" + ]) != [ ]; + }; + + meta = { + description = "Performance portable programming model for machine learning tensor operators"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/composablekernel"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + broken = true; # this base package shouldn't be built directly + }; +}) diff --git a/pkgs/development/rocm-modules/10/composable_kernel/ck4inductor.nix b/pkgs/development/rocm-modules/10/composable_kernel/ck4inductor.nix new file mode 100644 index 0000000000000..6c8839fb75f69 --- /dev/null +++ b/pkgs/development/rocm-modules/10/composable_kernel/ck4inductor.nix @@ -0,0 +1,44 @@ +{ + buildPythonPackage, + python, + composable_kernel, + lib, + rocm-toolchain, + setuptools, + setuptools-scm, +}: +buildPythonPackage { + pyproject = true; + pname = "ck4inductor"; + build-system = [ + setuptools + setuptools-scm + ]; + inherit (composable_kernel) version src sourceRoot; + # Upstream uses the distribution name "rocm-composable-kernel". + dontCheckPythonMetadata = true; + pythonImportsCheck = [ + "ck4inductor" + "ck4inductor.universal_gemm.gen_instances" + "ck4inductor.universal_gemm.gen_instances" + "ck4inductor.universal_gemm.op" + ]; + propagatedBuildInputs = [ + # At runtime will fail to compile anything with ck4inductor without this + # can't easily use in checks phase because most of the compiler machinery is in torch + rocm-toolchain + ]; + checkPhase = '' + if [ ! -d "$out/${python.sitePackages}/ck4inductor" ]; then + echo "ck4inductor isn't at the expected location in $out/${python.sitePackages}/ck4inductor" + exit 1 + fi + ''; + meta = { + description = "Pytorch inductor backend which uses composable_kernel universal GEMM implementations"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/composablekernel"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +} diff --git a/pkgs/development/rocm-modules/10/composable_kernel/default.nix b/pkgs/development/rocm-modules/10/composable_kernel/default.nix new file mode 100644 index 0000000000000..ae0707fabbd01 --- /dev/null +++ b/pkgs/development/rocm-modules/10/composable_kernel/default.nix @@ -0,0 +1,319 @@ +{ + lib, + clr, + composable_kernel_base, +}: + +let + inherit (composable_kernel_base) miOpenReqLibsOnly; + parts = { + _mha = { + enabled = !miOpenReqLibsOnly; + # mha takes ~3hrs on 64 cores on an EPYC milan system at ~2.5GHz + # big-parallel builders are one gen newer and clocked ~30% higher but only 24 cores + # Should be <10h timeout but might be cutting it close + # TODO: work out how to split this into smaller chunks instead of all 3k mha instances together + # mha_0,1,2, search ninja target file for the individual instances, split by the index? + # TODO: can we prune the generated instances down to only what in practice are used with popular models + # when using flash-attention + MHA kernels? + targets = [ + "device_mha_instance" + ]; + extraCmakeFlags = [ "-DHIP_CLANG_NUM_PARALLEL_JOBS=2" ]; + }; + gemm_multiply_multiply = { + enabled = !miOpenReqLibsOnly; + targets = [ + "device_gemm_multiply_multiply_instance" + ]; + extraCmakeFlags = [ "-DHIP_CLANG_NUM_PARALLEL_JOBS=2" ]; + onlyFor = [ + "gfx942" + "gfx950" + ]; + }; + gemm_multiply_multiply_wp = { + enabled = !miOpenReqLibsOnly; + targets = [ + "device_gemm_multiply_multiply_wp_instance" + ]; + extraCmakeFlags = [ "-DHIP_CLANG_NUM_PARALLEL_JOBS=2" ]; + onlyFor = [ + "gfx942" + "gfx950" + ]; + }; + grouped_conv_bwd = { + targets = [ + "device_grouped_conv1d_bwd_weight_instance" + "device_grouped_conv2d_bwd_data_instance" + "device_grouped_conv2d_bwd_weight_instance" + ]; + }; + grouped_conv_fwd = { + targets = [ + "device_grouped_conv1d_fwd_instance" + "device_grouped_conv2d_fwd_instance" + "device_grouped_conv2d_fwd_bias_bnorm_clamp_instance" + "device_grouped_conv2d_fwd_bias_clamp_instance" + "device_grouped_conv2d_fwd_clamp_instance" + "device_grouped_conv2d_fwd_dynamic_op_instance" + ]; + }; + grouped_conv_bwd_3d1 = { + targets = [ + "device_grouped_conv3d_bwd_data_instance" + "device_grouped_conv3d_bwd_data_bilinear_instance" + "device_grouped_conv3d_bwd_data_scale_instance" + ]; + }; + grouped_conv_bwd_3d2 = { + targets = [ + "device_grouped_conv3d_bwd_weight_instance" + "device_grouped_conv3d_bwd_weight_bilinear_instance" + "device_grouped_conv3d_bwd_weight_scale_instance" + ]; + }; + grouped_conv_fwd_3d1 = { + targets = [ + "device_grouped_conv3d_fwd_instance" + "device_grouped_conv3d_fwd_clamp_instance" + "device_grouped_conv3d_fwd_bias_bnorm_clamp_instance" + "device_grouped_conv3d_fwd_bias_clamp_instance" + "device_grouped_conv3d_fwd_bilinear_instance" + "device_grouped_conv3d_fwd_convinvscale_instance" + "device_grouped_conv3d_fwd_convscale_instance" + "device_grouped_conv3d_fwd_convscale_add_instance" + ]; + }; + grouped_conv_fwd_3d2 = { + targets = [ + "device_grouped_conv3d_fwd_convscale_relu_instance" + "device_grouped_conv3d_fwd_dynamic_op_instance" + "device_grouped_conv3d_fwd_scale_instance" + "device_grouped_conv3d_fwd_scaleadd_ab_instance" + "device_grouped_conv3d_fwd_scaleadd_scaleadd_relu_instance" + ]; + }; + grouped_conv_fwd_nd = { + targets = [ + "device_grouped_convnd_bwd_weight_instance" + ]; + }; + batched_gemm1 = { + enabled = !miOpenReqLibsOnly; + targets = [ + "device_batched_gemm_instance" + "device_batched_gemm_b_scale_instance" + "device_batched_gemm_multi_d_instance" + "device_batched_gemm_add_relu_gemm_add_instance" + "device_batched_gemm_bias_permute_instance" + "device_batched_gemm_gemm_instance" + "device_batched_gemm_reduce_instance" + "device_batched_gemm_softmax_gemm_instance" + ]; + }; + batched_gemm2 = { + enabled = !miOpenReqLibsOnly; + targets = [ + "device_batched_gemm_softmax_gemm_permute_instance" + "device_grouped_gemm_instance" + "device_grouped_gemm_bias_instance" + "device_grouped_gemm_fastgelu_instance" + "device_grouped_gemm_fixed_nk_instance" + "device_grouped_gemm_fixed_nk_multi_abd_instance" + "device_grouped_gemm_tile_loop_instance" + ]; + }; + gemm_universal1 = { + enabled = !miOpenReqLibsOnly; + targets = [ + "device_gemm_universal_instance" + "device_gemm_universal_batched_instance" + ]; + }; + gemm_universal2 = { + enabled = !miOpenReqLibsOnly; + targets = [ + "device_gemm_universal_reduce_instance" + "device_gemm_universal_streamk_instance" + ]; + }; + gemm_other1 = { + enabled = !miOpenReqLibsOnly; + targets = [ + "device_gemm_instance" + "device_gemm_b_scale_instance" + "device_gemm_ab_scale_instance" + "device_gemm_add_instance" + "device_gemm_add_add_fastgelu_instance" + "device_gemm_add_fastgelu_instance" + "device_gemm_add_multiply_instance" + "device_gemm_add_relu_instance" + ]; + }; + gemm_other2 = { + enabled = !miOpenReqLibsOnly; + targets = [ + "device_gemm_add_relu_add_layernorm_instance" + "device_gemm_add_silu_instance" + "device_gemm_bias_add_reduce_instance" + "device_gemm_bilinear_instance" + "device_gemm_fastgelu_instance" + "device_gemm_multi_abd_instance" + "device_gemm_multiply_add_instance" + "device_gemm_reduce_instance" + "device_gemm_splitk_instance" + "device_gemm_streamk_instance" + ]; + }; + conv = { + targets = [ + "device_conv1d_bwd_data_instance" + "device_conv2d_bwd_data_instance" + "device_conv2d_fwd_instance" + "device_conv2d_fwd_bias_relu_instance" + "device_conv2d_fwd_bias_relu_add_instance" + "device_conv3d_bwd_data_instance" + ]; + }; + pool = { + enabled = !miOpenReqLibsOnly; + targets = [ + "device_avg_pool2d_bwd_instance" + "device_avg_pool3d_bwd_instance" + "device_pool2d_fwd_instance" + "device_pool3d_fwd_instance" + "device_max_pool_bwd_instance" + ]; + }; + other0 = { + targets = [ + "device_quantization_instance" + ]; + }; + other1 = { + enabled = !miOpenReqLibsOnly; + targets = [ + "device_batchnorm_instance" + "device_contraction_bilinear_instance" + "device_contraction_scale_instance" + "device_elementwise_instance" + "device_elementwise_normalization_instance" + ]; + }; + other2 = { + enabled = !miOpenReqLibsOnly; + targets = [ + "device_column_to_image_instance" + "device_image_to_column_instance" + "device_permute_scale_instance" + "device_reduce_instance" + ]; + }; + other3 = { + enabled = !miOpenReqLibsOnly; + targets = [ + "device_normalization_bwd_data_instance" + "device_normalization_bwd_gamma_beta_instance" + "device_normalization_fwd_instance" + "device_softmax_instance" + "device_transpose_instance" + ]; + }; + }; + tensorOpBuilder = + { + part, + targets, + extraCmakeFlags ? [ ], + requiredSystemFeatures ? [ "big-parallel" ], + enabled ? true, + onlyFor ? [ ], + }: + let + supported = + enabled + && (onlyFor == [ ] || (lib.lists.intersectLists composable_kernel_base.gpuTargets onlyFor) != [ ]); + in + if supported then + (composable_kernel_base.overrideAttrs (old: { + inherit requiredSystemFeatures; + pname = "composable_kernel${clr.gpuArchSuffix}-${part}"; + makeTargets = targets; + preBuild = '' + echo "Building ${part}" + makeFlagsArray+=($makeTargets) + substituteInPlace $(find ./ -name "Makefile" -type f) \ + --replace-fail '.NOTPARALLEL:' '.UNUSED_NOTPARALLEL:' + ''; + + # Compile parallelism adjusted based on available RAM + # Never uses less than NIX_BUILD_CORES/4, never uses more than NIX_BUILD_CORES + # CK uses an unusually high amount of memory per core in the build step + # Nix/nixpkgs doesn't really have any infra to tell it that this build is unusually memory hungry + # So, bodge. Otherwise you end up having to build all of ROCm with a low core limit when + # it's only this package that has trouble. + preConfigure = old.preConfigure or "" + '' + MEM_GB_TOTAL=$(awk '/MemTotal/ { printf "%d \n", $2/1024/1024 }' /proc/meminfo) + MEM_GB_AVAILABLE=$(awk '/MemAvailable/ { printf "%d \n", $2/1024/1024 }' /proc/meminfo) + APPX_GB=$((MEM_GB_AVAILABLE > MEM_GB_TOTAL ? MEM_GB_TOTAL : MEM_GB_AVAILABLE)) + MAX_CORES=$((1 + APPX_GB/3)) + MAX_CORES=$((MAX_CORES < NIX_BUILD_CORES/3 ? NIX_BUILD_CORES/3 : MAX_CORES)) + export NIX_BUILD_CORES="$((NIX_BUILD_CORES > MAX_CORES ? MAX_CORES : NIX_BUILD_CORES))" + echo "Picked new core limit NIX_BUILD_CORES=$NIX_BUILD_CORES based on available mem: $APPX_GB GB" + cmakeFlagsArray+=( + "-DCK_PARALLEL_COMPILE_JOBS=$NIX_BUILD_CORES" + ) + ''; + cmakeFlags = old.cmakeFlags ++ extraCmakeFlags; + # Early exit after build phase with success, skips fixups etc + # Will get copied back into /build of the final CK + postBuild = '' + find . -name "*.o" -type f | while read -r file; do + mkdir -p "$out/$(dirname "$file")" + cp --reflink=auto "$file" "$out/$file" + done + exit 0 + ''; + meta = old.meta // { + broken = false; + }; + })) + else + null; + composable_kernel_parts = builtins.mapAttrs ( + part: targets: tensorOpBuilder (targets // { inherit part; }) + ) parts; +in + +composable_kernel_base.overrideAttrs ( + finalAttrs: old: { + pname = "composable_kernel${clr.gpuArchSuffix}"; + parts_dirs = builtins.filter (x: x != null) (builtins.attrValues composable_kernel_parts); + disallowedReferences = builtins.filter (x: x != null) (builtins.attrValues composable_kernel_parts); + preBuild = '' + for dir in $parts_dirs; do + find "$dir" -type f -name "*.o" | while read -r file; do + # Extract the relative path by removing the output directory prefix + rel_path="''${file#"$dir/"}" + + # Create parent directory if it doesn't exist + mkdir -p "$(dirname "$rel_path")" + + # Copy the file back to its original location, give it a future timestamp + # so make treats it as up to date + cp --reflink=auto --no-preserve=all "$file" "$rel_path" + touch -d "now +10 hours" "$rel_path" + done + done + ''; + passthru = old.passthru // { + parts = composable_kernel_parts; + }; + meta = old.meta // { + # Builds without any gfx9 fail + broken = !finalAttrs.passthru.anyGfx9Target; + }; + } +) diff --git a/pkgs/development/rocm-modules/10/composable_kernel/fix-empty-offload-targets.diff b/pkgs/development/rocm-modules/10/composable_kernel/fix-empty-offload-targets.diff new file mode 100644 index 0000000000000..d314873ff61b6 --- /dev/null +++ b/pkgs/development/rocm-modules/10/composable_kernel/fix-empty-offload-targets.diff @@ -0,0 +1,23 @@ +diff --git a/library/src/tensor_operation_instance/gpu/CMakeLists.txt b/library/src/tensor_operation_instance/gpu/CMakeLists.txt +index 172f6681b8..d3ddbb2f15 100644 +--- a/library/src/tensor_operation_instance/gpu/CMakeLists.txt ++++ b/library/src/tensor_operation_instance/gpu/CMakeLists.txt +@@ -154,9 +154,15 @@ function(add_instance_library INSTANCE_NAME) + list(FILTER INST_TARGETS INCLUDE REGEX "gfx12") + endif() + set(offload_targets) +- foreach(target IN LISTS INST_TARGETS) +- string(APPEND offload_targets "--offload-arch=${target} ") +- endforeach() ++ if(NOT INST_TARGETS) ++ # No valid GPU targets for this source, compile for 90a as fallback ++ # so the add_device…instances and hip_fatbin… symbols still exist ++ set(offload_targets "--offload-arch=gfx90a") ++ else() ++ foreach(target IN LISTS INST_TARGETS) ++ string(APPEND offload_targets "--offload-arch=${target} ") ++ endforeach() ++ endif() + set_source_files_properties(${source} PROPERTIES COMPILE_FLAGS ${offload_targets}) + list(APPEND INST_OBJ ${source}) + endforeach() From 7068ad1072736cc09c34806c1c3fd13033078200 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:20 -0700 Subject: [PATCH 59/79] rocmPackages_10.composable_kernel: init at 10.1 Update the rocmPackages.composable_kernel copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.composable_kernel: adapt to ROCm 10 conv targets and clang 24": ROCm 10 restructured CK's per-op conv instance libraries into OBJECT libraries aggregated under a single STATIC target device_conv_operations. clang 24 forwards NIX_LDFLAGS to the HIP device linker, so every split "parts" instance's device object is stamped with DT_RUNPATH=$out/lib. That RUNPATH is baked into the --offload-compress'd .hip_fatbin (a CCOB integrity-checked blob that cannot be scrubbed post-hoc without corrupting the device code), and since those .o are copied into the final CK derivation it becomes a disallowed cross-reference. The parts only emit relocatable .o, so the self-rpath is useless here; strip "-rpath $out/lib" from NIX_LDFLAGS (and any role-suffixed copies) in preConfigure, keeping offload compression. Also give fix-empty-offload-targets.diff a gfx90a fallback for an empty offload-target list. Revised during the split review: Restore memory-bounded per-group parts for the convolution instances, using ROCm 10's layout-specific OBJECT targets; the final build only archives their objects into device_conv_operations. Parts skip targets CMake did not generate for the configuration and fail on names the CK source no longer defines. Drop the streamk targets, removed upstream. Assisted-by: Claude Code (claude-opus-5-5) --- .../10/composable_kernel/base.nix | 6 +- .../10/composable_kernel/default.nix | 184 ++++++++++-------- .../fix-empty-offload-targets.diff | 9 +- pkgs/development/rocm-modules/10/default.nix | 9 + 4 files changed, 124 insertions(+), 84 deletions(-) diff --git a/pkgs/development/rocm-modules/10/composable_kernel/base.nix b/pkgs/development/rocm-modules/10/composable_kernel/base.nix index ef7304291ed4c..b740419c1bf4c 100644 --- a/pkgs/development/rocm-modules/10/composable_kernel/base.nix +++ b/pkgs/development/rocm-modules/10/composable_kernel/base.nix @@ -44,7 +44,7 @@ stdenv.mkDerivation (finalAttrs: { ''; pname = "composable_kernel_base"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -59,12 +59,12 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ projectRoot "shared" ]; - hash = "sha256-Zs6wwPmys1kUlgDD4XzKKw273nH/Ur3HtuYxJjvjDs0="; + hash = "sha256-1ycnnO7ul/uFsIPAOWfg641nsx96LI/Txs79RAxaBDI="; }; sourceRoot = "${finalAttrs.src.name}/${projectRoot}"; diff --git a/pkgs/development/rocm-modules/10/composable_kernel/default.nix b/pkgs/development/rocm-modules/10/composable_kernel/default.nix index ae0707fabbd01..cbe11dfebd2aa 100644 --- a/pkgs/development/rocm-modules/10/composable_kernel/default.nix +++ b/pkgs/development/rocm-modules/10/composable_kernel/default.nix @@ -7,6 +7,88 @@ let inherit (composable_kernel_base) miOpenReqLibsOnly; parts = { + # Compile convolution OBJECT targets in groups; the final build archives them. + grouped_conv_bwd = { + targets = [ + "device_grouped_conv1d_bwd_weight_gnwc_instance" + "device_grouped_conv1d_bwd_weight_nwgc_instance" + "device_grouped_conv2d_bwd_data_nhwgc_instance" + "device_grouped_conv2d_bwd_data_gnhwc_instance" + "device_grouped_conv2d_bwd_data_ngchw_instance" + "device_grouped_conv2d_bwd_weight_nhwgc_instance" + "device_grouped_conv2d_bwd_weight_gnhwc_instance" + "device_grouped_conv2d_bwd_weight_ngchw_instance" + ]; + }; + grouped_conv_fwd = { + targets = [ + "device_grouped_conv1d_fwd_gnwc_instance" + "device_grouped_conv2d_fwd_nhwgc_instance" + "device_grouped_conv2d_fwd_gnhwc_instance" + "device_grouped_conv2d_fwd_ngchw_instance" + "device_grouped_conv2d_fwd_bias_bnorm_clamp_nhwgc_instance" + "device_grouped_conv2d_fwd_bias_clamp_nhwgc_instance" + "device_grouped_conv2d_fwd_clamp_nhwgc_instance" + "device_grouped_conv2d_fwd_dynamic_op_nhwgc_instance" + ]; + }; + grouped_conv_bwd_3d1 = { + targets = [ + "device_grouped_conv3d_bwd_data_ndhwgc_instance" + "device_grouped_conv3d_bwd_data_gndhwc_instance" + "device_grouped_conv3d_bwd_data_ngcdhw_instance" + "device_grouped_conv3d_bwd_data_bilinear_ndhwgc_instance" + "device_grouped_conv3d_bwd_data_scale_ndhwgc_instance" + ]; + }; + grouped_conv_bwd_3d2 = { + targets = [ + "device_grouped_conv3d_bwd_weight_ndhwgc_instance" + "device_grouped_conv3d_bwd_weight_gndhwc_instance" + "device_grouped_conv3d_bwd_weight_ngcdhw_instance" + "device_grouped_conv3d_bwd_weight_bilinear_ndhwgc_instance" + "device_grouped_conv3d_bwd_weight_scale_ndhwgc_instance" + ]; + }; + grouped_conv_fwd_3d1 = { + targets = [ + "device_grouped_conv3d_fwd_ndhwgc_instance" + "device_grouped_conv3d_fwd_gndhwc_instance" + "device_grouped_conv3d_fwd_ngcdhw_instance" + "device_grouped_conv3d_fwd_clamp_ndhwgc_instance" + "device_grouped_conv3d_fwd_bias_bnorm_clamp_ndhwgc_instance" + "device_grouped_conv3d_fwd_bias_bnorm_clamp_nhwgc_instance" + "device_grouped_conv3d_fwd_bias_clamp_ndhwgc_instance" + "device_grouped_conv3d_fwd_bilinear_ndhwgc_instance" + "device_grouped_conv3d_fwd_convinvscale_ndhwgc_instance" + "device_grouped_conv3d_fwd_convscale_ndhwgc_instance" + "device_grouped_conv3d_fwd_convscale_add_ndhwgc_instance" + ]; + }; + grouped_conv_fwd_3d2 = { + targets = [ + "device_grouped_conv3d_fwd_convscale_relu_ndhwgc_instance" + "device_grouped_conv3d_fwd_dynamic_op_ndhwgc_instance" + "device_grouped_conv3d_fwd_scale_ndhwgc_instance" + "device_grouped_conv3d_fwd_scaleadd_ab_ndhwgc_instance" + "device_grouped_conv3d_fwd_scaleadd_scaleadd_relu_ndhwgc_instance" + ]; + }; + grouped_conv_fwd_nd = { + targets = [ + "device_grouped_convnd_bwd_weight_instance" + ]; + }; + conv_other = { + targets = [ + "device_conv1d_bwd_data_instance" + "device_conv2d_bwd_data_instance" + "device_conv2d_fwd_instance" + "device_conv2d_fwd_bias_relu_instance" + "device_conv2d_fwd_bias_relu_add_instance" + "device_conv3d_bwd_data_instance" + ]; + }; _mha = { enabled = !miOpenReqLibsOnly; # mha takes ~3hrs on 64 cores on an EPYC milan system at ~2.5GHz @@ -43,63 +125,6 @@ let "gfx950" ]; }; - grouped_conv_bwd = { - targets = [ - "device_grouped_conv1d_bwd_weight_instance" - "device_grouped_conv2d_bwd_data_instance" - "device_grouped_conv2d_bwd_weight_instance" - ]; - }; - grouped_conv_fwd = { - targets = [ - "device_grouped_conv1d_fwd_instance" - "device_grouped_conv2d_fwd_instance" - "device_grouped_conv2d_fwd_bias_bnorm_clamp_instance" - "device_grouped_conv2d_fwd_bias_clamp_instance" - "device_grouped_conv2d_fwd_clamp_instance" - "device_grouped_conv2d_fwd_dynamic_op_instance" - ]; - }; - grouped_conv_bwd_3d1 = { - targets = [ - "device_grouped_conv3d_bwd_data_instance" - "device_grouped_conv3d_bwd_data_bilinear_instance" - "device_grouped_conv3d_bwd_data_scale_instance" - ]; - }; - grouped_conv_bwd_3d2 = { - targets = [ - "device_grouped_conv3d_bwd_weight_instance" - "device_grouped_conv3d_bwd_weight_bilinear_instance" - "device_grouped_conv3d_bwd_weight_scale_instance" - ]; - }; - grouped_conv_fwd_3d1 = { - targets = [ - "device_grouped_conv3d_fwd_instance" - "device_grouped_conv3d_fwd_clamp_instance" - "device_grouped_conv3d_fwd_bias_bnorm_clamp_instance" - "device_grouped_conv3d_fwd_bias_clamp_instance" - "device_grouped_conv3d_fwd_bilinear_instance" - "device_grouped_conv3d_fwd_convinvscale_instance" - "device_grouped_conv3d_fwd_convscale_instance" - "device_grouped_conv3d_fwd_convscale_add_instance" - ]; - }; - grouped_conv_fwd_3d2 = { - targets = [ - "device_grouped_conv3d_fwd_convscale_relu_instance" - "device_grouped_conv3d_fwd_dynamic_op_instance" - "device_grouped_conv3d_fwd_scale_instance" - "device_grouped_conv3d_fwd_scaleadd_ab_instance" - "device_grouped_conv3d_fwd_scaleadd_scaleadd_relu_instance" - ]; - }; - grouped_conv_fwd_nd = { - targets = [ - "device_grouped_convnd_bwd_weight_instance" - ]; - }; batched_gemm1 = { enabled = !miOpenReqLibsOnly; targets = [ @@ -136,7 +161,6 @@ let enabled = !miOpenReqLibsOnly; targets = [ "device_gemm_universal_reduce_instance" - "device_gemm_universal_streamk_instance" ]; }; gemm_other1 = { @@ -164,17 +188,6 @@ let "device_gemm_multiply_add_instance" "device_gemm_reduce_instance" "device_gemm_splitk_instance" - "device_gemm_streamk_instance" - ]; - }; - conv = { - targets = [ - "device_conv1d_bwd_data_instance" - "device_conv2d_bwd_data_instance" - "device_conv2d_fwd_instance" - "device_conv2d_fwd_bias_relu_instance" - "device_conv2d_fwd_bias_relu_add_instance" - "device_conv3d_bwd_data_instance" ]; }; pool = { @@ -187,11 +200,6 @@ let "device_max_pool_bwd_instance" ]; }; - other0 = { - targets = [ - "device_quantization_instance" - ]; - }; other1 = { enabled = !miOpenReqLibsOnly; targets = [ @@ -243,7 +251,24 @@ let makeTargets = targets; preBuild = '' echo "Building ${part}" - makeFlagsArray+=($makeTargets) + # Build the targets this configuration generates; fail on names the CK + # source no longer defines, so they are not compiled unsplit later. + partTargets=() + for target in $makeTargets; do + if grep -q "^$target:" Makefile; then + partTargets+=("$target") + elif grep -rqsE "add_instance_library\($target([[:space:])]|$)" ../library/src/tensor_operation_instance; then + echo "CK part ${part}: $target not configured, skipping" + else + echo "CK part ${part}: $target is not defined in the CK source" >&2 + exit 1 + fi + done + if (( ''${#partTargets[@]} == 0 )); then + mkdir -p "$out" + exit 0 + fi + makeFlagsArray+=("''${partTargets[@]}") substituteInPlace $(find ./ -name "Makefile" -type f) \ --replace-fail '.NOTPARALLEL:' '.UNUSED_NOTPARALLEL:' ''; @@ -254,7 +279,14 @@ let # Nix/nixpkgs doesn't really have any infra to tell it that this build is unusually memory hungry # So, bodge. Otherwise you end up having to build all of ROCm with a low core limit when # it's only this package that has trouble. - preConfigure = old.preConfigure or "" + '' + preConfigure = (old.preConfigure or "") + '' + # clang 24 passes NIX_LDFLAGS' self-rpath into the compressed .hip_fatbin, + # where it cannot be scrubbed; the parts only emit objects. + for _v in NIX_LDFLAGS ''${!NIX_LDFLAGS_*}; do + printf -v "$_v" '%s' "$(sed "s| *-rpath $out/lib||g" <<< "''${!_v-}")" + export "$_v" + done + MEM_GB_TOTAL=$(awk '/MemTotal/ { printf "%d \n", $2/1024/1024 }' /proc/meminfo) MEM_GB_AVAILABLE=$(awk '/MemAvailable/ { printf "%d \n", $2/1024/1024 }' /proc/meminfo) APPX_GB=$((MEM_GB_AVAILABLE > MEM_GB_TOTAL ? MEM_GB_TOTAL : MEM_GB_AVAILABLE)) diff --git a/pkgs/development/rocm-modules/10/composable_kernel/fix-empty-offload-targets.diff b/pkgs/development/rocm-modules/10/composable_kernel/fix-empty-offload-targets.diff index d314873ff61b6..ca7b7aceccaed 100644 --- a/pkgs/development/rocm-modules/10/composable_kernel/fix-empty-offload-targets.diff +++ b/pkgs/development/rocm-modules/10/composable_kernel/fix-empty-offload-targets.diff @@ -1,8 +1,7 @@ diff --git a/library/src/tensor_operation_instance/gpu/CMakeLists.txt b/library/src/tensor_operation_instance/gpu/CMakeLists.txt -index 172f6681b8..d3ddbb2f15 100644 ---- a/library/src/tensor_operation_instance/gpu/CMakeLists.txt -+++ b/library/src/tensor_operation_instance/gpu/CMakeLists.txt -@@ -154,9 +154,15 @@ function(add_instance_library INSTANCE_NAME) +--- a/library/src/tensor_operation_instance/gpu/CMakeLists.txt 2026-10-08 00:34:05.472466099 -0700 ++++ b/library/src/tensor_operation_instance/gpu/CMakeLists.txt 2026-10-08 00:34:05.502420794 -0700 +@@ -182,9 +182,15 @@ list(FILTER INST_TARGETS INCLUDE REGEX "gfx12") endif() set(offload_targets) @@ -18,6 +17,6 @@ index 172f6681b8..d3ddbb2f15 100644 + string(APPEND offload_targets "--offload-arch=${target} ") + endforeach() + endif() - set_source_files_properties(${source} PROPERTIES COMPILE_FLAGS ${offload_targets}) + set_source_files_properties(${source} PROPERTIES COMPILE_FLAGS "${offload_targets}") list(APPEND INST_OBJ ${source}) endforeach() diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 709e07e947f7e..5c966e60298b3 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -158,6 +158,15 @@ let hipsparselt = self.callPackage ./hipsparselt { }; + # hipTensor - Only supports GFX9 + + composable_kernel_base = self.callPackage ./composable_kernel/base.nix { }; + composable_kernel = self.callPackage ./composable_kernel { }; + + ck4inductor = pyPackages.callPackage ./composable_kernel/ck4inductor.nix { + inherit (self) composable_kernel rocm-toolchain; + }; + half = self.callPackage ./half { }; # Even if config.rocmSupport is false we need rocmSupport true From 5623264e45275127854ede242157fb648f8c96b7 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:21 -0700 Subject: [PATCH 60/79] rocmPackages_10.rocmlir-triton: init at 10.1 rocmlirTriton is the fork of rocMLIR that AMDMIGraphX 10.1 pins (requirements.txt: ROCm/rocmlirTriton@release/rocm-rel-10.1, a branch; the repository has no tags). ROCm/rocMLIR has no ROCm 10 release, so rocmPackages_10 has no rocmlir; with aliases enabled, rocmlir and rocmlir-rock throw with that explanation. The expression starts from rocmPackages.rocmlir. From "rocmPackages.rocmlir: track rocmlirTriton for therock-10.1": ROCm 10.1's AMDMIGraphX (rocm-10.1) moved its rocMLIR pin to a new upstream repo: requirements.txt pins ROCm/rocmlirTriton@release/rocm-rel-10.1. It has no ROCm 10.x tag, so track the branch-head commit directly, as the old ROCm/rocMLIR pin did. Build fixes for the new source: - pybind11 for the Rock Python bindings' find_package(pybind11). - LLVM_TARGETS_TO_BUILD: append the native target unconditionally. Triton's librockcompiler_deps.cmake bundles host codegen (LLVMX86AsmParser/CodeGen/ Desc/Disassembler/Info) into the librockCompiler fat archive, which failed to link with AMDGPU-only. - MLIR_INCLUDE_TESTS=false: the check-rocmlir lit suite DEPENDS on ci-performance-scripts, a target only created when MLIR_ENABLE_ROCM_RUNNER is on (off for the rock-compiler build), so Generate failed. - preConfigure: give the build a writable HOME and TRITON_CACHE_PATH. Triton's build_helpers.py symlinks the in-tree LLVM into $HOME/.triton at configure time, which failed against the read-only /homeless-shelter. - postPatch: patchShebangs the whole external/llvm-project/mlir subtree and drop the BufferDependencyAnalysis.cpp enum-class fix (file no longer ships). Revised during the split review: Package it as rocmlir-triton instead of replacing rocmlir. Point the homepage at rocmlirTriton and remove the generic tag updater: the revision must move together with MIGraphX's pin. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 5 + .../10/rocmlir-triton/default.nix | 176 ++++++++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 pkgs/development/rocm-modules/10/rocmlir-triton/default.nix diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 5c966e60298b3..035dde57e92d6 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -148,6 +148,11 @@ let rocalution = self.callPackage ./rocalution { }; + # ROCm/rocMLIR has no ROCm 10 release; MIGraphX 10.1 pins this fork. + rocmlir-triton = self.callPackage ./rocmlir-triton { + buildRockCompiler = true; + }; + hipsolver = self.callPackage ./hipsolver { }; hipblas-common = self.callPackage ./hipblas-common { }; diff --git a/pkgs/development/rocm-modules/10/rocmlir-triton/default.nix b/pkgs/development/rocm-modules/10/rocmlir-triton/default.nix new file mode 100644 index 0000000000000..68fcfc3eece2d --- /dev/null +++ b/pkgs/development/rocm-modules/10/rocmlir-triton/default.nix @@ -0,0 +1,176 @@ +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + rocm-cmake, + clr, + libxml2, + libedit, + rocm-comgr, + rocm-device-libs, + rocm-runtime, + zstd, + zlib, + ncurses, + python3Packages, + buildRockCompiler ? false, + buildTests ? false, # `argument of type 'NoneType' is not iterable` +}: + +# FIXME: rocmlir has an entire separate LLVM build in a subdirectory this is silly +# It seems to be forked from AMD's own LLVM +# If possible reusing the rocmPackages.llvm build would be better +# Would have to confirm it is compatible with ROCm's tagged LLVM. +# Fairly likely it's not given AMD's track record with forking their own software in incompatible ways +# in subdirs + +# Theoretically, we could have our MLIR have an output +# with the source and built objects so that we can just +# use it as the external LLVM repo for this +let + suffix = if buildRockCompiler then "-rock" else ""; + + llvmNativeTarget = + if stdenv.hostPlatform.isx86_64 then + "X86" + else if stdenv.hostPlatform.isAarch64 then + "AArch64" + else + throw "Unsupported ROCm LLVM platform"; +in +stdenv.mkDerivation (finalAttrs: { + pname = "rocmlir-triton${suffix}"; + version = "10.1"; + + outputs = [ + "out" + ] + ++ lib.optionals (!buildRockCompiler) [ + "external" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + # Snapshot of release/rocm-rel-10.1, the branch required by MIGraphX 10.1. + # Update this revision together with MIGraphX; the repository has no release tags. + repo = "rocmlirTriton"; + rev = "f347064fea12aa0ab325e1244b65766652a2530c"; + hash = "sha256-w/eGFiXDfmY9Yog+U037mIG7wEQ9nD/m8z/2sErSuE8="; + }; + + nativeBuildInputs = [ + clr + cmake + rocm-cmake + python3Packages.python + python3Packages.tomli + # mlir/lib/Dialect/Rock/utility/Bindings/CMakeLists.txt does find_package(pybind11); + # without this the (buildRockCompiler) configure fails. + python3Packages.pybind11 + ]; + + buildInputs = [ + libxml2 + libedit + rocm-comgr + rocm-runtime + rocm-device-libs + ]; + + propagatedBuildInputs = [ + zstd + zlib + ncurses + ]; + + cmakeFlags = [ + # The rock-compiler build must build the native (host) target too, not only + # AMDGPU: rocmlirTriton's librockcompiler_deps.cmake bundles the host codegen + # members (LLVMX86AsmParser/CodeGen/Desc/Disassembler/Info; Triton does host + # JIT) into the librockCompiler fat archive, so with LLVM_TARGETS_TO_BUILD=AMDGPU + # only the archive step fails with `No rule to make target '.../LLVMX86AsmParser'`. + (lib.cmakeFeature "LLVM_TARGETS_TO_BUILD" "AMDGPU;${llvmNativeTarget}") + (lib.cmakeFeature "LLVM_USE_LINKER" "lld") + (lib.cmakeFeature "LLVM_ENABLE_ZSTD" "FORCE_ON") + (lib.cmakeFeature "LLVM_ENABLE_ZLIB" "FORCE_ON") + (lib.cmakeBool "LLVM_ENABLE_LIBCXX" true) + (lib.cmakeBool "LLVM_ENABLE_TERMINFO" true) + (lib.cmakeFeature "ROCM_PATH" "${clr}") + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") + (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") + (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") + (lib.cmakeBool "MLIR_ENABLE_ROCM_RUNNER" (!buildRockCompiler)) + (lib.cmakeBool "BUILD_FAT_LIBROCKCOMPILER" buildRockCompiler) + ] + ++ lib.optionals buildRockCompiler [ + (lib.cmakeBool "LLVM_INCLUDE_TESTS" false) + # mlir/test declares the `check-rocmlir` lit suite with a DEPENDS on + # `ci-performance-scripts`, a target only created by mlir/utils/performance, + # which is gated behind MLIR_ENABLE_ROCM_RUNNER (= !buildRockCompiler, i.e. OFF + # here). With MLIR tests left ON, CMake's Generate step fails with `The + # dependency target "ci-performance-scripts" ... does not exist`. The + # rock-compiler build only needs librockCompiler, so turn MLIR tests off + # (LLVM_INCLUDE_TESTS above governs a different variable). + (lib.cmakeBool "MLIR_INCLUDE_TESTS" false) + ] + ++ lib.optionals (!buildRockCompiler) [ + (lib.cmakeFeature "ROCM_TEST_CHIPSET" "gfx900") + ]; + + postPatch = '' + patchShebangs mlir + patchShebangs external/llvm-project/mlir + + substituteInPlace mlir/utils/performance/common/CMakeLists.txt \ + --replace-fail " PATHS /opt/rocm" "" + ''; + + # The source bundles Triton, whose external/triton/python/build_helpers.py + # symlinks the pinned in-tree LLVM into $TRITON_CACHE_PATH (= $HOME/.triton) at + # configure time. The sandbox HOME is the read-only /homeless-shelter, so give + # the build a writable HOME (and point TRITON_CACHE_PATH at it explicitly). + preConfigure = '' + export HOME="$(mktemp -d)" + export TRITON_CACHE_PATH="$HOME/.triton" + ''; + + dontBuild = true; + doCheck = true; + + # Certain libs aren't being generated, try enabling tests next update + checkTarget = + if buildRockCompiler then + "librockCompiler" + else if buildTests then + "check-rocmlir" + else + "check-rocmlir-build-only"; + + postInstall = + let + libPath = lib.makeLibraryPath [ + zstd + zlib + ncurses + clr + stdenv.cc.cc + ]; + in + lib.optionalString (!buildRockCompiler) '' + mkdir -p $external/lib + cp -a external/llvm-project/llvm/lib/{*.a*,*.so*} $external/lib + patchelf --set-rpath $external/lib:$out/lib:${libPath} $external/lib/*.so* + patchelf --set-rpath $out/lib:$external/lib:${libPath} $out/{bin/*,lib/*.so*} + ''; + + meta = { + description = "Fork of rocMLIR, the MLIR-based convolution and GEMM kernel generator, used by MIGraphX"; + homepage = "https://github.com/ROCm/rocmlirTriton"; + license = lib.licenses.asl20; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) From cdbb6ebeeb6d96b9455dbcad9ecda452364e2b1c Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:21 -0700 Subject: [PATCH 61/79] rocmPackages_10: copy MIOpen from rocmPackages Verbatim copies of the rocmPackages (ROCm 7.2.4) expressions for miopen, not yet part of the rocmPackages_10 scope. The following commits update each one to ROCm 10.1, so their diffs read against 7.2.4. Assisted-by: Claude Code (claude-opus-5-5) --- .../rocm-modules/10/miopen/default.nix | 338 ++++++++++++++++++ .../rocm-modules/10/miopen/kdbs.nix | 27 ++ .../10/miopen/skip-preexisting-dbs.patch | 22 ++ .../test-frugally-deep-model-loading.cpp | 55 +++ .../test-frugally-deep-model-loading.nix | 49 +++ .../10/miopen/test-runtime-compilation.nix | 37 ++ .../rocm-modules/10/miopen/update.sh | 48 +++ 7 files changed, 576 insertions(+) create mode 100644 pkgs/development/rocm-modules/10/miopen/default.nix create mode 100644 pkgs/development/rocm-modules/10/miopen/kdbs.nix create mode 100644 pkgs/development/rocm-modules/10/miopen/skip-preexisting-dbs.patch create mode 100644 pkgs/development/rocm-modules/10/miopen/test-frugally-deep-model-loading.cpp create mode 100644 pkgs/development/rocm-modules/10/miopen/test-frugally-deep-model-loading.nix create mode 100644 pkgs/development/rocm-modules/10/miopen/test-runtime-compilation.nix create mode 100755 pkgs/development/rocm-modules/10/miopen/update.sh diff --git a/pkgs/development/rocm-modules/10/miopen/default.nix b/pkgs/development/rocm-modules/10/miopen/default.nix new file mode 100644 index 0000000000000..881b0a2bbbdf6 --- /dev/null +++ b/pkgs/development/rocm-modules/10/miopen/default.nix @@ -0,0 +1,338 @@ +{ + lib, + stdenv, + callPackage, + fetchFromGitHub, + fetchpatch, + fetchurl, + runCommand, + pkg-config, + cmake, + rocm-cmake, + rocblas, + rocmlir, + rocrand, + rocm-runtime, + hipblas-common, + hipblas, + hipblaslt, + clr, + composable_kernel, + frugally-deep, + rocm-docs-core, + half, + boost, + sqlite, + symlinkJoin, + bzip2, + lbzip2, + nlohmann_json, + texliveSmall, + doxygen, + sphinx, + zlib, + gtest, + rocm-comgr, + roctracer, + python3Packages, + gpuTargets ? clr.localGpuTargets or clr.gpuTargets, + buildDocs ? false, # Needs internet because of rocm-docs-core + buildTests ? false, + withComposableKernel ? true, +}: + +let + # FIXME: cmake files need patched to include this properly + cFlags = "-Wno-documentation-pedantic --offload-compress -I${hipblas-common}/include -I${hipblas}/include -I${roctracer}/include -I${nlohmann_json}/include -I${sqlite.dev}/include -I${rocrand}/include"; + version = "7.2.4"; + + # Targets outside this list will get + # error: use of undeclared identifier 'CK_BUFFER_RESOURCE_3RD_DWORD' + supportedTargets = lib.intersectLists [ + "gfx900" + "gfx906" + "gfx908" + "gfx90a" + "gfx942" + "gfx950" + "gfx1030" + "gfx1031" + "gfx1100" + "gfx1101" + "gfx1102" + "gfx1150" + "gfx1151" + "gfx1200" + "gfx1201" + ] gpuTargets; + + latex = lib.optionalAttrs buildDocs ( + texliveSmall.withPackages ( + ps: with ps; [ + latexmk + tex-gyre + fncychap + wrapfig + capt-of + framed + needspace + tabulary + varwidth + titlesec + ] + ) + ); + + # for hiprtcCompileProgram (dropout kernels require rocrand in -I at runtime) + hiprtcCompileRocmPath = symlinkJoin { + name = "miopen-hiprtc-compile-rocm-path"; + paths = [ + clr + rocrand + ]; + }; + + # Kernel databases moved from Git LFS to DVC (anonymous s3 bucket s3://therock-dvc/rocm-libraries) + fetchKdb = + name: + { url, hash }: + runCommand "miopen-${name}.kdb" { preferLocalBuild = true; } '' + ${lbzip2}/bin/lbzip2 -ckd ${ + fetchurl { + inherit url hash; + name = "${name}.kdb.bz2"; + } + } > $out + ''; + + kdbs = lib.mapAttrs fetchKdb ( + lib.filterAttrs (name: _: lib.elem name supportedTargets) (import ./kdbs.nix) + ); + + linkKDBsTo = + targetPath: + lib.concatStringsSep "" ( + lib.mapAttrsToList (name: kdb: '' + ln -sf ${kdb} ${targetPath}/${name}.kdb + '') kdbs + ); +in +stdenv.mkDerivation (finalAttrs: { + inherit version; + pname = "miopen"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-libraries"; + tag = "rocm-${finalAttrs.version}"; + sparseCheckout = [ + "projects/miopen" + "shared" + ]; + fetchSubmodules = true; + hash = "sha256-plZpBTbEBVMa5CasjfbUsu45xP/BYstrEpWKK2H7QQ4="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/miopen"; + + env.CFLAGS = cFlags; + env.CXXFLAGS = cFlags; + + # Find zstd and add to target. Mainly for torch. + patches = [ + ./skip-preexisting-dbs.patch + (fetchpatch { + url = "https://github.com/ROCm/MIOpen/commit/e608b4325646afeabb5e52846997b926d2019d19.patch"; + hash = "sha256-oxa3qlIC2bzbwGxrQOZXoY/S7CpLsMrnWRB7Og0tk0M="; + }) + (fetchpatch { + url = "https://github.com/ROCm/MIOpen/commit/3413d2daaeb44b7d6eadcc03033a5954a118491e.patch"; + hash = "sha256-ST4snUcTmmSI1Ogx815KEX9GdMnmubsavDzXCGJkiKs="; + }) + (fetchpatch { + # [miopen] Extend HIP ISA compatibility + name = "Extend-MIOpen-ISA-compatibility.patch"; + url = "https://github.com/GZGavinZhao/rocm-libraries/commit/02f0fedffdc197f146dd45f41e10990a00cde3ee.patch"; + hash = "sha256-My32iZw75rvB4fyvUJJ2kw2bU9/39awGteFGjzijixw="; + relative = "projects/miopen"; + }) + ]; + + outputs = [ + "out" + ] + ++ lib.optionals buildDocs [ + "doc" + ] + ++ lib.optionals buildTests [ + "test" + ]; + enableParallelBuilding = true; + env.ROCM_PATH = clr; + env.LD_LIBRARY_PATH = lib.makeLibraryPath [ rocm-runtime ]; + + nativeBuildInputs = [ + pkg-config + cmake + rocm-cmake + clr + ]; + + buildInputs = [ + hipblas + hipblas-common + rocblas + rocmlir + half + boost + sqlite + bzip2 + nlohmann_json + frugally-deep + roctracer + rocrand + hipblaslt + ] + ++ lib.optionals withComposableKernel [ + composable_kernel + ] + ++ lib.optionals buildDocs [ + latex + doxygen + sphinx + rocm-docs-core + python3Packages.sphinx-rtd-theme + python3Packages.breathe + python3Packages.myst-parser + ] + ++ lib.optionals buildTests [ + gtest + zlib + ]; + + cmakeFlags = [ + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" supportedTargets}" + "-DGPU_TARGETS=${lib.concatStringsSep ";" supportedTargets}" + "-DGPU_ARCHS=${lib.concatStringsSep ";" supportedTargets}" + "-DCMAKE_VERBOSE_MAKEFILE=ON" + "-DCMAKE_MODULE_PATH=${clr}/hip/cmake" + + # needs to stream to stdout so bzcat rather than bunzip2 + "-DUNZIPPER=${bzip2}/bin/bzcat" + + "-DCMAKE_C_COMPILER=amdclang" + "-DCMAKE_CXX_COMPILER=amdclang++" + "-DROCM_PATH=${clr}" + "-DHIP_ROOT_DIR=${clr}" + (lib.cmakeBool "MIOPEN_USE_ROCBLAS" true) + (lib.cmakeBool "MIOPEN_USE_HIPBLASLT" true) + (lib.cmakeBool "MIOPEN_USE_COMPOSABLEKERNEL" withComposableKernel) + (lib.cmakeBool "MIOPEN_USE_HIPRTC" true) + (lib.cmakeBool "MIOPEN_USE_COMGR" true) + "-DCMAKE_HIP_COMPILER_ROCM_ROOT=${clr}" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + "-DMIOPEN_BACKEND=HIP" + ] + ++ lib.optionals buildTests [ + "-DBUILD_TESTS=ON" + "-DMIOPEN_TEST_ALL=ON" + ]; + + postPatch = '' + substituteInPlace cmake/ClangTidy.cmake \ + --replace-fail 'macro(enable_clang_tidy)' 'macro(enable_clang_tidy) + endmacro() + macro(enable_clang_tidy_unused)' \ + --replace-fail 'function(clang_tidy_check TARGET)' 'function(clang_tidy_check TARGET) + return()' + + patchShebangs test src/composable_kernel fin utils install_deps.cmake + + substituteInPlace src/comgr.cpp \ + --replace-fail '"/opt/rocm"' '"${hiprtcCompileRocmPath}"' + '' + + linkKDBsTo "src/kernels" + + '' + mkdir -p build/share/miopen/db/ + '' + + linkKDBsTo "build/share/miopen/db"; + + # Unfortunately, it seems like we have to call make on these manually + postBuild = + lib.optionalString buildDocs '' + python -m sphinx -T -E -b html -d _build/doctrees -D language=en ../docs _build/html + '' + + lib.optionalString buildTests '' + make -j$NIX_BUILD_CORES check + ''; + + postInstall = '' + rm $out/libexec/miopen/install_precompiled_kernels.sh + '' + + linkKDBsTo "$out/share/miopen/db" + + lib.optionalString buildDocs '' + mv ../doc/html $out/share/doc/miopen-hip + '' + + lib.optionalString buildTests '' + mkdir -p $test/bin + mv bin/test_* $test/bin + patchelf --set-rpath $out/lib:${ + lib.makeLibraryPath ( + finalAttrs.buildInputs + ++ [ + clr + rocm-comgr + ] + ) + } $test/bin/* + ''; + + requiredSystemFeatures = [ "big-parallel" ]; + + passthru.impureTests = { + # bash $(nix-build -A rocmPackages.miopen.passthru.impureTests.conv) etc + bnorm = callPackage ./test-runtime-compilation.nix { + miopen = finalAttrs.finalPackage; + name = "bnorm"; + testScript = "MIOpenDriver bnorm -n 16 -c 16 -H 512 -W 512 -m 1 -F 1 -s 1 -r 1"; + }; + conv = callPackage ./test-runtime-compilation.nix { + miopen = finalAttrs.finalPackage; + name = "conv"; + testScript = "MIOpenDriver conv -n 1 -c 1 -H 4 -W 4 -k 1 -y 3 -x 3 -p 0 -q 0 -V 0"; + }; + dropout = callPackage ./test-runtime-compilation.nix { + miopen = finalAttrs.finalPackage; + name = "dropout"; + testScript = "MIOpenDriver dropout -d 64,32,14,14"; + }; + pool = callPackage ./test-runtime-compilation.nix { + miopen = finalAttrs.finalPackage; + name = "pool"; + testScript = "MIOpenDriver pool -W 1x1x4x4 -y 2 -x 2 -p 0 -q 0 -F 1 -V 0"; + }; + }; + passthru.tests = { + # Ensure all .tn.model files can be loaded by whatever version of frugally-deep we have + # This is otherwise hard to verify as MIOpen will only use these models on specific, + # expensive Instinct GPUs + # If MIOpen stops embedding .tn.model files the test will also fail, and can be deleted, + # likely along with the frugally-deep dependency + can-load-models = callPackage ./test-frugally-deep-model-loading.nix { + inherit (finalAttrs) src version; + inherit frugally-deep nlohmann_json; + }; + }; + passthru.updateScript = ./update.sh; + + meta = { + description = "Machine intelligence library for ROCm"; + homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/miopen"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/miopen/kdbs.nix b/pkgs/development/rocm-modules/10/miopen/kdbs.nix new file mode 100644 index 0000000000000..d4156a97324d7 --- /dev/null +++ b/pkgs/development/rocm-modules/10/miopen/kdbs.nix @@ -0,0 +1,27 @@ +# Generated by update.sh +{ + gfx1030 = { + url = "https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5/22/c4bd38cc34d3906add061ee57b099b"; + hash = "sha256-LESExp7sFl7osCM7HdVMpzOE0dU7953e2yzgeHSGgfI="; + }; + gfx900 = { + url = "https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5/cf/9c12dafe25b15ea1e93088b7b061af"; + hash = "sha256-lFFB5GQFTjUnx3JDx816yH+96OGRt9XvBzfLFFHtUrE="; + }; + gfx906 = { + url = "https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5/04/b3be6a15c700ff382e0a5e136010e1"; + hash = "sha256-cn1ODLcUQi+/QJUlWbELukMUj4+b1vjjRhhTseL9tdM="; + }; + gfx908 = { + url = "https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5/35/b9082b72e661dc5e37f14de1d9d4ed"; + hash = "sha256-pI30zpZL3OEP3aeLdVpM00nHeTyD5K+XDH47g0W2A+M="; + }; + gfx90a = { + url = "https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5/a1/1615323e06c5774fe19cf34c51baef"; + hash = "sha256-TkzSgY3V/Xs5YXfr69TrL8JjqDr1MZMgeBeQ/e2kEjE="; + }; + gfx942 = { + url = "https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5/6a/fe97d7bd441fe15280b28b6e3b1748"; + hash = "sha256-fyhnR3+xPFkHLN36dI9UYIhqoVstt5RpareGn2S9lMM="; + }; +} diff --git a/pkgs/development/rocm-modules/10/miopen/skip-preexisting-dbs.patch b/pkgs/development/rocm-modules/10/miopen/skip-preexisting-dbs.patch new file mode 100644 index 0000000000000..89be2f4076cb4 --- /dev/null +++ b/pkgs/development/rocm-modules/10/miopen/skip-preexisting-dbs.patch @@ -0,0 +1,22 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d0ffaf983..0b9ed0952 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -554,7 +554,7 @@ endif() + function(unpack_db db_bzip2_file) + get_filename_component(__fname ${db_bzip2_file} NAME_WLE) + add_custom_command(OUTPUT ${KERNELS_BINARY_DIR}/${__fname} +- COMMAND ${UNZIPPER} -dc -k ${db_bzip2_file} > ${KERNELS_BINARY_DIR}/${__fname}) ++ COMMAND test -e ${KERNELS_BINARY_DIR}/${__fname} || ${UNZIPPER} -dc -k ${db_bzip2_file} > ${KERNELS_BINARY_DIR}/${__fname}) + string(REPLACE "." "_" __tname ${__fname}) + add_custom_target(generate_${__tname} ALL DEPENDS ${KERNELS_BINARY_DIR}/${__fname}) + +@@ -563,7 +563,7 @@ function(unpack_db db_bzip2_file) + if(NOT MIOPEN_USE_SQLITE_PERFDB AND __extension STREQUAL ".db") + add_custom_command(OUTPUT ${KERNELS_BINARY_DIR}/${__fname}.txt + DEPENDS sqlite2txt generate_${__tname} +- COMMAND $ ${KERNELS_BINARY_DIR}/${__fname} ${KERNELS_BINARY_DIR}/${__fname}.txt ++ COMMAND test -e ${KERNELS_BINARY_DIR}/${__fname}.txt || $ ${KERNELS_BINARY_DIR}/${__fname} ${KERNELS_BINARY_DIR}/${__fname}.txt + ) + add_custom_target(generate_${__tname}_txt ALL DEPENDS ${KERNELS_BINARY_DIR}/${__fname}.txt) + add_dependencies(generate_kernels generate_${__tname}_txt) diff --git a/pkgs/development/rocm-modules/10/miopen/test-frugally-deep-model-loading.cpp b/pkgs/development/rocm-modules/10/miopen/test-frugally-deep-model-loading.cpp new file mode 100644 index 0000000000000..6b64b80999850 --- /dev/null +++ b/pkgs/development/rocm-modules/10/miopen/test-frugally-deep-model-loading.cpp @@ -0,0 +1,55 @@ +#include +#include +#include +#include +#include + +int main() { + std::vector model_files; + std::string src_dir = std::getenv("SRC_DIR") ? std::getenv("SRC_DIR") : "."; + + // collect *tn.model files except _metadata + try { + for (const auto& entry : std::filesystem::recursive_directory_iterator(src_dir)) { + if (entry.is_regular_file()) { + std::string path = entry.path().string(); + if (path.find("tn.model") != std::string::npos && path.find("_metadata.") == std::string::npos) { + model_files.push_back(path); + } + } + } + } catch (const std::exception& e) { + std::cerr << "Error scanning directory: " << e.what() << std::endl; + return 1; + } + + if (model_files.empty()) { + std::cout << "No *.tn.model files found in " << src_dir << std::endl; + return 1; + } + + std::cout << "Found " << model_files.size() << " model files to test" << std::endl; + + int failed_count = 0; + for (const auto& model_file : model_files) { + std::cout << "Loading: " << model_file << " ... "; + std::cout.flush(); + + try { + const auto model = fdeep::load_model(model_file); + std::cout << "OK" << std::endl; + } catch (const std::exception& e) { + std::cout << "FAILED: " << e.what() << std::endl; + failed_count++; + } + } + + if (failed_count > 0) { + std::cerr << "\n" << failed_count << " out of " << model_files.size() + << " models failed to load" << std::endl; + return 1; + } + + std::cout << "\nAll " << model_files.size() << " models loaded successfully!" << std::endl; + return 0; +} diff --git a/pkgs/development/rocm-modules/10/miopen/test-frugally-deep-model-loading.nix b/pkgs/development/rocm-modules/10/miopen/test-frugally-deep-model-loading.nix new file mode 100644 index 0000000000000..7f82083d23492 --- /dev/null +++ b/pkgs/development/rocm-modules/10/miopen/test-frugally-deep-model-loading.nix @@ -0,0 +1,49 @@ +{ + lib, + stdenv, + eigen, + frugally-deep, + functionalplus, + nlohmann_json, + src, + version, +}: + +stdenv.mkDerivation { + pname = "miopen-frugally-deep-model-test"; + inherit version src; + + dontConfigure = true; + dontInstall = true; + doCheck = true; + + buildPhase = '' + runHook preBuild + + $CXX -std=c++20 \ + -I${lib.getDev eigen}/include/eigen3 \ + -I${lib.getDev functionalplus}/include \ + -I${lib.getDev frugally-deep}/include \ + -I${lib.getDev nlohmann_json}/include \ + ${./test-frugally-deep-model-loading.cpp} \ + -o test_models + + runHook postBuild + ''; + + checkPhase = '' + runHook preCheck + + echo "Running model loading tests..." + SRC_DIR="${src}" ./test_models + mkdir -p $out + + runHook postCheck + ''; + + meta = { + description = "Test that frugally-deep can load MIOpen model files"; + teams = with lib.teams; [ rocm ]; + platforms = lib.platforms.linux; + }; +} diff --git a/pkgs/development/rocm-modules/10/miopen/test-runtime-compilation.nix b/pkgs/development/rocm-modules/10/miopen/test-runtime-compilation.nix new file mode 100644 index 0000000000000..c781d36462513 --- /dev/null +++ b/pkgs/development/rocm-modules/10/miopen/test-runtime-compilation.nix @@ -0,0 +1,37 @@ +{ + lib, + makeImpureTest, + writableTmpDirAsHomeHook, + miopen, + clr, + rocm-smi, + name, + testScript, +}: + +makeImpureTest { + inherit name; + testedPackage = "rocmPackages.miopen"; + + sandboxPaths = [ + "/sys" + "/dev/dri" + "/dev/kfd" + ]; + + nativeBuildInputs = [ + writableTmpDirAsHomeHook + miopen + clr + rocm-smi + ]; + + testScript = '' + rocm-smi + ${testScript} + ''; + + meta = { + teams = [ lib.teams.rocm ]; + }; +} diff --git a/pkgs/development/rocm-modules/10/miopen/update.sh b/pkgs/development/rocm-modules/10/miopen/update.sh new file mode 100755 index 0000000000000..8e2e92585760d --- /dev/null +++ b/pkgs/development/rocm-modules/10/miopen/update.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl jq nix common-updater-scripts + +set -euo pipefail + +gh_curl() { curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} -sf "$@"; } + +version="${1:-$(gh_curl "https://api.github.com/repos/ROCm/rocm-libraries/releases?per_page=4" \ + | jq -re 'map(.tag_name // .name) + | map(select(test("^rocm-[0-9]+\\.[0-9]+(\\.[0-9]+)?$"))) + | first | ltrimstr("rocm-")')}" + +# main source version +echo "Updating MIOpen to $version" >&2 +update-source-version rocmPackages.miopen "$version" --ignore-same-hash + +# kdbs.nix from s3 bucket +cd "$(dirname "${BASH_SOURCE[0]}")" +bucket="https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5" + +# Fetch directory listing; extract name + download_url for .dvc files +dvc_entries=$(gh_curl "https://api.github.com/repos/ROCm/rocm-libraries/contents/projects/miopen/src/kernels?ref=rocm-${version}" \ + | jq -r '.[] | select(.name | endswith(".kdb.bz2.dvc")) | "\(.name)\t\(.download_url)"') + +[[ -n "$dvc_entries" ]] || { echo "No .kdb.bz2.dvc files found, upstream likely changed packaging again" >&2; exit 1; } + +{ + echo "# Generated by update.sh" + echo "{" + + while IFS=$'\t' read -r dvc_file raw_url; do + arch="${dvc_file%.kdb.bz2.dvc}" + md5=$(curl -sf "$raw_url" | awk '/- md5:/{print $3}') + url="${bucket}/${md5:0:2}/${md5:2}" + sri=$(nix --extra-experimental-features nix-command store prefetch-file --json "$url" --name "${arch}.kdb.bz2" | jq -r .hash) + echo " $arch: $sri" >&2 + cat < kdbs.nix + +echo "Wrote kdbs.nix" >&2 From 8e7e6e825ebc2de49b7f6a78b4a55b295e2ebc1f Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:22 -0700 Subject: [PATCH 62/79] rocmPackages_10.miopen: init at 10.1 Update the rocmPackages.miopen copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.miopen: 3.6.0 (standalone build off, ISA compat, hipconv off)": MIOpen 3.6.0 defaults MIOPEN_STANDALONE_BUILD ON (FetchContents its deps) and dropped Boost/OpenCL for C++20. Build with STANDALONE_BUILD=OFF and supplied deps, neutralise -Werror, and add extend-miopen-isa-compatibility.patch (rebased from GZGavinZhao 02f0fedf) to keep the ISA-compat behaviour. Disable the new hipconv convolution subsystem. It serves only cdna3/cdna4/ cdna5 (gfx942/gfx950 and newer), its CMake unconditionally compiles every arch dir, and the cdna4 direct_wgrad kernels do not compile with clang 24, which rejects their `static constexpr` members and namespace-scope constexpr variable templates as references to __host__ variables in __device__ code. conv_hipconv.cpp self-guards on MIOPEN_USE_HIPCONV, so other targets are unaffected. Re-enable once the kernels build with clang 24. Revised during the split review: Drop rocMLIR: MIOpen 10.1 defaults MIOPEN_USE_MLIR to OFF (rocm-libraries 73eb90e3021c, the superbuild integration), which is also how TheRock builds it, so the MLIR solvers 7.2.4 had are not built. ROCm/rocMLIR has no 10.x release; rocmlir-triton, the fork MIGraphX pins, is not used by MIOpen. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 7 +++ .../rocm-modules/10/miopen/default.nix | 54 ++++++++++--------- .../extend-miopen-isa-compatibility.patch | 40 ++++++++++++++ 3 files changed, 77 insertions(+), 24 deletions(-) create mode 100644 pkgs/development/rocm-modules/10/miopen/extend-miopen-isa-compatibility.patch diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 035dde57e92d6..213f0452e0c1a 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -3,6 +3,7 @@ config, callPackage, newScope, + boost179, python3Packages, openmpi, stdenv, @@ -174,6 +175,12 @@ let half = self.callPackage ./half { }; + miopen = self.callPackage ./miopen { + boost = boost179.override { enableStatic = true; }; + }; + + miopen-hip = self.miopen; + # Even if config.rocmSupport is false we need rocmSupport true # version of ucc/ucx in openmpi in this package set openmpi = openmpi-orig.override ( diff --git a/pkgs/development/rocm-modules/10/miopen/default.nix b/pkgs/development/rocm-modules/10/miopen/default.nix index 881b0a2bbbdf6..ee6cd1a16aa52 100644 --- a/pkgs/development/rocm-modules/10/miopen/default.nix +++ b/pkgs/development/rocm-modules/10/miopen/default.nix @@ -10,7 +10,6 @@ cmake, rocm-cmake, rocblas, - rocmlir, rocrand, rocm-runtime, hipblas-common, @@ -31,9 +30,11 @@ doxygen, sphinx, zlib, + zstd, gtest, rocm-comgr, roctracer, + python3, python3Packages, gpuTargets ? clr.localGpuTargets or clr.gpuTargets, buildDocs ? false, # Needs internet because of rocm-docs-core @@ -43,8 +44,9 @@ let # FIXME: cmake files need patched to include this properly - cFlags = "-Wno-documentation-pedantic --offload-compress -I${hipblas-common}/include -I${hipblas}/include -I${roctracer}/include -I${nlohmann_json}/include -I${sqlite.dev}/include -I${rocrand}/include"; - version = "7.2.4"; + # nlohmann_json 3.12 headers warn under MIOpen's -Werror. + cFlags = "-Wno-documentation-pedantic -Wno-covered-switch-default --offload-compress -I${hipblas-common}/include -I${hipblas}/include -I${roctracer}/include -isystem ${nlohmann_json}/include -I${sqlite.dev}/include -I${rocrand}/include"; + version = "10.1"; # Targets outside this list will get # error: use of undeclared identifier 'CK_BUFFER_RESOURCE_3RD_DWORD' @@ -124,37 +126,24 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; + tag = "therock-${finalAttrs.version}"; sparseCheckout = [ "projects/miopen" "shared" ]; fetchSubmodules = true; - hash = "sha256-plZpBTbEBVMa5CasjfbUsu45xP/BYstrEpWKK2H7QQ4="; + hash = "sha256-pIo0QeVJ64Abte5u319kd2O6gjHIOtMkBo3h4thpzDo="; }; sourceRoot = "${finalAttrs.src.name}/projects/miopen"; env.CFLAGS = cFlags; env.CXXFLAGS = cFlags; - # Find zstd and add to target. Mainly for torch. patches = [ ./skip-preexisting-dbs.patch - (fetchpatch { - url = "https://github.com/ROCm/MIOpen/commit/e608b4325646afeabb5e52846997b926d2019d19.patch"; - hash = "sha256-oxa3qlIC2bzbwGxrQOZXoY/S7CpLsMrnWRB7Og0tk0M="; - }) - (fetchpatch { - url = "https://github.com/ROCm/MIOpen/commit/3413d2daaeb44b7d6eadcc03033a5954a118491e.patch"; - hash = "sha256-ST4snUcTmmSI1Ogx815KEX9GdMnmubsavDzXCGJkiKs="; - }) - (fetchpatch { - # [miopen] Extend HIP ISA compatibility - name = "Extend-MIOpen-ISA-compatibility.patch"; - url = "https://github.com/GZGavinZhao/rocm-libraries/commit/02f0fedffdc197f146dd45f41e10990a00cde3ee.patch"; - hash = "sha256-My32iZw75rvB4fyvUJJ2kw2bU9/39awGteFGjzijixw="; - relative = "projects/miopen"; - }) + # Extend MIOpen's HIP ISA compatibility check (e.g. gfx906 code objects on + # gfx90c-class devices). Rebased from GZGavinZhao/MIOpen 02f0fedf. + ./extend-miopen-isa-compatibility.patch ]; outputs = [ @@ -174,6 +163,8 @@ stdenv.mkDerivation (finalAttrs: { pkg-config cmake rocm-cmake + # cmake/CopyExternalHeader.cmake does find_package(Python3 REQUIRED) + python3 clr ]; @@ -181,11 +172,11 @@ stdenv.mkDerivation (finalAttrs: { hipblas hipblas-common rocblas - rocmlir half boost sqlite bzip2 + zstd nlohmann_json frugally-deep roctracer @@ -210,6 +201,8 @@ stdenv.mkDerivation (finalAttrs: { ]; cmakeFlags = [ + # The standalone build FetchContents its dependencies. + (lib.cmakeBool "MIOPEN_STANDALONE_BUILD" false) "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" supportedTargets}" "-DGPU_TARGETS=${lib.concatStringsSep ";" supportedTargets}" "-DGPU_ARCHS=${lib.concatStringsSep ";" supportedTargets}" @@ -228,6 +221,8 @@ stdenv.mkDerivation (finalAttrs: { (lib.cmakeBool "MIOPEN_USE_COMPOSABLEKERNEL" withComposableKernel) (lib.cmakeBool "MIOPEN_USE_HIPRTC" true) (lib.cmakeBool "MIOPEN_USE_COMGR" true) + # hipconv's cdna4 kernels fail with clang 24 ("reference to __host__ variable in __device__ function"). + (lib.cmakeBool "MIOPEN_USE_HIPCONV" false) "-DCMAKE_HIP_COMPILER_ROCM_ROOT=${clr}" # Manually define CMAKE_INSTALL_ # See: https://github.com/NixOS/nixpkgs/pull/197838 @@ -242,6 +237,14 @@ stdenv.mkDerivation (finalAttrs: { ]; postPatch = '' + # Keep the rocmClangStdenv compiler instead of MIOpen's ClangToolChain.cmake. + substituteInPlace CMakeLists.txt \ + --replace-fail 'if(NOT CMAKE_TOOLCHAIN_FILE AND NOT DEFINED ENV{CMAKE_TOOLCHAIN_FILE})' 'if(FALSE)' + + # ROCm 10 clang and C++20 add warnings throughout; drop -Werror like composable_kernel. + substituteInPlace cmake/EnableCompilerWarnings.cmake \ + --replace-fail ' -Werror' ' -Wno-error' + substituteInPlace cmake/ClangTidy.cmake \ --replace-fail 'macro(enable_clang_tidy)' 'macro(enable_clang_tidy) endmacro() @@ -249,10 +252,13 @@ stdenv.mkDerivation (finalAttrs: { --replace-fail 'function(clang_tidy_check TARGET)' 'function(clang_tidy_check TARGET) return()' - patchShebangs test src/composable_kernel fin utils install_deps.cmake + patchShebangs test fin utils install_deps.cmake + # Runtime hiprtc compilation finds ROCm headers only through ROCM_PATH; default it. substituteInPlace src/comgr.cpp \ - --replace-fail '"/opt/rocm"' '"${hiprtcCompileRocmPath}"' + --replace-fail 'auto rocm_path = env::value(ROCM_PATH);' 'auto rocm_path = env::value(ROCM_PATH); + if(rocm_path.empty()) + rocm_path = "${hiprtcCompileRocmPath}";' '' + linkKDBsTo "src/kernels" + '' diff --git a/pkgs/development/rocm-modules/10/miopen/extend-miopen-isa-compatibility.patch b/pkgs/development/rocm-modules/10/miopen/extend-miopen-isa-compatibility.patch new file mode 100644 index 0000000000000..eff7f1bda61bb --- /dev/null +++ b/pkgs/development/rocm-modules/10/miopen/extend-miopen-isa-compatibility.patch @@ -0,0 +1,40 @@ +diff --git a/src/hip/handlehip.cpp b/src/hip/handlehip.cpp +--- a/src/hip/handlehip.cpp 2026-09-23 21:21:51.170790313 -0700 ++++ b/src/hip/handlehip.cpp 2026-09-23 21:21:51.190325176 -0700 +@@ -217,8 +217,35 @@ + { + hipDeviceProp_t props{}; + (void)hipGetDeviceProperties(&props, device); +- const std::string name(props.gcnArchName); ++ std::string name(props.gcnArchName); + MIOPEN_LOG_NQI("Raw device name: " << name); ++ ++ // Coerce device name so MIOpen selects a compatible ISA's kernels on ++ // GPUs that share a binary-compatible base (e.g. gfx906/MI50 -> gfx900). ++ // Ported from GZGavinZhao's "Extend MIOpen ISA compatibility" onto ++ // ROCm 10 (get_device_name now (void)-casts hipGetDeviceProperties). ++ size_t loc = std::string::npos; ++ if((loc = name.find("gfx103")) != std::string::npos) ++ { ++ size_t offset = std::char_traits::length("gfx103"); ++ name.at(loc + offset) = '0'; ++ } ++ else if((loc = name.find("gfx101")) != std::string::npos) ++ { ++ size_t offset = std::char_traits::length("gfx101"); ++ name.at(loc + offset) = '0'; ++ } ++ else if((loc = name.find("gfx90")) != std::string::npos) ++ { ++ size_t offset = std::char_traits::length("gfx90"); ++ char ver = name.at(loc + offset); ++ if(ver == '2' || ver == '6' || ver == '9' || ver == 'c') ++ { ++ name.at(loc + offset) = '0'; ++ } ++ } ++ ++ MIOPEN_LOG_NQI("Coerced device name: " << name); + return name; // NOLINT (performance-no-automatic-move) + } + From 6c1dada2320db6d612c8ec2b7d7681d909c8636f Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:22 -0700 Subject: [PATCH 63/79] rocmPackages_10: copy MIGraphX, RPP, MIVisionX from rocmPackages Verbatim copies of the rocmPackages (ROCm 7.2.4) expressions for migraphx, rpp, not yet part of the rocmPackages_10 scope. The following commits update each one to ROCm 10.1, so their diffs read against 7.2.4. Assisted-by: Claude Code (claude-opus-5-5) --- .../rocm-modules/10/migraphx/default.nix | 208 ++++++++++++++++++ .../10/migraphx/test-migraphx-driver.nix | 47 ++++ .../rocm-modules/10/rpp/default.nix | 77 +++++++ 3 files changed, 332 insertions(+) create mode 100644 pkgs/development/rocm-modules/10/migraphx/default.nix create mode 100644 pkgs/development/rocm-modules/10/migraphx/test-migraphx-driver.nix create mode 100644 pkgs/development/rocm-modules/10/rpp/default.nix diff --git a/pkgs/development/rocm-modules/10/migraphx/default.nix b/pkgs/development/rocm-modules/10/migraphx/default.nix new file mode 100644 index 0000000000000..dfa8bd5ea4576 --- /dev/null +++ b/pkgs/development/rocm-modules/10/migraphx/default.nix @@ -0,0 +1,208 @@ +{ + lib, + stdenv, + callPackage, + fetchFromGitHub, + rocmUpdateScript, + pkg-config, + cmake, + rocm-cmake, + clr, + openmp, + rocblas, + hipblas-common, + hipblas, + hipblaslt, + rocmlir, + miopen, + protobuf, + abseil-cpp, + half, + nlohmann_json, + boost, + msgpack-cxx, + sqlite, + # TODO(@LunNova): Swap to `onednn` once v3 is supported + # Upstream issue: https://github.com/ROCm/AMDMIGraphX/issues/4351 + onednn_2, + blaze, + texliveSmall, + doxygen, + sphinx, + docutils, + ghostscript, + python3Packages, + writableTmpDirAsHomeHook, + buildDocs ? false, + buildTests ? false, + gpuTargets ? clr.localGpuTargets or clr.gpuTargets, +}: + +let + # this standard version needs to match the version that migraphx pins, or + # compilation fails if the pinned version is not the same as the compiler's + # default. + # https://github.com/ROCm/AMDMIGraphX/blob/07ef4ba4f9ef95d241b7be165e60ad148f3344ee/CMakeLists.txt#L143-L148 + abseil-cpp' = abseil-cpp.override { cxxStandard = "17"; }; + + latex = lib.optionalAttrs buildDocs ( + texliveSmall.withPackages ( + ps: with ps; [ + latexmk + tex-gyre + fncychap + wrapfig + capt-of + framed + needspace + tabulary + varwidth + titlesec + epstopdf + ] + ) + ); +in +stdenv.mkDerivation (finalAttrs: { + pname = "migraphx"; + version = "7.2.4"; + + outputs = [ + "out" + ] + ++ lib.optionals buildDocs [ + "doc" + ] + ++ lib.optionals buildTests [ + "test" + ]; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "AMDMIGraphX"; + tag = "rocm-${finalAttrs.version}"; + hash = "sha256-oDVJn2vwSoLxrA5ynRduZ3uRR8XhBa0pAf3Vyx7o3HE="; + }; + + nativeBuildInputs = [ + pkg-config + cmake + rocm-cmake + clr + python3Packages.python + ] + ++ lib.optionals buildDocs [ + latex + doxygen + sphinx + docutils + ghostscript + python3Packages.sphinx-rtd-theme + python3Packages.breathe + writableTmpDirAsHomeHook + ]; + + buildInputs = [ + openmp + rocblas + hipblas-common + hipblas + hipblaslt + rocmlir + miopen + protobuf + half + nlohmann_json + boost + msgpack-cxx + sqlite + onednn_2 + blaze + python3Packages.pybind11 + python3Packages.onnx + ]; + + env.LDFLAGS = "-Wl,--allow-shlib-undefined"; + + cmakeFlags = [ + "-DMIGRAPHX_ENABLE_GPU=ON" + "-DMIGRAPHX_ENABLE_CPU=ON" + "-DMIGRAPHX_ENABLE_FPGA=ON" + "-DMIGRAPHX_ENABLE_MLIR=ON" + "-DCMAKE_C_COMPILER=amdclang" + "-DCMAKE_CXX_COMPILER=amdclang++" + "-DCMAKE_VERBOSE_MAKEFILE=ON" + "-DEMBED_USE=CArrays" # Fixes error with lld + "-DDMIGRAPHX_ENABLE_PYTHON=ON" + "-DROCM_PATH=${clr}" + "-DHIP_ROOT_DIR=${clr}" + # migraphx relies on an incompatible fork of composable_kernel + # migraphxs relies on miopen which relies on current composable_kernel + # impossible to build with this ON; we can't link both of them even if we package both + "-DMIGRAPHX_USE_COMPOSABLEKERNEL=OFF" + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ]; + + postPatch = '' + export CXXFLAGS+=" -w -isystem${rocmlir}/include/rocmlir -I${half}/include -I${lib.getInclude abseil-cpp'}/include -I${hipblas-common}/include -I${lib.getInclude protobuf}/include" + patchShebangs tools + + # `error: '__clang_hip_runtime_wrapper.h' file not found [clang-diagnostic-error]` + substituteInPlace CMakeLists.txt \ + --replace "set(MIGRAPHX_TIDY_ERRORS ALL)" "" + + # Fix Unicode minus sign (U+2212) in comment that breaks EMBED_USE=CArrays + # The embed mechanism generates char[] arrays that can't store unicode − + # which has values >127 + substituteInPlace src/targets/gpu/kernels/include/migraphx/kernels/bit.hpp \ + --replace-fail "// popcount(~(x | −x))" "// popcount(~(x | -x))" + '' + + lib.optionalString (!buildDocs) '' + substituteInPlace CMakeLists.txt \ + --replace "add_subdirectory(doc)" "" + '' + + lib.optionalString (!buildTests) '' + substituteInPlace CMakeLists.txt \ + --replace "add_subdirectory(test)" "" + ''; + + # Unfortunately, it seems like we have to call make on this manually + preInstall = lib.optionalString buildDocs '' + make -j$NIX_BUILD_CORES doc + cd ../doc/pdf + make -j$NIX_BUILD_CORES + cd - + ''; + + postInstall = + lib.optionalString buildDocs '' + mv ../doc/html $out/share/doc/migraphx + mv ../doc/pdf/MIGraphX.pdf $out/share/doc/migraphx + '' + + lib.optionalString buildTests '' + mkdir -p $test/bin + mv bin/test_* $test/bin + patchelf $test/bin/test_* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" + ''; + + passthru.impureTests = { + # NIXPKGS_ALLOW_UNFREE=1 bash $(nix-build -A rocmPackages.migraphx.impureTests.migraphx-driver) + migraphx-driver = callPackage ./test-migraphx-driver.nix { + migraphx = finalAttrs.finalPackage; + }; + }; + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "AMD's graph optimization engine"; + homepage = "https://github.com/ROCm/AMDMIGraphX"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/10/migraphx/test-migraphx-driver.nix b/pkgs/development/rocm-modules/10/migraphx/test-migraphx-driver.nix new file mode 100644 index 0000000000000..c34c5a8a71d49 --- /dev/null +++ b/pkgs/development/rocm-modules/10/migraphx/test-migraphx-driver.nix @@ -0,0 +1,47 @@ +{ + lib, + fetchurl, + makeImpureTest, + writableTmpDirAsHomeHook, + migraphx, + clr, + rocm-smi, +}: + +# Verify that a ≈50MiB resnet onnx can run with migraphx +let + resnet18 = fetchurl { + url = "https://huggingface.co/onnxmodelzoo/resnet18_Opset18_timm/resolve/main/resnet18_Opset18_timm.onnx"; + hash = "sha256-u2Io20n72qoA9atRsFIWb0zHF1WdJYgHQdMWfJhJGHA="; + meta.license = lib.licenses.unfree; + }; +in +makeImpureTest { + name = "migraphx-driver"; + testedPackage = "rocmPackages.migraphx"; + + sandboxPaths = [ + "/sys" + "/dev/dri" + "/dev/kfd" + ]; + + nativeBuildInputs = [ + writableTmpDirAsHomeHook + migraphx + clr + rocm-smi + ]; + + # FIXME(@LunNova): tol values are set too high - was seeing high divergence on iGPU + # want this test to be useful for verifying workloads run at all + # and will investigate what's broken for accuracy + testScript = '' + rocm-smi + migraphx-driver verify -O --rms-tol 0.03 --atol 1.0 --rtol 0.01 ${resnet18} + ''; + + meta = { + teams = [ lib.teams.rocm ]; + }; +} diff --git a/pkgs/development/rocm-modules/10/rpp/default.nix b/pkgs/development/rocm-modules/10/rpp/default.nix new file mode 100644 index 0000000000000..f43c630e470ed --- /dev/null +++ b/pkgs/development/rocm-modules/10/rpp/default.nix @@ -0,0 +1,77 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + rocm-docs-core, + half, + clr, + openmp, + boost, + python3Packages, + buildDocs ? false, # Needs internet + useCPU ? false, + gpuTargets ? clr.localGpuTargets or [ ], +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rpp-${if useCPU then "cpu" else "hip"}"; + + version = "7.2.4"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rpp"; + tag = "rocm-${finalAttrs.version}"; + hash = "sha256-6e4JHKFC2dvtSGo9xbQKzIdUwlHB09pr5C/5xHwP3l4="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + clr + ] + ++ lib.optionals buildDocs [ + rocm-docs-core + python3Packages.python + ]; + + buildInputs = [ + half + openmp + boost + ]; + + cmakeFlags = [ + "-DROCM_PATH=${clr}" + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + "-DBACKEND=${if useCPU then "CPU" else "HIP"}" + ] + ++ lib.optionals (gpuTargets != [ ]) [ + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ]; + + postPatch = lib.optionalString (!useCPU) '' + # Bad path + substituteInPlace CMakeLists.txt \ + --replace "COMPILER_FOR_HIP \''${ROCM_PATH}/llvm/bin/clang++" "COMPILER_FOR_HIP ${clr}/bin/hipcc" + ''; + + postBuild = lib.optionalString buildDocs '' + python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en ../docs _build/html + ''; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "Comprehensive high-performance computer vision library for AMD processors"; + homepage = "https://github.com/ROCm/rpp"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) From 011c29d10e2053afe168b1a9d11ad4b68ab65b1b Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:23 -0700 Subject: [PATCH 64/79] rocmPackages_10.migraphx: init at 10.1 Update the rocmPackages.migraphx copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From "rocmPackages.migraphx: 7.2.4 -> 10.1.0, stub rocm_add_version_resource": Its rocm-10.1 tag calls rocm_add_version_resource() in src/CMakeLists.txt, but that rocm-cmake macro is not present in the therock-10.1 tag the rest of the set builds against (it currently only lives on rocm-cmake's develop branch), so configure fails with 'Unknown CMake command "rocm_add_version_resource"'. Upstream the macro's entire body is guarded by if(WIN32) -- it only emits a Windows .rc VERSIONINFO resource and is a no-op on Linux. Provide a guarded no-op stub after find_package(ROCmCMakeBuildTools) so it stays inert once rocm-cmake ships the macro on a release tag. This unblocks onnxruntime's MIGraphX execution provider and, through it, obs-backgroundremoval on ROCm 10. Revised during the split review: Take rocmlir-triton, the rocMLIR fork MIGraphX 10.1 pins. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 + .../rocm-modules/10/migraphx/default.nix | 42 ++++++++++++------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 213f0452e0c1a..6d29b532ea4e8 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -181,6 +181,8 @@ let miopen-hip = self.miopen; + migraphx = self.callPackage ./migraphx { stdenv = origStdenv; }; + # Even if config.rocmSupport is false we need rocmSupport true # version of ucc/ucx in openmpi in this package set openmpi = openmpi-orig.override ( diff --git a/pkgs/development/rocm-modules/10/migraphx/default.nix b/pkgs/development/rocm-modules/10/migraphx/default.nix index dfa8bd5ea4576..3008b3bba10de 100644 --- a/pkgs/development/rocm-modules/10/migraphx/default.nix +++ b/pkgs/development/rocm-modules/10/migraphx/default.nix @@ -13,7 +13,7 @@ hipblas-common, hipblas, hipblaslt, - rocmlir, + rocmlir-triton, miopen, protobuf, abseil-cpp, @@ -65,7 +65,7 @@ let in stdenv.mkDerivation (finalAttrs: { pname = "migraphx"; - version = "7.2.4"; + version = "10.1"; outputs = [ "out" @@ -81,7 +81,7 @@ stdenv.mkDerivation (finalAttrs: { owner = "ROCm"; repo = "AMDMIGraphX"; tag = "rocm-${finalAttrs.version}"; - hash = "sha256-oDVJn2vwSoLxrA5ynRduZ3uRR8XhBa0pAf3Vyx7o3HE="; + hash = "sha256-NusXF2BrmLrAbImnBh4zGKrsBs2O8E6R0kMmPN5S858="; }; nativeBuildInputs = [ @@ -108,7 +108,7 @@ stdenv.mkDerivation (finalAttrs: { hipblas-common hipblas hipblaslt - rocmlir + rocmlir-triton miopen protobuf half @@ -149,18 +149,32 @@ stdenv.mkDerivation (finalAttrs: { ]; postPatch = '' - export CXXFLAGS+=" -w -isystem${rocmlir}/include/rocmlir -I${half}/include -I${lib.getInclude abseil-cpp'}/include -I${hipblas-common}/include -I${lib.getInclude protobuf}/include" - patchShebangs tools + export CXXFLAGS+=" -w -isystem${rocmlir-triton}/include/rocmlir -I${half}/include -I${lib.getInclude abseil-cpp'}/include -I${hipblas-common}/include -I${lib.getInclude protobuf}/include" + patchShebangs tools - # `error: '__clang_hip_runtime_wrapper.h' file not found [clang-diagnostic-error]` - substituteInPlace CMakeLists.txt \ - --replace "set(MIGRAPHX_TIDY_ERRORS ALL)" "" + # `error: '__clang_hip_runtime_wrapper.h' file not found [clang-diagnostic-error]` + substituteInPlace CMakeLists.txt \ + --replace "set(MIGRAPHX_TIDY_ERRORS ALL)" "" + + # AMDMIGraphX's rocm-10.1 tag calls rocm_add_version_resource (src/CMakeLists.txt), + # a macro only present in rocm-cmake newer than the therock-10.1 tag the rest of + # the set builds against. Upstream it merely emits a Windows .rc VERSIONINFO + # resource (its whole body is guarded by `if(WIN32)`), so it is a no-op on Linux. + # Provide a guarded stub until rocm-cmake ships it on a release tag. + substituteInPlace CMakeLists.txt \ + --replace-fail \ + 'find_package(ROCmCMakeBuildTools REQUIRED)' \ + 'find_package(ROCmCMakeBuildTools REQUIRED) + if(NOT COMMAND rocm_add_version_resource) + function(rocm_add_version_resource) + endfunction() + endif()' - # Fix Unicode minus sign (U+2212) in comment that breaks EMBED_USE=CArrays - # The embed mechanism generates char[] arrays that can't store unicode − - # which has values >127 - substituteInPlace src/targets/gpu/kernels/include/migraphx/kernels/bit.hpp \ - --replace-fail "// popcount(~(x | −x))" "// popcount(~(x | -x))" + # Fix Unicode minus sign (U+2212) in comment that breaks EMBED_USE=CArrays + # The embed mechanism generates char[] arrays that can't store unicode − + # which has values >127 + substituteInPlace src/targets/gpu/kernels/include/migraphx/kernels/bit.hpp \ + --replace-fail "// popcount(~(x | −x))" "// popcount(~(x | -x))" '' + lib.optionalString (!buildDocs) '' substituteInPlace CMakeLists.txt \ From 348af65a14ed7c9300e454353b2b16fbc70412c4 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:24 -0700 Subject: [PATCH 65/79] rocmPackages_10.rpp: init at 10.1 Update the rocmPackages.rpp copy from the previous commit to ROCm 10.1 and add it to the rocmPackages_10 scope. From the mass bump: - rocalution, rpp: moved into the rocm-libraries monorepo (sparse From "rocmPackages.rpp: fix the 10.1.0 build for both backends": Two failures surfaced by building the full rocmPackages set at 10.1.0: - The new in-tree test (test_rpp_backend_macro) builds against the rpp target, whose public header api/rppdefs.h includes , but HALF::half is linked PRIVATE, so the test cannot find it. Export it as a PUBLIC dependency. - CPU backend only: with -fopenmp the clang driver adds `/../include` as a plain -I to locate omp.h. In the merged rocm-toolchain that directory also holds the glibc headers, so stdlib.h stops being a system header and clang 24 rejects mm_malloc.h's redeclaration of posix_memalign ("missing exception specification 'noexcept(true)'" with glibc 2.44). Passing the same directory as -isystem makes clang treat it as a system directory again. The HIP backend compiles through hipcc, whose prefix has no libc headers. Revised during the split review: Use a checked substituteInPlace for the public half dependency. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 + .../rocm-modules/10/rpp/default.nix | 37 ++++++++++++++----- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 6d29b532ea4e8..5d1ef605aea2e 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -183,6 +183,8 @@ let migraphx = self.callPackage ./migraphx { stdenv = origStdenv; }; + rpp = self.callPackage ./rpp { }; + # Even if config.rocmSupport is false we need rocmSupport true # version of ucc/ucx in openmpi in this package set openmpi = openmpi-orig.override ( diff --git a/pkgs/development/rocm-modules/10/rpp/default.nix b/pkgs/development/rocm-modules/10/rpp/default.nix index f43c630e470ed..00e00f47fca3e 100644 --- a/pkgs/development/rocm-modules/10/rpp/default.nix +++ b/pkgs/development/rocm-modules/10/rpp/default.nix @@ -19,14 +19,20 @@ stdenv.mkDerivation (finalAttrs: { pname = "rpp-${if useCPU then "cpu" else "hip"}"; - version = "7.2.4"; + version = "10.1"; src = fetchFromGitHub { owner = "ROCm"; - repo = "rpp"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-6e4JHKFC2dvtSGo9xbQKzIdUwlHB09pr5C/5xHwP3l4="; + # rpp lives in the rocm-libraries monorepo since ROCm 10 + repo = "rocm-libraries"; + tag = "therock-${finalAttrs.version}"; + sparseCheckout = [ + "projects/rpp" + "shared" + ]; + hash = "sha256-ZD3gzZhb1n5hSJ6nnYVksuoYEEy+wzaLbh02tMdv8dQ="; }; + sourceRoot = "${finalAttrs.src.name}/projects/rpp"; nativeBuildInputs = [ cmake @@ -55,11 +61,24 @@ stdenv.mkDerivation (finalAttrs: { "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" ]; - postPatch = lib.optionalString (!useCPU) '' - # Bad path - substituteInPlace CMakeLists.txt \ - --replace "COMPILER_FOR_HIP \''${ROCM_PATH}/llvm/bin/clang++" "COMPILER_FOR_HIP ${clr}/bin/hipcc" - ''; + # -fopenmp adds the toolchain include dir, which holds glibc's headers, as a + # plain -I; keep it a system dir so mm_malloc.h compiles with glibc >= 2.44. + env = lib.optionalAttrs useCPU { + CXXFLAGS = "-isystem ${stdenv.cc}/include"; + }; + + postPatch = + # api/rppdefs.h includes , so half must be a PUBLIC dependency. + '' + substituteInPlace CMakeLists.txt \ + --replace-fail 'set_target_properties(''${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)' \ + $'target_link_libraries(''${PROJECT_NAME} PUBLIC HALF::half)\nset_target_properties(''${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)' + '' + + lib.optionalString (!useCPU) '' + # Bad path + substituteInPlace CMakeLists.txt \ + --replace "COMPILER_FOR_HIP \''${ROCM_PATH}/llvm/bin/clang++" "COMPILER_FOR_HIP ${clr}/bin/hipcc" + ''; postBuild = lib.optionalString buildDocs '' python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en ../docs _build/html From 6cc767a1f4ccaab231b62fce04f070789de05ad4 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:24 -0700 Subject: [PATCH 66/79] rocmPackages_10: share mivisionx with rocmPackages mivisionx is unchanged between ROCm 7.2.4 and 10.1 (no 10.x upstream release, or versioned independently of ROCm), so the rocmPackages_10 scope calls the existing expression instead of copying it. Also add rpp-hip, rpp-cpu, mivisionx-hip, mivisionx-cpu. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 5d1ef605aea2e..f05e592ff9e46 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -4,6 +4,7 @@ callPackage, newScope, boost179, + opencv, python3Packages, openmpi, stdenv, @@ -185,6 +186,27 @@ let rpp = self.callPackage ./rpp { }; + rpp-hip = self.rpp.override { useCPU = false; }; + + rpp-cpu = self.rpp.override { useCPU = true; }; + + mivisionx = self.callPackage ../mivisionx { + stdenv = origStdenv; + opencv = opencv.override { enablePython = true; }; + }; + + mivisionx-hip = self.mivisionx.override { + rpp = self.rpp-hip; + useOpenCL = false; + useCPU = false; + }; + + mivisionx-cpu = self.mivisionx.override { + rpp = self.rpp-cpu; + useOpenCL = false; + useCPU = true; + }; + # Even if config.rocmSupport is false we need rocmSupport true # version of ucc/ucx in openmpi in this package set openmpi = openmpi-orig.override ( From 830fb535206410d3b5f4e26a3a06ad25e24e521b Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:24 -0700 Subject: [PATCH 67/79] rocmPackages_10: share aotriton, hiprt, rocm-tests with rocmPackages aotriton, hiprt, rocm-tests are unchanged between ROCm 7.2.4 and 10.1 (no 10.x upstream release, or versioned independently of ROCm), so the rocmPackages_10 scope calls the existing expression instead of copying it. Also add meta. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 90 ++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index f05e592ff9e46..7e44b01c40d27 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -8,6 +8,7 @@ python3Packages, openmpi, stdenv, + pkgs, }: let @@ -78,6 +79,8 @@ let # Replaces hip, opencl-runtime, and rocclr clr = self.callPackage ./clr { }; + aotriton = self.callPackage ../aotriton { stdenv = origStdenv; }; + hipify = self.callPackage ./hipify { stdenv = origStdenv; }; @@ -131,6 +134,8 @@ let hipfft = self.callPackage ./hipfft { }; + hiprt = self.callPackage ../hiprt { }; + tensile = pyPackages.callPackage ./tensile { inherit (self) rocmUpdateScript @@ -227,6 +232,91 @@ let } ); mpi = self.openmpi; + + meta = { + # eval all pkgsRocm release attrs with + # nix-eval-jobs --force-recurse pkgs/top-level/release.nix -I . --select "p: p.pkgsRocm" --no-instantiate + release-packagePlatforms = + let + platforms = [ + "x86_64-linux" + ]; + attrPaths = (builtins.fromJSON (builtins.readFile ../release-attrPaths.json)).attrPaths; + in + lib.foldl' ( + acc: path: + if lib.hasAttrByPath (lib.splitString "." path) pkgs then + lib.recursiveUpdate acc (lib.setAttrByPath (lib.splitString "." path) platforms) + else + acc + ) { } attrPaths; + }; + + rocm-tests = self.callPackage ../rocm-tests { + rocmPackages = self; + }; + } + // lib.optionalAttrs config.allowAliases { + rocmlir = throw '' + 'rocmlir' (ROCm/rocMLIR) has no ROCm 10 release. MIGraphX uses + 'rocmlir-triton', the fork it pins. + ''; # Added 2026-10-17 + rocmlir-rock = throw "'rocmlir-rock' has been replaced by 'rocmlir-triton'"; # Added 2026-10-17 + + rocm-bandwidth-test = throw '' + 'rocm-bandwidth-test' has been removed as it is no longer maintained upstream. + ''; # Added 2026-10-14 + + rpp-opencl = throw '' + 'rpp-opencl' has been removed as it has been broken for a year and has no consuming packages. + Use 'rpp' or 'rpp-cpu' instead. + ''; # Added 2026-03-08 + + rocmPath = throw '' + 'rocm-path' has been removed. If a ROCM_PATH value is required in nixpkgs please + construct one with the minimal set of required deps. + For convenience use outside of nixpkgs consider one of the entries in + 'rocmPackages.meta'. + ''; # Added 2025-09-30 + + rocm-merged-llvm = throw '' + 'rocm-merged-llvm' has been removed. + For 'libllvm' or 'libclang' use 'rocmPackages.llvm.libllvm/clang'. + For a ROCm compiler toolchain use 'rocmPackages.rocm-toolchain'. + If a package uses '$' in CMake from 'libclang' + it may be necessary to convince it to use 'rocm-toolchain' instead. + 'rocm-merged-llvm' avoided this at the cost of significantly bloating closure + size. + ''; # Added 2025-09-30 + + hsa-amd-aqlprofile-bin = lib.warn '' + 'hsa-amd-aqlprofile-bin' has been replaced by 'aqlprofile'. + '' self.aqlprofile; # Added 2025-08-27 + + triton = throw '' + 'rocmPackages.triton' has been removed. Please use python3Packages.triton + ''; # Added 2025-08-24 + + rocm-thunk = throw '' + 'rocm-thunk' has been removed. It's now part of the ROCm runtime. + ''; # Added 2025-3-16 + + clang-ocl = throw '' + 'clang-ocl' has been deprecated upstream. Use ROCm's clang directly. + ''; # Added 2025-3-16 + + miopengemm = throw '' + 'miopengemm' has been deprecated. + ''; # Added 2024-3-3 + + miopen-opencl = throw '' + 'miopen-opencl' has been deprecated. + ''; # Added 2024-3-3 + + mivisionx-opencl = throw '' + 'mivisionx-opencl' has been deprecated. + Other versions of mivisionx are still available. + ''; # Added 2024-3-24 } ); scopeForArches = From fdad8632168a602a99aa2e347bb4f00b8ea3df53 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Sun, 25 Oct 2026 15:55:35 -0700 Subject: [PATCH 68/79] rocmPackages_10.hipfile: init at 10.1 hipFile is ROCm's direct-to-GPU file I/O library, the counterpart of cuFile. TheRock 10.1 builds it from rocm-systems projects/hipfile (storage-libs/CMakeLists.txt). torch 2.14 needs it: Caffe2's LoadHIP runs find_package(hipfile REQUIRED) for ROCm 7.14 and later. - ROCM_PATH and ROCM_VERSION are passed explicitly; without them the build reads /opt/rocm/core-10.1/.info/version. - backend/memcpy-kernel.hip is device code, so the library is built for the scope's GPU targets and carries the arch suffix. - The unwrapped clang++ ignores NIX_CFLAGS_COMPILE and hipFile links libmount with a bare find_library, so util-linux's include directory is added through CXXFLAGS. - Tests and examples are off; the ais-check and ais-stats tools are installed. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/rocm-modules/10/default.nix | 2 + .../rocm-modules/10/hipfile/default.nix | 72 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 pkgs/development/rocm-modules/10/hipfile/default.nix diff --git a/pkgs/development/rocm-modules/10/default.nix b/pkgs/development/rocm-modules/10/default.nix index 7e44b01c40d27..c72d06e9a16e7 100644 --- a/pkgs/development/rocm-modules/10/default.nix +++ b/pkgs/development/rocm-modules/10/default.nix @@ -96,6 +96,8 @@ let }; rocprofiler-sdk = self.callPackage ./rocprofiler-sdk { }; + hipfile = self.callPackage ./hipfile { }; + rocprof-compute-viewer = self.callPackage ../rocprof-compute-viewer { }; rocprof-trace-decoder = self.callPackage ./rocprof-trace-decoder { }; diff --git a/pkgs/development/rocm-modules/10/hipfile/default.nix b/pkgs/development/rocm-modules/10/hipfile/default.nix new file mode 100644 index 0000000000000..86b3353af1365 --- /dev/null +++ b/pkgs/development/rocm-modules/10/hipfile/default.nix @@ -0,0 +1,72 @@ +{ + lib, + stdenv, + fetchFromGitHub, + rocmUpdateScript, + cmake, + rocm-cmake, + clr, + rocm-runtime, + rocprofiler-register, + util-linux, + gpuTargets ? (clr.localGpuTargets or clr.gpuTargets), +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "hipfile${clr.gpuArchSuffix}"; + version = "10.1"; + + src = fetchFromGitHub { + owner = "ROCm"; + repo = "rocm-systems"; + tag = "therock-${finalAttrs.version}"; + sparseCheckout = [ "projects/hipfile" ]; + hash = "sha256-huhoP2J2qw/y6xdhlcLF3kH7CO2cjL5FEJXAmVucANY="; + }; + sourceRoot = "${finalAttrs.src.name}/projects/hipfile"; + + # The unwrapped clang++ ignores NIX_CFLAGS_COMPILE, and hipFile links + # libmount with a bare find_library and no include directory. + env.CXXFLAGS = "-isystem ${lib.getDev util-linux}/include"; + + nativeBuildInputs = [ + cmake + rocm-cmake + clr + ]; + + buildInputs = [ + clr + rocm-runtime + rocprofiler-register + # libmount, for mount-point detection + util-linux + ]; + + cmakeFlags = [ + # Without ROCM_PATH, the build reads /opt/rocm/core-10.1/.info/version. + (lib.cmakeFeature "ROCM_PATH" "${clr}") + (lib.cmakeFeature "ROCM_VERSION" "10.1.0") + (lib.cmakeFeature "CMAKE_HIP_COMPILER" "amdclang++") + (lib.cmakeFeature "CMAKE_HIP_COMPILER_ROCM_ROOT" "${clr}") + # backend/memcpy-kernel.hip is device code. + (lib.cmakeFeature "CMAKE_HIP_ARCHITECTURES" (lib.concatStringsSep ";" gpuTargets)) + (lib.cmakeBool "BUILD_TESTING" false) + (lib.cmakeBool "AIS_INSTALL_EXAMPLES" false) + # Manually define CMAKE_INSTALL_ + # See: https://github.com/NixOS/nixpkgs/pull/197838 + (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") + (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") + (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") + ]; + + passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; + + meta = { + description = "Direct-to-GPU file I/O for ROCm, the counterpart of cuFile"; + homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/hipfile"; + license = lib.licenses.mit; + teams = [ lib.teams.rocm ]; + platforms = lib.platforms.linux; + }; +}) From 88683af2553bb46c1122e7ffe955a1fa117d18d4 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Fri, 16 Oct 2026 19:45:39 -0700 Subject: [PATCH 69/79] rocmPackages.rocm-bandwidth-test: remove Upstream retired rocm_bandwidth_test during the TheRock 7.x series and it has received no updates in nixpkgs since 6.3.3. No package depends on it. https://rocm.docs.amd.com/projects/rocm_bandwidth_test/en/latest/index.html Assisted-by: Claude Code (claude-opus-5-5) --- .../manual/release-notes/rl-2611.section.md | 2 + pkgs/development/rocm-modules/default.nix | 8 ++-- .../rocm-bandwidth-test/default.nix | 43 ------------------- 3 files changed, 6 insertions(+), 47 deletions(-) delete mode 100644 pkgs/development/rocm-modules/rocm-bandwidth-test/default.nix diff --git a/nixos/doc/manual/release-notes/rl-2611.section.md b/nixos/doc/manual/release-notes/rl-2611.section.md index 9c6bac4f7aa62..06d6aeab3660b 100644 --- a/nixos/doc/manual/release-notes/rl-2611.section.md +++ b/nixos/doc/manual/release-notes/rl-2611.section.md @@ -632,3 +632,5 @@ The above example can be migrated via the following structured code block: If your environment requires strict reverse path filtering, you must now explicitly configure it with `networking.firewall.checkReversePath = "strict";`. - `services.photoprism` installations that are upgrading to version `260919-28c46a116` or later are advised to [migrate their library](https://docs.photoprism.app/user-guide/ai/face-recognition/#upgrading-an-existing-library) to take advantage of the newer face detection and embedding models. This can be done by using the `photoprism-manage` script. + +- `rocmPackages.rocm-bandwidth-test` has been removed; upstream retired it. diff --git a/pkgs/development/rocm-modules/default.nix b/pkgs/development/rocm-modules/default.nix index b9617499a66ab..14b993c1d83ba 100644 --- a/pkgs/development/rocm-modules/default.nix +++ b/pkgs/development/rocm-modules/default.nix @@ -241,15 +241,15 @@ let ) { } attrPaths; }; - rocm-bandwidth-test = self.callPackage ./rocm-bandwidth-test { - rocmPackages = self; - }; - rocm-tests = self.callPackage ./rocm-tests { rocmPackages = self; }; } // lib.optionalAttrs config.allowAliases { + rocm-bandwidth-test = throw '' + 'rocm-bandwidth-test' has been removed as it is no longer maintained upstream. + ''; # Added 2026-10-14 + rpp-opencl = throw '' 'rpp-opencl' has been removed as it has been broken for a year and has no consuming packages. Use 'rpp' or 'rpp-cpu' instead. diff --git a/pkgs/development/rocm-modules/rocm-bandwidth-test/default.nix b/pkgs/development/rocm-modules/rocm-bandwidth-test/default.nix deleted file mode 100644 index f3f1b67095381..0000000000000 --- a/pkgs/development/rocm-modules/rocm-bandwidth-test/default.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmPackages, - cmake, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocm-bandwidth-test"; - version = "6.3.3"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm_bandwidth_test"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-dHyfYpRB13wUvim152nZ61McZOQ1zUZFx4dUo2vVqZM="; - }; - - __structuredAttrs = true; - strictDeps = true; - - nativeBuildInputs = [ - cmake - ]; - - buildInputs = [ rocmPackages.rocm-runtime ]; - - cmakeFlags = [ - (lib.cmakeFeature "ROCT_INC_DIR" "${rocmPackages.rocm-runtime}/include/libhsakmt") - ]; - - meta = { - description = "Bandwidth test for AMD GPUs supported by ROCm"; - homepage = "https://github.com/ROCm/rocm_bandwidth_test"; - changelog = "https://github.com/ROCm/rocm_bandwidth_test/releases/tag/${finalAttrs.src.tag}"; - license = lib.licenses.mit; - mainProgram = "rocm-bandwidth-test"; - maintainers = with lib.maintainers; [ fangpen ]; - teams = [ lib.teams.rocm ]; - platforms = [ "x86_64-linux" ]; - }; -}) From 346bd22e6572ae6e952d52b967bbeec3156033fa Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Sat, 17 Oct 2026 09:14:31 -0700 Subject: [PATCH 70/79] opensplat: add pkg-config for ROCm 10 opensplat does find_package(Torch), which includes Caffe2's LoadHIP.cmake and find_package(rocm_smi). On ROCm 10 rocm_smi-config.cmake does find_dependency(PkgConfig) followed by pkg_check_modules(libdrm), so pkg-config must be present as a host tool. libdrm itself comes from torch.cxxdev, which propagates it once rocmPackages is ROCm 10. Also drop a duplicated rocsolver input. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/by-name/op/opensplat/package.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/op/opensplat/package.nix b/pkgs/by-name/op/opensplat/package.nix index c69f7ce03478b..f679723b89ab7 100644 --- a/pkgs/by-name/op/opensplat/package.nix +++ b/pkgs/by-name/op/opensplat/package.nix @@ -3,6 +3,7 @@ stdenv, cmake, ninja, + pkg-config, fetchFromGitHub, python3, opencv, @@ -81,6 +82,7 @@ stdenv'.mkDerivation (finalAttrs: { ] ++ lib.optionals rocmSupport [ rocmPackages.clr + pkg-config ] ++ lib.optionals cudaSupport [ cudaPackages.cuda_nvcc @@ -106,7 +108,6 @@ stdenv'.mkDerivation (finalAttrs: { rocmPackages.hipblaslt rocmPackages.rocblas rocmPackages.rocsolver - rocmPackages.rocsolver rocmPackages.miopen ] ++ lib.optionals cudaSupport [ From 11f758dcb18ed48b709df1c01d4fb078a67df9b5 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Fri, 16 Oct 2026 19:45:41 -0700 Subject: [PATCH 71/79] torchcodec: add libdrm for ROCm 10 Like opensplat, torchcodec's find_package(Torch) pulls in ROCm 10's rocm_smi-config.cmake, which runs pkg_check_modules(libdrm). pkg-config was already a nativeBuildInput; add libdrm so libdrm.pc is found on PKG_CONFIG_PATH. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/python-modules/torchcodec/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/torchcodec/default.nix b/pkgs/development/python-modules/torchcodec/default.nix index cd8934ea99927..f663619e1c4cd 100644 --- a/pkgs/development/python-modules/torchcodec/default.nix +++ b/pkgs/development/python-modules/torchcodec/default.nix @@ -15,6 +15,7 @@ libjpeg, libpng, libwebp, + libdrm, # build-system cmake, @@ -113,7 +114,8 @@ buildPythonPackage.override { inherit (torch) stdenv; } (finalAttrs: { libnpp # nppicc libnvjpeg # nvjpeg.h ] - ); + ) + ++ lib.optionals rocmSupport [ libdrm ]; build-system = [ cmake From c25ac0e6d861b579366d923c7cd38dc1ee92274a Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Fri, 16 Oct 2026 19:45:42 -0700 Subject: [PATCH 72/79] rocmPackages.rocprof-trace-decoder: take comgr and runtime from scope It took the top-level rocmPackages and used rocmPackages.rocm-comgr and rocmPackages.rocm-runtime, so the per-arch scopes (rocmPackages.gfx906, ...) and any other instance of the scope built it against the default set's libraries. Take them as scope arguments like every other package. The default rocmPackages.rocprof-trace-decoder derivation is unchanged. Assisted-by: Claude Code (claude-opus-5-5) --- .../rocm-modules/rocprof-trace-decoder/default.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/development/rocm-modules/rocprof-trace-decoder/default.nix b/pkgs/development/rocm-modules/rocprof-trace-decoder/default.nix index 3ab1bb6446886..edc20bfa33976 100644 --- a/pkgs/development/rocm-modules/rocprof-trace-decoder/default.nix +++ b/pkgs/development/rocm-modules/rocprof-trace-decoder/default.nix @@ -2,7 +2,8 @@ lib, stdenv, fetchFromGitHub, - rocmPackages, + rocm-comgr, + rocm-runtime, cmake, python3, nlohmann_json, @@ -38,8 +39,8 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ cmake ]; buildInputs = [ - rocmPackages.rocm-comgr - rocmPackages.rocm-runtime + rocm-comgr + rocm-runtime ]; cmakeFlags = [ From b77073c81d566765c743a9346c6cf56afdbdb918 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:28 -0700 Subject: [PATCH 73/79] rocmPackages: 7.2.4 -> 10.1 Make the ROCm 10.1 scope the default: rocmPackages is now rocmPackages_10, which stays a concrete attribute (rocm-modules/10/, like rocm-modules/6 before it) so it also exists with allowAliases = false. Every rocmPackages derivation is identical to the corresponding rocmPackages_10 derivation before this commit, including the per-architecture scopes. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/top-level/all-packages.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 63d4d6a926e7d..8df1eb142aee6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1854,8 +1854,7 @@ with pkgs; dvtm-unstable = callPackage ../tools/misc/dvtm/unstable.nix { }; - rocmPackages = recurseIntoAttrs (callPackage ../development/rocm-modules { }); - # Kept out of Hydra until the default ROCm scope switches. + rocmPackages = recurseIntoAttrs rocmPackages_10; rocmPackages_10 = callPackage ../development/rocm-modules/10 { }; tsm-client-withGui = callPackage ../by-name/ts/tsm-client/package.nix { enableGui = true; }; From 98541b6ea6937163d4055ed06ae23470e4f9f91d Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:56 -0700 Subject: [PATCH 74/79] rocmPackages: remove the ROCm 7.2.4 expressions After the switch nothing refers to rocm-modules/default.nix (the 7.2.4 scope) or to the 50 package directories that rocm-modules/10/ replaced. The directories rocmPackages_10 still shares (aotriton, hipcc, hiprt, mivisionx, mscclpp, rocm-docs-core, rocm-tests, rocprof-compute-viewer) and update.nix stay. The rocm-bandwidth-test throw alias lives on in rocm-modules/10/default.nix. Assisted-by: Claude Code (claude-opus-5-5) --- .../rocm-modules/amdsmi/default.nix | 96 -- .../amdsmi/drm-struct-redefinition-fix.patch | 35 - .../rocm-modules/aqlprofile/default.nix | 42 - .../clr/cmake-find-x11-libgl.patch | 40 - pkgs/development/rocm-modules/clr/default.nix | 345 ------- .../clr/test-hiprtc-type-traits.cpp | 68 -- .../clr/test-hiprtc-type-traits.nix | 57 -- .../rocm-modules/clr/test-isa-compat.nix | 74 -- .../rocm-modules/clr/test-opencl-cts.nix | 28 - .../rocm-modules/clr/test-rocm-smi.nix | 27 - .../rocm-modules/composable_kernel/base.nix | 205 ----- .../composable_kernel/ck4inductor.nix | 44 - .../composable_kernel/default.nix | 319 ------- .../fix-empty-offload-targets.diff | 23 - pkgs/development/rocm-modules/default.nix | 339 ------- .../development/rocm-modules/half/default.nix | 35 - .../rocm-modules/hip-common/default.nix | 46 - .../rocm-modules/hipblas-common/default.nix | 43 - .../rocm-modules/hipblas/default.nix | 132 --- .../hipblaslt/Tensile-interning.patch | 181 ---- .../TensileCreateLibrary-refactor.patch | 849 ------------------ .../rocm-modules/hipblaslt/default.nix | 256 ------ .../messagepack-compression-support.patch | 56 -- .../parallel-buildSourceCodeObjectFile.diff | 12 - .../rocm-modules/hipcub/default.nix | 100 --- .../rocm-modules/hipfft/default.nix | 121 --- .../rocm-modules/hipfort/default.nix | 70 -- .../rocm-modules/hipify/default.nix | 66 -- .../rocm-modules/hiprand/default.nix | 78 -- .../rocm-modules/hipsolver/default.nix | 117 --- .../rocm-modules/hipsparse/default.nix | 148 --- .../rocm-modules/hipsparselt/default.nix | 123 --- .../clang-bodge-ignore-systemwide-incls.diff | 23 - .../rocm-modules/llvm/clang-log-jobs.diff | 40 - .../development/rocm-modules/llvm/default.nix | 614 ------------- .../opt-offload-compress-on-by-default.patch | 22 - .../llvm/perf-increase-namestring-size.patch | 28 - .../perf-shorten-gcclib-include-paths.patch | 59 -- .../rocm-modules/migraphx/default.nix | 208 ----- .../migraphx/test-migraphx-driver.nix | 47 - .../rocm-modules/miopen/default.nix | 338 ------- pkgs/development/rocm-modules/miopen/kdbs.nix | 27 - .../miopen/skip-preexisting-dbs.patch | 22 - .../test-frugally-deep-model-loading.cpp | 55 -- .../test-frugally-deep-model-loading.nix | 49 - .../miopen/test-runtime-compilation.nix | 37 - .../development/rocm-modules/miopen/update.sh | 48 - .../development/rocm-modules/rccl/default.nix | 158 ---- .../rccl/fix_hw_reg_hw_id_gt_gfx10.patch | 33 - .../rccl/rccl-test-missing-iomanip.diff | 10 - pkgs/development/rocm-modules/rdc/default.nix | 150 ---- .../rocm-modules/rdc/fix-cmake-cxxflags.patch | 217 ----- .../rdc/fix-libcap-pkgconfig.patch | 57 -- .../rocm-modules/rocalution/default.nix | 122 --- .../rocm-modules/rocblas/default.nix | 208 ----- .../rocblas/hiplaslt-unstable-compat.patch | 99 -- .../rocm-modules/rocdbgapi/default.nix | 109 --- .../rocm-modules/rocfft/default.nix | 170 ---- .../rocfft/log-every-n-aot-jobs.patch | 35 - .../rocm-modules/rocgdb/default.nix | 113 --- .../rocm-modules/rocm-cmake/default.nix | 34 - .../rocm-modules/rocm-comgr/default.nix | 88 -- .../fix-ccob-compat-output-filename.patch | 11 - .../rocm-modules/rocm-core/default.nix | 95 -- .../rocm-core/env-rocm-path.patch | 22 - .../rocm-modules/rocm-device-libs/cmake.patch | 43 - .../rocm-modules/rocm-device-libs/default.nix | 67 -- .../rocm-modules/rocm-runtime/default.nix | 109 --- .../rocm-runtime/queue-failure.patch | 71 -- .../remove-hsa-aqlprofile-dep.patch | 27 - .../rocm-modules/rocm-smi/default.nix | 78 -- .../rocm-modules/rocminfo/default.nix | 57 -- .../rocm-modules/rocmlir/default.nix | 161 ---- .../rocm-modules/rocprim/default.nix | 97 -- .../rocprof-trace-decoder/default.nix | 86 -- .../fix-test-dependency.patch | 15 - .../use-system-dependencies.patch | 81 -- .../rocprofiler-register/default.nix | 97 -- ...missing-CPackComponent-cmake-include.patch | 25 - ...2-allow-using-system-yaml-dependency.patch | 68 -- ...-allow-using-system-elfio-dependency.patch | 70 -- ...4-allow-using-system-otf2-dependency.patch | 54 -- ...5-allow-using-system-json-dependency.patch | 54 -- .../0006-fix-amd-comgr-resolution.patch | 154 ---- ...udes-and-api-changes-with-fmt-v12.2..patch | 260 ------ ...ilation-errors-from-missing-includes.patch | 93 -- ...ocprofiler-sdk-guard-ompt-auto-start.patch | 50 -- .../rocm-modules/rocprofiler-sdk/default.nix | 226 ----- .../rocm-modules/rocprofiler/default.nix | 141 --- .../rocm-modules/rocr-debug-agent/default.nix | 55 -- .../rocm-modules/rocrand/default.nix | 98 -- .../rocm-modules/rocshmem/default.nix | 69 -- .../rocm-modules/rocsolver/default.nix | 135 --- .../rocm-modules/rocsparse/default.nix | 159 ---- .../rocm-modules/rocsparse/deps.nix | 223 ----- .../rocm-modules/rocthrust/default.nix | 93 -- .../rocm-modules/roctracer/default.nix | 118 --- .../rocwmma/0000-dont-fetch-googletest.patch | 35 - .../rocm-modules/rocwmma/default.nix | 116 --- pkgs/development/rocm-modules/rpp/default.nix | 77 -- .../rocm-modules/tensile/default.nix | 96 -- ...ensile-create-library-dont-copy-twice.diff | 20 - .../tensile-solutionstructs-perf-fix.diff | 48 - 103 files changed, 11049 deletions(-) delete mode 100644 pkgs/development/rocm-modules/amdsmi/default.nix delete mode 100644 pkgs/development/rocm-modules/amdsmi/drm-struct-redefinition-fix.patch delete mode 100644 pkgs/development/rocm-modules/aqlprofile/default.nix delete mode 100644 pkgs/development/rocm-modules/clr/cmake-find-x11-libgl.patch delete mode 100644 pkgs/development/rocm-modules/clr/default.nix delete mode 100644 pkgs/development/rocm-modules/clr/test-hiprtc-type-traits.cpp delete mode 100644 pkgs/development/rocm-modules/clr/test-hiprtc-type-traits.nix delete mode 100644 pkgs/development/rocm-modules/clr/test-isa-compat.nix delete mode 100644 pkgs/development/rocm-modules/clr/test-opencl-cts.nix delete mode 100644 pkgs/development/rocm-modules/clr/test-rocm-smi.nix delete mode 100644 pkgs/development/rocm-modules/composable_kernel/base.nix delete mode 100644 pkgs/development/rocm-modules/composable_kernel/ck4inductor.nix delete mode 100644 pkgs/development/rocm-modules/composable_kernel/default.nix delete mode 100644 pkgs/development/rocm-modules/composable_kernel/fix-empty-offload-targets.diff delete mode 100644 pkgs/development/rocm-modules/default.nix delete mode 100644 pkgs/development/rocm-modules/half/default.nix delete mode 100644 pkgs/development/rocm-modules/hip-common/default.nix delete mode 100644 pkgs/development/rocm-modules/hipblas-common/default.nix delete mode 100644 pkgs/development/rocm-modules/hipblas/default.nix delete mode 100644 pkgs/development/rocm-modules/hipblaslt/Tensile-interning.patch delete mode 100644 pkgs/development/rocm-modules/hipblaslt/TensileCreateLibrary-refactor.patch delete mode 100644 pkgs/development/rocm-modules/hipblaslt/default.nix delete mode 100644 pkgs/development/rocm-modules/hipblaslt/messagepack-compression-support.patch delete mode 100644 pkgs/development/rocm-modules/hipblaslt/parallel-buildSourceCodeObjectFile.diff delete mode 100644 pkgs/development/rocm-modules/hipcub/default.nix delete mode 100644 pkgs/development/rocm-modules/hipfft/default.nix delete mode 100644 pkgs/development/rocm-modules/hipfort/default.nix delete mode 100644 pkgs/development/rocm-modules/hipify/default.nix delete mode 100644 pkgs/development/rocm-modules/hiprand/default.nix delete mode 100644 pkgs/development/rocm-modules/hipsolver/default.nix delete mode 100644 pkgs/development/rocm-modules/hipsparse/default.nix delete mode 100644 pkgs/development/rocm-modules/hipsparselt/default.nix delete mode 100644 pkgs/development/rocm-modules/llvm/clang-bodge-ignore-systemwide-incls.diff delete mode 100644 pkgs/development/rocm-modules/llvm/clang-log-jobs.diff delete mode 100644 pkgs/development/rocm-modules/llvm/default.nix delete mode 100644 pkgs/development/rocm-modules/llvm/opt-offload-compress-on-by-default.patch delete mode 100644 pkgs/development/rocm-modules/llvm/perf-increase-namestring-size.patch delete mode 100644 pkgs/development/rocm-modules/llvm/perf-shorten-gcclib-include-paths.patch delete mode 100644 pkgs/development/rocm-modules/migraphx/default.nix delete mode 100644 pkgs/development/rocm-modules/migraphx/test-migraphx-driver.nix delete mode 100644 pkgs/development/rocm-modules/miopen/default.nix delete mode 100644 pkgs/development/rocm-modules/miopen/kdbs.nix delete mode 100644 pkgs/development/rocm-modules/miopen/skip-preexisting-dbs.patch delete mode 100644 pkgs/development/rocm-modules/miopen/test-frugally-deep-model-loading.cpp delete mode 100644 pkgs/development/rocm-modules/miopen/test-frugally-deep-model-loading.nix delete mode 100644 pkgs/development/rocm-modules/miopen/test-runtime-compilation.nix delete mode 100755 pkgs/development/rocm-modules/miopen/update.sh delete mode 100644 pkgs/development/rocm-modules/rccl/default.nix delete mode 100644 pkgs/development/rocm-modules/rccl/fix_hw_reg_hw_id_gt_gfx10.patch delete mode 100644 pkgs/development/rocm-modules/rccl/rccl-test-missing-iomanip.diff delete mode 100644 pkgs/development/rocm-modules/rdc/default.nix delete mode 100644 pkgs/development/rocm-modules/rdc/fix-cmake-cxxflags.patch delete mode 100644 pkgs/development/rocm-modules/rdc/fix-libcap-pkgconfig.patch delete mode 100644 pkgs/development/rocm-modules/rocalution/default.nix delete mode 100644 pkgs/development/rocm-modules/rocblas/default.nix delete mode 100644 pkgs/development/rocm-modules/rocblas/hiplaslt-unstable-compat.patch delete mode 100644 pkgs/development/rocm-modules/rocdbgapi/default.nix delete mode 100644 pkgs/development/rocm-modules/rocfft/default.nix delete mode 100644 pkgs/development/rocm-modules/rocfft/log-every-n-aot-jobs.patch delete mode 100644 pkgs/development/rocm-modules/rocgdb/default.nix delete mode 100644 pkgs/development/rocm-modules/rocm-cmake/default.nix delete mode 100644 pkgs/development/rocm-modules/rocm-comgr/default.nix delete mode 100644 pkgs/development/rocm-modules/rocm-comgr/fix-ccob-compat-output-filename.patch delete mode 100644 pkgs/development/rocm-modules/rocm-core/default.nix delete mode 100644 pkgs/development/rocm-modules/rocm-core/env-rocm-path.patch delete mode 100644 pkgs/development/rocm-modules/rocm-device-libs/cmake.patch delete mode 100644 pkgs/development/rocm-modules/rocm-device-libs/default.nix delete mode 100644 pkgs/development/rocm-modules/rocm-runtime/default.nix delete mode 100644 pkgs/development/rocm-modules/rocm-runtime/queue-failure.patch delete mode 100644 pkgs/development/rocm-modules/rocm-runtime/remove-hsa-aqlprofile-dep.patch delete mode 100644 pkgs/development/rocm-modules/rocm-smi/default.nix delete mode 100644 pkgs/development/rocm-modules/rocminfo/default.nix delete mode 100644 pkgs/development/rocm-modules/rocmlir/default.nix delete mode 100644 pkgs/development/rocm-modules/rocprim/default.nix delete mode 100644 pkgs/development/rocm-modules/rocprof-trace-decoder/default.nix delete mode 100644 pkgs/development/rocm-modules/rocprof-trace-decoder/fix-test-dependency.patch delete mode 100644 pkgs/development/rocm-modules/rocprof-trace-decoder/use-system-dependencies.patch delete mode 100644 pkgs/development/rocm-modules/rocprofiler-register/default.nix delete mode 100644 pkgs/development/rocm-modules/rocprofiler-sdk/0001-fix-missing-CPackComponent-cmake-include.patch delete mode 100644 pkgs/development/rocm-modules/rocprofiler-sdk/0002-allow-using-system-yaml-dependency.patch delete mode 100644 pkgs/development/rocm-modules/rocprofiler-sdk/0003-allow-using-system-elfio-dependency.patch delete mode 100644 pkgs/development/rocm-modules/rocprofiler-sdk/0004-allow-using-system-otf2-dependency.patch delete mode 100644 pkgs/development/rocm-modules/rocprofiler-sdk/0005-allow-using-system-json-dependency.patch delete mode 100644 pkgs/development/rocm-modules/rocprofiler-sdk/0006-fix-amd-comgr-resolution.patch delete mode 100644 pkgs/development/rocm-modules/rocprofiler-sdk/0007-fix-missing-includes-and-api-changes-with-fmt-v12.2..patch delete mode 100644 pkgs/development/rocm-modules/rocprofiler-sdk/0008-fix-compilation-errors-from-missing-includes.patch delete mode 100644 pkgs/development/rocm-modules/rocprofiler-sdk/0009-rocprofiler-sdk-guard-ompt-auto-start.patch delete mode 100644 pkgs/development/rocm-modules/rocprofiler-sdk/default.nix delete mode 100644 pkgs/development/rocm-modules/rocprofiler/default.nix delete mode 100644 pkgs/development/rocm-modules/rocr-debug-agent/default.nix delete mode 100644 pkgs/development/rocm-modules/rocrand/default.nix delete mode 100644 pkgs/development/rocm-modules/rocshmem/default.nix delete mode 100644 pkgs/development/rocm-modules/rocsolver/default.nix delete mode 100644 pkgs/development/rocm-modules/rocsparse/default.nix delete mode 100644 pkgs/development/rocm-modules/rocsparse/deps.nix delete mode 100644 pkgs/development/rocm-modules/rocthrust/default.nix delete mode 100644 pkgs/development/rocm-modules/roctracer/default.nix delete mode 100644 pkgs/development/rocm-modules/rocwmma/0000-dont-fetch-googletest.patch delete mode 100644 pkgs/development/rocm-modules/rocwmma/default.nix delete mode 100644 pkgs/development/rocm-modules/rpp/default.nix delete mode 100644 pkgs/development/rocm-modules/tensile/default.nix delete mode 100644 pkgs/development/rocm-modules/tensile/tensile-create-library-dont-copy-twice.diff delete mode 100644 pkgs/development/rocm-modules/tensile/tensile-solutionstructs-perf-fix.diff diff --git a/pkgs/development/rocm-modules/amdsmi/default.nix b/pkgs/development/rocm-modules/amdsmi/default.nix deleted file mode 100644 index d483dde8b6e8a..0000000000000 --- a/pkgs/development/rocm-modules/amdsmi/default.nix +++ /dev/null @@ -1,96 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - pkg-config, - libdrm, - python, - wrapPython, - autoPatchelfHook, -}: - -let - esmi_ib_src = fetchFromGitHub { - owner = "amd"; - repo = "esmi_ib_library"; - tag = "esmi_pkg_ver-4.2"; - hash = "sha256-czF9ezkAO0PuDkXh8y639AcOZH+KVcWiXPX74H5W/nw="; - }; -in -stdenv.mkDerivation (finalAttrs: { - pname = "amdsmi"; - version = "7.2.4"; - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/amdsmi" - "shared" - ]; - hash = "sha256-TFi+3txemvV6K827e8S3hZOd9jcj4Qzop6V9CdKrpLg="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/amdsmi"; - - postPatch = '' - substituteInPlace goamdsmi_shim/CMakeLists.txt \ - --replace-fail "amd_smi)" ${"'"}''${AMD_SMI_TARGET})' \ - --replace-fail 'target_link_libraries(''${GOAMDSMI_SHIM_TARGET} -L' '#' - substituteInPlace CMakeLists.txt \ - --replace-fail "if(NOT latest_esmi_tag STREQUAL current_esmi_tag)" "if(OFF)" - - # Manually unpack esmi_ib_src and add amd_hsmp.h so execute-process git clone doesn't run - cp -rf --no-preserve=mode ${esmi_ib_src} ./esmi_ib_library - mkdir -p ./esmi_ib_library/include/asm - cp ./include/amd_smi/impl/amd_hsmp.h ./esmi_ib_library/include/asm/amd_hsmp.h - ''; - - patches = [ - # Fix error: redefinition of 'struct drm_color_ctm_3x4' - # https://github.com/ROCm/amdsmi/pull/165 - ./drm-struct-redefinition-fix.patch - ]; - - nativeBuildInputs = [ - cmake - pkg-config - wrapPython - autoPatchelfHook - ]; - - buildInputs = [ - libdrm - ]; - - cmakeFlags = [ - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ]; - - postInstall = '' - mkdir -p $out/${python.sitePackages} - ln -s $out/share/amd_smi/amdsmi $out/${python.sitePackages}/amdsmi - - makeWrapperArgs=(--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libdrm ]}) - wrapPythonProgramsIn $out - rm $out/bin/amd-smi - ln -sf $out/libexec/amdsmi_cli/amdsmi_cli.py $out/bin/amd-smi - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "System management interface for AMD GPUs supported by ROCm"; - homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/amdsmi"; - license = lib.licenses.mit; - maintainers = with lib.maintainers; [ lovesegfault ]; - teams = [ lib.teams.rocm ]; - platforms = [ "x86_64-linux" ]; - mainProgram = "amd-smi"; - }; -}) diff --git a/pkgs/development/rocm-modules/amdsmi/drm-struct-redefinition-fix.patch b/pkgs/development/rocm-modules/amdsmi/drm-struct-redefinition-fix.patch deleted file mode 100644 index caf23edcef57a..0000000000000 --- a/pkgs/development/rocm-modules/amdsmi/drm-struct-redefinition-fix.patch +++ /dev/null @@ -1,35 +0,0 @@ -From b8b4a6bcfe35ba9539a120cfd16573123ddd9241 Mon Sep 17 00:00:00 2001 -From: "Sv. Lockal" -Date: Mon, 15 Dec 2025 03:46:35 +0800 -Subject: [PATCH] Fix compilation with libdrm-2.4.130 - -Fix error: redefinition of 'struct drm_color_ctm_3x4'. - -drm_color_ctm_3x4 structure is now defined in https://github.com/torvalds/linux/commit/e5719e7f19009d4fbedf685fc22eec9cd8de154f#diff-4c51fb416ec7cc69566cd7b795ee57eb070aa1006ad65d6962081f039ffb2718 - -As this structure is unused and not a part of amdsmi public interface, -it is safe to remove it. ---- - include/amd_smi/impl/amdgpu_drm.h | 9 --------- - 1 file changed, 9 deletions(-) - -diff --git a/include/amd_smi/impl/amdgpu_drm.h b/include/amd_smi/impl/amdgpu_drm.h -index b56a5ac4b..0e483d13b 100644 ---- a/include/amd_smi/impl/amdgpu_drm.h -+++ b/include/amd_smi/impl/amdgpu_drm.h -@@ -1625,15 +1625,6 @@ struct drm_amdgpu_info_uq_metadata { - #define AMDGPU_FAMILY_GC_11_5_0 150 /* GC 11.5.0 */ - #define AMDGPU_FAMILY_GC_12_0_0 152 /* GC 12.0.0 */ - --/* FIXME wrong namespace! */ --struct drm_color_ctm_3x4 { -- /* -- * Conversion matrix with 3x4 dimensions in S31.32 sign-magnitude -- * (not two's complement!) format. -- */ -- __u64 matrix[12]; --}; -- - #if defined(__cplusplus) - } - #endif diff --git a/pkgs/development/rocm-modules/aqlprofile/default.nix b/pkgs/development/rocm-modules/aqlprofile/default.nix deleted file mode 100644 index 34b1d92f3d57f..0000000000000 --- a/pkgs/development/rocm-modules/aqlprofile/default.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ - lib, - stdenv, - clr, - cmake, - fetchFromGitHub, - rocmUpdateScript, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "aqlprofile"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/aqlprofile" - "shared" - ]; - hash = "sha256-74HjB5Ughu17rSRx9mfCCsPJI4TVyXnT4aU7vIbm7ak="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/aqlprofile"; - - env.CXXFLAGS = "-DROCP_LD_AQLPROFILE=1"; - - nativeBuildInputs = [ - cmake - clr - ]; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "AQLPROFILE library for AMD HSA runtime API extension support"; - homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/aqlprofile"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/clr/cmake-find-x11-libgl.patch b/pkgs/development/rocm-modules/clr/cmake-find-x11-libgl.patch deleted file mode 100644 index 5a36a2c2c74d0..0000000000000 --- a/pkgs/development/rocm-modules/clr/cmake-find-x11-libgl.patch +++ /dev/null @@ -1,40 +0,0 @@ -diff --git a/rocclr/cmake/ROCclr.cmake b/rocclr/cmake/ROCclr.cmake -index 3f233b72f..67bdc62ee 100644 ---- a/rocclr/cmake/ROCclr.cmake -+++ b/rocclr/cmake/ROCclr.cmake -@@ -44,6 +44,19 @@ find_package(Threads REQUIRED) - - find_package(AMD_OPENCL) - -+# Find X11 package -+find_package(X11 REQUIRED) -+if(NOT X11_FOUND) -+ message(FATAL_ERROR "X11 libraries not found") -+endif() -+ -+# Find OpenGL package -+find_package(OpenGL REQUIRED) -+if(NOT OpenGL_FOUND) -+ message(FATAL_ERROR "OpenGL not found") -+endif() -+ -+ - add_library(rocclr STATIC) - - include(ROCclrCompilerOptions) -@@ -123,9 +136,14 @@ target_include_directories(rocclr PUBLIC - ${ROCCLR_SRC_DIR}/device - ${ROCCLR_SRC_DIR}/elf - ${ROCCLR_SRC_DIR}/include -+ ${X11_INCLUDE_DIR} -+ ${OPENGL_INCLUDE_DIR} - ${AMD_OPENCL_INCLUDE_DIRS}) - --target_link_libraries(rocclr PUBLIC Threads::Threads) -+target_link_libraries(rocclr PUBLIC -+ Threads::Threads -+ ${X11_LIBRARIES} -+ ${OPENGL_LIBRARIES}) - # IPC on Windows is not supported - if(UNIX) - target_link_libraries(rocclr PUBLIC rt) diff --git a/pkgs/development/rocm-modules/clr/default.nix b/pkgs/development/rocm-modules/clr/default.nix deleted file mode 100644 index 554c76d845c04..0000000000000 --- a/pkgs/development/rocm-modules/clr/default.nix +++ /dev/null @@ -1,345 +0,0 @@ -{ - lib, - stdenv, - callPackage, - fetchFromGitHub, - fetchpatch, - rocmUpdateScript, - makeWrapper, - cmake, - perl, - hip-common, - hipcc, - rocm-device-libs, - rocm-comgr, - rocm-runtime, - rocm-core, - roctracer, - rocminfo, - rocm-smi, - rocprofiler-register, - symlinkJoin, - numactl, - libffi, - zstd, - zlib, - libGL, - libxml2, - libx11, - python3Packages, - llvm, - khronos-ocl-icd-loader, - gcc-unwrapped, - writeShellScriptBin, - localGpuTargets ? null, -}: - -let - inherit (rocm-core) ROCM_LIBPATCH_VERSION; - # HIP_CLANG_PATH or ROCM_PATH/llvm - # Note: relying on ROCM_PATH/llvm is bad for cross - hipClang = symlinkJoin { - name = "hipClang"; - paths = [ - # FIXME: if we don't put this first aotriton build fails with ld.lld: -flavor gnu - # Probably wrapper jank - llvm.bintools.bintools - llvm.rocm-toolchain - ]; - postBuild = '' - rm -rf $out/{include,lib,share,etc,nix-support,usr} - ''; - }; - hipClangPath = "${hipClang}/bin"; - wrapperArgs = [ - "--prefix PATH : $out/bin" - "--prefix LD_LIBRARY_PATH : ${rocm-runtime}" - "--set HIP_PLATFORM amd" - "--set HIP_PATH $out" - "--set HIP_CLANG_PATH ${hipClangPath}" - "--set DEVICE_LIB_PATH ${rocm-device-libs}/amdgcn/bitcode" - "--set HSA_PATH ${rocm-runtime}" - "--set ROCM_PATH $out" - ]; - amdclang = writeShellScriptBin "amdclang" '' - exec ${hipClang}/bin/clang "$@" - ''; - amdclangxx = writeShellScriptBin "amdclang++" '' - exec ${hipClang}/bin/clang++ "$@" - ''; -in -stdenv.mkDerivation (finalAttrs: { - pname = "clr"; - version = "7.2.4"; - - outputs = [ - "out" - "icd" - ]; - - __structuredAttrs = true; - strictDeps = true; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/clr" - "shared" - ]; - hash = "sha256-//cQBKlSB9uSP4fBgJpI1FxnqlzyQN913CHVGa2tqv8="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/clr"; - - nativeBuildInputs = [ - makeWrapper - cmake - perl - python3Packages.python - python3Packages.cppheaderparser - amdclang - amdclangxx - ]; - - buildInputs = [ - llvm.llvm - numactl - libGL - libxml2 - libx11 - khronos-ocl-icd-loader - hipClang - libffi - zstd - zlib - rocprofiler-register - ]; - - propagatedBuildInputs = [ - rocm-core - rocm-device-libs - rocm-comgr - rocm-runtime - rocminfo - hipClangPath - ]; - - cmakeBuildType = "RelWithDebInfo"; - separateDebugInfo = true; - - cmakeFlags = [ - (lib.cmakeFeature "CMAKE_POLICY_DEFAULT_CMP0072" "NEW") # Prefer newer OpenGL libraries - (lib.cmakeBool "CLR_BUILD_HIP" true) - (lib.cmakeBool "CLR_BUILD_OCL" true) - (lib.cmakeFeature "HIP_COMMON_DIR" hip-common.outPath) - (lib.cmakeFeature "HIPCC_BIN_DIR" "${hipcc}/bin") - (lib.cmakeFeature "HIP_PLATFORM" "amd") - (lib.cmakeFeature "PROF_API_HEADER_PATH" "${roctracer.src}/inc/ext") - (lib.cmakeFeature "ROCM_PATH" rocminfo.outPath) - (lib.cmakeBool "BUILD_ICD" true) - (lib.cmakeFeature "AMD_ICD_LIBRARY_DIR" khronos-ocl-icd-loader.outPath) - - # Temporarily set variables to work around upstream CMakeLists issue - # Can be removed once https://github.com/ROCm/rocm-cmake/issues/121 is fixed - (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") - (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") - (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") - ]; - - env.LLVM_DIR = ""; - - patches = [ - ./cmake-find-x11-libgl.patch - (fetchpatch { - # [PATCH] rocclr: Extend HIP ISA compatibility checks - hash = "sha256-3MsDL+OQg24wH1RDhbao74RuIbzEAmduwla9KOPzQ/M="; - url = "https://github.com/GZGavinZhao/rocm-systems/commit/039cb23b24d739adb8c0f9de8b550d9f557de031.patch"; - relative = "projects/clr"; - }) - ]; - - postPatch = '' - patchShebangs hipamd/*.sh - patchShebangs hipamd/src - '' - # We're not on Windows so these are never installed to hipcc... - + '' - substituteInPlace hipamd/CMakeLists.txt \ - --replace-fail "install(PROGRAMS \''${HIPCC_BIN_DIR}/hipcc.bat DESTINATION bin)" "" \ - --replace-fail "install(PROGRAMS \''${HIPCC_BIN_DIR}/hipconfig.bat DESTINATION bin)" "" - '' - + '' - substituteInPlace hipamd/src/hip_embed_pch.sh \ - --replace-fail "\''$LLVM_DIR/bin/clang" "${hipClangPath}/clang" \ - --replace-fail "\''$LLVM_DIR/bin/llvm-mc" "${lib.getExe' llvm.bintools.bintools "llvm-mc"}" - '' - + '' - substituteInPlace opencl/khronos/icd/loader/icd_platform.h \ - --replace-fail '#define ICD_VENDOR_PATH "/etc/OpenCL/vendors/";' \ - '#define ICD_VENDOR_PATH "/run/opengl-driver/etc/OpenCL/vendors/";' - '' - # HIP defines __noinline__ as an empty macro for host compilers, which breaks - # [[__gnu__::__noinline__]] in libstdc++ 16's - # https://github.com/ROCm/rocm-systems/pull/12596 - + '' - substituteInPlace hipamd/include/hip/amd_detail/host_defines.h \ - --replace-fail $'#define __noinline__\n' "" - ''; - - postInstall = '' - chmod +x $out/bin/* - patchShebangs $out/bin - - cp ${amdclang}/bin/* $out/bin/ - cp ${amdclangxx}/bin/* $out/bin/ - - for prog in hip{cc,config}; do - wrapProgram $out/bin/$prog ${lib.concatStringsSep " " wrapperArgs} - done - - mkdir -p $out/nix-support/ - echo ' - export HIP_PATH="${placeholder "out"}" - export HIP_PLATFORM=amd - export HIP_DEVICE_LIB_PATH="${rocm-device-libs}/amdgcn/bitcode" - export NIX_CC_USE_RESPONSE_FILE=0 - export HIP_CLANG_PATH="${hipClangPath}" - export ROCM_LIBPATCH_VERSION="${ROCM_LIBPATCH_VERSION}" - export HSA_PATH="${rocm-runtime}"' > $out/nix-support/setup-hook - - # Just link rocminfo, it's easier - ln -s ${rocminfo}/bin/* $out/bin - ln -s ${rocm-core}/include/* $out/include/ - - # Replace rocm-opencl-icd functionality - mkdir -p $icd/etc/OpenCL/vendors - echo "$out/lib/libamdocl64.so" > $icd/etc/OpenCL/vendors/amdocl64.icd - - # add version info to output (downstream rocmPackages look for this) - ln -s ${rocm-core}/.info/ $out/.info - - ln -s ${hipClang} $out/llvm - ''; - - # libamdhip64.so dlopens its own bare name for hipGetProcAddress symbol resolution, - # same pattern with libhiprtc.so, so add own lib directory to all .so's - # RPATHs so they can find themselves and neighbouring libs - # Must be in postFixup so it runs after patchelf --shrink-rpath which removes - # the apparently useless rpath - postFixup = '' - patchelf --add-rpath "$out/lib" "$out"/lib/*.so - ''; - - disallowedRequisites = [ - gcc-unwrapped - ]; - - passthru = { - # All known and valid general GPU targets - # We cannot use this for each ROCm library, as each defines their own supported targets - # See: https://github.com/ROCm/ROCm/blob/77cbac4abab13046ee93d8b5bf410684caf91145/README.md#library-target-matrix - gpuTargets = lib.forEach [ - # "9-generic" # can handle all Vega variants - "900" # MI25, Vega 56/64 - # "902" # Vega 8 - # "909" # Renoir Vega APU - # "90c" # Renoir Vega APU - # Past this point cards need their own kernels for perf despite gfx9-generic compat - "906" # MI50/60, Radeon VII - adds dot product & mixed precision FMA ops - "908" # MI100 - adds MFMA (matrix fused multiply-add) ops - "90a" # MI210/MI250 - additional MFMA variants - # "9-4-generic" - since only 942 is valid for 6.4 target it directly - # 940/1 - never released publicly, maybe HPE cray specific MI3xx? - "942" # MI300A/X, MI325X - "950" # MI350X, MI355X - # "10-1-generic" # fine for all RDNA1 cards - "1010" - # "10-3-generic" - "1030" # W6800, various Radeon cards - # 1100 through 1103 = RDNA3 - # "11-generic" # will handle 7600, hopefully ryzen AI series iGPUs - "1100" - "1101" - "1102" - "1103" # RDNA3 iGPU like Radeon 780M - "1150" # Strix Point - "1151" # Strix Halo - # "12-generic" - "1200" # RX 9060 - "1201" # RX 9070 + XT - ] (target: "gfx${target}"); - - inherit hipClangPath; - - updateScript = rocmUpdateScript { inherit finalAttrs; }; - - impureTests = { - # bash $(nix-build -A rocmPackages.clr.impureTests.rocm-smi) - rocm-smi = callPackage ./test-rocm-smi.nix { - inherit rocm-smi; - clr = finalAttrs.finalPackage; - }; - # Simple subset of opencl-cts test_basic - opencl-cts = callPackage ./test-opencl-cts.nix { - clr = finalAttrs.finalPackage; - }; - generic-arch = callPackage ./test-isa-compat.nix { - clr = finalAttrs.finalPackage; - name = "generic-arch"; - offloadArches = [ - "gfx9-generic" - "gfx10-1-generic" - "gfx10-3-generic" - "gfx11-generic" - "gfx12-generic" - ]; - }; - isa-compat = callPackage ./test-isa-compat.nix { - clr = finalAttrs.finalPackage; - name = "isa-compat"; - offloadArches = [ - "gfx900" - "gfx1010" - "gfx1030" - ]; - }; - spirv = callPackage ./test-isa-compat.nix { - clr = finalAttrs.finalPackage; - name = "spirv"; - offloadArches = [ - "amdgcnspirv" - ]; - }; - hiprtc-type-traits = callPackage ./test-hiprtc-type-traits.nix { - clr = finalAttrs.finalPackage; - inherit rocm-smi; - }; - }; - - selectGpuTargets = - { - supported ? [ ], - }: - supported; - gpuArchSuffix = ""; - } - // lib.optionalAttrs (localGpuTargets != null) { - inherit localGpuTargets; - gpuArchSuffix = "-" + (builtins.concatStringsSep "-" localGpuTargets); - selectGpuTargets = - { - supported ? [ ], - }: - if supported == [ ] then localGpuTargets else lib.lists.intersectLists localGpuTargets supported; - }; - - meta = { - description = "AMD Common Language Runtime for hipamd, opencl, and rocclr"; - homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/clr"; - license = lib.licenses.mit; - maintainers = with lib.maintainers; [ lovesegfault ]; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/clr/test-hiprtc-type-traits.cpp b/pkgs/development/rocm-modules/clr/test-hiprtc-type-traits.cpp deleted file mode 100644 index 39a99f39eae11..0000000000000 --- a/pkgs/development/rocm-modules/clr/test-hiprtc-type-traits.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include -#include - -#define CHECK_HIP(expr) do { \ - if ((expr) != hipSuccess) { \ - std::cerr << #expr << " failed" << std::endl; \ - return 1; \ - } \ -} while(0) - -#define CHECK_HIPRTC(expr) do { \ - hiprtcResult _res = (expr); \ - if (_res != HIPRTC_SUCCESS) { \ - std::cerr << #expr << " failed: " << hiprtcGetErrorString(_res) << std::endl; \ - hiprtcGetProgramLogSize(prog, &log_size); \ - if (log_size > 0) { \ - std::string log(log_size, '\0'); \ - hiprtcGetProgramLog(prog, log.data()); \ - std::cerr << "Compile log:\n" << log << std::endl; \ - } \ - return 1; \ - } \ -} while(0) - -static const char* kernelSource = R"( - #include - - extern "C" __global__ void test_kernel(int* out) { - static_assert(std::is_same::type>::value, - "type_traits not working"); - out[0] = 5; - } -)"; - -int main() { - hiprtcProgram prog; - size_t log_size = 0; - CHECK_HIPRTC(hiprtcCreateProgram(&prog, kernelSource, "test.hip", 0, nullptr, nullptr)); - CHECK_HIPRTC(hiprtcCompileProgram(prog, 0, nullptr)); - - size_t code_size; - CHECK_HIPRTC(hiprtcGetCodeSize(prog, &code_size)); - std::string code(code_size, '\0'); - CHECK_HIPRTC(hiprtcGetCode(prog, code.data())); - hiprtcDestroyProgram(&prog); - - hipModule_t module; - hipFunction_t kernel; - CHECK_HIP(hipModuleLoadData(&module, code.data())); - CHECK_HIP(hipModuleGetFunction(&kernel, module, "test_kernel")); - - int* d_out; - int h_out = 0; - CHECK_HIP(hipMalloc(&d_out, sizeof(int))); - void* args[] = { &d_out }; - CHECK_HIP(hipModuleLaunchKernel(kernel, 1, 1, 1, 1, 1, 1, 0, nullptr, args, nullptr)); - CHECK_HIP(hipMemcpy(&h_out, d_out, sizeof(int), hipMemcpyDeviceToHost)); - - if (h_out != 5) { - std::cerr << "Kernel output mismatch: expected 5, got " << h_out << std::endl; - return 1; - } - - std::cout << "HIPRTC type_traits test passed (output=" << h_out << ")" << std::endl; - return 0; -} diff --git a/pkgs/development/rocm-modules/clr/test-hiprtc-type-traits.nix b/pkgs/development/rocm-modules/clr/test-hiprtc-type-traits.nix deleted file mode 100644 index f0f3628fcdaa3..0000000000000 --- a/pkgs/development/rocm-modules/clr/test-hiprtc-type-traits.nix +++ /dev/null @@ -1,57 +0,0 @@ -{ - lib, - stdenv, - makeImpureTest, - clr, - rocm-smi, -}: -# minimal hiprtc test that compiles a kernel using at runtime -# mirrors an migraphx workload, better test/iteration UX to be able to confirm -# with just a build up to clr -let - hiprtc-test = stdenv.mkDerivation { - pname = "hiprtc-type-traits-test"; - version = "0"; - - dontUnpack = true; - - nativeBuildInputs = [ clr ]; - - buildPhase = '' - runHook preBuild - hipcc -o hiprtc-test ${./test-hiprtc-type-traits.cpp} -lhiprtc - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - mkdir -p $out/bin - cp hiprtc-test $out/bin/ - runHook postInstall - ''; - }; -in -makeImpureTest { - name = "hiprtc-type-traits"; - testedPackage = "rocmPackages.clr"; - - sandboxPaths = [ - "/sys" - "/dev/dri" - "/dev/kfd" - ]; - - nativeBuildInputs = [ - hiprtc-test - rocm-smi - ]; - - testScript = '' - rocm-smi - hiprtc-test - ''; - - meta = { - teams = [ lib.teams.rocm ]; - }; -} diff --git a/pkgs/development/rocm-modules/clr/test-isa-compat.nix b/pkgs/development/rocm-modules/clr/test-isa-compat.nix deleted file mode 100644 index 2eca8edbff3d5..0000000000000 --- a/pkgs/development/rocm-modules/clr/test-isa-compat.nix +++ /dev/null @@ -1,74 +0,0 @@ -{ - lib, - stdenv, - makeImpureTest, - fetchFromGitHub, - clr, - rocm-smi, - name, - offloadArches, -}: - -let - # TODO: swap to another tiny test if this breaks; upstream is archived but fine for now - vectoradd = stdenv.mkDerivation { - pname = "rocm-hip-vectoradd"; - version = "2024-04-11"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "HIP-Examples"; - rev = "cdf9d101acd9a3fc89ee750f73c1f1958cbd5cc3"; - hash = "sha256-/I1KmOBFbEZIjA1vRE+2tPTtEKtOgazjCbnZtr+87E0="; - }; - - nativeBuildInputs = [ - clr - ]; - - installPhase = '' - runHook preInstall - - mkdir -p $out/bin - amdclang++ -x hip -o $out/bin/vectoradd \ - ${lib.concatMapStringsSep " " (arch: "--offload-arch=${arch}") offloadArches} \ - vectorAdd/vectoradd_hip.cpp - - runHook postInstall - ''; - - meta = { - description = "vectorAdd HIP example for ROCm"; - homepage = "https://github.com/ROCm/HIP-Examples"; - license = lib.licenses.unfree; - platforms = lib.platforms.linux; - teams = [ lib.teams.rocm ]; - }; - }; - -in -makeImpureTest { - inherit name; - testedPackage = "rocmPackages.clr"; - - sandboxPaths = [ - "/sys" - "/dev/dri" - "/dev/kfd" - ]; - - nativeBuildInputs = [ - vectoradd - rocm-smi - ]; - - testScript = '' - rocm-smi - - vectoradd - ''; - - meta = { - teams = [ lib.teams.rocm ]; - }; -} diff --git a/pkgs/development/rocm-modules/clr/test-opencl-cts.nix b/pkgs/development/rocm-modules/clr/test-opencl-cts.nix deleted file mode 100644 index 77929531f9009..0000000000000 --- a/pkgs/development/rocm-modules/clr/test-opencl-cts.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ - lib, - makeImpureTest, - opencl-cts, - clr, -}: - -makeImpureTest { - name = "opencl-cts"; - testedPackage = "rocmPackages.clr"; - - sandboxPaths = [ - "/sys" - "/dev/dri" - "/dev/kfd" - ]; - - nativeBuildInputs = [ opencl-cts ]; - OCL_ICD_VENDORS = "${clr.icd}/etc/OpenCL/vendors"; - - testScript = '' - test_basic arraycopy arrayreadwrite astype barrier vector_swizzle work_item_functions - ''; - - meta = { - teams = [ lib.teams.rocm ]; - }; -} diff --git a/pkgs/development/rocm-modules/clr/test-rocm-smi.nix b/pkgs/development/rocm-modules/clr/test-rocm-smi.nix deleted file mode 100644 index e03655907c7b1..0000000000000 --- a/pkgs/development/rocm-modules/clr/test-rocm-smi.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ - lib, - makeImpureTest, - clinfo, - clr, - rocm-smi, -}: - -makeImpureTest { - name = "rocm-smi"; - testedPackage = "rocmPackages.clr"; - nativeBuildInputs = [ - clinfo - rocm-smi - ]; - OCL_ICD_VENDORS = "${clr.icd}/etc/OpenCL/vendors"; - - testScript = '' - # Test fails if the number of platforms is 0 - clinfo | grep -E 'Number of platforms * [1-9]' - rocm-smi | grep -A1 GPU - ''; - - meta = { - teams = [ lib.teams.rocm ]; - }; -} diff --git a/pkgs/development/rocm-modules/composable_kernel/base.nix b/pkgs/development/rocm-modules/composable_kernel/base.nix deleted file mode 100644 index ef7304291ed4c..0000000000000 --- a/pkgs/development/rocm-modules/composable_kernel/base.nix +++ /dev/null @@ -1,205 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - clr, - rocminfo, - python3, - hipify, - gitMinimal, - gtest, - jemalloc, - zstd, - buildTests ? false, - buildExamples ? false, - # limits prebuilt kernel selection to those needed for MIOPEN (currently "*conv*") - # Other kernels can still be used if treating CK as a header only library - # and building specific instances, as done with ck4inductor/torch - miOpenReqLibsOnly ? true, - withDeprecatedKernels ? false, - gpuTargets ? ( - clr.localGpuTargets or [ - "gfx900" - "gfx906" - "gfx908" - "gfx90a" - "gfx942" - "gfx950" - "gfx10-3-generic" - "gfx11-generic" - "gfx12-generic" - ] - ), -}: -let - projectRoot = "projects/composablekernel"; -in -stdenv.mkDerivation (finalAttrs: { - preBuild = '' - echo "This derivation isn't intended to be built directly and only exists to be overridden and built in chunks"; - exit 1 - ''; - - pname = "composable_kernel_base"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildTests [ - "test" - ] - ++ lib.optionals buildExamples [ - "example" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - projectRoot - "shared" - ]; - hash = "sha256-Zs6wwPmys1kUlgDD4XzKKw273nH/Ur3HtuYxJjvjDs0="; - }; - sourceRoot = "${finalAttrs.src.name}/${projectRoot}"; - - nativeBuildInputs = [ - # Deliberately not using ninja - # because we're jankily composing build outputs from multiple drvs - # ninja won't believe they're up to date - gitMinimal - cmake - rocminfo - clr - hipify - zstd - python3 - ]; - - buildInputs = [ - rocm-cmake - clr - zstd - ]; - - strictDeps = true; - enableParallelBuilding = true; - env.ROCM_PATH = clr; - # Speed up build by ~7% with jemalloc (template torture test workload means allocation heavy clang invocations) - env.LD_PRELOAD = "${jemalloc}/lib/libjemalloc.so"; - env.MALLOC_CONF = "background_thread:true,metadata_thp:auto,dirty_decay_ms:10000,muzzy_decay_ms:10000"; - - cmakeFlags = [ - (lib.cmakeBool "MIOPEN_REQ_LIBS_ONLY" miOpenReqLibsOnly) - (lib.cmakeBool "BUILD_MHA_LIB" (!miOpenReqLibsOnly)) - (lib.cmakeBool "DISABLE_DL_KERNELS" true) - (lib.cmakeBool "DISABLE_DPP_KERNELS" true) - (lib.cmakeBool "CK_TIME_KERNEL" false) - "-DCMAKE_MODULE_PATH=${clr}/hip/cmake" - "-DCMAKE_POLICY_DEFAULT_CMP0069=NEW" - "-DDL_KERNELS=OFF" - # CK_USE_CODEGEN Required for migraphx which uses device_gemm_multiple_d.hpp - # but migraphx requires an incompatible fork of CK and fails anyway - # "-DCK_USE_CODEGEN=ON" - # It might be worth skipping fp64 in future with this: - # "-DDTYPES=fp32;fp16;fp8;bf16;int8" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - "-DBUILD_DEV=OFF" - "-DBUILD_MHA_LIB=ON" - "-DROCM_PATH=${clr}" - "-DENABLE_CLANG_CPP_CHECKS=OFF" - "-DCMAKE_HIP_COMPILER_ROCM_ROOT=${clr}" - - # FP8 can build for 908/90a but very slow build - # and produces unusably slow kernels that are huge - "-DCK_USE_FP8_ON_UNSUPPORTED_ARCH=OFF" - ] - ++ lib.optionals (gpuTargets != [ ]) [ - # We intentionally set GPU_ARCHS and not AMD/GPU_TARGETS - # per readme this is required if archs are dissimilar - # In rocm-6.3.x not setting any arch flag worked - # but setting dissimilar arches always failed - "-DGPU_ARCHS=${lib.concatStringsSep ";" gpuTargets}" - ] - ++ lib.optionals buildTests [ - "-DGOOGLETEST_DIR=${gtest.src}" # Custom linker names - ]; - - patches = [ - # Hacky fix for failure for some targets when all targets are selected out - # for a non-optional at link time kernel - ./fix-empty-offload-targets.diff - ]; - - postPatch = - # Reduce configure time by preventing thousands of clang-tidy targets being added - # We will never call them - # Never build profiler - '' - substituteInPlace library/src/utility/CMakeLists.txt library/src/tensor_operation_instance/gpu/CMakeLists.txt \ - --replace-fail clang_tidy_check '#clang_tidy_check' - substituteInPlace CMakeLists.txt \ - --replace-fail "add_subdirectory(profiler)" "" - substituteInPlace cmake/EnableCompilerWarnings.cmake \ - --replace-fail "-Werror" "" - '' - + lib.optionalString (!withDeprecatedKernels) '' - substituteInPlace include/ck/ck.hpp \ - --replace-fail "CK_BUILD_DEPRECATED 1" "CK_BUILD_DEPRECATED 0" - '' - # Optionally remove tests - + lib.optionalString (!buildTests) '' - substituteInPlace CMakeLists.txt \ - --replace-fail "add_subdirectory(test)" "" - substituteInPlace codegen/CMakeLists.txt \ - --replace-fail "include(ROCMTest)" "" - '' - # Optionally remove examples - + lib.optionalString (!buildExamples) '' - substituteInPlace CMakeLists.txt \ - --replace-fail "add_subdirectory(example)" "" - ''; - - postInstall = - lib.optionalString buildTests '' - mkdir -p $test/bin - mv $out/bin/test_* $test/bin - '' - + lib.optionalString buildExamples '' - mkdir -p $example/bin - mv $out/bin/example_* $example/bin - ''; - - passthru = { - inherit gpuTargets miOpenReqLibsOnly; - composable_kernel_src = "${finalAttrs.src}/${projectRoot}"; - - updateScript = rocmUpdateScript { inherit finalAttrs; }; - anyGfx9Target = lib.lists.any (lib.strings.hasPrefix "gfx9") gpuTargets; - anyMfmaTarget = - (lib.lists.intersectLists gpuTargets [ - "gfx908" - "gfx90a" - "gfx942" - "gfx950" - ]) != [ ]; - }; - - meta = { - description = "Performance portable programming model for machine learning tensor operators"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/composablekernel"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - broken = true; # this base package shouldn't be built directly - }; -}) diff --git a/pkgs/development/rocm-modules/composable_kernel/ck4inductor.nix b/pkgs/development/rocm-modules/composable_kernel/ck4inductor.nix deleted file mode 100644 index 6c8839fb75f69..0000000000000 --- a/pkgs/development/rocm-modules/composable_kernel/ck4inductor.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ - buildPythonPackage, - python, - composable_kernel, - lib, - rocm-toolchain, - setuptools, - setuptools-scm, -}: -buildPythonPackage { - pyproject = true; - pname = "ck4inductor"; - build-system = [ - setuptools - setuptools-scm - ]; - inherit (composable_kernel) version src sourceRoot; - # Upstream uses the distribution name "rocm-composable-kernel". - dontCheckPythonMetadata = true; - pythonImportsCheck = [ - "ck4inductor" - "ck4inductor.universal_gemm.gen_instances" - "ck4inductor.universal_gemm.gen_instances" - "ck4inductor.universal_gemm.op" - ]; - propagatedBuildInputs = [ - # At runtime will fail to compile anything with ck4inductor without this - # can't easily use in checks phase because most of the compiler machinery is in torch - rocm-toolchain - ]; - checkPhase = '' - if [ ! -d "$out/${python.sitePackages}/ck4inductor" ]; then - echo "ck4inductor isn't at the expected location in $out/${python.sitePackages}/ck4inductor" - exit 1 - fi - ''; - meta = { - description = "Pytorch inductor backend which uses composable_kernel universal GEMM implementations"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/composablekernel"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -} diff --git a/pkgs/development/rocm-modules/composable_kernel/default.nix b/pkgs/development/rocm-modules/composable_kernel/default.nix deleted file mode 100644 index ae0707fabbd01..0000000000000 --- a/pkgs/development/rocm-modules/composable_kernel/default.nix +++ /dev/null @@ -1,319 +0,0 @@ -{ - lib, - clr, - composable_kernel_base, -}: - -let - inherit (composable_kernel_base) miOpenReqLibsOnly; - parts = { - _mha = { - enabled = !miOpenReqLibsOnly; - # mha takes ~3hrs on 64 cores on an EPYC milan system at ~2.5GHz - # big-parallel builders are one gen newer and clocked ~30% higher but only 24 cores - # Should be <10h timeout but might be cutting it close - # TODO: work out how to split this into smaller chunks instead of all 3k mha instances together - # mha_0,1,2, search ninja target file for the individual instances, split by the index? - # TODO: can we prune the generated instances down to only what in practice are used with popular models - # when using flash-attention + MHA kernels? - targets = [ - "device_mha_instance" - ]; - extraCmakeFlags = [ "-DHIP_CLANG_NUM_PARALLEL_JOBS=2" ]; - }; - gemm_multiply_multiply = { - enabled = !miOpenReqLibsOnly; - targets = [ - "device_gemm_multiply_multiply_instance" - ]; - extraCmakeFlags = [ "-DHIP_CLANG_NUM_PARALLEL_JOBS=2" ]; - onlyFor = [ - "gfx942" - "gfx950" - ]; - }; - gemm_multiply_multiply_wp = { - enabled = !miOpenReqLibsOnly; - targets = [ - "device_gemm_multiply_multiply_wp_instance" - ]; - extraCmakeFlags = [ "-DHIP_CLANG_NUM_PARALLEL_JOBS=2" ]; - onlyFor = [ - "gfx942" - "gfx950" - ]; - }; - grouped_conv_bwd = { - targets = [ - "device_grouped_conv1d_bwd_weight_instance" - "device_grouped_conv2d_bwd_data_instance" - "device_grouped_conv2d_bwd_weight_instance" - ]; - }; - grouped_conv_fwd = { - targets = [ - "device_grouped_conv1d_fwd_instance" - "device_grouped_conv2d_fwd_instance" - "device_grouped_conv2d_fwd_bias_bnorm_clamp_instance" - "device_grouped_conv2d_fwd_bias_clamp_instance" - "device_grouped_conv2d_fwd_clamp_instance" - "device_grouped_conv2d_fwd_dynamic_op_instance" - ]; - }; - grouped_conv_bwd_3d1 = { - targets = [ - "device_grouped_conv3d_bwd_data_instance" - "device_grouped_conv3d_bwd_data_bilinear_instance" - "device_grouped_conv3d_bwd_data_scale_instance" - ]; - }; - grouped_conv_bwd_3d2 = { - targets = [ - "device_grouped_conv3d_bwd_weight_instance" - "device_grouped_conv3d_bwd_weight_bilinear_instance" - "device_grouped_conv3d_bwd_weight_scale_instance" - ]; - }; - grouped_conv_fwd_3d1 = { - targets = [ - "device_grouped_conv3d_fwd_instance" - "device_grouped_conv3d_fwd_clamp_instance" - "device_grouped_conv3d_fwd_bias_bnorm_clamp_instance" - "device_grouped_conv3d_fwd_bias_clamp_instance" - "device_grouped_conv3d_fwd_bilinear_instance" - "device_grouped_conv3d_fwd_convinvscale_instance" - "device_grouped_conv3d_fwd_convscale_instance" - "device_grouped_conv3d_fwd_convscale_add_instance" - ]; - }; - grouped_conv_fwd_3d2 = { - targets = [ - "device_grouped_conv3d_fwd_convscale_relu_instance" - "device_grouped_conv3d_fwd_dynamic_op_instance" - "device_grouped_conv3d_fwd_scale_instance" - "device_grouped_conv3d_fwd_scaleadd_ab_instance" - "device_grouped_conv3d_fwd_scaleadd_scaleadd_relu_instance" - ]; - }; - grouped_conv_fwd_nd = { - targets = [ - "device_grouped_convnd_bwd_weight_instance" - ]; - }; - batched_gemm1 = { - enabled = !miOpenReqLibsOnly; - targets = [ - "device_batched_gemm_instance" - "device_batched_gemm_b_scale_instance" - "device_batched_gemm_multi_d_instance" - "device_batched_gemm_add_relu_gemm_add_instance" - "device_batched_gemm_bias_permute_instance" - "device_batched_gemm_gemm_instance" - "device_batched_gemm_reduce_instance" - "device_batched_gemm_softmax_gemm_instance" - ]; - }; - batched_gemm2 = { - enabled = !miOpenReqLibsOnly; - targets = [ - "device_batched_gemm_softmax_gemm_permute_instance" - "device_grouped_gemm_instance" - "device_grouped_gemm_bias_instance" - "device_grouped_gemm_fastgelu_instance" - "device_grouped_gemm_fixed_nk_instance" - "device_grouped_gemm_fixed_nk_multi_abd_instance" - "device_grouped_gemm_tile_loop_instance" - ]; - }; - gemm_universal1 = { - enabled = !miOpenReqLibsOnly; - targets = [ - "device_gemm_universal_instance" - "device_gemm_universal_batched_instance" - ]; - }; - gemm_universal2 = { - enabled = !miOpenReqLibsOnly; - targets = [ - "device_gemm_universal_reduce_instance" - "device_gemm_universal_streamk_instance" - ]; - }; - gemm_other1 = { - enabled = !miOpenReqLibsOnly; - targets = [ - "device_gemm_instance" - "device_gemm_b_scale_instance" - "device_gemm_ab_scale_instance" - "device_gemm_add_instance" - "device_gemm_add_add_fastgelu_instance" - "device_gemm_add_fastgelu_instance" - "device_gemm_add_multiply_instance" - "device_gemm_add_relu_instance" - ]; - }; - gemm_other2 = { - enabled = !miOpenReqLibsOnly; - targets = [ - "device_gemm_add_relu_add_layernorm_instance" - "device_gemm_add_silu_instance" - "device_gemm_bias_add_reduce_instance" - "device_gemm_bilinear_instance" - "device_gemm_fastgelu_instance" - "device_gemm_multi_abd_instance" - "device_gemm_multiply_add_instance" - "device_gemm_reduce_instance" - "device_gemm_splitk_instance" - "device_gemm_streamk_instance" - ]; - }; - conv = { - targets = [ - "device_conv1d_bwd_data_instance" - "device_conv2d_bwd_data_instance" - "device_conv2d_fwd_instance" - "device_conv2d_fwd_bias_relu_instance" - "device_conv2d_fwd_bias_relu_add_instance" - "device_conv3d_bwd_data_instance" - ]; - }; - pool = { - enabled = !miOpenReqLibsOnly; - targets = [ - "device_avg_pool2d_bwd_instance" - "device_avg_pool3d_bwd_instance" - "device_pool2d_fwd_instance" - "device_pool3d_fwd_instance" - "device_max_pool_bwd_instance" - ]; - }; - other0 = { - targets = [ - "device_quantization_instance" - ]; - }; - other1 = { - enabled = !miOpenReqLibsOnly; - targets = [ - "device_batchnorm_instance" - "device_contraction_bilinear_instance" - "device_contraction_scale_instance" - "device_elementwise_instance" - "device_elementwise_normalization_instance" - ]; - }; - other2 = { - enabled = !miOpenReqLibsOnly; - targets = [ - "device_column_to_image_instance" - "device_image_to_column_instance" - "device_permute_scale_instance" - "device_reduce_instance" - ]; - }; - other3 = { - enabled = !miOpenReqLibsOnly; - targets = [ - "device_normalization_bwd_data_instance" - "device_normalization_bwd_gamma_beta_instance" - "device_normalization_fwd_instance" - "device_softmax_instance" - "device_transpose_instance" - ]; - }; - }; - tensorOpBuilder = - { - part, - targets, - extraCmakeFlags ? [ ], - requiredSystemFeatures ? [ "big-parallel" ], - enabled ? true, - onlyFor ? [ ], - }: - let - supported = - enabled - && (onlyFor == [ ] || (lib.lists.intersectLists composable_kernel_base.gpuTargets onlyFor) != [ ]); - in - if supported then - (composable_kernel_base.overrideAttrs (old: { - inherit requiredSystemFeatures; - pname = "composable_kernel${clr.gpuArchSuffix}-${part}"; - makeTargets = targets; - preBuild = '' - echo "Building ${part}" - makeFlagsArray+=($makeTargets) - substituteInPlace $(find ./ -name "Makefile" -type f) \ - --replace-fail '.NOTPARALLEL:' '.UNUSED_NOTPARALLEL:' - ''; - - # Compile parallelism adjusted based on available RAM - # Never uses less than NIX_BUILD_CORES/4, never uses more than NIX_BUILD_CORES - # CK uses an unusually high amount of memory per core in the build step - # Nix/nixpkgs doesn't really have any infra to tell it that this build is unusually memory hungry - # So, bodge. Otherwise you end up having to build all of ROCm with a low core limit when - # it's only this package that has trouble. - preConfigure = old.preConfigure or "" + '' - MEM_GB_TOTAL=$(awk '/MemTotal/ { printf "%d \n", $2/1024/1024 }' /proc/meminfo) - MEM_GB_AVAILABLE=$(awk '/MemAvailable/ { printf "%d \n", $2/1024/1024 }' /proc/meminfo) - APPX_GB=$((MEM_GB_AVAILABLE > MEM_GB_TOTAL ? MEM_GB_TOTAL : MEM_GB_AVAILABLE)) - MAX_CORES=$((1 + APPX_GB/3)) - MAX_CORES=$((MAX_CORES < NIX_BUILD_CORES/3 ? NIX_BUILD_CORES/3 : MAX_CORES)) - export NIX_BUILD_CORES="$((NIX_BUILD_CORES > MAX_CORES ? MAX_CORES : NIX_BUILD_CORES))" - echo "Picked new core limit NIX_BUILD_CORES=$NIX_BUILD_CORES based on available mem: $APPX_GB GB" - cmakeFlagsArray+=( - "-DCK_PARALLEL_COMPILE_JOBS=$NIX_BUILD_CORES" - ) - ''; - cmakeFlags = old.cmakeFlags ++ extraCmakeFlags; - # Early exit after build phase with success, skips fixups etc - # Will get copied back into /build of the final CK - postBuild = '' - find . -name "*.o" -type f | while read -r file; do - mkdir -p "$out/$(dirname "$file")" - cp --reflink=auto "$file" "$out/$file" - done - exit 0 - ''; - meta = old.meta // { - broken = false; - }; - })) - else - null; - composable_kernel_parts = builtins.mapAttrs ( - part: targets: tensorOpBuilder (targets // { inherit part; }) - ) parts; -in - -composable_kernel_base.overrideAttrs ( - finalAttrs: old: { - pname = "composable_kernel${clr.gpuArchSuffix}"; - parts_dirs = builtins.filter (x: x != null) (builtins.attrValues composable_kernel_parts); - disallowedReferences = builtins.filter (x: x != null) (builtins.attrValues composable_kernel_parts); - preBuild = '' - for dir in $parts_dirs; do - find "$dir" -type f -name "*.o" | while read -r file; do - # Extract the relative path by removing the output directory prefix - rel_path="''${file#"$dir/"}" - - # Create parent directory if it doesn't exist - mkdir -p "$(dirname "$rel_path")" - - # Copy the file back to its original location, give it a future timestamp - # so make treats it as up to date - cp --reflink=auto --no-preserve=all "$file" "$rel_path" - touch -d "now +10 hours" "$rel_path" - done - done - ''; - passthru = old.passthru // { - parts = composable_kernel_parts; - }; - meta = old.meta // { - # Builds without any gfx9 fail - broken = !finalAttrs.passthru.anyGfx9Target; - }; - } -) diff --git a/pkgs/development/rocm-modules/composable_kernel/fix-empty-offload-targets.diff b/pkgs/development/rocm-modules/composable_kernel/fix-empty-offload-targets.diff deleted file mode 100644 index d314873ff61b6..0000000000000 --- a/pkgs/development/rocm-modules/composable_kernel/fix-empty-offload-targets.diff +++ /dev/null @@ -1,23 +0,0 @@ -diff --git a/library/src/tensor_operation_instance/gpu/CMakeLists.txt b/library/src/tensor_operation_instance/gpu/CMakeLists.txt -index 172f6681b8..d3ddbb2f15 100644 ---- a/library/src/tensor_operation_instance/gpu/CMakeLists.txt -+++ b/library/src/tensor_operation_instance/gpu/CMakeLists.txt -@@ -154,9 +154,15 @@ function(add_instance_library INSTANCE_NAME) - list(FILTER INST_TARGETS INCLUDE REGEX "gfx12") - endif() - set(offload_targets) -- foreach(target IN LISTS INST_TARGETS) -- string(APPEND offload_targets "--offload-arch=${target} ") -- endforeach() -+ if(NOT INST_TARGETS) -+ # No valid GPU targets for this source, compile for 90a as fallback -+ # so the add_device…instances and hip_fatbin… symbols still exist -+ set(offload_targets "--offload-arch=gfx90a") -+ else() -+ foreach(target IN LISTS INST_TARGETS) -+ string(APPEND offload_targets "--offload-arch=${target} ") -+ endforeach() -+ endif() - set_source_files_properties(${source} PROPERTIES COMPILE_FLAGS ${offload_targets}) - list(APPEND INST_OBJ ${source}) - endforeach() diff --git a/pkgs/development/rocm-modules/default.nix b/pkgs/development/rocm-modules/default.nix deleted file mode 100644 index 14b993c1d83ba..0000000000000 --- a/pkgs/development/rocm-modules/default.nix +++ /dev/null @@ -1,339 +0,0 @@ -{ - lib, - config, - callPackage, - newScope, - boost179, - opencv, - python3Packages, - openmpi, - stdenv, - pkgs, -}: - -let - outer = lib.makeScope newScope ( - self: - let - inherit (self) llvm; - origStdenv = stdenv; - pyPackages = python3Packages; - openmpi-orig = openmpi; - rocmClangStdenv = llvm.rocmClangStdenv; - in - { - inherit rocmClangStdenv; - stdenv = rocmClangStdenv; - - rocmUpdateScript = self.callPackage ./update.nix { }; - - ## ROCm ## - llvm = lib.recurseIntoAttrs ( - callPackage ./llvm/default.nix { - # rocm-device-libs is used for .src only - # otherwise would cause infinite recursion - inherit (self) rocm-device-libs; - } - ); - inherit (self.llvm) rocm-toolchain clang openmp; - - rocm-core = self.callPackage ./rocm-core { stdenv = origStdenv; }; - - rocm-cmake = self.callPackage ./rocm-cmake { stdenv = origStdenv; }; - - rocm-device-libs = self.callPackage ./rocm-device-libs { }; - - rocm-runtime = self.callPackage ./rocm-runtime { - stdenv = origStdenv; - }; - - rocm-comgr = self.callPackage ./rocm-comgr { }; - - rocminfo = self.callPackage ./rocminfo { stdenv = origStdenv; }; - - amdsmi = pyPackages.callPackage ./amdsmi { - inherit (self) rocmUpdateScript; - }; - - rocm-smi = pyPackages.callPackage ./rocm-smi { - inherit (self) rocmUpdateScript; - }; - - aqlprofile = self.callPackage ./aqlprofile { }; - - rdc = self.callPackage ./rdc { }; - - rocm-docs-core = python3Packages.callPackage ./rocm-docs-core { }; - - hip-common = self.callPackage ./hip-common { }; - - hipcc = self.callPackage ./hipcc { stdenv = origStdenv; }; - - # Replaces hip, opencl-runtime, and rocclr - clr = self.callPackage ./clr { }; - - aotriton = self.callPackage ./aotriton { stdenv = origStdenv; }; - - hipify = self.callPackage ./hipify { - stdenv = origStdenv; - }; - - # hsakmt was merged into rocm-runtime - hsakmt = self.rocm-runtime; - - rocprofiler = self.callPackage ./rocprofiler { - inherit (llvm) clang; - }; - rocprofiler-register = self.callPackage ./rocprofiler-register { - inherit (llvm) clang; - }; - rocprofiler-sdk = self.callPackage ./rocprofiler-sdk { }; - - rocprof-compute-viewer = self.callPackage ./rocprof-compute-viewer { }; - - rocprof-trace-decoder = self.callPackage ./rocprof-trace-decoder { }; - - roctracer = self.callPackage ./roctracer { }; - - rocgdb = self.callPackage ./rocgdb { }; - - rocdbgapi = self.callPackage ./rocdbgapi { }; - - rocr-debug-agent = self.callPackage ./rocr-debug-agent { }; - - rocprim = self.callPackage ./rocprim { }; - - rocsparse = self.callPackage ./rocsparse { }; - - rocthrust = self.callPackage ./rocthrust { }; - - rocrand = self.callPackage ./rocrand { }; - - hiprand = self.callPackage ./hiprand { }; - - rocfft = self.callPackage ./rocfft { }; - - mscclpp = self.callPackage ./mscclpp { }; - - rccl = self.callPackage ./rccl { }; - - rocshmem = self.callPackage ./rocshmem { }; - - hipcub = self.callPackage ./hipcub { }; - - hipsparse = self.callPackage ./hipsparse { }; - - hipfort = self.callPackage ./hipfort { }; - - hipfft = self.callPackage ./hipfft { }; - - hiprt = self.callPackage ./hiprt { }; - - tensile = pyPackages.callPackage ./tensile { - inherit (self) - rocmUpdateScript - clr - ; - }; - - rocblas = self.callPackage ./rocblas { }; - - rocsolver = self.callPackage ./rocsolver { }; - - rocwmma = self.callPackage ./rocwmma { }; - - rocalution = self.callPackage ./rocalution { }; - - rocmlir-rock = self.callPackage ./rocmlir { - buildRockCompiler = true; - }; - rocmlir = self.rocmlir-rock; - - hipsolver = self.callPackage ./hipsolver { }; - - hipblas-common = self.callPackage ./hipblas-common { }; - - hipblas = self.callPackage ./hipblas { }; - - hipblaslt = self.callPackage ./hipblaslt { }; - - hipsparselt = self.callPackage ./hipsparselt { }; - - # hipTensor - Only supports GFX9 - - composable_kernel_base = self.callPackage ./composable_kernel/base.nix { }; - composable_kernel = self.callPackage ./composable_kernel { }; - - ck4inductor = pyPackages.callPackage ./composable_kernel/ck4inductor.nix { - inherit (self) composable_kernel rocm-toolchain; - }; - - half = self.callPackage ./half { }; - - miopen = self.callPackage ./miopen { - boost = boost179.override { enableStatic = true; }; - }; - - miopen-hip = self.miopen; - - migraphx = self.callPackage ./migraphx { stdenv = origStdenv; }; - - rpp = self.callPackage ./rpp { }; - - rpp-hip = self.rpp.override { useCPU = false; }; - - rpp-cpu = self.rpp.override { useCPU = true; }; - - mivisionx = self.callPackage ./mivisionx { - stdenv = origStdenv; - opencv = opencv.override { enablePython = true; }; - }; - - mivisionx-hip = self.mivisionx.override { - rpp = self.rpp-hip; - useOpenCL = false; - useCPU = false; - }; - - mivisionx-cpu = self.mivisionx.override { - rpp = self.rpp-cpu; - useOpenCL = false; - useCPU = true; - }; - - # Even if config.rocmSupport is false we need rocmSupport true - # version of ucc/ucx in openmpi in this package set - openmpi = openmpi-orig.override ( - prev: - let - ucx = prev.ucx.override { - enableCuda = false; - enableRocm = true; - rocmPackages = self; - }; - in - { - inherit ucx; - ucc = prev.ucc.override { - enableCuda = false; - inherit ucx; - }; - } - ); - mpi = self.openmpi; - - meta = { - # eval all pkgsRocm release attrs with - # nix-eval-jobs --force-recurse pkgs/top-level/release.nix -I . --select "p: p.pkgsRocm" --no-instantiate - release-packagePlatforms = - let - platforms = [ - "x86_64-linux" - ]; - attrPaths = (builtins.fromJSON (builtins.readFile ./release-attrPaths.json)).attrPaths; - in - lib.foldl' ( - acc: path: - if lib.hasAttrByPath (lib.splitString "." path) pkgs then - lib.recursiveUpdate acc (lib.setAttrByPath (lib.splitString "." path) platforms) - else - acc - ) { } attrPaths; - }; - - rocm-tests = self.callPackage ./rocm-tests { - rocmPackages = self; - }; - } - // lib.optionalAttrs config.allowAliases { - rocm-bandwidth-test = throw '' - 'rocm-bandwidth-test' has been removed as it is no longer maintained upstream. - ''; # Added 2026-10-14 - - rpp-opencl = throw '' - 'rpp-opencl' has been removed as it has been broken for a year and has no consuming packages. - Use 'rpp' or 'rpp-cpu' instead. - ''; # Added 2026-03-08 - - rocmPath = throw '' - 'rocm-path' has been removed. If a ROCM_PATH value is required in nixpkgs please - construct one with the minimal set of required deps. - For convenience use outside of nixpkgs consider one of the entries in - 'rocmPackages.meta'. - ''; # Added 2025-09-30 - - rocm-merged-llvm = throw '' - 'rocm-merged-llvm' has been removed. - For 'libllvm' or 'libclang' use 'rocmPackages.llvm.libllvm/clang'. - For a ROCm compiler toolchain use 'rocmPackages.rocm-toolchain'. - If a package uses '$' in CMake from 'libclang' - it may be necessary to convince it to use 'rocm-toolchain' instead. - 'rocm-merged-llvm' avoided this at the cost of significantly bloating closure - size. - ''; # Added 2025-09-30 - - hsa-amd-aqlprofile-bin = lib.warn '' - 'hsa-amd-aqlprofile-bin' has been replaced by 'aqlprofile'. - '' self.aqlprofile; # Added 2025-08-27 - - triton = throw '' - 'rocmPackages.triton' has been removed. Please use python3Packages.triton - ''; # Added 2025-08-24 - - rocm-thunk = throw '' - 'rocm-thunk' has been removed. It's now part of the ROCm runtime. - ''; # Added 2025-3-16 - - clang-ocl = throw '' - 'clang-ocl' has been deprecated upstream. Use ROCm's clang directly. - ''; # Added 2025-3-16 - - miopengemm = throw '' - 'miopengemm' has been deprecated. - ''; # Added 2024-3-3 - - miopen-opencl = throw '' - 'miopen-opencl' has been deprecated. - ''; # Added 2024-3-3 - - mivisionx-opencl = throw '' - 'mivisionx-opencl' has been deprecated. - Other versions of mivisionx are still available. - ''; # Added 2024-3-24 - } - ); - scopeForArches = - arches: - outer.overrideScope ( - _final: prev: { - clr = prev.clr.override { - localGpuTargets = arches; - }; - } - ); -in -outer -// lib.genAttrs outer.clr.gpuTargets (arch: scopeForArches [ arch ]) -// { - gfx9 = scopeForArches [ - "gfx906" - "gfx908" - "gfx90a" - "gfx942" - ]; - gfx10 = scopeForArches [ - "gfx1010" - "gfx1030" - ]; - gfx11 = scopeForArches [ - "gfx1100" - "gfx1101" - "gfx1102" - "gfx1150" - "gfx1151" - ]; - gfx12 = scopeForArches [ - "gfx1200" - "gfx1201" - ]; -} diff --git a/pkgs/development/rocm-modules/half/default.nix b/pkgs/development/rocm-modules/half/default.nix deleted file mode 100644 index 8541b82d596fe..0000000000000 --- a/pkgs/development/rocm-modules/half/default.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "half"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "half"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-If9O5BEeymsLN+C0drZsPSxEWXpJTxeDBGNHNXSumm4="; - }; - - nativeBuildInputs = [ - cmake - rocm-cmake - ]; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "C++ library for half precision floating point arithmetics"; - homepage = "https://github.com/ROCm/half"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.unix; - }; -}) diff --git a/pkgs/development/rocm-modules/hip-common/default.nix b/pkgs/development/rocm-modules/hip-common/default.nix deleted file mode 100644 index f2415ab549c33..0000000000000 --- a/pkgs/development/rocm-modules/hip-common/default.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "hip-common"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/hip" - "shared" - ]; - hash = "sha256-orfTXKjcZJ5E73cmXEyltZVYhCQo8FLExVHM3J/rqUM="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/hip"; - - dontConfigure = true; - dontBuild = true; - - installPhase = '' - runHook preInstall - - mkdir -p $out - mv * $out - - runHook postInstall - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "C++ Heterogeneous-Compute Interface for Portability"; - homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/hip"; - license = lib.licenses.mit; - maintainers = with lib.maintainers; [ lovesegfault ]; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/hipblas-common/default.nix b/pkgs/development/rocm-modules/hipblas-common/default.nix deleted file mode 100644 index 6ddc7c8e258a5..0000000000000 --- a/pkgs/development/rocm-modules/hipblas-common/default.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ - lib, - stdenv, - cmake, - fetchFromGitHub, - rocm-cmake, - rocmUpdateScript, -}: -stdenv.mkDerivation (finalAttrs: { - pname = "hipblas-common"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/hipblas-common" - "shared" - ]; - hash = "sha256-83LgS4I1fMSaNtWdVFf1qhYRMT7a9jVzO3XpUzEipXg="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/hipblas-common"; - - nativeBuildInputs = [ - cmake - ]; - - buildInputs = [ - rocm-cmake - ]; - - strictDeps = true; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - meta = { - description = "Common files shared by hipBLAS and hipBLASLt"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipblas-common"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/hipblas/default.nix b/pkgs/development/rocm-modules/hipblas/default.nix deleted file mode 100644 index af6c620211805..0000000000000 --- a/pkgs/development/rocm-modules/hipblas/default.nix +++ /dev/null @@ -1,132 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - clr, - gfortran, - hipblas-common, - rocblas, - rocsolver, - rocsparse, - rocprim, - gtest, - lapack-reference, - buildTests ? false, - buildBenchmarks ? false, - buildSamples ? false, - # for passthru.tests - hipblas, -}: - -# Can also use cuBLAS -stdenv.mkDerivation (finalAttrs: { - pname = "hipblas"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildTests [ - "test" - ] - ++ lib.optionals buildBenchmarks [ - "benchmark" - ] - ++ lib.optionals buildSamples [ - "sample" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/hipblas" - "shared" - ]; - hash = "sha256-1+aNDotV5liHBnGddmWtaKYCcsWPxQD3AoEubnghV0M="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/hipblas"; - - postPatch = '' - substituteInPlace library/CMakeLists.txt \ - --replace-fail "find_package(Git REQUIRED)" "" - ''; - - nativeBuildInputs = [ - cmake - rocm-cmake - clr - gfortran - ]; - - propagatedBuildInputs = [ hipblas-common ]; - - buildInputs = [ - rocblas - rocprim - rocsparse - rocsolver - ] - ++ lib.optionals buildTests [ - gtest - ] - ++ lib.optionals (buildTests || buildBenchmarks) [ - lapack-reference - ]; - - cmakeFlags = [ - "-DCMAKE_CXX_COMPILER=${lib.getExe' clr "amdclang++"}" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - "-DBUILD_WITH_SOLVER=ON" - "-DAMDGPU_TARGETS=${rocblas.amdgpu_targets}" - ] - ++ lib.optionals buildTests [ - "-DBUILD_CLIENTS_TESTS=ON" - ] - ++ lib.optionals buildBenchmarks [ - "-DBUILD_CLIENTS_BENCHMARKS=ON" - ] - ++ lib.optionals buildSamples [ - "-DBUILD_CLIENTS_SAMPLES=ON" - ]; - - postInstall = - lib.optionalString buildTests '' - mkdir -p $test/bin - mv $out/bin/hipblas-test $test/bin - '' - + lib.optionalString buildBenchmarks '' - mkdir -p $benchmark/bin - mv $out/bin/hipblas-bench $benchmark/bin - '' - + lib.optionalString buildSamples '' - mkdir -p $sample/bin - mv $out/bin/example-* $sample/bin - '' - + lib.optionalString (buildTests || buildBenchmarks || buildSamples) '' - rmdir $out/bin - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - passthru.tests.hipblas-tested = hipblas.override { - buildTests = true; - buildBenchmarks = true; - buildSamples = true; - }; - - meta = { - description = "ROCm BLAS marshalling library"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipblas"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/hipblaslt/Tensile-interning.patch b/pkgs/development/rocm-modules/hipblaslt/Tensile-interning.patch deleted file mode 100644 index acf44437520db..0000000000000 --- a/pkgs/development/rocm-modules/hipblaslt/Tensile-interning.patch +++ /dev/null @@ -1,181 +0,0 @@ -diff --git a/tensilelite/Tensile/Common/Utilities.py b/tensilelite/Tensile/Common/Utilities.py -index 0a9d9db5b3..cb9779eaac 100644 ---- a/tensilelite/Tensile/Common/Utilities.py -+++ b/tensilelite/Tensile/Common/Utilities.py -@@ -24,6 +24,7 @@ - - import functools - import math -+import operator - import os - import sys - import time -@@ -269,8 +270,20 @@ def state(obj): - - - def state_key_ordering(cls): -- def tup(obj): -- return tuple([getattr(obj, k) for k in cls.StateKeys]) -+ # Use operator.attrgetter for efficiency if __slots__ is defined -+ if hasattr(cls, '__slots__'): -+ # attrgetter is faster for slotted classes -+ getter = operator.attrgetter(*cls.StateKeys) -+ if len(cls.StateKeys) == 1: -+ # attrgetter returns scalar for single key, we need tuple -+ def tup(obj): -+ return (getter(obj),) -+ else: -+ tup = getter -+ else: -+ # Fallback for regular classes -+ def tup(obj): -+ return tuple([getattr(obj, k) for k in cls.StateKeys]) - - def lt(a, b): - return tup(a) < tup(b) -diff --git a/tensilelite/Tensile/Contractions.py b/tensilelite/Tensile/Contractions.py -index c0d4e851b1..3f2c2e98c6 100644 ---- a/tensilelite/Tensile/Contractions.py -+++ b/tensilelite/Tensile/Contractions.py -@@ -37,9 +37,60 @@ from Tensile.Toolchain.Component import Assembler - from math import ceil - - MIN_K_FOR_GSU = 32 -+ -+# Interning helpers to reduce memory usage by reusing identical objects -+_free_index_cache = {} -+def intern_free_index(isA, i=None, c=None, d=None, a=None, b=None): -+ key = (isA, i, c, d, a, b) -+ if key not in _free_index_cache: -+ obj = FreeIndex(isA, i, c, d) -+ obj.a = a -+ if b is not None: -+ obj.b = b -+ _free_index_cache[key] = obj -+ return _free_index_cache[key] -+ -+_batch_index_cache = {} -+def intern_batch_index(a=None, b=None, c=None, d=None): -+ key = (a, b, c, d) -+ if key not in _batch_index_cache: -+ obj = BatchIndex(c=c, d=d) -+ obj.a = a -+ obj.b = b -+ _batch_index_cache[key] = obj -+ return _batch_index_cache[key] -+ -+_bound_index_cache = {} -+def intern_bound_index(a=None, b=None, aMirror=False, bMirror=False): -+ key = (a, b, aMirror, bMirror) -+ if key not in _bound_index_cache: -+ obj = BoundIndex(aMirror=aMirror, bMirror=bMirror) -+ obj.a = a -+ obj.b = b -+ _bound_index_cache[key] = obj -+ return _bound_index_cache[key] -+ -+_size_mapping_cache = {} -+def intern_size_mapping(size_mapping): -+ """Intern a SizeMapping instance to reduce redundancy.""" -+ # Build hashable key from StateKeys, converting lists to tuples -+ key_parts = [] -+ for attr in size_mapping.StateKeys: -+ val = getattr(size_mapping, attr) -+ # Convert lists to tuples for hashing -+ if isinstance(val, list): -+ val = tuple(val) -+ key_parts.append(val) -+ key = tuple(key_parts) -+ -+ if key not in _size_mapping_cache: -+ _size_mapping_cache[key] = size_mapping -+ return _size_mapping_cache[key] -+ - @state_key_ordering - class FreeIndex: - StateKeys = ['isA', 'i', 'c', 'd'] -+ __slots__ = ['isA', 'i', 'c', 'd', 'a', 'b'] - - def __init__(self, isA, i=None, c=None, d=None): - self.isA = isA -@@ -50,6 +101,7 @@ class FreeIndex: - @state_key_ordering - class BatchIndex: - StateKeys = ['a', 'b', 'c', 'd'] -+ __slots__ = ['a', 'b', 'c', 'd'] - def __init__(self, a=None, b=None, c=None, d=None): - self.a = a - self.b = b -@@ -59,6 +111,7 @@ class BatchIndex: - @state_key_ordering - class BoundIndex: - StateKeys = ['a', 'b', 'aMirror', 'bMirror'] -+ __slots__ = ['a', 'b', 'aMirror', 'bMirror'] - def __init__(self, a=None, b=None, aMirror=False, bMirror=False): - self.a = a - self.b = b -@@ -107,6 +160,23 @@ class ProblemType: - for ib, ic in enumerate(d['IndexAssignmentsB']): - indices[ic].b = ib - -+ # Now intern all indices with their final state (including .a and .b) -+ for i, idx in enumerate(indices): -+ if isinstance(idx, FreeIndex): -+ indices[i] = intern_free_index(idx.isA, idx.i, idx.c, idx.d, -+ getattr(idx, 'a', None), getattr(idx, 'b', None)) -+ elif isinstance(idx, BatchIndex): -+ indices[i] = intern_batch_index(getattr(idx, 'a', None), getattr(idx, 'b', None), -+ idx.c, idx.d) -+ elif isinstance(idx, BoundIndex): -+ indices[i] = intern_bound_index(getattr(idx, 'a', None), getattr(idx, 'b', None), -+ idx.aMirror, idx.bMirror) -+ -+ # Update the lists with interned versions -+ freeIndices = [idx for idx in indices if isinstance(idx, FreeIndex)] -+ batchIndices = [idx for idx in indices if isinstance(idx, BatchIndex)] -+ boundIndices = [idx for idx in indices if isinstance(idx, BoundIndex)] -+ - for idx in indices: - assert idx is not None - idxState = state(idx) -@@ -596,6 +666,7 @@ class SizeMapping: - 'nonTemporalA', - 'nonTemporalB', - ] -+ __slots__ = StateKeys - - @classmethod - def FromOriginalState(cls, d): -@@ -751,7 +822,7 @@ class Solution: - info = cls.ReadOriginalInfo(d) - rv.libraryLogicIndex = int(info.get("SolutionIndex", -1)) - -- rv.sizeMapping = SizeMapping.FromOriginalState(d) -+ rv.sizeMapping = intern_size_mapping(SizeMapping.FromOriginalState(d)) - - rv.internalArgsSupport = InternalArgsSupport.FromOriginalState(d) - -diff --git a/tensilelite/Tensile/TensileCreateLibrary/Run.py b/tensilelite/Tensile/TensileCreateLibrary/Run.py -index 730b6b1fff..b0068563a0 100644 ---- a/tensilelite/Tensile/TensileCreateLibrary/Run.py -+++ b/tensilelite/Tensile/TensileCreateLibrary/Run.py -@@ -104,7 +104,6 @@ class KernelCodeGenResult(NamedTuple): - src: str - header: Optional[str] - name: str -- targetObjFilename: str - isa: IsaVersion - wavefrontSize: int - cuoccupancy: int -@@ -127,10 +126,9 @@ def processKernelSource(kernelWriterAssembly, data, splitGSU, kernel) -> KernelC - asmFilename = getKernelFileBase(splitGSU, kernel) - err, src = kernelWriter.getSourceFileString(kernel) - header = kernelWriter.getHeaderFileString(kernel) -- objFilename = kernel._state.get("codeObjectFile", None) - pgr = int(kernel["PrefetchGlobalRead"]) - return KernelCodeGenResult( -- err, src, header, asmFilename, objFilename, tuple(kernel["ISA"]), \ -+ err, src, header, asmFilename, tuple(kernel["ISA"]), \ - kernel["WavefrontSize"], kernel["CUOccupancy"], \ - pgr, kernel["MathClocksUnrolledLoop"] - ) diff --git a/pkgs/development/rocm-modules/hipblaslt/TensileCreateLibrary-refactor.patch b/pkgs/development/rocm-modules/hipblaslt/TensileCreateLibrary-refactor.patch deleted file mode 100644 index 1accf91426f46..0000000000000 --- a/pkgs/development/rocm-modules/hipblaslt/TensileCreateLibrary-refactor.patch +++ /dev/null @@ -1,849 +0,0 @@ -diff --git a/tensilelite/Tensile/Common/Parallel.py b/tensilelite/Tensile/Common/Parallel.py -index 1a2bf9e119..f46100c7b8 100644 ---- a/tensilelite/Tensile/Common/Parallel.py -+++ b/tensilelite/Tensile/Common/Parallel.py -@@ -22,43 +22,58 @@ - # - ################################################################################ - --import concurrent.futures --import itertools -+import multiprocessing - import os -+import re - import sys - import time -- --from joblib import Parallel, delayed -+from functools import partial -+from typing import Any, Callable - - from .Utilities import tqdm - - --def joblibParallelSupportsGenerator(): -- import joblib -- from packaging.version import Version -+def get_inherited_job_limit() -> int: -+ # 1. Check CMAKE_BUILD_PARALLEL_LEVEL (CMake 3.12+) -+ if 'CMAKE_BUILD_PARALLEL_LEVEL' in os.environ: -+ try: -+ return int(os.environ['CMAKE_BUILD_PARALLEL_LEVEL']) -+ except ValueError: -+ pass - -- joblibVer = joblib.__version__ -- return Version(joblibVer) >= Version("1.4.0") -+ # 2. Parse MAKEFLAGS for -jN -+ makeflags = os.environ.get('MAKEFLAGS', '') -+ match = re.search(r'-j\s*(\d+)', makeflags) -+ if match: -+ return int(match.group(1)) - -+ return -1 - --def CPUThreadCount(enable=True): -- from .GlobalParameters import globalParameters - -+def CPUThreadCount(enable=True): - if not enable: - return 1 -- else: -+ from .GlobalParameters import globalParameters -+ -+ # Priority order: -+ # 1. Inherited from build system (CMAKE_BUILD_PARALLEL_LEVEL or MAKEFLAGS) -+ # 2. Explicit --jobs flag -+ # 3. Auto-detect -+ inherited_limit = get_inherited_job_limit() -+ cpuThreads = inherited_limit if inherited_limit > 0 else globalParameters["CpuThreads"] -+ -+ if cpuThreads < 1: - if os.name == "nt": -- # Windows supports at most 61 workers because the scheduler uses -- # WaitForMultipleObjects directly, which has the limit (the limit -- # is actually 64, but some handles are needed for accounting). -- cpu_count = min(os.cpu_count(), 61) -+ cpuThreads = os.cpu_count() - else: -- cpu_count = len(os.sched_getaffinity(0)) -- cpuThreads = globalParameters["CpuThreads"] -- if cpuThreads == -1: -- return cpu_count -+ cpuThreads = len(os.sched_getaffinity(0)) - -- return min(cpu_count, cpuThreads) -+ if os.name == "nt": -+ # Windows supports at most 61 workers because the scheduler uses -+ # WaitForMultipleObjects directly, which has the limit (the limit -+ # is actually 64, but some handles are needed for accounting). -+ cpuThreads = min(cpuThreads, 61) -+ return max(1, cpuThreads) - - - def pcallWithGlobalParamsMultiArg(f, args, newGlobalParameters): -@@ -71,19 +86,22 @@ def pcallWithGlobalParamsSingleArg(f, arg, newGlobalParameters): - return f(arg) - - --def apply_print_exception(item, *args): -- # print(item, args) -+def OverwriteGlobalParameters(newGlobalParameters): -+ from . import GlobalParameters -+ -+ GlobalParameters.globalParameters.clear() -+ GlobalParameters.globalParameters.update(newGlobalParameters) -+ -+ -+def worker_function(args, function, multiArg): -+ """Worker function that executes in the pool process.""" - try: -- if len(args) > 0: -- func = item -- args = args[0] -- return func(*args) -+ if multiArg: -+ return function(*args) - else: -- func, item = item -- return func(item) -+ return function(args) - except Exception: - import traceback -- - traceback.print_exc() - raise - finally: -@@ -98,154 +116,121 @@ def OverwriteGlobalParameters(newGlobalParameters): - GlobalParameters.globalParameters.update(newGlobalParameters) - - --def ProcessingPool(enable=True, maxTasksPerChild=None): -- import multiprocessing -- import multiprocessing.dummy -- -- threadCount = CPUThreadCount() -- -- if (not enable) or threadCount <= 1: -- return multiprocessing.dummy.Pool(1) -- -- if multiprocessing.get_start_method() == "spawn": -- from . import GlobalParameters -- -- return multiprocessing.Pool( -- threadCount, -- initializer=OverwriteGlobalParameters, -- maxtasksperchild=maxTasksPerChild, -- initargs=(GlobalParameters.globalParameters,), -- ) -- else: -- return multiprocessing.Pool(threadCount, maxtasksperchild=maxTasksPerChild) -+def progress_logger(iterable, total, message, min_log_interval=5.0): -+ """ -+ Generator that wraps an iterable and logs progress with time-based throttling. - -+ Only logs progress if at least min_log_interval seconds have passed since last log. -+ Only prints completion message if task took >= min_log_interval seconds. - --def ParallelMap(function, objects, message="", enable=True, method=None, maxTasksPerChild=None): -+ Yields (index, item) tuples. - """ -- Generally equivalent to list(map(function, objects)), possibly executing in parallel. -- -- message: A message describing the operation to be performed. -- enable: May be set to false to disable parallelism. -- method: A function which can fetch the mapping function from a processing pool object. -- Leave blank to use .map(), other possiblities: -- - `lambda x: x.starmap` - useful if `function` takes multiple parameters. -- - `lambda x: x.imap` - lazy evaluation -- - `lambda x: x.imap_unordered` - lazy evaluation, does not preserve order of return value. -- """ -- from .GlobalParameters import globalParameters -+ start_time = time.time() -+ last_log_time = start_time -+ log_interval = 1 + (total // 100) - -- threadCount = CPUThreadCount(enable) -- pool = ProcessingPool(enable, maxTasksPerChild) -- -- if threadCount <= 1 and globalParameters["ShowProgressBar"]: -- # Provide a progress bar for single-threaded operation. -- # This works for method=None, and for starmap. -- mapFunc = map -- if method is not None: -- # itertools provides starmap which can fill in for pool.starmap. It provides imap on Python 2.7. -- # If this works, we will use it, otherwise we will fallback to the "dummy" pool for single threaded -- # operation. -- try: -- mapFunc = method(itertools) -- except NameError: -- mapFunc = None -- -- if mapFunc is not None: -- return list(mapFunc(function, tqdm(objects, message))) -- -- mapFunc = pool.map -- if method: -- mapFunc = method(pool) -- -- objects = zip(itertools.repeat(function), objects) -- function = apply_print_exception -- -- countMessage = "" -- try: -- countMessage = " for {} tasks".format(len(objects)) -- except TypeError: -- pass -+ for idx, item in enumerate(iterable): -+ if idx % log_interval == 0: -+ current_time = time.time() -+ if (current_time - last_log_time) >= min_log_interval: -+ print(f"{message}\t{idx+1: 5d}/{total: 5d}") -+ last_log_time = current_time -+ yield idx, item - -- if message != "": -- message += ": " -+ elapsed = time.time() - start_time -+ final_idx = idx + 1 if 'idx' in locals() else 0 - -- print("{0}Launching {1} threads{2}...".format(message, threadCount, countMessage)) -- sys.stdout.flush() -- currentTime = time.time() -- rv = mapFunc(function, objects) -- totalTime = time.time() - currentTime -- print("{0}Done. ({1:.1f} secs elapsed)".format(message, totalTime)) -- sys.stdout.flush() -- pool.close() -- return rv -+ if elapsed >= min_log_interval or last_log_time > start_time: -+ print(f"{message} done in {elapsed:.1f}s!\t{final_idx: 5d}/{total: 5d}") - - --def ParallelMapReturnAsGenerator(function, objects, message="", enable=True, multiArg=True): -- from .GlobalParameters import globalParameters -+def imap_with_progress(pool, func, iterable, total, message, chunksize): -+ results = [] -+ for _, result in progress_logger(pool.imap(func, iterable, chunksize=chunksize), total, message): -+ results.append(result) -+ return results - -- threadCount = CPUThreadCount(enable) -- print("{0}Launching {1} threads...".format(message, threadCount)) - -- if threadCount <= 1 and globalParameters["ShowProgressBar"]: -- # Provide a progress bar for single-threaded operation. -- callFunc = lambda args: function(*args) if multiArg else lambda args: function(args) -- return [callFunc(args) for args in tqdm(objects, message)] -+def _ParallelMap_generator(worker, objects, objLen, message, chunksize, threadCount, globalParameters, maxtasksperchild): -+ # separate fn because yield makes the entire fn a generator even if unreachable -+ ctx = multiprocessing.get_context('forkserver' if os.name != 'nt' else 'spawn') - -- with concurrent.futures.ProcessPoolExecutor(max_workers=threadCount) as executor: -- resultFutures = (executor.submit(function, *arg if multiArg else arg) for arg in objects) -- for result in concurrent.futures.as_completed(resultFutures): -- yield result.result() -+ with ctx.Pool(processes=threadCount, maxtasksperchild=maxtasksperchild, -+ initializer=OverwriteGlobalParameters, initargs=(globalParameters,)) as pool: -+ for _, result in progress_logger(pool.imap_unordered(worker, objects, chunksize=chunksize), objLen, message): -+ yield result - - - def ParallelMap2( -- function, objects, message="", enable=True, multiArg=True, return_as="list", procs=None -+ function: Callable, -+ objects: Any, -+ message: str = "", -+ enable: bool = True, -+ multiArg: bool = True, -+ minChunkSize: int = 1, -+ maxWorkers: int = -1, -+ maxtasksperchild: int = 1024, -+ return_as: str = "list" - ): -+ """Executes a function over a list of objects in parallel or sequentially. -+ -+ This function is generally equivalent to ``list(map(function, objects))``. However, it provides -+ additional functionality to run in parallel, depending on the 'enable' flag and available CPU -+ threads. -+ -+ Args: -+ function: The function to apply to each item in 'objects'. If 'multiArg' is True, 'function' -+ should accept multiple arguments. -+ objects: An iterable of objects to be processed by 'function'. If 'multiArg' is True, each -+ item in 'objects' should be an iterable of arguments for 'function'. -+ message: Optional; a message describing the operation. Default is an empty string. -+ enable: Optional; if False, disables parallel execution and runs sequentially. Default is True. -+ multiArg: Optional; if True, treats each item in 'objects' as multiple arguments for -+ 'function'. Default is True. -+ return_as: Optional; "list" (default) or "generator_unordered" for streaming results -+ -+ Returns: -+ A list or generator containing the results of applying **function** to each item in **objects**. - """ -- Generally equivalent to list(map(function, objects)), possibly executing in parallel. -+ from .GlobalParameters import globalParameters - -- message: A message describing the operation to be performed. -- enable: May be set to false to disable parallelism. -- multiArg: True if objects represent multiple arguments -- (differentiates multi args vs single collection arg) -- """ -- if return_as in ("generator", "generator_unordered") and not joblibParallelSupportsGenerator(): -- return ParallelMapReturnAsGenerator(function, objects, message, enable, multiArg) -+ threadCount = CPUThreadCount(enable) - -- from .GlobalParameters import globalParameters -+ if not hasattr(objects, "__len__"): -+ objects = list(objects) - -- threadCount = procs if procs else CPUThreadCount(enable) -+ objLen = len(objects) -+ if objLen == 0: -+ return [] if return_as == "list" else iter([]) - -- threadCount = CPUThreadCount(enable) -+ f = (lambda x: function(*x)) if multiArg else function -+ if objLen == 1: -+ print(f"{message}: (1 task)") -+ result = [f(x) for x in objects] -+ return result if return_as == "list" else iter(result) - -- if threadCount <= 1 and globalParameters["ShowProgressBar"]: -- # Provide a progress bar for single-threaded operation. -- return [function(*args) if multiArg else function(args) for args in tqdm(objects, message)] -+ extra_message = ( -+ f": {threadCount} thread(s)" + f", {objLen} tasks" -+ if objLen -+ else "" -+ ) - -- countMessage = "" -- try: -- countMessage = " for {} tasks".format(len(objects)) -- except TypeError: -- pass -- -- if message != "": -- message += ": " -- print("{0}Launching {1} threads{2}...".format(message, threadCount, countMessage)) -- sys.stdout.flush() -- currentTime = time.time() -- -- pcall = pcallWithGlobalParamsMultiArg if multiArg else pcallWithGlobalParamsSingleArg -- pargs = zip(objects, itertools.repeat(globalParameters)) -- -- if joblibParallelSupportsGenerator(): -- rv = Parallel(n_jobs=threadCount, timeout=99999, return_as=return_as)( -- delayed(pcall)(function, a, params) for a, params in pargs -- ) -+ print(f"ParallelMap {message}{extra_message}") -+ -+ if threadCount <= 1: -+ result = [f(x) for x in objects] -+ return result if return_as == "list" else iter(result) -+ -+ if maxWorkers > 0: -+ threadCount = min(maxWorkers, threadCount) -+ -+ chunksize = max(minChunkSize, objLen // 2000) -+ worker = partial(worker_function, function=function, multiArg=multiArg) -+ if return_as == "generator_unordered": -+ # yield results as they complete without buffering -+ return _ParallelMap_generator(worker, objects, objLen, message, chunksize, threadCount, globalParameters, maxtasksperchild) - else: -- rv = Parallel(n_jobs=threadCount, timeout=99999)( -- delayed(pcall)(function, a, params) for a, params in pargs -- ) -- -- totalTime = time.time() - currentTime -- print("{0}Done. ({1:.1f} secs elapsed)".format(message, totalTime)) -- sys.stdout.flush() -- return rv -+ ctx = multiprocessing.get_context('forkserver' if os.name != 'nt' else 'spawn') -+ with ctx.Pool(processes=threadCount, maxtasksperchild=maxtasksperchild, -+ initializer=OverwriteGlobalParameters, initargs=(globalParameters,)) as pool: -+ return list(imap_with_progress(pool, worker, objects, objLen, message, chunksize)) -diff --git a/tensilelite/Tensile/CustomKernels.py b/tensilelite/Tensile/CustomKernels.py -index ffceb636f5..127b3386a1 100644 ---- a/tensilelite/Tensile/CustomKernels.py -+++ b/tensilelite/Tensile/CustomKernels.py -@@ -24,7 +24,9 @@ - - from . import CUSTOM_KERNEL_PATH - from Tensile.Common.ValidParameters import checkParametersAreValid, validParameters, newMIValidParameters -+from Tensile.CustomYamlLoader import DEFAULT_YAML_LOADER - -+from functools import lru_cache - import yaml - - import os -@@ -58,10 +60,13 @@ def getCustomKernelConfigAndAssembly(name, directory=CUSTOM_KERNEL_PATH): - - return (config, assembly) - -+# getCustomKernelConfig will get called repeatedly on the same file -+# 20x logic loading speedup for aquavanjaram_Cijk_Ailk_Bljk_F8NH_HHS_BH_Bias_HAS_SAB_SAV_freesize_custom_GSUs -+@lru_cache - def readCustomKernelConfig(name, directory=CUSTOM_KERNEL_PATH): - rawConfig, _ = getCustomKernelConfigAndAssembly(name, directory) - try: -- return yaml.safe_load(rawConfig)["custom.config"] -+ return yaml.load(rawConfig, Loader=DEFAULT_YAML_LOADER)["custom.config"] - except yaml.scanner.ScannerError as e: - raise RuntimeError("Failed to read configuration for custom kernel: {0}\nDetails:\n{1}".format(name, e)) - -diff --git a/tensilelite/Tensile/CustomYamlLoader.py b/tensilelite/Tensile/CustomYamlLoader.py -index e03f456fbe..ed7510f2ce 100644 ---- a/tensilelite/Tensile/CustomYamlLoader.py -+++ b/tensilelite/Tensile/CustomYamlLoader.py -@@ -1,6 +1,7 @@ - # Copyright © Advanced Micro Devices, Inc., or its affiliates. - # SPDX-License-Identifier: MIT - -+import sys - import yaml - from pathlib import Path - -@@ -70,7 +71,7 @@ def parse_scalar(loader: yaml.Loader): - elif is_float(value_lower): - return float(value_lower) - -- return value -+ return sys.intern(value) - - def load_yaml_stream(yaml_path: Path, loader_type: yaml.Loader): - with open(yaml_path, 'r') as f: -diff --git a/tensilelite/Tensile/TensileCreateLibrary/Run.py b/tensilelite/Tensile/TensileCreateLibrary/Run.py -index 22d19851a3..348068b3bf 100644 ---- a/tensilelite/Tensile/TensileCreateLibrary/Run.py -+++ b/tensilelite/Tensile/TensileCreateLibrary/Run.py -@@ -26,8 +26,10 @@ import rocisa - - import functools - import glob -+import gc - import itertools - import os -+import resource - import shutil - from pathlib import Path - from timeit import default_timer as timer -@@ -78,6 +80,25 @@ from Tensile.Utilities.Decorators.Timing import timing - from .ParseArguments import parseArguments - - -+def getMemoryUsage(): -+ """Get peak and current memory usage in MB.""" -+ rusage = resource.getrusage(resource.RUSAGE_SELF) -+ peak_memory_mb = rusage.ru_maxrss / 1024 # KB to MB on Linux -+ -+ # Get current memory from /proc/self/status -+ current_memory_mb = 0 -+ try: -+ with open('/proc/self/status') as f: -+ for line in f: -+ if line.startswith('VmRSS:'): -+ current_memory_mb = int(line.split()[1]) / 1024 # KB to MB -+ break -+ except: -+ current_memory_mb = peak_memory_mb # Fallback -+ -+ return (peak_memory_mb, current_memory_mb) -+ -+ - class KernelCodeGenResult(NamedTuple): - err: int - src: str -@@ -115,6 +136,29 @@ def processKernelSource(kernelWriterAssembly, data, outOptions, splitGSU, kernel - ) - - -+def processAndAssembleKernelTCL(kernelWriterAssembly, rocisa_data, outOptions, splitGSU, kernel, assemblyTmpPath, assembler): -+ """ -+ Pipeline function for TCL mode that: -+ 1. Generates kernel source -+ 2. Writes .s file to disk -+ 3. Assembles to .o file -+ 4. Deletes .s file -+ """ -+ result = processKernelSource(kernelWriterAssembly, rocisa_data, outOptions, splitGSU, kernel) -+ return writeAndAssembleKernel(result, assemblyTmpPath, assembler) -+ -+ -+def writeMasterSolutionLibrary(name_lib_tuple, newLibraryDir, splitGSU, libraryFormat): -+ """ -+ Write a master solution library to disk. -+ Module-level function to support multiprocessing. -+ """ -+ name, lib = name_lib_tuple -+ filename = os.path.join(newLibraryDir, name) -+ lib.applyNaming(splitGSU) -+ LibraryIO.write(filename, state(lib), libraryFormat) -+ -+ - def removeInvalidSolutionsAndKernels(results, kernels, solutions, errorTolerant, printLevel: bool, splitGSU: bool): - removeKernels = [] - removeKernelNames = [] -@@ -189,6 +233,24 @@ def writeAssembly(asmPath: Union[Path, str], result: KernelCodeGenResult): - return path, isa, wfsize, minResult - - -+def writeAndAssembleKernel(result: KernelCodeGenResult, asmPath: Union[Path, str], assembler): -+ """Write assembly file and immediately assemble it to .o file""" -+ if result.err: -+ printExit(f"Failed to build kernel {result.name} because it has error code {result.err}") -+ -+ path = Path(asmPath) / f"{result.name}.s" -+ with open(path, "w", encoding="utf-8") as f: -+ f.write(result.src) -+ -+ # Assemble .s -> .o -+ assembler(isaToGfx(result.isa), result.wavefrontSize, str(path), str(path.with_suffix(".o"))) -+ -+ # Delete assembly file immediately to save disk space -+ path.unlink() -+ -+ return KernelMinResult(result.err, result.cuoccupancy, result.pgr, result.mathclk) -+ -+ - def writeHelpers( - outputPath, kernelHelperObjs, KERNEL_HELPER_FILENAME_CPP, KERNEL_HELPER_FILENAME_H - ): -@@ -272,14 +334,15 @@ def writeSolutionsAndKernels( - numAsmKernels = len(asmKernels) - numKernels = len(asmKernels) - assert numKernels == numAsmKernels, "Only assembly kernels are supported in TensileLite" -- asmIter = zip( -- itertools.repeat(kernelWriterAssembly), -- itertools.repeat(rocisa.rocIsa.getInstance().getData()), -- itertools.repeat(outOptions), -- itertools.repeat(splitGSU), -- asmKernels -+ -+ processKernelFn = functools.partial( -+ processKernelSource, -+ kernelWriterAssembly=kernelWriterAssembly, -+ data=rocisa.rocIsa.getInstance().getData(), -+ outOptions=outOptions, -+ splitGSU=splitGSU - ) -- asmResults = ParallelMap2(processKernelSource, asmIter, "Generating assembly kernels", return_as="list") -+ asmResults = ParallelMap2(processKernelFn, asmKernels, "Generating assembly kernels", return_as="list", multiArg=False) - removeInvalidSolutionsAndKernels( - asmResults, asmKernels, solutions, errorTolerant, getVerbosity(), splitGSU - ) -@@ -287,19 +350,21 @@ def writeSolutionsAndKernels( - asmResults, asmKernels, solutions, splitGSU - ) - -- def assemble(ret): -- p, isa, wavefrontsize, _ = ret -- asmToolchain.assembler(isaToGfx(isa), wavefrontsize, str(p), str(p.with_suffix(".o"))) -- -- unaryWriteAssembly = functools.partial(writeAssembly, assemblyTmpPath) -- compose = lambda *F: functools.reduce(lambda f, g: lambda x: f(g(x)), F) -+ # Use functools.partial to bind assemblyTmpPath and assembler -+ writeAndAssembleFn = functools.partial( -+ writeAndAssembleKernel, -+ asmPath=assemblyTmpPath, -+ assembler=asmToolchain.assembler -+ ) - ret = ParallelMap2( -- compose(assemble, unaryWriteAssembly), -+ writeAndAssembleFn, - asmResults, - "Writing assembly kernels", - return_as="list", - multiArg=False, - ) -+ del asmResults -+ gc.collect() - - writeHelpers(outputPath, kernelHelperObjs, KERNEL_HELPER_FILENAME_CPP, KERNEL_HELPER_FILENAME_H) - srcKernelFile = Path(outputPath) / "Kernels.cpp" -@@ -376,40 +441,35 @@ def writeSolutionsAndKernelsTCL( - - uniqueAsmKernels = [k for k in asmKernels if not k.duplicate] - -- def assemble(ret, removeTemporaries: bool): -- asmPath, isa, wavefrontsize, result = ret -- asmToolchain.assembler(isaToGfx(isa), wavefrontsize, str(asmPath), str(asmPath.with_suffix(".o"))) -- if removeTemporaries: -- asmPath.unlink() -- return result -- -- unaryAssemble = functools.partial(assemble, removeTemporaries=removeTemporaries) -- - outOptions = rocisa.rocIsa.getInstance().getOutputOptions() - outOptions.outputNoComment = not disableAsmComments - -- unaryProcessKernelSource = functools.partial( -- processKernelSource, -+ processKernelFn = functools.partial( -+ processAndAssembleKernelTCL, - kernelWriterAssembly, - rocisa.rocIsa.getInstance().getData(), - outOptions, - splitGSU, -+ assemblyTmpPath=assemblyTmpPath, -+ assembler=asmToolchain.assembler - ) - -- unaryWriteAssembly = functools.partial(writeAssembly, assemblyTmpPath) -- compose = lambda *F: functools.reduce(lambda f, g: lambda x: f(g(x)), F) -- ret = ParallelMap2( -- compose(unaryAssemble, unaryWriteAssembly, unaryProcessKernelSource), -+ results = ParallelMap2( -+ processKernelFn, - uniqueAsmKernels, - "Generating assembly kernels", - multiArg=False, - return_as="list" - ) -+ del processKernelFn -+ gc.collect() -+ - passPostKernelInfoToSolution( -- ret, uniqueAsmKernels, solutions, splitGSU -+ results, uniqueAsmKernels, solutions, splitGSU - ) -- # result.src is very large so let garbage collector know to clean up -- del ret -+ del results -+ gc.collect() -+ - buildAssemblyCodeObjectFiles( - asmToolchain.linker, - asmToolchain.bundler, -@@ -508,6 +568,15 @@ def generateKernelHelperObjects(solutions: List[Solution], cxxCompiler: str, isa - return sorted(khos, key=sortByEnum, reverse=True) # Ensure that we write Enum kernel helpers are first in list - - -+def libraryIter(lib: MasterSolutionLibrary): -+ if len(lib.solutions): -+ for i, s in enumerate(lib.solutions.items()): -+ yield (i, *s) -+ else: -+ for _, lazyLib in lib.lazyLibraries.items(): -+ yield from libraryIter(lazyLib) -+ -+ - @timing - def generateLogicDataAndSolutions(logicFiles, args, assembler: Assembler, isaInfoMap): - -@@ -523,26 +592,23 @@ def generateLogicDataAndSolutions(logicFiles, args, assembler: Assembler, isaInf - printSolutionRejectionReason = True - printIndexAssignmentInfo = False - -- fIter = zip( -- logicFiles, -- itertools.repeat(assembler), -- itertools.repeat(splitGSU), -- itertools.repeat(printSolutionRejectionReason), -- itertools.repeat(printIndexAssignmentInfo), -- itertools.repeat(isaInfoMap), -- itertools.repeat(args["LazyLibraryLoading"]), -+ parseLogicFn = functools.partial( -+ LibraryIO.parseLibraryLogicFile, -+ assembler=assembler, -+ splitGSU=splitGSU, -+ printSolutionRejectionReason=printSolutionRejectionReason, -+ printIndexAssignmentInfo=printIndexAssignmentInfo, -+ isaInfoMap=isaInfoMap, -+ lazyLibraryLoading=args["LazyLibraryLoading"] - ) - -- def libraryIter(lib: MasterSolutionLibrary): -- if len(lib.solutions): -- for i, s in enumerate(lib.solutions.items()): -- yield (i, *s) -- else: -- for _, lazyLib in lib.lazyLibraries.items(): -- yield from libraryIter(lazyLib) -- - for library in ParallelMap2( -- LibraryIO.parseLibraryLogicFile, fIter, "Loading Logics...", return_as="generator_unordered" -+ parseLogicFn, logicFiles, "Loading Logics...", -+ return_as="generator_unordered", -+ minChunkSize=24, -+ maxWorkers=32, -+ maxtasksperchild=1, -+ multiArg=False, - ): - _, architectureName, _, _, _, newLibrary = library - -@@ -554,6 +620,9 @@ def generateLogicDataAndSolutions(logicFiles, args, assembler: Assembler, isaInf - else: - masterLibraries[architectureName] = newLibrary - masterLibraries[architectureName].version = args["CodeObjectVersion"] -+ del library, newLibrary -+ -+ gc.collect() - - # Sort masterLibraries to make global soln index values deterministic - solnReIndex = 0 -@@ -751,6 +820,9 @@ def run(): - ) - stop_wsk = timer() - print(f"Time to generate kernels (s): {(stop_wsk-start_wsk):3.2f}") -+ numKernelHelperObjs = len(kernelHelperObjs) -+ del kernelWriterAssembly, kernelHelperObjs -+ gc.collect() - - archs = [ # is this really different than the other archs above? - isaToGfx(arch) -@@ -768,13 +840,10 @@ def run(): - if kName not in solDict: - solDict["%s"%kName] = kernel - -- def writeMsl(name, lib): -- filename = os.path.join(newLibraryDir, name) -- lib.applyNaming(splitGSU) -- LibraryIO.write(filename, state(lib), arguments["LibraryFormat"]) -- - filename = os.path.join(newLibraryDir, "TensileLiteLibrary_lazy_Mapping") - LibraryIO.write(filename, libraryMapping, "msgpack") -+ del libraryMapping -+ gc.collect() - - start_msl = timer() - for archName, newMasterLibrary in masterLibraries.items(): -@@ -791,12 +860,22 @@ def run(): - kName = getKeyNoInternalArgs(s.originalSolution, splitGSU) - s.sizeMapping.CUOccupancy = solDict["%s"%kName]["CUOccupancy"] - -- ParallelMap2(writeMsl, -+ writeFn = functools.partial( -+ writeMasterSolutionLibrary, -+ newLibraryDir=newLibraryDir, -+ splitGSU=splitGSU, -+ libraryFormat=arguments["LibraryFormat"] -+ ) -+ -+ ParallelMap2(writeFn, - newMasterLibrary.lazyLibraries.items(), - "Writing master solution libraries", -+ multiArg=False, - return_as="list") - stop_msl = timer() - print(f"Time to write master solution libraries (s): {(stop_msl-start_msl):3.2f}") -+ del masterLibraries, solutions, kernels, solDict -+ gc.collect() - - if not arguments["KeepBuildTmp"]: - buildTmp = Path(arguments["OutputPath"]).parent / "library" / "build_tmp" -@@ -813,8 +892,11 @@ def run(): - print("") - - stop = timer() -+ peak_memory_mb, current_memory_mb = getMemoryUsage() - - print(f"Total time (s): {(stop-start):3.2f}") - print(f"Total kernels processed: {numKernels}") - print(f"Kernels processed per second: {(numKernels/(stop-start)):3.2f}") -- print(f"KernelHelperObjs: {len(kernelHelperObjs)}") -+ print(f"KernelHelperObjs: {numKernelHelperObjs}") -+ print(f"Peak memory usage (MB): {peak_memory_mb:,.1f}") -+ print(f"Current memory usage (MB): {current_memory_mb:,.1f}") -diff --git a/tensilelite/Tensile/TensileMergeLibrary.py b/tensilelite/Tensile/TensileMergeLibrary.py -index e33c617b6f..ba163e9918 100644 ---- a/tensilelite/Tensile/TensileMergeLibrary.py -+++ b/tensilelite/Tensile/TensileMergeLibrary.py -@@ -303,8 +303,7 @@ def avoidRegressions(originalDir, incrementalDir, outputPath, forceMerge, noEff= - logicsFiles[origFile] = origFile - logicsFiles[incFile] = incFile - -- iters = zip(logicsFiles.keys()) -- logicsList = ParallelMap2(loadData, iters, "Loading Logics...", return_as="list") -+ logicsList = ParallelMap2(loadData, logicsFiles.keys(), "Loading Logics...", return_as="list", multiArg=False) - logicsDict = {} - for i, _ in enumerate(logicsList): - logicsDict[logicsList[i][0]] = logicsList[i][1] -diff --git a/tensilelite/Tensile/TensileUpdateLibrary.py b/tensilelite/Tensile/TensileUpdateLibrary.py -index 5ff265d0ed..c1803a6349 100644 ---- a/tensilelite/Tensile/TensileUpdateLibrary.py -+++ b/tensilelite/Tensile/TensileUpdateLibrary.py -@@ -26,7 +26,7 @@ from . import LibraryIO - from .Tensile import addCommonArguments, argUpdatedGlobalParameters - - from .Common import assignGlobalParameters, print1, restoreDefaultGlobalParameters, HR, \ -- globalParameters, architectureMap, ensurePath, ParallelMap, __version__ -+ globalParameters, architectureMap, ensurePath, ParallelMap2, __version__ - - import argparse - import copy -@@ -149,7 +149,7 @@ def TensileUpdateLibrary(userArgs): - for logicFile in logicFiles: - print("# %s" % logicFile) - fIter = zip(logicFiles, itertools.repeat(args.logic_path), itertools.repeat(outputPath)) -- libraries = ParallelMap(UpdateLogic, fIter, "Updating logic files", method=lambda x: x.starmap) -+ libraries = ParallelMap2(UpdateLogic, fIter, "Updating logic files", multiArg=True, return_as="list") - - - def main(): -diff --git a/tensilelite/Tensile/Toolchain/Assembly.py b/tensilelite/Tensile/Toolchain/Assembly.py -index a8b91e8d62..265e1d532c 100644 ---- a/tensilelite/Tensile/Toolchain/Assembly.py -+++ b/tensilelite/Tensile/Toolchain/Assembly.py -@@ -30,7 +30,7 @@ import subprocess - from pathlib import Path - from typing import List, Union, NamedTuple - --from Tensile.Common import print2 -+from Tensile.Common import print1, print2 - from Tensile.Common.Architectures import isaToGfx - from ..SolutionStructs import Solution - -@@ -92,8 +92,26 @@ def buildAssemblyCodeObjectFiles( - if coName: - coFileMap[asmDir / (coName + extCoRaw)].add(str(asmDir / (kernel["BaseName"] + extObj))) - -+ # Build reference count map for .o files to handle shared object files -+ # (.o files from kernels marked .duplicate in TensileCreateLibrary) -+ objFileRefCount = collections.Counter() -+ for coFileRaw, objFiles in coFileMap.items(): -+ for objFile in objFiles: -+ objFileRefCount[objFile] += 1 -+ -+ sharedObjFiles = {objFile: count for objFile, count in objFileRefCount.items() if count > 1} -+ if sharedObjFiles: -+ print1(f"Found {len(sharedObjFiles)} .o files shared across multiple code objects:") -+ - for coFileRaw, objFiles in coFileMap.items(): - linker(objFiles, str(coFileRaw)) -+ -+ # Delete .o files after linking once usage count reaches 0 -+ for objFile in objFiles: -+ objFileRefCount[objFile] -= 1 -+ if objFileRefCount[objFile] == 0: -+ Path(objFile).unlink() -+ - coFile = destDir / coFileRaw.name.replace(extCoRaw, extCo) - if compress: - bundler.compress(str(coFileRaw), str(coFile), gfx) -diff --git a/tensilelite/Tensile/Toolchain/Component.py b/tensilelite/Tensile/Toolchain/Component.py -index 67fa35e2d8..dde83af4c3 100644 ---- a/tensilelite/Tensile/Toolchain/Component.py -+++ b/tensilelite/Tensile/Toolchain/Component.py -@@ -355,6 +355,7 @@ class Linker(Component): - when invoking the linker, LLVM allows the provision of arguments via a "response file" - Reference: https://llvm.org/docs/CommandLine.html#response-files - """ -+ # FIXME: this prevents threading as clang_args.txt is overwritten - with open(Path.cwd() / "clang_args.txt", "wt") as file: - file.write(" ".join(srcPaths).replace('\\', '\\\\') if os_name == "nt" else " ".join(srcPaths)) - return [*(self.default_args), "-o", destPath, "@clang_args.txt"] -diff --git a/tensilelite/requirements.txt b/tensilelite/requirements.txt -index 60c4c11445..5c8fd66a88 100644 ---- a/tensilelite/requirements.txt -+++ b/tensilelite/requirements.txt -@@ -2,8 +2,6 @@ dataclasses; python_version == '3.6' - packaging - pyyaml - msgpack --joblib>=1.4.0; python_version >= '3.8' --joblib>=1.1.1; python_version < '3.8' - simplejson - ujson - orjson diff --git a/pkgs/development/rocm-modules/hipblaslt/default.nix b/pkgs/development/rocm-modules/hipblaslt/default.nix deleted file mode 100644 index d24759510a5c3..0000000000000 --- a/pkgs/development/rocm-modules/hipblaslt/default.nix +++ /dev/null @@ -1,256 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - cmake, - rocm-cmake, - rocm-smi, - pkg-config, - clr, - gfortran, - gtest, - boost, - llvm, - msgpack-cxx, - amd-blis, - libxml2, - python3, - python3Packages, - openmp, - hipblas-common, - lapack-reference, - ncurses, - ninja, - libffi, - jemalloc, - zlib, - zstd, - rocmUpdateScript, - buildTests ? false, - buildSamples ? false, - # hipblaslt supports only devices with MFMA or WMMA - gpuTargets ? (clr.localGpuTargets or clr.gpuTargets), -}: - -let - # hipblaslt is extremely particular about what it will build with - # so intersect with a known supported list and use only those - supportedTargets = ( - lib.lists.intersectLists gpuTargets [ - "gfx908" - "gfx90a" - "gfx942" - "gfx950" - "gfx1100" - "gfx1101" - "gfx1150" - "gfx1151" - "gfx1200" - "gfx1201" - ] - ); - supportsTargetArches = supportedTargets != [ ]; - py = python3.withPackages (ps: [ - ps.pyyaml - ps.setuptools - ps.packaging - ps.nanobind - ps.msgpack - ]); - # workaround: build for one working target if no targets are supported - # a few CXX files are still build for the device - gpuTargets' = - if supportsTargetArches then (lib.concatStringsSep ";" supportedTargets) else "gfx1200"; - compiler = "amdclang++"; - # no-switch due to spammy warnings on some cases with fixme messages - # FIXME(LunNova@): cmake files need patched to include this properly or - # maybe we improve the toolchain to use config files + assemble a sysroot - # so system wide include assumptions work - cFlags = "-Wno-switch -fopenmp -I${lib.getDev zstd}/include -I${amd-blis}/include/blis/ -I${lib.getDev msgpack-cxx}/include"; -in -stdenv.mkDerivation (finalAttrs: { - pname = "hipblaslt${clr.gpuArchSuffix}"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-+xMmPKb32NP9U35dHCXfXWwa6exfiL5TezfXERVDfe4="; - sparseCheckout = [ - "projects/hipblaslt" - "shared" - ]; - # Compress the 5ish GiB of yaml files so this .src is under output size limit - postFetch = '' - find $out -name '*.yaml' -path '*/Tensile/Logic/*' -exec ${lib.getExe zstd} --rm {} \; - ''; - }; - sourceRoot = "${finalAttrs.src.name}/projects/hipblaslt"; - env.CXX = compiler; - env.CFLAGS = cFlags; - env.CXXFLAGS = cFlags; - env.ROCM_PATH = "${clr}"; - env.TENSILE_ROCM_ASSEMBLER_PATH = lib.getExe' clr "amdclang++"; - env.TENSILE_GEN_ASSEMBLY_TOOLCHAIN = lib.getExe' clr "amdclang++"; - env.LD_PRELOAD = "${jemalloc}/lib/libjemalloc.so"; - env.MALLOC_CONF = "background_thread:true,metadata_thp:auto,dirty_decay_ms:10000,muzzy_decay_ms:10000"; - requiredSystemFeatures = [ "big-parallel" ]; - - __structuredAttrs = true; - strictDeps = true; - - outputs = [ - "out" - # benchmarks are non-optional - "benchmark" - ] - ++ lib.optionals buildTests [ - "test" - ] - ++ lib.optionals buildSamples [ - "sample" - ]; - - patches = [ - # Upstream issue requesting properly specifying - # parallel-jobs for these invocations - # https://github.com/ROCm/rocm-libraries/issues/1242 - ./parallel-buildSourceCodeObjectFile.diff - # Support loading zstd compressed .dat files, required to keep output under - # hydra size limit - ./messagepack-compression-support.patch - # [hipblaslt] Refactor Parallel.py to drop joblib, massively reduce peak disk space usage - # https://github.com/ROCm/rocm-libraries/pull/2073 - ./TensileCreateLibrary-refactor.patch - ./Tensile-interning.patch - ]; - - preConfigure = '' - find . -name '*.yaml.zst' -path '*/Tensile/Logic/*' -exec zstd -d --rm {} \; - ''; - - postPatch = '' - # git isn't needed and we have no .git - substituteInPlace cmake/dependencies.cmake \ - --replace-fail "find_package(Git REQUIRED)" "" - substituteInPlace CMakeLists.txt \ - --replace-fail " LANGUAGES CXX" " LANGUAGES CXX C ASM" - ''; - - doCheck = false; - doInstallCheck = true; - - nativeBuildInputs = [ - cmake - rocm-cmake - py - clr - gfortran - pkg-config - ninja - rocm-smi - zstd - ]; - - buildInputs = [ - llvm.llvm - clr - rocm-cmake - hipblas-common - amd-blis - rocm-smi - openmp - libffi - ncurses - lapack-reference - - # Tensile deps - not optional, building without tensile isn't actually supported - msgpack-cxx - libxml2 - python3Packages.msgpack - zlib - zstd - ] - ++ lib.optionals buildTests [ - gtest - ]; - - cmakeFlags = [ - (lib.cmakeFeature "Boost_INCLUDE_DIR" "${lib.getDev boost}/include") # msgpack FindBoost fails to find boost - (lib.cmakeFeature "GPU_TARGETS" gpuTargets') - (lib.cmakeBool "BUILD_TESTING" buildTests) - (lib.cmakeBool "HIPBLASLT_ENABLE_BLIS" true) - (lib.cmakeBool "HIPBLASLT_BUILD_TESTING" buildTests) - (lib.cmakeBool "HIPBLASLT_ENABLE_SAMPLES" buildSamples) - (lib.cmakeBool "HIPBLASLT_ENABLE_DEVICE" supportsTargetArches) - # FIXME: Enable for ROCm 7.x - (lib.cmakeBool "HIPBLASLT_ENABLE_ROCROLLER" false) - "-DCMAKE_C_COMPILER=amdclang" - "-DCMAKE_HIP_COMPILER=${compiler}" - "-DCMAKE_CXX_COMPILER=${compiler}" - "-DROCM_FOUND=ON" # hipblaslt tries to download rocm-cmake if this isn't set - "-DBLIS_ROOT=${amd-blis}" - "-DBLIS_LIB=${amd-blis}/lib/libblis-mt.so" - "-DBLIS_INCLUDE_DIR=${amd-blis}/include/blis/" - "-DBLA_PREFER_PKGCONFIG=ON" - "-DFETCHCONTENT_SOURCE_DIR_NANOBIND=${python3Packages.nanobind.src}" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - "-DHIPBLASLT_ENABLE_MARKER=Off" - ]; - - postInstall = - # Compress msgpack .dat files to stay under hydra output size limit - # Relies on messagepack-compression-support.patch - '' - for file in $out/lib/hipblaslt/library/*.dat; do - zstd -19 --long -f "$file" -o "$file.tmp" && mv "$file.tmp" "$file" - done - '' - # Move binaries to appropriate outputs and delete leftover /bin - + '' - mkdir -p $benchmark/bin - mv $out/bin/hipblaslt-{api-overhead,bench*} $out/bin/*.yaml $out/bin/*.py $benchmark/bin - ${lib.optionalString buildTests '' - mkdir -p $test/bin - mv $out/bin/hipblas-test $test/bin - ''} - ${lib.optionalString buildSamples '' - mkdir -p $sample/bin - mv $out/bin/example-* $sample/bin - ''} - rmdir $out/bin - ''; - - installCheckPhase = - # Verify compression worked and .dat files aren't huge - '' - runHook preInstallCheck - find "$out" -type f -name "*.dat" -size "+2M" -exec sh -c ' - echo "ERROR: oversized .dat file, check for issues with install compression: {}" >&2 - exit 1 - ' {} \; - echo "Verified .dat files in $out are not huge" - runHook postInstallCheck - ''; - - # If this is false there are no kernels in the output lib - # supporting the target device - # so if it's an optional dep it's best to not depend on it - # Some packages like torch need hipblaslt to compile - # and are fine ignoring it at runtime if it's not supported - # so we have to support building an empty hipblaslt - passthru.supportsTargetArches = supportsTargetArches; - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - meta = { - description = "Library that provides general matrix-matrix operations with a flexible API"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipblaslt"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/hipblaslt/messagepack-compression-support.patch b/pkgs/development/rocm-modules/hipblaslt/messagepack-compression-support.patch deleted file mode 100644 index ace6b2b728ad2..0000000000000 --- a/pkgs/development/rocm-modules/hipblaslt/messagepack-compression-support.patch +++ /dev/null @@ -1,56 +0,0 @@ -diff --git a/Tensile/Source/lib/source/msgpack/MessagePack.cpp b/Tensile/Source/lib/source/msgpack/MessagePack.cpp -index de97929c..dbc397e0 100644 ---- a/tensilelite/src/msgpack/MessagePack.cpp -+++ b/tensilelite/src/msgpack/MessagePack.cpp -@@ -28,6 +28,8 @@ - - #include - -+#include -+ - #include - - namespace Tensile -@@ -86,6 +88,34 @@ namespace Tensile - return nullptr; - } - -+ // Check if the file is zstd compressed -+ char magic[4]; -+ in.read(magic, 4); -+ bool isCompressed = (in.gcount() == 4 && magic[0] == '\x28' && magic[1] == '\xB5' && magic[2] == '\x2F' && magic[3] == '\xFD'); -+ // Reset file pointer to the beginning -+ in.seekg(0, std::ios::beg); -+ -+ if (isCompressed) { -+ // Decompress zstd file -+ std::vector compressedData((std::istreambuf_iterator(in)), std::istreambuf_iterator()); -+ -+ size_t decompressedSize = ZSTD_getFrameContentSize(compressedData.data(), compressedData.size()); -+ if (decompressedSize == ZSTD_CONTENTSIZE_ERROR || decompressedSize == ZSTD_CONTENTSIZE_UNKNOWN) { -+ if(Debug::Instance().printDataInit()) -+ std::cout << "Error: Unable to determine decompressed size for " << filename << std::endl; -+ return false; -+ } -+ -+ std::vector decompressedData(decompressedSize); -+ size_t dSize = ZSTD_decompress(decompressedData.data(), decompressedSize, compressedData.data(), compressedData.size()); -+ if (ZSTD_isError(dSize)) { -+ if(Debug::Instance().printDataInit()) -+ std::cout << "Error: ZSTD decompression failed for " << filename << std::endl; -+ return false; -+ } -+ -+ msgpack::unpack(result, decompressedData.data(), dSize); -+ } else { - msgpack::unpacker unp; - bool finished_parsing; - constexpr size_t buffer_size = 1 << 19; -@@ -109,6 +139,7 @@ namespace Tensile - - return nullptr; - } -+ } - } - catch(std::runtime_error const& exc) - { diff --git a/pkgs/development/rocm-modules/hipblaslt/parallel-buildSourceCodeObjectFile.diff b/pkgs/development/rocm-modules/hipblaslt/parallel-buildSourceCodeObjectFile.diff deleted file mode 100644 index 019e7a6123b16..0000000000000 --- a/pkgs/development/rocm-modules/hipblaslt/parallel-buildSourceCodeObjectFile.diff +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/tensilelite/Tensile/Toolchain/Source.py b/tensilelite/Tensile/Toolchain/Source.py -index c9862e6c..dfa5ba40 100644 ---- a/tensilelite/Tensile/Toolchain/Source.py -+++ b/tensilelite/Tensile/Toolchain/Source.py -@@ -102,6 +102,7 @@ def buildSourceCodeObjectFiles( - coPaths= [] - - objPath = str(tmpObjDir / objFilename) -+ compiler.default_args += ["-parallel-jobs=8"] - compiler(str(includeDir), cmdlineArchs, str(kernelPath), objPath) - - for target in bundler.targets(objPath): diff --git a/pkgs/development/rocm-modules/hipcub/default.nix b/pkgs/development/rocm-modules/hipcub/default.nix deleted file mode 100644 index a775d81509a1e..0000000000000 --- a/pkgs/development/rocm-modules/hipcub/default.nix +++ /dev/null @@ -1,100 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - rocprim, - clr, - gtest, - gbenchmark, - buildTests ? false, - buildBenchmarks ? false, - gpuTargets ? clr.localGpuTargets or [ ], -}: - -# CUB can also be used as a backend instead of rocPRIM. -stdenv.mkDerivation (finalAttrs: { - pname = "hipcub"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildTests [ - "test" - ] - ++ lib.optionals buildBenchmarks [ - "benchmark" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/hipcub" - "shared" - ]; - hash = "sha256-geO6LS1osKAlmVRtiZ6keqFHsJccyB7pRZdWPEkue2M="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/hipcub"; - - nativeBuildInputs = [ - cmake - rocm-cmake - clr - ]; - - buildInputs = [ - rocprim - ] - ++ lib.optionals buildTests [ - gtest - ] - ++ lib.optionals buildBenchmarks [ - gbenchmark - ]; - - cmakeFlags = [ - "-DHIP_ROOT_DIR=${clr}" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ] - ++ lib.optionals (gpuTargets != [ ]) [ - "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - ] - ++ lib.optionals buildTests [ - "-DBUILD_TEST=ON" - ] - ++ lib.optionals buildBenchmarks [ - "-DBUILD_BENCHMARK=ON" - ]; - - postInstall = - lib.optionalString buildTests '' - mkdir -p $test/bin - mv $out/bin/test_* $test/bin - '' - + lib.optionalString buildBenchmarks '' - mkdir -p $benchmark/bin - mv $out/bin/benchmark_* $benchmark/bin - '' - + lib.optionalString (buildTests || buildBenchmarks) '' - rmdir $out/bin - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "Thin wrapper library on top of rocPRIM or CUB"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipcub"; - license = lib.licenses.bsd3; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/hipfft/default.nix b/pkgs/development/rocm-modules/hipfft/default.nix deleted file mode 100644 index 62c98375d029a..0000000000000 --- a/pkgs/development/rocm-modules/hipfft/default.nix +++ /dev/null @@ -1,121 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - clr, - rocfft, - gtest, - boost, - fftw, - fftwFloat, - openmp, - buildTests ? false, - buildBenchmarks ? false, - buildSamples ? false, - gpuTargets ? clr.localGpuTargets or [ ], -}: - -# Can also use cuFFT -stdenv.mkDerivation (finalAttrs: { - pname = "hipfft"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildTests [ - "test" - ] - ++ lib.optionals buildBenchmarks [ - "benchmark" - ] - ++ lib.optionals buildSamples [ - "sample" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/hipfft" - "shared" - ]; - fetchSubmodules = true; - hash = "sha256-EtxZuxBPx6trTN9iC7uri2+UR0Eolp919Ry4U1PEqNA="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/hipfft"; - - nativeBuildInputs = [ - clr - cmake - rocm-cmake - ]; - - buildInputs = [ - rocfft - ] - ++ lib.optionals (buildTests || buildBenchmarks || buildSamples) [ - gtest - boost - fftw - fftwFloat - openmp - ]; - - cmakeFlags = [ - "-DCMAKE_C_COMPILER=hipcc" - "-DCMAKE_CXX_COMPILER=hipcc" - "-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip" - "-DHIP_ROOT_DIR=${clr}" - "-DHIP_PATH=${clr}" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ] - ++ lib.optionals (gpuTargets != [ ]) [ - "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - ] - ++ lib.optionals buildTests [ - "-DBUILD_CLIENTS_TESTS=ON" - ] - ++ lib.optionals buildBenchmarks [ - "-DBUILD_CLIENTS_RIDER=ON" - ] - ++ lib.optionals buildSamples [ - "-DBUILD_CLIENTS_SAMPLES=ON" - ]; - - postInstall = - lib.optionalString buildTests '' - mkdir -p $test/bin - mv $out/bin/hipfft-test $test/bin - '' - + lib.optionalString buildBenchmarks '' - mkdir -p $benchmark/bin - mv $out/bin/hipfft-rider $benchmark/bin - '' - + lib.optionalString buildSamples '' - mkdir -p $sample/bin - mv clients/staging/hipfft_* $sample/bin - patchelf $sample/bin/hipfft_* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" - '' - + lib.optionalString (buildTests || buildBenchmarks) '' - rmdir $out/bin - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "FFT marshalling library"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipfft"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/hipfort/default.nix b/pkgs/development/rocm-modules/hipfort/default.nix deleted file mode 100644 index 72519db7b0458..0000000000000 --- a/pkgs/development/rocm-modules/hipfort/default.nix +++ /dev/null @@ -1,70 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - gfortran, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "hipfort"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "hipfort"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-XaB4jauCN41tgD1YHHA2td/yckwfMBemBe/iL0SCxQo="; - }; - - __structuredAttrs = true; - strictDeps = true; - - nativeBuildInputs = [ - cmake - gfortran - ]; - - buildInputs = [ - rocm-cmake - ]; - - cmakeFlags = [ - (lib.cmakeFeature "HIPFORT_COMPILER" "${gfortran}/bin/gfortran") - (lib.cmakeFeature "HIPFORT_AR" "${gfortran.cc}/bin/gcc-ar") - (lib.cmakeFeature "HIPFORT_RANLIB" "${gfortran.cc}/bin/gcc-ranlib") - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") - (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") - (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") - ]; - - postPatch = '' - patchShebangs bin - - substituteInPlace bin/hipfc bin/mymcpu \ - --replace-fail "/bin/cat" "cat" - - substituteInPlace bin/CMakeLists.txt \ - --replace-fail "/bin/mkdir" "mkdir" \ - --replace-fail "/bin/cp" "cp" \ - --replace-fail "/bin/sed" "sed" \ - --replace-fail "/bin/chmod" "chmod" \ - --replace-fail "/bin/ln" "ln" - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "Fortran interfaces for ROCm libraries"; - homepage = "https://github.com/ROCm/hipfort"; - changelog = "https://github.com/ROCm/hipfort/releases/tag/${finalAttrs.src.tag}"; - license = lib.licenses.mit; # mitx11 - mainProgram = "hipfc"; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/hipify/default.nix b/pkgs/development/rocm-modules/hipify/default.nix deleted file mode 100644 index b121f0859dce6..0000000000000 --- a/pkgs/development/rocm-modules/hipify/default.nix +++ /dev/null @@ -1,66 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - llvm, - zlib, - zstd, - perl, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "hipify"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "HIPIFY"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-LC0lnYetV7RPVw92zew6za6bDH4zmnERXUM4MVaRVtc="; - }; - - strictDeps = true; - - nativeBuildInputs = [ - cmake - perl - llvm.rocm-toolchain - ]; - - buildInputs = [ - llvm.llvm - llvm.clang-unwrapped - perl - zlib - zstd - ]; - - env.CXXFLAGS = "-I${lib.getInclude llvm.llvm}/include -I${lib.getInclude llvm.clang-unwrapped}/include"; - - postPatch = '' - substituteInPlace CMakeLists.txt \ - --replace-fail "\''${LLVM_TOOLS_BINARY_DIR}/clang" "${llvm.rocm-toolchain}/bin/clang" - chmod +x bin/* - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - postInstall = '' - rm $out/bin/hipify-perl - chmod +x $out/bin/* - chmod +x $out/libexec/* - patchShebangs $out/bin/ - patchShebangs $out/libexec/ - ln -s $out/{libexec/hipify,bin}/hipify-perl - ''; - - meta = { - description = "Convert CUDA to Portable C++ Code"; - homepage = "https://github.com/ROCm/HIPIFY"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/hiprand/default.nix b/pkgs/development/rocm-modules/hiprand/default.nix deleted file mode 100644 index 5e0fd0812ada3..0000000000000 --- a/pkgs/development/rocm-modules/hiprand/default.nix +++ /dev/null @@ -1,78 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - clr, - rocrand, - gtest, - buildTests ? false, - gpuTargets ? clr.localGpuTargets or [ ], -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "hiprand"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildTests [ - "test" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/hiprand" - "shared" - ]; - hash = "sha256-bjcwjN1dNukhoDAbiSpATlK6dtAwM8bOJTe3IjhdwwY="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/hiprand"; - - nativeBuildInputs = [ - cmake - rocm-cmake - clr - ]; - - buildInputs = [ rocrand ] ++ (lib.optionals buildTests [ gtest ]); - - cmakeFlags = [ - "-DHIP_ROOT_DIR=${clr}" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ] - ++ lib.optionals (gpuTargets != [ ]) [ - "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - ] - ++ lib.optionals buildTests [ - "-DBUILD_TEST=ON" - ]; - - postInstall = lib.optionalString buildTests '' - mkdir -p $test/bin - mv $out/bin/test_* $test/bin - rm -r $out/bin/hipRAND - # Fail if bin/ isn't actually empty - rmdir $out/bin - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "HIP wrapper for rocRAND and cuRAND"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hiprand"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/hipsolver/default.nix b/pkgs/development/rocm-modules/hipsolver/default.nix deleted file mode 100644 index c0f548bf7d1e9..0000000000000 --- a/pkgs/development/rocm-modules/hipsolver/default.nix +++ /dev/null @@ -1,117 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - clr, - gfortran, - rocblas, - rocsolver, - rocsparse, - suitesparse, - gtest, - lapack-reference, - buildTests ? false, - buildBenchmarks ? false, - buildSamples ? false, -}: - -# Can also use cuSOLVER -stdenv.mkDerivation (finalAttrs: { - pname = "hipsolver"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildTests [ - "test" - ] - ++ lib.optionals buildBenchmarks [ - "benchmark" - ] - ++ lib.optionals buildSamples [ - "sample" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/hipsolver" - "shared" - ]; - hash = "sha256-ts5wuXHoBFZ1WMAk8Ir5cucP75G0SMOWmn3FEH04ZEQ="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/hipsolver"; - - nativeBuildInputs = [ - cmake - rocm-cmake - clr - gfortran - ]; - - buildInputs = [ - rocblas - rocsolver - rocsparse - suitesparse - ] - ++ lib.optionals buildTests [ - gtest - ] - ++ lib.optionals (buildTests || buildBenchmarks) [ - lapack-reference - ]; - - cmakeFlags = [ - "-DCMAKE_CXX_COMPILER=hipcc" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - "-DBUILD_WITH_SPARSE=OFF" # FIXME: broken - can't find suitesparse/cholmod, looks fixed in master - ] - ++ lib.optionals buildTests [ - "-DBUILD_CLIENTS_TESTS=ON" - ] - ++ lib.optionals buildBenchmarks [ - "-DBUILD_CLIENTS_BENCHMARKS=ON" - ] - ++ lib.optionals buildSamples [ - "-DBUILD_CLIENTS_SAMPLES=ON" - ]; - - postInstall = - lib.optionalString buildTests '' - mkdir -p $test/bin - mv $out/bin/hipsolver-test $test/bin - '' - + lib.optionalString buildBenchmarks '' - mkdir -p $benchmark/bin - mv $out/bin/hipsolver-bench $benchmark/bin - '' - + lib.optionalString buildSamples '' - mkdir -p $sample/bin - mv clients/staging/example-* $sample/bin - patchelf $sample/bin/example-* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" - '' - + lib.optionalString (buildTests || buildBenchmarks) '' - rmdir $out/bin - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "ROCm SOLVER marshalling library"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipsolver"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/hipsparse/default.nix b/pkgs/development/rocm-modules/hipsparse/default.nix deleted file mode 100644 index 7057fb8ceb5b0..0000000000000 --- a/pkgs/development/rocm-modules/hipsparse/default.nix +++ /dev/null @@ -1,148 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - rocsparse, - clr, - gfortran, - gtest, - openmp, - buildTests ? false, - buildBenchmarks ? false, - buildSamples ? false, - gpuTargets ? clr.localGpuTargets or [ ], -}: - -# This can also use cuSPARSE as a backend instead of rocSPARSE -stdenv.mkDerivation (finalAttrs: { - pname = "hipsparse"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildTests [ - "test" - ] - ++ lib.optionals buildSamples [ - "sample" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/hipsparse" - "shared" - ]; - hash = "sha256-E1chG+giFtf02fjutoV4yM2XvrQKjgXRSvxs0NBBkvI="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/hipsparse"; - - nativeBuildInputs = [ - cmake - rocm-cmake - clr - gfortran - ]; - - buildInputs = [ - rocsparse - ] - ++ lib.optionals (buildTests || buildBenchmarks) [ - gtest - ] - ++ lib.optionals (buildTests || buildSamples) [ - openmp - ]; - - cmakeFlags = [ - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - (lib.cmakeBool "BUILD_CLIENTS_TESTS" buildTests) - (lib.cmakeBool "BUILD_CLIENTS_BENCHMARKS" buildBenchmarks) - (lib.cmakeBool "BUILD_CLIENTS_SAMPLES" buildSamples) - ] - ++ lib.optionals (gpuTargets != [ ]) [ - "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - ]; - - # We have to manually generate the matrices - # CMAKE_MATRICES_DIR seems to be reset in clients/tests/CMakeLists.txt - postPatch = lib.optionalString buildTests '' - mkdir -p matrices - - ln -s ${rocsparse.passthru.matrices.matrix-01}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-02}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-03}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-04}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-05}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-06}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-07}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-08}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-09}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-10}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-11}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-12}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-13}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-14}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-15}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-16}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-17}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-18}/*.mtx matrices - ln -s ${rocsparse.passthru.matrices.matrix-19}/*.mtx matrices - - # Not used by the original cmake, causes an error - rm matrices/*_b.mtx - - echo "deps/convert.cpp -> deps/mtx2csr" - hipcc deps/convert.cpp -O3 -o deps/mtx2csr - - for mat in $(ls -1 matrices | cut -d "." -f 1); do - echo "mtx2csr: $mat.mtx -> $mat.bin" - deps/mtx2csr matrices/$mat.mtx matrices/$mat.bin - unlink matrices/$mat.mtx - done - - substituteInPlace clients/tests/CMakeLists.txt \ - --replace "\''${PROJECT_BINARY_DIR}/matrices" "/build/source/matrices" - ''; - - postInstall = - lib.optionalString buildTests '' - mkdir -p $test/bin - mv $out/bin/hipsparse-test $test/bin - mv /build/source/matrices $test - rmdir $out/bin - '' - + lib.optionalString buildSamples '' - mkdir -p $sample/bin - mv clients/staging/example_* $sample/bin - patchelf --set-rpath $out/lib:${ - lib.makeLibraryPath ( - finalAttrs.buildInputs - ++ [ - clr - gfortran.cc - ] - ) - } $sample/bin/example_* - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "ROCm SPARSE marshalling library"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipsparse"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/hipsparselt/default.nix b/pkgs/development/rocm-modules/hipsparselt/default.nix deleted file mode 100644 index 9cd7c710a6d6c..0000000000000 --- a/pkgs/development/rocm-modules/hipsparselt/default.nix +++ /dev/null @@ -1,123 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - ninja, - git, - pkg-config, - rocm-cmake, - rocm-smi, - clr, - hipsparse, - openmp, - llvm, - msgpack-cxx, - libxml2, - zlib, - zstd, - python3, - python3Packages, - # hipsparselt only supports gfx942/gfx950 - gpuTargets ? (clr.localGpuTargets or clr.gpuTargets), -}: - -let - supportedTargets = ( - lib.lists.intersectLists gpuTargets [ - "gfx942" - "gfx950" - ] - ); - supportsTargetArches = supportedTargets != [ ]; - py = python3.withPackages (ps: [ - ps.pyyaml - ps.setuptools - ps.packaging - ps.nanobind - ps.msgpack - ps.joblib - ]); - compiler = "amdclang++"; -in -stdenv.mkDerivation (finalAttrs: { - pname = "hipsparselt${clr.gpuArchSuffix}"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-Al/0yZPn/wqtBFQU1FcGoSquDMObk6HQ3D5sSh5biHg="; - sparseCheckout = [ - "projects/hipsparselt" - "projects/hipblaslt/tensilelite" - "projects/hipblaslt/cmake" - "projects/hipblaslt/device-library" - "shared/origami" - ]; - }; - sourceRoot = "${finalAttrs.src.name}/projects/hipsparselt"; - - env.CXX = compiler; - env.ROCM_PATH = "${clr}"; - env.TENSILE_ROCM_ASSEMBLER_PATH = lib.getExe' clr "amdclang++"; - env.TENSILE_GEN_ASSEMBLY_TOOLCHAIN = lib.getExe' clr "amdclang++"; - requiredSystemFeatures = [ "big-parallel" ]; - - __structuredAttrs = true; - strictDeps = true; - - nativeBuildInputs = [ - cmake - ninja - git - pkg-config - rocm-cmake - rocm-smi - py - clr - ]; - - buildInputs = [ - llvm.llvm - clr - rocm-cmake - hipsparse - openmp - msgpack-cxx - libxml2 - python3Packages.msgpack - zlib - zstd - ]; - - cmakeFlags = [ - (lib.cmakeFeature "GPU_TARGETS" (lib.concatStringsSep ";" supportedTargets)) - (lib.cmakeBool "HIPSPARSELT_ENABLE_DEVICE" supportsTargetArches) - (lib.cmakeBool "HIPSPARSELT_ENABLE_CLIENT" false) - (lib.cmakeBool "HIPSPARSELT_BUILD_TESTING" false) - (lib.cmakeBool "HIPSPARSELT_ENABLE_MARKER" false) - (lib.cmakeBool "HIPBLASLT_ENABLE_ROCROLLER" false) - (lib.cmakeBool "HIPBLASLT_ENABLE_MARKER" false) - (lib.cmakeFeature "CMAKE_C_COMPILER" "amdclang") - (lib.cmakeFeature "CMAKE_HIP_COMPILER" compiler) - (lib.cmakeFeature "CMAKE_CXX_COMPILER" compiler) - (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_NANOBIND" "${python3Packages.nanobind.src}") - (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") - (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") - (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") - ]; - - passthru.supportsTargetArches = supportsTargetArches; - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "ROCm hipSPARSELt - a SPARSE marshalling library"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipsparselt"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/llvm/clang-bodge-ignore-systemwide-incls.diff b/pkgs/development/rocm-modules/llvm/clang-bodge-ignore-systemwide-incls.diff deleted file mode 100644 index 5f44dbe15655c..0000000000000 --- a/pkgs/development/rocm-modules/llvm/clang-bodge-ignore-systemwide-incls.diff +++ /dev/null @@ -1,23 +0,0 @@ -diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp -index 57368104c914..71c57f72078e 100644 ---- a/lib/Driver/ToolChains/Linux.cpp -+++ b/lib/Driver/ToolChains/Linux.cpp -@@ -640,6 +640,7 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs, - return; - - // LOCAL_INCLUDE_DIR -+ if (!SysRoot.empty()) - addSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/usr/local/include")); - // TOOL_INCLUDE_DIR - AddMultilibIncludeArgs(DriverArgs, CC1Args); -@@ -672,8 +673,10 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs, - // Add an include of '/include' directly. This isn't provided by default by - // system GCCs, but is often used with cross-compiling GCCs, and harmless to - // add even when Clang is acting as-if it were a system compiler. -+ if (!SysRoot.empty()) - addExternCSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/include")); - -+ if (!SysRoot.empty()) - addExternCSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/usr/include")); - - if (!DriverArgs.hasArg(options::OPT_nobuiltininc) && getTriple().isMusl()) diff --git a/pkgs/development/rocm-modules/llvm/clang-log-jobs.diff b/pkgs/development/rocm-modules/llvm/clang-log-jobs.diff deleted file mode 100644 index 3a3a712c8bbaf..0000000000000 --- a/pkgs/development/rocm-modules/llvm/clang-log-jobs.diff +++ /dev/null @@ -1,40 +0,0 @@ -diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp -index 06f5e7e7e335..8407d664886a 100644 ---- a/lib/Driver/Compilation.cpp -+++ b/lib/Driver/Compilation.cpp -@@ -340,6 +340,9 @@ private: - void Compilation::ExecuteJobs(const JobList &Jobs, - FailingCommandList &FailingCommands, - bool LogOnly) const { -+ // If >1 job, log as each job finishes so can see progress while building many offloads -+ const bool logJobs = Jobs.size() > 1; -+ auto start_time = std::chrono::steady_clock::now(); - // According to UNIX standard, driver need to continue compiling all the - // inputs on the command line even one of them failed. - // In all but CLMode, execute all the jobs unless the necessary inputs for the -@@ -364,11 +367,25 @@ void Compilation::ExecuteJobs(const JobList &Jobs, - - JS.setJobState(Next, JobScheduler::JS_RUN); - auto Work = [&, Next]() { -+ auto job_start_time = std::chrono::steady_clock::now(); - const Command *FailingCommand = nullptr; - if (int Res = ExecuteCommand(*Next, FailingCommand, LogOnly)) { - FailingCommands.push_back(std::make_pair(Res, FailingCommand)); - JS.setJobState(Next, JobScheduler::JS_FAIL); - } else { -+ if (logJobs && Next) { -+ auto now = std::chrono::steady_clock::now(); -+ auto job_duration = std::chrono::duration_cast(now - job_start_time).count(); -+ auto duration = std::chrono::duration_cast(now - start_time).count(); -+ if (duration > 10 && job_duration > 0) { -+ if (Next->getOutputFilenames().empty()) -+ if (Next->getExecutable()) llvm::errs() << "Job completed: " << Next->getExecutable() << "\n"; -+ else (llvm::errs() << "Job completed: "), Next->Print(llvm::errs(), "\n", true); -+ else -+ llvm::errs() << "Job completed: " << Next->getOutputFilenames().front().c_str() << "\n"; -+ } -+ } -+ - JS.setJobState(Next, JobScheduler::JS_DONE); - } - }; diff --git a/pkgs/development/rocm-modules/llvm/default.nix b/pkgs/development/rocm-modules/llvm/default.nix deleted file mode 100644 index 4fbb9fb0d1c92..0000000000000 --- a/pkgs/development/rocm-modules/llvm/default.nix +++ /dev/null @@ -1,614 +0,0 @@ -{ - lib, - stdenv, - # LLVM version closest to ROCm fork to override - llvmPackages_22, - overrideCC, - lndir, - rocm-device-libs, - fetchFromGitHub, - runCommand, - symlinkJoin, - rdfind, - zstd, - gcc-unwrapped, - glibc, - libffi, - libxml2, - removeReferencesTo, - fetchpatch, - # Build compilers and stdenv suitable for profiling - # leaving compressed line tables (-g1 -gz) unstripped - # TODO: Should also apply to downstream packages which use rocmClangStdenv? - profilableStdenv ? false, - # FIXME: proper two-stage bootstrap & PGO/BOLT/LTO - # LTO currently disabled due to llvm 22 vs 22.1 bitcode mismatch between - # llvmPackages_22 (22.1) and ROCm LLVM (22.0). Uses new bitcode attr - # 105 nocreateundeforpoison fails to link hipify. - # Whether to use LTO when building the ROCm toolchain - # Slows down this toolchain's build, for typical ROCm usecase - # time saved building composable_kernel and other heavy packages - # will outweight that. ~3-4% speedup multiplied by thousands - # of corehours. - withLto ? false, - # whether rocm stdenv uses libcxx (clang c++ stdlib) instead of gcc stdlibc++ - withLibcxx ? false, -}: - -let - version = "7.2.4"; - # major version of this should be the clang version ROCm forked from - rocmLlvmVersion = "22.0.0-rocm"; - # llvmPackages_base version should match rocmLlvmVersion - # so libllvm's bitcode is compatible with the built toolchain - llvmPackages_base = llvmPackages_22; - llvmPackagesNoBintools = llvmPackages_base.override { - bootBintools = null; - bootBintoolsNoLibc = null; - }; - - stdenvToBuildRocmLlvm = - if withLibcxx then - overrideCC llvmPackagesNoBintools.libcxxStdenv llvmPackagesNoBintools.clangUseLLVM - else - # oddly fuse-ld=lld fails without this override - overrideCC llvmPackagesNoBintools.stdenv ( - llvmPackagesNoBintools.libstdcxxClang.override { - inherit (llvmPackages_base) bintools; - } - ); - - gcc-include = runCommand "gcc-include" { } '' - mkdir -p $out - ln -s ${gcc-unwrapped}/include/ $out/ - ln -s ${gcc-unwrapped}/lib/ $out/ - ''; - - disallowedRefsForToolchain = [ - stdenv.cc - stdenv.cc.cc - stdenv.cc.bintools - gcc-unwrapped - stdenvToBuildRocmLlvm - stdenvToBuildRocmLlvm.cc - stdenvToBuildRocmLlvm.cc.cc - ]; - # A prefix for use as the GCC prefix when building rocm-toolchain - gcc-prefix-headers = symlinkJoin { - name = "gcc-prefix-headers"; - paths = [ - glibc.dev - gcc-unwrapped.out - ]; - disallowedRequisites = [ - glibc.dev - gcc-unwrapped.out - ]; - postBuild = '' - rm -rf $out/{bin,libexec,nix-support,lib64,share,etc} - rm $out/lib/gcc/x86_64-unknown-linux-gnu/*/plugin/include/auto-host.h - - mkdir /build/tmpout - mv $out/* /build/tmpout - cp -Lr --no-preserve=mode /build/tmpout/* $out/ - set -x - versionedIncludePath="$(echo $out/include/c++/*/)" - mv $versionedIncludePath/* $out/include/c++/ - rm -rf $versionedIncludePath/ - ''; - }; - gcc-prefix = symlinkJoin { - name = "gcc-prefix"; - paths = [ - gcc-prefix-headers - glibc - gcc-unwrapped.lib - ]; - disallowedRequisites = [ - glibc.dev - gcc-unwrapped.out - ]; - postBuild = '' - rm -rf $out/{bin,libexec,nix-support,lib64,share,etc} - rm $out/lib/ld-linux-x86-64.so.2 - ln -s $out $out/x86_64-unknown-linux-gnu - ''; - }; - llvmSrc = fetchFromGitHub { - owner = "ROCm"; - repo = "llvm-project"; - tag = "rocm-${version}"; - hash = "sha256-TwFvQimbax2E37ZC/52lNkHXCgyBNfSGDBaqmas2x/s="; - }; - llvmMajorVersion = lib.versions.major rocmLlvmVersion; - # An llvmPackages (pkgs/development/compilers/llvm/) built from ROCm LLVM's source tree - llvmPackagesRocm = llvmPackages_base.override (_old: { - stdenv = stdenvToBuildRocmLlvm; - - # not setting gitRelease = because that causes patch selection logic to use git patches - # ROCm LLVM is closer to 20 official - # gitRelease = {}; officialRelease = null; - officialRelease = { }; # Set but empty because we're overriding everything from it. - # this version determines which patches are applied - version = rocmLlvmVersion; - src = llvmSrc; - monorepoSrc = llvmSrc; - doCheck = false; - }); - refsToRemove = builtins.concatStringsSep " -t " [ - stdenvToBuildRocmLlvm - stdenvToBuildRocmLlvm.cc - stdenvToBuildRocmLlvm.cc.cc - stdenv.cc - stdenv.cc.cc - stdenv.cc.bintools - ]; - # Hacky way to avoid nixfmt indenting the entire scope body suggested by @emilazy - overrideLlvmPackagesRocm = - f: - let - overridenScope = llvmPackagesRocm.overrideScope (final: prev: f { inherit final prev; }); - in - { - inherit (overridenScope) - # Expose only a limited set of packages that we care about for ROCm - bintools - compiler-rt - compiler-rt-libc - clang - clang-unwrapped - libcxx - lld - llvm - rocm-toolchain - rocmClangStdenv - openmp - ; - }; - sysrootCompiler = - { - cc, - name, - paths, - linkPaths, - }: - let - linked = symlinkJoin { inherit name paths; }; - in - runCommand name - { - pname = name; - # If this is erroring, try why-depends --precise on the symlinkJoin of inputs to look for the problem - # nix why-depends --precise .#rocmPackages.llvm.rocm-toolchain.linked /store/path/its/not/allowed - outputChecks.out.disallowedRequisites = disallowedRefsForToolchain; - passthru.linked = linked; - inherit linkPaths; - __structuredAttrs = true; - # TODO(@LunNova): Try to use --sysroot with clang in its original location instead of - # relying on copying the binary? - # $clang/bin/clang++ --sysroot=$rocm-toolchain is not equivalent - # to a clang copied to $rocm-toolchain/bin here, have not yet figured out why - } - '' - mkdir -p $out/ - cp --reflink=auto -rL ${linked}/* $out/ - chmod -R +rw $out - mkdir -p $out/usr - ln -s $out/ $out/usr/local - # we don't need mixed 32 bit, the presence of lib64 is used by LLVM to decide it's a multilib sysroot - rm -rf $out/lib64 - rm -rf $out/lib/cmake $out/lib/lib*.a - mkdir -p $out/lib/clang/${llvmMajorVersion}/lib/linux/ - ln -s $out/lib/linux/libclang_rt.* $out/lib/clang/${llvmMajorVersion}/lib/linux/ - mkdir -p $out/lib/clang/${llvmMajorVersion}/lib/${stdenv.hostPlatform.config}/ - for f in $out/lib/linux/*-${stdenv.hostPlatform.parsed.cpu.name}.*; do - [ -e "$f" ] || continue - base="$(basename "$f" | sed 's/-${stdenv.hostPlatform.parsed.cpu.name}\././')" - ln -sf "$f" "$out/lib/clang/${llvmMajorVersion}/lib/${stdenv.hostPlatform.config}/$base" - done - - find $out -type f -exec sed -i "s|${cc.out}|$out|g" {} + - find $out -type f -exec sed -i "s|${cc.dev}|$out|g" {} + - - # Clang config file: redirect resource dir to the sysroot (where compiler-rt - # lives) and set GCC install prefix for header/library search - cat > $out/bin/${stdenv.hostPlatform.config}.cfg <> $out/nix-support/setup-hook - echo 'export CXX=clang++' >> $out/nix-support/setup-hook - ''; - tablegenUsage = x: !(lib.strings.hasInfix "llvm-tblgen" x); - llvmTargetsFlag = "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${ - { - "x86_64" = "X86"; - "aarch64" = "AArch64"; - } - .${stdenv.targetPlatform.parsed.cpu.name} - or (throw "Unsupported CPU architecture: ${stdenv.targetPlatform.parsed.cpu.name}") - }"; - llvmMeta = { - # TODO(@LunNova): it would be nice to support aarch64 for rocmPackages - platforms = [ "x86_64-linux" ]; - }; - # TODO(@LunNova): Some of this might be worth supporting in llvmPackages, dropping from here - commonCmakeFlags = [ - llvmTargetsFlag - # Compression support is required for compressed offload kernels - # Set FORCE_ON so that failure to find the compression lib will be a build error - (lib.cmakeFeature "LLVM_ENABLE_ZSTD" "FORCE_ON") - # required for threaded ThinLTO to work - (lib.cmakeBool "LLVM_ENABLE_THREADS" true) - # third-party/benchmark is broken in rocm-7.2.0 - # error: '__COUNTER__' is a C2y extension [-Werror,-Wc2y-extensions] - (lib.cmakeBool "LLVM_INCLUDE_BENCHMARKS" false) - # LLVM tries to call git to embed VCS info if FORCE_VC_ aren't set - (lib.cmakeFeature "LLVM_FORCE_VC_REVISION" "rocm-${version}") - (lib.cmakeFeature "LLVM_FORCE_VC_REPOSITORY" "https://github.com/ROCm/llvm-project") - (lib.cmakeFeature "LLVM_VERSION_SUFFIX" "") - (lib.cmakeBool "LLVM_ENABLE_LIBCXX" withLibcxx) - (lib.cmakeFeature "CLANG_DEFAULT_CXX_STDLIB" (if withLibcxx then "libc++" else "libstdc++")) - (lib.cmakeFeature "CLANG_VENDOR" "nixpkgs-AMD") - (lib.cmakeFeature "CLANG_REPOSITORY_STRING" "https://github.com/ROCm/llvm-project/tree/rocm-${version}") - ] - ++ lib.optionals withLibcxx [ - (lib.cmakeFeature "CLANG_DEFAULT_RTLIB" "compiler-rt") - ] - ++ lib.optionals withLto [ - (lib.cmakeBool "CMAKE_INTERPROCEDURAL_OPTIMIZATION" true) - (lib.cmakeBool "LLVM_ENABLE_FATLTO" false) - ] - ++ lib.optionals (withLto && stdenvToBuildRocmLlvm.cc.isClang) [ - (lib.cmakeFeature "LLVM_ENABLE_LTO" "FULL") - (lib.cmakeFeature "LLVM_USE_LINKER" "lld") - ]; - - llvmExtraCflags = lib.concatStringsSep " " ( - lib.optionals (stdenv.hostPlatform.system == "x86_64-linux") [ - # Unprincipled decision to build x86_64 ROCm clang for at least skylake and tune for zen3+ - # In practice building the ROCm package set with anything earlier than zen3 is annoying - # and earlier than skylake is implausible due to too few cores and too little RAM - # Speeds up composable_kernel builds by ~4% - # If this causes trouble in practice we can drop this. Set since 2025-03-24. - "-march=skylake" - "-mtune=znver3" - ] - ++ lib.optionals profilableStdenv [ - # compressed line only debug info for profiling - "-gz" - "-g1" - ] - ); - inherit (llvmPackagesRocm) libcxx; -in -overrideLlvmPackagesRocm (s: { - libllvm = (s.prev.libllvm.override { }).overrideAttrs (old: { - patches = [ - # Backport select ptr combine fixes so our LLVM 22 sdag fix backport can apply - (fetchpatch { - name = "amdgpu-add-baseline-load-select-ptr-combine-test.patch"; - url = "https://github.com/llvm/llvm-project/commit/ac27b2455ad7c89cc1f928de7beb05933a035031.patch"; - relative = "llvm"; - hash = "sha256-1mine1h/oqnn2tKDYW4FntyZXu/foyifrKGkqKOHrPg="; - }) - (fetchpatch { - name = "amdgpu-fix-treating-divergent-loads-as-uniform.patch"; - url = "https://github.com/llvm/llvm-project/commit/d3c3c6bab5df051d9db12ea96add2211df9d81be.patch"; - relative = "llvm"; - hash = "sha256-9VB77d4d+nwX8s+JBq1PXmbmqT7oD6lRC0uDIrTgjjo="; - }) - (fetchpatch { - name = "dag-allow-select-ptr-combine-for-non-0-address-spaces.patch"; - url = "https://github.com/llvm/llvm-project/commit/0e1cb2de90aafa1d5dbd46fc9e6c4e743700fa8b.patch"; - relative = "llvm"; - hash = "sha256-6Pj3pRESaho60YhXWwaQxEKteSuziZseeT4FbZqZANk="; - }) - ] - # https://github.com/NixOS/nixpkgs/pull/564039 introduces minimal-arm64e_x1-support.patch that depends on llvm 22.1.0 - # Patches to clang, compiler-rt-libc, and these patches bridge the gap between llvm 22.0.0 and ~22.1.8 - # arm64e_x1: Can be removed when upgrading to rocm 10 - ++ [ - (fetchpatch { - name = "wasm-add-wasm32-linux-muslwali-target.patch"; - url = "https://github.com/llvm/llvm-project/commit/7e7c923b5890e62f4b5920c2f8a2e51f586a186c.patch"; - relative = "llvm"; - hash = "sha256-KbM7M4osxaaxkn5UN+csNm+aKvaWgJ0KQnKHHpI+Qxo="; - }) - (fetchpatch { - name = "adt-allow-arbitrary-number-of-cases-in-stringswitch.patch"; - url = "https://github.com/llvm/llvm-project/commit/8642762ac356f0b8432b78d7a32c1f5213e494b3.patch"; - relative = "llvm"; - hash = "sha256-aQBmMSJ+aunE7HLpfIizBH7Be1kmcN6nxUk2sV9d3Qo="; - }) - (fetchpatch { - name = "adt-migrate-stringswitch-cases-to-new-overload.patch"; - url = "https://github.com/llvm/llvm-project/commit/2ed7baafc3bf5b4321e3f77dfb1ce291e62bcadc.patch"; - relative = "llvm"; - hash = "sha256-cV9POhuJFCnjCdPL6Lym2cmKLeW/2k34N2rwauxU7MA="; - }) - (fetchpatch { - name = "lfi-introduce-aarch64-lfi-target.patch"; - url = "https://github.com/llvm/llvm-project/commit/2c05ae4b8f85927d55f862fdf61bea564e2ea944.patch"; - relative = "llvm"; - hash = "sha256-yxvmZg3BTlIrNeer90cYnF7yuRyraeVg1nbiaRVr+zc="; - }) - ] - ++ old.patches - ++ [ - ./perf-increase-namestring-size.patch - # v64i8 shuffle lowering inf loop on VBMI targets, hangs whisper-cpp etc - # https://github.com/NixOS/nixpkgs/issues/497745 - (fetchpatch { - # https://github.com/llvm/llvm-project/pull/182832 - name = "llvm-x86-v64i8-add-test-coverage.patch"; - url = "https://github.com/llvm/llvm-project/commit/0e3a96d0ec01e3575674d72c4e23bf98affdca28.patch"; - relative = "llvm"; - hash = "sha256-qhRkB8Fjz/fNacuGv1OFkiTNOQ0/QQ9p4pLFudwrTzM="; - }) - (fetchpatch { - # https://github.com/llvm/llvm-project/pull/182852 - name = "llvm-x86-v64i8-prefer-vpermv3-on-vbmi.patch"; - url = "https://github.com/llvm/llvm-project/commit/8f5880d3ae4e5dfc748985d90e5413671028aa3e.patch"; - relative = "llvm"; - hash = "sha256-4DU6gu/1+iQpzvVYBlTTUKtw77QSRyTja4hdel4D5Cw="; - }) - (fetchpatch { - # https://github.com/llvm/llvm-project/pull/183109 - name = "llvm-x86-v64i8-skip-repeated-mask-lane-permute-on-vbmi.patch"; - url = "https://github.com/llvm/llvm-project/commit/1b9fea021840f17c41ea980300d0fc45e7285909.patch"; - relative = "llvm"; - hash = "sha256-9Akm78QQr8BIMrVWwDG3poWS1HuQ0hpIQWfke3oADgg="; - }) - # TODO: consider reapplying "Don't include aliases in RegisterClassInfo::IgnoreCSRForAllocOrder" - # it was reverted as it's a pessimization for non-GPU archs, but this compiler - # is used mostly for amdgpu - ]; - dontStrip = profilableStdenv; - hardeningDisable = [ "all" ]; - nativeBuildInputs = old.nativeBuildInputs ++ [ removeReferencesTo ]; - buildInputs = old.buildInputs ++ [ - zstd - ]; - preFixup = '' - moveToOutput "lib/lib*.a" "$dev" - moveToOutput "lib/cmake" "$dev" - sed -Ei "s|$lib/lib/(lib[^/]*)\.a|$dev/lib/\1.a|g" $dev/lib/cmake/llvm/*.cmake - ''; - env = (old.env or { }) // { - NIX_CFLAGS_COMPILE = "${(old.env or { }).NIX_CFLAGS_COMPILE or ""} ${llvmExtraCflags}"; - }; - cmakeFlags = (builtins.filter tablegenUsage old.cmakeFlags) ++ commonCmakeFlags; - # Ensure we don't leak refs to compiler that was used to bootstrap this LLVM - disallowedReferences = (old.disallowedReferences or [ ]) ++ disallowedRefsForToolchain; - postFixup = '' - ${old.postFixup or ""} - find $lib -type f -exec remove-references-to -t ${refsToRemove} {} + - ''; - meta = old.meta // llvmMeta; - }); - lld = - (s.prev.lld.override { - }).overrideAttrs - (old: { - dontStrip = profilableStdenv; - hardeningDisable = [ "all" ]; - nativeBuildInputs = old.nativeBuildInputs ++ [ - removeReferencesTo - ]; - buildInputs = old.buildInputs ++ [ - zstd - ]; - env = (old.env or { }) // { - NIX_CFLAGS_COMPILE = "${(old.env or { }).NIX_CFLAGS_COMPILE or ""} ${llvmExtraCflags}"; - }; - cmakeFlags = (builtins.filter tablegenUsage old.cmakeFlags) ++ commonCmakeFlags; - # Ensure we don't leak refs to compiler that was used to bootstrap this LLVM - disallowedReferences = (old.disallowedReferences or [ ]) ++ disallowedRefsForToolchain; - postFixup = '' - ${old.postFixup or ""} - find $lib -type f -exec remove-references-to -t ${refsToRemove} {} + - ''; - meta = old.meta // llvmMeta; - }); - clang-unwrapped = ( - (s.prev.clang-unwrapped.override { - enableClangToolsExtra = false; - }).overrideAttrs - (old: { - passthru = old.passthru // { - inherit gcc-prefix; - }; - patches = [ - (fetchpatch { - # [clang][cmake] Add option to control scan-build-py installation (#172727) - name = "clang-scan-build-py-configurable.patch"; - url = "https://github.com/llvm/llvm-project/commit/f5759eeb63a3a5ce7d555c13c3126cea84e0c7b1.patch"; - relative = "clang"; - hash = "sha256-73IDPGZWKX4vny3x5FJ3/NQw8XRad9UNwfYkvQdMB4s="; - }) - ] - # arm64e_x1: Can be removed when upgrading to rocm 10 - ++ [ - (fetchpatch { - name = "wasm-add-wasm32-linux-muslwali-target.patch"; - url = "https://github.com/llvm/llvm-project/commit/7e7c923b5890e62f4b5920c2f8a2e51f586a186c.patch"; - relative = "clang"; - hash = "sha256-QGqil4rs9wFFa8J25ghWKTE8YG2+AbGG81dt5ReAw9k="; - }) - (fetchpatch { - name = "adt-migrate-stringswitch-cases-to-new-overload.patch"; - url = "https://github.com/llvm/llvm-project/commit/2ed7baafc3bf5b4321e3f77dfb1ce291e62bcadc.patch"; - relative = "clang"; - hash = "sha256-w9sS+pwawHqxGkTAWMinzF1r9ZyWMTmI119X/NdQoc8="; - }) - (fetchpatch { - name = "lfi-introduce-aarch64-lfi-target.patch"; - url = "https://github.com/llvm/llvm-project/commit/2c05ae4b8f85927d55f862fdf61bea564e2ea944.patch"; - relative = "clang"; - hash = "sha256-CcwqLvhDAJSr3dkRDqJKe3pVD2G+w5JMgtGkUx6pUPc="; - }) - ] - ++ old.patches - ++ [ - # Never add FHS include paths - ./clang-bodge-ignore-systemwide-incls.diff - # Prevents builds timing out if a single compiler invocation is very slow but - # per-arch jobs are completing by ensuring there's terminal output - ./clang-log-jobs.diff - ./opt-offload-compress-on-by-default.patch - ./perf-shorten-gcclib-include-paths.patch - (fetchpatch { - # [ClangOffloadBundler]: Add GetBundleIDsInFile to OffloadBundler - hash = "sha256-OsarDZXuJ5vAXTP4i0NBUeK/r6tQPumaqmMWkf29UtM="; - url = "https://github.com/GZGavinZhao/rocm-llvm-project/commit/c7de294b0d1d25f277f9d1cbb2c9e09c7600e210.patch"; - relative = "clang"; - }) - ]; - # ROCm 7.2 commits 4dda51261a6 "Replace hostexec with upstream rpc" - # and 2ca1509d6d2 "Put the RTL, Back!", added CGEmitEmissaryExec.cpp which - # includes ../../openmp/device/include/EmissaryIds.h, breaking - # standalone clang builds. The upstream PR llvm/llvm-project#175265 - # ("[OpenMP] support for Emissary APIs") moves EmissaryIds.h into - # clang/lib/Headers/ so this should not be needed once that lands - # and ROCm rebases onto it. - postUnpack = '' - ${old.postUnpack or ""} - mkdir -p "''${sourceRoot}/openmp/device/include" - ln -s "${llvmSrc}/openmp/device/include/EmissaryIds.h" "''${sourceRoot}/openmp/device/include/" - ''; - hardeningDisable = [ "all" ]; - nativeBuildInputs = old.nativeBuildInputs ++ [ - removeReferencesTo - ]; - buildInputs = old.buildInputs ++ [ - zstd - ]; - env = (old.env or { }) // { - NIX_CFLAGS_COMPILE = "${(old.env or { }).NIX_CFLAGS_COMPILE or ""} ${llvmExtraCflags}"; - }; - dontStrip = profilableStdenv; - # Ensure we don't leak refs to compiler that was used to bootstrap this LLVM - disallowedReferences = (old.disallowedReferences or [ ]) ++ disallowedRefsForToolchain; - # Enable structured attrs for separateDebugInfo, because it is required with disallowedReferences set - __structuredAttrs = true; - # https://github.com/llvm/llvm-project/blob/6976deebafa8e7de993ce159aa6b82c0e7089313/clang/cmake/caches/DistributionExample-stage2.cmake#L9-L11 - cmakeFlags = - # TODO: Remove in followup, tblgen now works correctly but would rebuild - (builtins.filter tablegenUsage old.cmakeFlags) ++ commonCmakeFlags; - preFixup = '' - ${toString old.preFixup or ""} - moveToOutput "lib/lib*.a" "$dev" - moveToOutput "lib/cmake" "$dev" - mkdir -p $dev/lib/clang/ - ln -s $lib/lib/clang/${llvmMajorVersion} $dev/lib/clang/ - sed -Ei "s|$lib/lib/(lib[^/]*)\.a|$dev/lib/\1.a|g" $dev/lib/cmake/clang/*.cmake - ''; - postFixup = '' - ${toString old.postFixup or ""} - find $lib -type f -exec remove-references-to -t ${refsToRemove} {} + - find $dev -type f -exec remove-references-to -t ${refsToRemove} {} + - ''; - meta = old.meta // llvmMeta; - }) - ); - # A clang that understands standard include searching in a GNU sysroot and will put GPU libs in include path - # in the right order - # and expects its libc to be in the sysroot - rocm-toolchain = - with s.final; - (sysrootCompiler { - cc = clang-unwrapped; - name = "rocm-toolchain"; - paths = [ - clang-unwrapped.out - clang-unwrapped.lib - bintools.out - compiler-rt.out - openmp.out - openmp.dev - ] - ++ lib.optionals withLibcxx [ - libcxx - ] - ++ lib.optionals (!withLibcxx) [ - glibc - glibc.dev - ]; - linkPaths = [ - bintools.bintools.out - ] - ++ lib.optionals (!withLibcxx) [ - gcc-include.out - ]; - }) - // { - version = llvmMajorVersion; - cc = rocm-toolchain; - libllvm = llvm; - isClang = true; - isGNU = false; - }; - compiler-rt-libc = s.prev.compiler-rt-libc.overrideAttrs (old: { - patches = [ - # arm64e_x1: Can be removed when upgrading to rocm 10 - (fetchpatch { - name = "lfi-introduce-aarch64-lfi-target.patch"; - url = "https://github.com/llvm/llvm-project/commit/2c05ae4b8f85927d55f862fdf61bea564e2ea944.patch"; - relative = "compiler-rt"; - hash = "sha256-xgvVXG+IGa9qwv60ioER6N5nC7XPRPEDHVUrQ5n9RBI="; - }) - ] - ++ old.patches; - meta = old.meta // llvmMeta; - }); - compiler-rt = s.final.compiler-rt-libc; - clang = s.final.rocm-toolchain; - - rocmClangStdenv = with s.final; overrideCC (if withLibcxx then libcxxStdenv else stdenv) clang; - - # Projects - openmp = - with s.final; - (llvmPackagesRocm.openmp.override { - llvm = llvm; - clang-unwrapped = clang-unwrapped; - }).overrideAttrs - (old: { - disallowedReferences = (old.disallowedReferences or [ ]) ++ disallowedRefsForToolchain; - nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ - removeReferencesTo - ]; - cmakeFlags = - old.cmakeFlags - ++ commonCmakeFlags - ++ [ - "-DDEVICELIBS_ROOT=${rocm-device-libs.src}" - # OMPD support is broken in ROCm 6.3+ Haven't investigated why. - "-DLIBOMP_OMPD_SUPPORT:BOOL=FALSE" - "-DLIBOMP_OMPD_GDB_SUPPORT:BOOL=FALSE" - ]; - buildInputs = old.buildInputs ++ [ - clang-unwrapped - zstd - libxml2 - libffi - ]; - postFixup = '' - ${old.postFixup or ""} - ln -s $out/lib/libomp.so $dev/lib/libomp.so - ''; - }); - # AMD has a separate MLIR impl which we package under rocmPackages.rocmlir - # It would be an error to rely on the original mlir package from this scope - mlir = null; -}) diff --git a/pkgs/development/rocm-modules/llvm/opt-offload-compress-on-by-default.patch b/pkgs/development/rocm-modules/llvm/opt-offload-compress-on-by-default.patch deleted file mode 100644 index d5cb1a363ea5d..0000000000000 --- a/pkgs/development/rocm-modules/llvm/opt-offload-compress-on-by-default.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 762511ad9c9cac7769a795cc4df888a1559dca02 Mon Sep 17 00:00:00 2001 -From: Luna Nova -Date: Mon, 16 Dec 2024 14:56:57 -0800 -Subject: [PATCH] [AMDGPU] CommonArgs: Enable offload compression by default - ---- - clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp -index 33f12fb2d075d..ba35f65210c7a 100644 ---- a/lib/Driver/ToolChains/CommonArgs.cpp -+++ b/lib/Driver/ToolChains/CommonArgs.cpp -@@ -2914,7 +2914,7 @@ void tools::addHIPRuntimeLibArgs(const ToolChain &TC, Compilation &C, - void tools::addOffloadCompressArgs(const llvm::opt::ArgList &TCArgs, - llvm::opt::ArgStringList &CmdArgs) { - if (TCArgs.hasFlag(options::OPT_offload_compress, -- options::OPT_no_offload_compress, false)) -+ options::OPT_no_offload_compress, true)) - CmdArgs.push_back("--compress"); - if (TCArgs.hasArg(options::OPT_v)) - CmdArgs.push_back("-verbose"); diff --git a/pkgs/development/rocm-modules/llvm/perf-increase-namestring-size.patch b/pkgs/development/rocm-modules/llvm/perf-increase-namestring-size.patch deleted file mode 100644 index 84046a588630a..0000000000000 --- a/pkgs/development/rocm-modules/llvm/perf-increase-namestring-size.patch +++ /dev/null @@ -1,28 +0,0 @@ -From a57eb548d46a37e4aed33eefccc9e6374b579ff9 Mon Sep 17 00:00:00 2001 -From: Luna Nova -Date: Mon, 16 Dec 2024 13:58:54 -0800 -Subject: [PATCH] [AMDGPU] TargetMachine: increase NameString size to 256 - -128 is too small a default for compilers used to build -AMD's rocBLAS, composable_kernel and similar libs because -they use very long symbol names such as -device_gemm_xdl_universal_bf16_bf16_bf16_mk_nk_mn_comp_default_instance - -This fixes spending ~10% of compile time in malloc inside this function. ---- - llvm/lib/Target/TargetMachine.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp -index abd0fdf2390c0..86ce468b75643 100644 ---- a/lib/Target/TargetMachine.cpp -+++ b/lib/Target/TargetMachine.cpp -@@ -270,7 +270,7 @@ MCSymbol *TargetMachine::getSymbol(const GlobalValue *GV) const { - if (MCSymbol *TargetSymbol = TLOF->getTargetSymbol(GV, *this)) - return TargetSymbol; - -- SmallString<128> NameStr; -+ SmallString<256> NameStr; - getNameWithPrefix(NameStr, GV, TLOF->getMangler()); - return TLOF->getContext().getOrCreateSymbol(NameStr); - } diff --git a/pkgs/development/rocm-modules/llvm/perf-shorten-gcclib-include-paths.patch b/pkgs/development/rocm-modules/llvm/perf-shorten-gcclib-include-paths.patch deleted file mode 100644 index b23a3886c3d00..0000000000000 --- a/pkgs/development/rocm-modules/llvm/perf-shorten-gcclib-include-paths.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 8c64deff2a82fcca5b521362193a1fd8b1a0dca7 Mon Sep 17 00:00:00 2001 -From: Luna Nova -Date: Tue, 17 Dec 2024 04:29:11 -0800 -Subject: [PATCH] HACK: Get canonical GCC include path so doesn't have - ../../../../ - -This allows more of the strings used in compilation to fit inside -fixed size stack allocated buffers instead of spilling into the heap ---- - lib/Driver/ToolChains/Gnu.cpp | 16 ++++++++++------ - 1 file changed, 10 insertions(+), 6 deletions(-) - -diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp -index 07df9864636..b1201b999f0 100644 ---- a/lib/Driver/ToolChains/Gnu.cpp -+++ b/lib/Driver/ToolChains/Gnu.cpp -@@ -3326,29 +3326,33 @@ static bool addLibStdCXXIncludePaths(llvm::vfs::FileSystem &vfs, - if (!vfs.exists(IncludeDir)) - return false; - -+ SmallString<260> CanonicalIncludeDir; -+ if (vfs.getRealPath(IncludeDir, CanonicalIncludeDir)) -+ return false; -+ - // Debian native gcc uses g++-multiarch-incdir.diff which uses - // include/x86_64-linux-gnu/c++/10$IncludeSuffix instead of - // include/c++/10/x86_64-linux-gnu$IncludeSuffix. -- std::string Dir = IncludeDir.str(); - StringRef Include = -- llvm::sys::path::parent_path(llvm::sys::path::parent_path(Dir)); -+ llvm::sys::path::parent_path(llvm::sys::path::parent_path(CanonicalIncludeDir)); - std::string Path = -- (Include + "/" + Triple + Dir.substr(Include.size()) + IncludeSuffix) -+ (Include + "/" + Triple + CanonicalIncludeDir.substr(Include.size()) + IncludeSuffix) - .str(); - if (DetectDebian && !vfs.exists(Path)) - return false; - - // GPLUSPLUS_INCLUDE_DIR -- ToolChain::addSystemInclude(DriverArgs, CC1Args, IncludeDir); -+ ToolChain::addSystemInclude(DriverArgs, CC1Args, CanonicalIncludeDir); - // GPLUSPLUS_TOOL_INCLUDE_DIR. If Triple is not empty, add a target-dependent - // include directory. - if (DetectDebian) - ToolChain::addSystemInclude(DriverArgs, CC1Args, Path); - else if (!Triple.empty()) - ToolChain::addSystemInclude(DriverArgs, CC1Args, -- IncludeDir + "/" + Triple + IncludeSuffix); -+ CanonicalIncludeDir + "/" + Triple + IncludeSuffix); - // GPLUSPLUS_BACKWARD_INCLUDE_DIR -- ToolChain::addSystemInclude(DriverArgs, CC1Args, IncludeDir + "/backward"); -+ if (vfs.exists(CanonicalIncludeDir + "/backward")) -+ ToolChain::addSystemInclude(DriverArgs, CC1Args, CanonicalIncludeDir + "/backward"); - return true; - } - --- -2.52.0 - diff --git a/pkgs/development/rocm-modules/migraphx/default.nix b/pkgs/development/rocm-modules/migraphx/default.nix deleted file mode 100644 index dfa8bd5ea4576..0000000000000 --- a/pkgs/development/rocm-modules/migraphx/default.nix +++ /dev/null @@ -1,208 +0,0 @@ -{ - lib, - stdenv, - callPackage, - fetchFromGitHub, - rocmUpdateScript, - pkg-config, - cmake, - rocm-cmake, - clr, - openmp, - rocblas, - hipblas-common, - hipblas, - hipblaslt, - rocmlir, - miopen, - protobuf, - abseil-cpp, - half, - nlohmann_json, - boost, - msgpack-cxx, - sqlite, - # TODO(@LunNova): Swap to `onednn` once v3 is supported - # Upstream issue: https://github.com/ROCm/AMDMIGraphX/issues/4351 - onednn_2, - blaze, - texliveSmall, - doxygen, - sphinx, - docutils, - ghostscript, - python3Packages, - writableTmpDirAsHomeHook, - buildDocs ? false, - buildTests ? false, - gpuTargets ? clr.localGpuTargets or clr.gpuTargets, -}: - -let - # this standard version needs to match the version that migraphx pins, or - # compilation fails if the pinned version is not the same as the compiler's - # default. - # https://github.com/ROCm/AMDMIGraphX/blob/07ef4ba4f9ef95d241b7be165e60ad148f3344ee/CMakeLists.txt#L143-L148 - abseil-cpp' = abseil-cpp.override { cxxStandard = "17"; }; - - latex = lib.optionalAttrs buildDocs ( - texliveSmall.withPackages ( - ps: with ps; [ - latexmk - tex-gyre - fncychap - wrapfig - capt-of - framed - needspace - tabulary - varwidth - titlesec - epstopdf - ] - ) - ); -in -stdenv.mkDerivation (finalAttrs: { - pname = "migraphx"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildDocs [ - "doc" - ] - ++ lib.optionals buildTests [ - "test" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "AMDMIGraphX"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-oDVJn2vwSoLxrA5ynRduZ3uRR8XhBa0pAf3Vyx7o3HE="; - }; - - nativeBuildInputs = [ - pkg-config - cmake - rocm-cmake - clr - python3Packages.python - ] - ++ lib.optionals buildDocs [ - latex - doxygen - sphinx - docutils - ghostscript - python3Packages.sphinx-rtd-theme - python3Packages.breathe - writableTmpDirAsHomeHook - ]; - - buildInputs = [ - openmp - rocblas - hipblas-common - hipblas - hipblaslt - rocmlir - miopen - protobuf - half - nlohmann_json - boost - msgpack-cxx - sqlite - onednn_2 - blaze - python3Packages.pybind11 - python3Packages.onnx - ]; - - env.LDFLAGS = "-Wl,--allow-shlib-undefined"; - - cmakeFlags = [ - "-DMIGRAPHX_ENABLE_GPU=ON" - "-DMIGRAPHX_ENABLE_CPU=ON" - "-DMIGRAPHX_ENABLE_FPGA=ON" - "-DMIGRAPHX_ENABLE_MLIR=ON" - "-DCMAKE_C_COMPILER=amdclang" - "-DCMAKE_CXX_COMPILER=amdclang++" - "-DCMAKE_VERBOSE_MAKEFILE=ON" - "-DEMBED_USE=CArrays" # Fixes error with lld - "-DDMIGRAPHX_ENABLE_PYTHON=ON" - "-DROCM_PATH=${clr}" - "-DHIP_ROOT_DIR=${clr}" - # migraphx relies on an incompatible fork of composable_kernel - # migraphxs relies on miopen which relies on current composable_kernel - # impossible to build with this ON; we can't link both of them even if we package both - "-DMIGRAPHX_USE_COMPOSABLEKERNEL=OFF" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - ]; - - postPatch = '' - export CXXFLAGS+=" -w -isystem${rocmlir}/include/rocmlir -I${half}/include -I${lib.getInclude abseil-cpp'}/include -I${hipblas-common}/include -I${lib.getInclude protobuf}/include" - patchShebangs tools - - # `error: '__clang_hip_runtime_wrapper.h' file not found [clang-diagnostic-error]` - substituteInPlace CMakeLists.txt \ - --replace "set(MIGRAPHX_TIDY_ERRORS ALL)" "" - - # Fix Unicode minus sign (U+2212) in comment that breaks EMBED_USE=CArrays - # The embed mechanism generates char[] arrays that can't store unicode − - # which has values >127 - substituteInPlace src/targets/gpu/kernels/include/migraphx/kernels/bit.hpp \ - --replace-fail "// popcount(~(x | −x))" "// popcount(~(x | -x))" - '' - + lib.optionalString (!buildDocs) '' - substituteInPlace CMakeLists.txt \ - --replace "add_subdirectory(doc)" "" - '' - + lib.optionalString (!buildTests) '' - substituteInPlace CMakeLists.txt \ - --replace "add_subdirectory(test)" "" - ''; - - # Unfortunately, it seems like we have to call make on this manually - preInstall = lib.optionalString buildDocs '' - make -j$NIX_BUILD_CORES doc - cd ../doc/pdf - make -j$NIX_BUILD_CORES - cd - - ''; - - postInstall = - lib.optionalString buildDocs '' - mv ../doc/html $out/share/doc/migraphx - mv ../doc/pdf/MIGraphX.pdf $out/share/doc/migraphx - '' - + lib.optionalString buildTests '' - mkdir -p $test/bin - mv bin/test_* $test/bin - patchelf $test/bin/test_* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" - ''; - - passthru.impureTests = { - # NIXPKGS_ALLOW_UNFREE=1 bash $(nix-build -A rocmPackages.migraphx.impureTests.migraphx-driver) - migraphx-driver = callPackage ./test-migraphx-driver.nix { - migraphx = finalAttrs.finalPackage; - }; - }; - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "AMD's graph optimization engine"; - homepage = "https://github.com/ROCm/AMDMIGraphX"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/migraphx/test-migraphx-driver.nix b/pkgs/development/rocm-modules/migraphx/test-migraphx-driver.nix deleted file mode 100644 index c34c5a8a71d49..0000000000000 --- a/pkgs/development/rocm-modules/migraphx/test-migraphx-driver.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ - lib, - fetchurl, - makeImpureTest, - writableTmpDirAsHomeHook, - migraphx, - clr, - rocm-smi, -}: - -# Verify that a ≈50MiB resnet onnx can run with migraphx -let - resnet18 = fetchurl { - url = "https://huggingface.co/onnxmodelzoo/resnet18_Opset18_timm/resolve/main/resnet18_Opset18_timm.onnx"; - hash = "sha256-u2Io20n72qoA9atRsFIWb0zHF1WdJYgHQdMWfJhJGHA="; - meta.license = lib.licenses.unfree; - }; -in -makeImpureTest { - name = "migraphx-driver"; - testedPackage = "rocmPackages.migraphx"; - - sandboxPaths = [ - "/sys" - "/dev/dri" - "/dev/kfd" - ]; - - nativeBuildInputs = [ - writableTmpDirAsHomeHook - migraphx - clr - rocm-smi - ]; - - # FIXME(@LunNova): tol values are set too high - was seeing high divergence on iGPU - # want this test to be useful for verifying workloads run at all - # and will investigate what's broken for accuracy - testScript = '' - rocm-smi - migraphx-driver verify -O --rms-tol 0.03 --atol 1.0 --rtol 0.01 ${resnet18} - ''; - - meta = { - teams = [ lib.teams.rocm ]; - }; -} diff --git a/pkgs/development/rocm-modules/miopen/default.nix b/pkgs/development/rocm-modules/miopen/default.nix deleted file mode 100644 index 881b0a2bbbdf6..0000000000000 --- a/pkgs/development/rocm-modules/miopen/default.nix +++ /dev/null @@ -1,338 +0,0 @@ -{ - lib, - stdenv, - callPackage, - fetchFromGitHub, - fetchpatch, - fetchurl, - runCommand, - pkg-config, - cmake, - rocm-cmake, - rocblas, - rocmlir, - rocrand, - rocm-runtime, - hipblas-common, - hipblas, - hipblaslt, - clr, - composable_kernel, - frugally-deep, - rocm-docs-core, - half, - boost, - sqlite, - symlinkJoin, - bzip2, - lbzip2, - nlohmann_json, - texliveSmall, - doxygen, - sphinx, - zlib, - gtest, - rocm-comgr, - roctracer, - python3Packages, - gpuTargets ? clr.localGpuTargets or clr.gpuTargets, - buildDocs ? false, # Needs internet because of rocm-docs-core - buildTests ? false, - withComposableKernel ? true, -}: - -let - # FIXME: cmake files need patched to include this properly - cFlags = "-Wno-documentation-pedantic --offload-compress -I${hipblas-common}/include -I${hipblas}/include -I${roctracer}/include -I${nlohmann_json}/include -I${sqlite.dev}/include -I${rocrand}/include"; - version = "7.2.4"; - - # Targets outside this list will get - # error: use of undeclared identifier 'CK_BUFFER_RESOURCE_3RD_DWORD' - supportedTargets = lib.intersectLists [ - "gfx900" - "gfx906" - "gfx908" - "gfx90a" - "gfx942" - "gfx950" - "gfx1030" - "gfx1031" - "gfx1100" - "gfx1101" - "gfx1102" - "gfx1150" - "gfx1151" - "gfx1200" - "gfx1201" - ] gpuTargets; - - latex = lib.optionalAttrs buildDocs ( - texliveSmall.withPackages ( - ps: with ps; [ - latexmk - tex-gyre - fncychap - wrapfig - capt-of - framed - needspace - tabulary - varwidth - titlesec - ] - ) - ); - - # for hiprtcCompileProgram (dropout kernels require rocrand in -I at runtime) - hiprtcCompileRocmPath = symlinkJoin { - name = "miopen-hiprtc-compile-rocm-path"; - paths = [ - clr - rocrand - ]; - }; - - # Kernel databases moved from Git LFS to DVC (anonymous s3 bucket s3://therock-dvc/rocm-libraries) - fetchKdb = - name: - { url, hash }: - runCommand "miopen-${name}.kdb" { preferLocalBuild = true; } '' - ${lbzip2}/bin/lbzip2 -ckd ${ - fetchurl { - inherit url hash; - name = "${name}.kdb.bz2"; - } - } > $out - ''; - - kdbs = lib.mapAttrs fetchKdb ( - lib.filterAttrs (name: _: lib.elem name supportedTargets) (import ./kdbs.nix) - ); - - linkKDBsTo = - targetPath: - lib.concatStringsSep "" ( - lib.mapAttrsToList (name: kdb: '' - ln -sf ${kdb} ${targetPath}/${name}.kdb - '') kdbs - ); -in -stdenv.mkDerivation (finalAttrs: { - inherit version; - pname = "miopen"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/miopen" - "shared" - ]; - fetchSubmodules = true; - hash = "sha256-plZpBTbEBVMa5CasjfbUsu45xP/BYstrEpWKK2H7QQ4="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/miopen"; - - env.CFLAGS = cFlags; - env.CXXFLAGS = cFlags; - - # Find zstd and add to target. Mainly for torch. - patches = [ - ./skip-preexisting-dbs.patch - (fetchpatch { - url = "https://github.com/ROCm/MIOpen/commit/e608b4325646afeabb5e52846997b926d2019d19.patch"; - hash = "sha256-oxa3qlIC2bzbwGxrQOZXoY/S7CpLsMrnWRB7Og0tk0M="; - }) - (fetchpatch { - url = "https://github.com/ROCm/MIOpen/commit/3413d2daaeb44b7d6eadcc03033a5954a118491e.patch"; - hash = "sha256-ST4snUcTmmSI1Ogx815KEX9GdMnmubsavDzXCGJkiKs="; - }) - (fetchpatch { - # [miopen] Extend HIP ISA compatibility - name = "Extend-MIOpen-ISA-compatibility.patch"; - url = "https://github.com/GZGavinZhao/rocm-libraries/commit/02f0fedffdc197f146dd45f41e10990a00cde3ee.patch"; - hash = "sha256-My32iZw75rvB4fyvUJJ2kw2bU9/39awGteFGjzijixw="; - relative = "projects/miopen"; - }) - ]; - - outputs = [ - "out" - ] - ++ lib.optionals buildDocs [ - "doc" - ] - ++ lib.optionals buildTests [ - "test" - ]; - enableParallelBuilding = true; - env.ROCM_PATH = clr; - env.LD_LIBRARY_PATH = lib.makeLibraryPath [ rocm-runtime ]; - - nativeBuildInputs = [ - pkg-config - cmake - rocm-cmake - clr - ]; - - buildInputs = [ - hipblas - hipblas-common - rocblas - rocmlir - half - boost - sqlite - bzip2 - nlohmann_json - frugally-deep - roctracer - rocrand - hipblaslt - ] - ++ lib.optionals withComposableKernel [ - composable_kernel - ] - ++ lib.optionals buildDocs [ - latex - doxygen - sphinx - rocm-docs-core - python3Packages.sphinx-rtd-theme - python3Packages.breathe - python3Packages.myst-parser - ] - ++ lib.optionals buildTests [ - gtest - zlib - ]; - - cmakeFlags = [ - "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" supportedTargets}" - "-DGPU_TARGETS=${lib.concatStringsSep ";" supportedTargets}" - "-DGPU_ARCHS=${lib.concatStringsSep ";" supportedTargets}" - "-DCMAKE_VERBOSE_MAKEFILE=ON" - "-DCMAKE_MODULE_PATH=${clr}/hip/cmake" - - # needs to stream to stdout so bzcat rather than bunzip2 - "-DUNZIPPER=${bzip2}/bin/bzcat" - - "-DCMAKE_C_COMPILER=amdclang" - "-DCMAKE_CXX_COMPILER=amdclang++" - "-DROCM_PATH=${clr}" - "-DHIP_ROOT_DIR=${clr}" - (lib.cmakeBool "MIOPEN_USE_ROCBLAS" true) - (lib.cmakeBool "MIOPEN_USE_HIPBLASLT" true) - (lib.cmakeBool "MIOPEN_USE_COMPOSABLEKERNEL" withComposableKernel) - (lib.cmakeBool "MIOPEN_USE_HIPRTC" true) - (lib.cmakeBool "MIOPEN_USE_COMGR" true) - "-DCMAKE_HIP_COMPILER_ROCM_ROOT=${clr}" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - "-DMIOPEN_BACKEND=HIP" - ] - ++ lib.optionals buildTests [ - "-DBUILD_TESTS=ON" - "-DMIOPEN_TEST_ALL=ON" - ]; - - postPatch = '' - substituteInPlace cmake/ClangTidy.cmake \ - --replace-fail 'macro(enable_clang_tidy)' 'macro(enable_clang_tidy) - endmacro() - macro(enable_clang_tidy_unused)' \ - --replace-fail 'function(clang_tidy_check TARGET)' 'function(clang_tidy_check TARGET) - return()' - - patchShebangs test src/composable_kernel fin utils install_deps.cmake - - substituteInPlace src/comgr.cpp \ - --replace-fail '"/opt/rocm"' '"${hiprtcCompileRocmPath}"' - '' - + linkKDBsTo "src/kernels" - + '' - mkdir -p build/share/miopen/db/ - '' - + linkKDBsTo "build/share/miopen/db"; - - # Unfortunately, it seems like we have to call make on these manually - postBuild = - lib.optionalString buildDocs '' - python -m sphinx -T -E -b html -d _build/doctrees -D language=en ../docs _build/html - '' - + lib.optionalString buildTests '' - make -j$NIX_BUILD_CORES check - ''; - - postInstall = '' - rm $out/libexec/miopen/install_precompiled_kernels.sh - '' - + linkKDBsTo "$out/share/miopen/db" - + lib.optionalString buildDocs '' - mv ../doc/html $out/share/doc/miopen-hip - '' - + lib.optionalString buildTests '' - mkdir -p $test/bin - mv bin/test_* $test/bin - patchelf --set-rpath $out/lib:${ - lib.makeLibraryPath ( - finalAttrs.buildInputs - ++ [ - clr - rocm-comgr - ] - ) - } $test/bin/* - ''; - - requiredSystemFeatures = [ "big-parallel" ]; - - passthru.impureTests = { - # bash $(nix-build -A rocmPackages.miopen.passthru.impureTests.conv) etc - bnorm = callPackage ./test-runtime-compilation.nix { - miopen = finalAttrs.finalPackage; - name = "bnorm"; - testScript = "MIOpenDriver bnorm -n 16 -c 16 -H 512 -W 512 -m 1 -F 1 -s 1 -r 1"; - }; - conv = callPackage ./test-runtime-compilation.nix { - miopen = finalAttrs.finalPackage; - name = "conv"; - testScript = "MIOpenDriver conv -n 1 -c 1 -H 4 -W 4 -k 1 -y 3 -x 3 -p 0 -q 0 -V 0"; - }; - dropout = callPackage ./test-runtime-compilation.nix { - miopen = finalAttrs.finalPackage; - name = "dropout"; - testScript = "MIOpenDriver dropout -d 64,32,14,14"; - }; - pool = callPackage ./test-runtime-compilation.nix { - miopen = finalAttrs.finalPackage; - name = "pool"; - testScript = "MIOpenDriver pool -W 1x1x4x4 -y 2 -x 2 -p 0 -q 0 -F 1 -V 0"; - }; - }; - passthru.tests = { - # Ensure all .tn.model files can be loaded by whatever version of frugally-deep we have - # This is otherwise hard to verify as MIOpen will only use these models on specific, - # expensive Instinct GPUs - # If MIOpen stops embedding .tn.model files the test will also fail, and can be deleted, - # likely along with the frugally-deep dependency - can-load-models = callPackage ./test-frugally-deep-model-loading.nix { - inherit (finalAttrs) src version; - inherit frugally-deep nlohmann_json; - }; - }; - passthru.updateScript = ./update.sh; - - meta = { - description = "Machine intelligence library for ROCm"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/miopen"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/miopen/kdbs.nix b/pkgs/development/rocm-modules/miopen/kdbs.nix deleted file mode 100644 index d4156a97324d7..0000000000000 --- a/pkgs/development/rocm-modules/miopen/kdbs.nix +++ /dev/null @@ -1,27 +0,0 @@ -# Generated by update.sh -{ - gfx1030 = { - url = "https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5/22/c4bd38cc34d3906add061ee57b099b"; - hash = "sha256-LESExp7sFl7osCM7HdVMpzOE0dU7953e2yzgeHSGgfI="; - }; - gfx900 = { - url = "https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5/cf/9c12dafe25b15ea1e93088b7b061af"; - hash = "sha256-lFFB5GQFTjUnx3JDx816yH+96OGRt9XvBzfLFFHtUrE="; - }; - gfx906 = { - url = "https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5/04/b3be6a15c700ff382e0a5e136010e1"; - hash = "sha256-cn1ODLcUQi+/QJUlWbELukMUj4+b1vjjRhhTseL9tdM="; - }; - gfx908 = { - url = "https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5/35/b9082b72e661dc5e37f14de1d9d4ed"; - hash = "sha256-pI30zpZL3OEP3aeLdVpM00nHeTyD5K+XDH47g0W2A+M="; - }; - gfx90a = { - url = "https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5/a1/1615323e06c5774fe19cf34c51baef"; - hash = "sha256-TkzSgY3V/Xs5YXfr69TrL8JjqDr1MZMgeBeQ/e2kEjE="; - }; - gfx942 = { - url = "https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5/6a/fe97d7bd441fe15280b28b6e3b1748"; - hash = "sha256-fyhnR3+xPFkHLN36dI9UYIhqoVstt5RpareGn2S9lMM="; - }; -} diff --git a/pkgs/development/rocm-modules/miopen/skip-preexisting-dbs.patch b/pkgs/development/rocm-modules/miopen/skip-preexisting-dbs.patch deleted file mode 100644 index 89be2f4076cb4..0000000000000 --- a/pkgs/development/rocm-modules/miopen/skip-preexisting-dbs.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index d0ffaf983..0b9ed0952 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -554,7 +554,7 @@ endif() - function(unpack_db db_bzip2_file) - get_filename_component(__fname ${db_bzip2_file} NAME_WLE) - add_custom_command(OUTPUT ${KERNELS_BINARY_DIR}/${__fname} -- COMMAND ${UNZIPPER} -dc -k ${db_bzip2_file} > ${KERNELS_BINARY_DIR}/${__fname}) -+ COMMAND test -e ${KERNELS_BINARY_DIR}/${__fname} || ${UNZIPPER} -dc -k ${db_bzip2_file} > ${KERNELS_BINARY_DIR}/${__fname}) - string(REPLACE "." "_" __tname ${__fname}) - add_custom_target(generate_${__tname} ALL DEPENDS ${KERNELS_BINARY_DIR}/${__fname}) - -@@ -563,7 +563,7 @@ function(unpack_db db_bzip2_file) - if(NOT MIOPEN_USE_SQLITE_PERFDB AND __extension STREQUAL ".db") - add_custom_command(OUTPUT ${KERNELS_BINARY_DIR}/${__fname}.txt - DEPENDS sqlite2txt generate_${__tname} -- COMMAND $ ${KERNELS_BINARY_DIR}/${__fname} ${KERNELS_BINARY_DIR}/${__fname}.txt -+ COMMAND test -e ${KERNELS_BINARY_DIR}/${__fname}.txt || $ ${KERNELS_BINARY_DIR}/${__fname} ${KERNELS_BINARY_DIR}/${__fname}.txt - ) - add_custom_target(generate_${__tname}_txt ALL DEPENDS ${KERNELS_BINARY_DIR}/${__fname}.txt) - add_dependencies(generate_kernels generate_${__tname}_txt) diff --git a/pkgs/development/rocm-modules/miopen/test-frugally-deep-model-loading.cpp b/pkgs/development/rocm-modules/miopen/test-frugally-deep-model-loading.cpp deleted file mode 100644 index 6b64b80999850..0000000000000 --- a/pkgs/development/rocm-modules/miopen/test-frugally-deep-model-loading.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include -#include -#include -#include - -int main() { - std::vector model_files; - std::string src_dir = std::getenv("SRC_DIR") ? std::getenv("SRC_DIR") : "."; - - // collect *tn.model files except _metadata - try { - for (const auto& entry : std::filesystem::recursive_directory_iterator(src_dir)) { - if (entry.is_regular_file()) { - std::string path = entry.path().string(); - if (path.find("tn.model") != std::string::npos && path.find("_metadata.") == std::string::npos) { - model_files.push_back(path); - } - } - } - } catch (const std::exception& e) { - std::cerr << "Error scanning directory: " << e.what() << std::endl; - return 1; - } - - if (model_files.empty()) { - std::cout << "No *.tn.model files found in " << src_dir << std::endl; - return 1; - } - - std::cout << "Found " << model_files.size() << " model files to test" << std::endl; - - int failed_count = 0; - for (const auto& model_file : model_files) { - std::cout << "Loading: " << model_file << " ... "; - std::cout.flush(); - - try { - const auto model = fdeep::load_model(model_file); - std::cout << "OK" << std::endl; - } catch (const std::exception& e) { - std::cout << "FAILED: " << e.what() << std::endl; - failed_count++; - } - } - - if (failed_count > 0) { - std::cerr << "\n" << failed_count << " out of " << model_files.size() - << " models failed to load" << std::endl; - return 1; - } - - std::cout << "\nAll " << model_files.size() << " models loaded successfully!" << std::endl; - return 0; -} diff --git a/pkgs/development/rocm-modules/miopen/test-frugally-deep-model-loading.nix b/pkgs/development/rocm-modules/miopen/test-frugally-deep-model-loading.nix deleted file mode 100644 index 7f82083d23492..0000000000000 --- a/pkgs/development/rocm-modules/miopen/test-frugally-deep-model-loading.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ - lib, - stdenv, - eigen, - frugally-deep, - functionalplus, - nlohmann_json, - src, - version, -}: - -stdenv.mkDerivation { - pname = "miopen-frugally-deep-model-test"; - inherit version src; - - dontConfigure = true; - dontInstall = true; - doCheck = true; - - buildPhase = '' - runHook preBuild - - $CXX -std=c++20 \ - -I${lib.getDev eigen}/include/eigen3 \ - -I${lib.getDev functionalplus}/include \ - -I${lib.getDev frugally-deep}/include \ - -I${lib.getDev nlohmann_json}/include \ - ${./test-frugally-deep-model-loading.cpp} \ - -o test_models - - runHook postBuild - ''; - - checkPhase = '' - runHook preCheck - - echo "Running model loading tests..." - SRC_DIR="${src}" ./test_models - mkdir -p $out - - runHook postCheck - ''; - - meta = { - description = "Test that frugally-deep can load MIOpen model files"; - teams = with lib.teams; [ rocm ]; - platforms = lib.platforms.linux; - }; -} diff --git a/pkgs/development/rocm-modules/miopen/test-runtime-compilation.nix b/pkgs/development/rocm-modules/miopen/test-runtime-compilation.nix deleted file mode 100644 index c781d36462513..0000000000000 --- a/pkgs/development/rocm-modules/miopen/test-runtime-compilation.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ - lib, - makeImpureTest, - writableTmpDirAsHomeHook, - miopen, - clr, - rocm-smi, - name, - testScript, -}: - -makeImpureTest { - inherit name; - testedPackage = "rocmPackages.miopen"; - - sandboxPaths = [ - "/sys" - "/dev/dri" - "/dev/kfd" - ]; - - nativeBuildInputs = [ - writableTmpDirAsHomeHook - miopen - clr - rocm-smi - ]; - - testScript = '' - rocm-smi - ${testScript} - ''; - - meta = { - teams = [ lib.teams.rocm ]; - }; -} diff --git a/pkgs/development/rocm-modules/miopen/update.sh b/pkgs/development/rocm-modules/miopen/update.sh deleted file mode 100755 index 8e2e92585760d..0000000000000 --- a/pkgs/development/rocm-modules/miopen/update.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -i bash -p curl jq nix common-updater-scripts - -set -euo pipefail - -gh_curl() { curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} -sf "$@"; } - -version="${1:-$(gh_curl "https://api.github.com/repos/ROCm/rocm-libraries/releases?per_page=4" \ - | jq -re 'map(.tag_name // .name) - | map(select(test("^rocm-[0-9]+\\.[0-9]+(\\.[0-9]+)?$"))) - | first | ltrimstr("rocm-")')}" - -# main source version -echo "Updating MIOpen to $version" >&2 -update-source-version rocmPackages.miopen "$version" --ignore-same-hash - -# kdbs.nix from s3 bucket -cd "$(dirname "${BASH_SOURCE[0]}")" -bucket="https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5" - -# Fetch directory listing; extract name + download_url for .dvc files -dvc_entries=$(gh_curl "https://api.github.com/repos/ROCm/rocm-libraries/contents/projects/miopen/src/kernels?ref=rocm-${version}" \ - | jq -r '.[] | select(.name | endswith(".kdb.bz2.dvc")) | "\(.name)\t\(.download_url)"') - -[[ -n "$dvc_entries" ]] || { echo "No .kdb.bz2.dvc files found, upstream likely changed packaging again" >&2; exit 1; } - -{ - echo "# Generated by update.sh" - echo "{" - - while IFS=$'\t' read -r dvc_file raw_url; do - arch="${dvc_file%.kdb.bz2.dvc}" - md5=$(curl -sf "$raw_url" | awk '/- md5:/{print $3}') - url="${bucket}/${md5:0:2}/${md5:2}" - sri=$(nix --extra-experimental-features nix-command store prefetch-file --json "$url" --name "${arch}.kdb.bz2" | jq -r .hash) - echo " $arch: $sri" >&2 - cat < kdbs.nix - -echo "Wrote kdbs.nix" >&2 diff --git a/pkgs/development/rocm-modules/rccl/default.nix b/pkgs/development/rocm-modules/rccl/default.nix deleted file mode 100644 index 1dbcd0c84945c..0000000000000 --- a/pkgs/development/rocm-modules/rccl/default.nix +++ /dev/null @@ -1,158 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - rocm-smi, - rocm-core, - pkg-config, - clr, - mscclpp, - perl, - hipify, - python3, - fmt, - gtest, - chrpath, - roctracer, - rocprofiler, - rocprofiler-register, - autoPatchelfHook, - buildTests ? false, - gpuTargets ? (clr.localGpuTargets or [ ]), - # for passthru.tests - rccl, -}: - -let - useAsan = buildTests; - useUbsan = buildTests; - san = lib.optionalString (useAsan || useUbsan) ( - "-fno-gpu-sanitize -fsanitize=undefined " - + (lib.optionalString useAsan "-fsanitize=address -shared-libsan ") - ); -in -# Note: we can't properly test or make use of multi-node collective ops -# https://github.com/NixOS/nixpkgs/issues/366242 tracks kernel support -# kfd_peerdirect support which is on out-of-tree amdkfd in ROCm/ROCK-Kernel-Driver -# infiniband ib_peer_mem support isn't in the mainline kernel but is carried by some distros -stdenv.mkDerivation (finalAttrs: { - pname = "rccl${clr.gpuArchSuffix}"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildTests [ - "test" - ]; - - patches = [ - ./rccl-test-missing-iomanip.diff - ./fix_hw_reg_hw_id_gt_gfx10.patch - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rccl"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-A1IQYIDWqu3JLiPQ70G52s1/0ZweQxFlgMUH81qJWmU="; - }; - - requiredSystemFeatures = [ "big-parallel" ]; # Very resource intensive LTO - - nativeBuildInputs = [ - cmake - rocm-cmake - clr - perl - hipify - python3 - pkg-config - autoPatchelfHook # ASAN doesn't add rpath without this - ]; - - buildInputs = [ - rocm-smi - fmt - gtest - roctracer - rocprofiler - rocprofiler-register - mscclpp - ] - ++ lib.optionals buildTests [ - chrpath - ]; - - cmakeFlags = [ - "-DHIP_CLANG_NUM_PARALLEL_JOBS=4" - "-DROCM_PATH=${clr}" - "-DHIP_COMPILER=${clr}/bin/amdclang++" - "-DCMAKE_CXX_COMPILER=${clr}/bin/amdclang++" - "-DROCM_PATCH_VERSION=${rocm-core.ROCM_LIBPATCH_VERSION}" - "-DROCM_VERSION=${rocm-core.ROCM_LIBPATCH_VERSION}" - "-DBUILD_BFD=OFF" # Can't get it to detect bfd.h - "-DENABLE_MSCCL_KERNEL=ON" - # FIXME: this is still running a download because if(NOT mscclpp_nccl_FOUND) is commented out T_T - "-DENABLE_MSCCLPP=OFF" - #"-DMSCCLPP_ROOT=${mscclpp}" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ] - ++ lib.optionals (gpuTargets != [ ]) [ - # AMD can't make up their minds and keep changing which one is used in different projects. - "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - ] - ++ lib.optionals buildTests [ - "-DBUILD_TESTS=ON" - ]; - - # -O2 and -fno-strict-aliasing due to UB issues in RCCL :c - # Reported upstream - env.CFLAGS = "-I${clr}/include -I${roctracer}/include -O2 -fno-strict-aliasing ${san}-fno-omit-frame-pointer -momit-leaf-frame-pointer"; - env.CXXFLAGS = "-I${clr}/include -I${roctracer}/include -O2 -fno-strict-aliasing ${san}-fno-omit-frame-pointer -momit-leaf-frame-pointer"; - env.LDFLAGS = "${san}"; - postPatch = '' - patchShebangs src tools - substituteInPlace CMakeLists.txt \ - --replace-fail '${"\${HOST_OS_ID}"}' '"ubuntu"' \ - --replace-fail 'target_include_directories(rccl PRIVATE ''${ROCM_SMI_INCLUDE_DIR})' \ - 'target_include_directories(rccl PRIVATE ''${ROCM_SMI_INCLUDE_DIRS})' - ''; - - postInstall = - lib.optionalString useAsan '' - patchelf --add-needed ${clr}/llvm/lib/linux/libclang_rt.asan-${stdenv.hostPlatform.parsed.cpu.name}.so $out/lib/librccl.so - '' - + lib.optionalString buildTests '' - mkdir -p $test/bin - mv $out/bin/* $test/bin - rmdir $out/bin - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - # This package with sanitizers + manual integration test binaries built - # must be ran manually - passthru.tests.rccl = rccl.override { - buildTests = true; - }; - - meta = { - description = "ROCm communication collectives library"; - homepage = "https://github.com/ROCm/rccl"; - license = with lib.licenses; [ - bsd2 - bsd3 - ]; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rccl/fix_hw_reg_hw_id_gt_gfx10.patch b/pkgs/development/rocm-modules/rccl/fix_hw_reg_hw_id_gt_gfx10.patch deleted file mode 100644 index c69000814a8a6..0000000000000 --- a/pkgs/development/rocm-modules/rccl/fix_hw_reg_hw_id_gt_gfx10.patch +++ /dev/null @@ -1,33 +0,0 @@ -fix: __trace_hwreg should use HW_REG_HW_ID1 for all gfx10/11/12 -diff --git a/src/device/common.h b/src/device/common.h -index c6c61021..742885f4 100644 ---- a/src/device/common.h -+++ b/src/device/common.h -@@ -26,8 +26,9 @@ - { __atomic_store_n((DST), (SRC), __ATOMIC_SEQ_CST); } - #endif - --#if defined(__gfx1100__) || defined(__gfx1101__) || defined(__gfx1102__) || defined(__gfx1200__) || defined(__gfx1201__) --#define __trace_hwreg() -+#if defined(__GFX10__) || defined(__GFX11__) || defined(__GFX12__) -+#define __trace_hwreg() \ -+ asm volatile ("s_getreg_b32 %0, hwreg(HW_REG_HW_ID1)" : "=s" (collTrace->data_0)); - #else - #define __trace_hwreg() \ - asm volatile ("s_getreg_b32 %0, hwreg(HW_REG_HW_ID)" : "=s" (collTrace->data_0)); -diff --git a/tools/JitterBench/Common.hpp b/tools/JitterBench/Common.hpp -index bad12a1b..b59856a8 100644 ---- a/tools/JitterBench/Common.hpp -+++ b/tools/JitterBench/Common.hpp -@@ -43,9 +43,9 @@ THE SOFTWARE. - #endif - - // Macro for collecting HW_REG_HW_ID --#if defined(__gfx1100__) || defined(__gfx1101__) || defined(__gfx1102__) || defined(__NVCC__) -+#if defined(__GFX10__) || defined(__GFX11__) || defined(__GFX12__) - #define GetHwId(val) \ -- val = 0 -+ asm volatile ("s_getreg_b32 %0, hwreg(HW_REG_HW_ID1)" : "=s" (val)); - #else - #define GetHwId(val) \ - asm volatile ("s_getreg_b32 %0, hwreg(HW_REG_HW_ID)" : "=s" (val)); diff --git a/pkgs/development/rocm-modules/rccl/rccl-test-missing-iomanip.diff b/pkgs/development/rocm-modules/rccl/rccl-test-missing-iomanip.diff deleted file mode 100644 index 3cc54a83c1429..0000000000000 --- a/pkgs/development/rocm-modules/rccl/rccl-test-missing-iomanip.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- a/test/common/TestBed.cpp -+++ b/test/common/TestBed.cpp -@@ -4,6 +4,7 @@ - * See LICENSE.txt for license information - ************************************************************************/ - #include -+#include - #include "TestBed.hpp" - #include - diff --git a/pkgs/development/rocm-modules/rdc/default.nix b/pkgs/development/rocm-modules/rdc/default.nix deleted file mode 100644 index 8c5debc4dec47..0000000000000 --- a/pkgs/development/rocm-modules/rdc/default.nix +++ /dev/null @@ -1,150 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - pkg-config, - amdsmi, - rocm-smi, - rocm-runtime, - libcap, - libdrm, - grpc, - protobuf, - openssl, - doxygen, - graphviz, - texliveSmall, - gtest, - buildDocs ? true, - buildTests ? false, -}: - -let - latex = lib.optionalAttrs buildDocs ( - texliveSmall.withPackages ( - ps: with ps; [ - changepage - latexmk - varwidth - multirow - hanging - adjustbox - collectbox - stackengine - enumitem - alphalph - wasysym - sectsty - tocloft - newunicodechar - etoc - helvetic - wasy - courier - ] - ) - ); -in -stdenv.mkDerivation (finalAttrs: { - pname = "rdc"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildDocs [ - "doc" - ] - ++ lib.optionals buildTests [ - "test" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/rdc" - "shared" - ]; - hash = "sha256-SmySauRxFnEQJVTjGYf4TpmQclTwZG2RZrk3u6ko5Qo="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rdc"; - - patches = [ - # https://github.com/ROCm/rocm-systems/pull/2423 - ./fix-cmake-cxxflags.patch - # https://github.com/ROCm/rocm-systems/pull/2424 - ./fix-libcap-pkgconfig.patch - ]; - - nativeBuildInputs = [ - cmake - pkg-config - protobuf - ] - ++ lib.optionals buildDocs [ - doxygen - graphviz - latex - ]; - - buildInputs = [ - amdsmi - rocm-smi - rocm-runtime - libcap - libdrm - grpc - openssl - ] - ++ lib.optionals buildTests [ - gtest - ]; - - cmakeFlags = [ - "-DCMAKE_VERBOSE_MAKEFILE=ON" - "-DRDC_INSTALL_PREFIX=${placeholder "out"}" - "-DBUILD_RVS=OFF" # TODO: Needs RVS package - "-DBUILD_ROCRTEST=ON" - "-DRSMI_INC_DIR=${rocm-smi}/include" - "-DRSMI_LIB_DIR=${rocm-smi}/lib" - "-DGRPC_ROOT=${grpc}" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - "-DCMAKE_INSTALL_LIBEXECDIR=libexec" - "-DCMAKE_INSTALL_DOCDIR=doc" - ] - ++ lib.optionals buildTests [ - "-DBUILD_TESTS=ON" - ]; - - postPatch = '' - substituteInPlace CMakeLists.txt \ - --replace-fail "file(STRINGS /etc/os-release LINUX_DISTRO LIMIT_COUNT 1 REGEX \"NAME=\")" "set(LINUX_DISTRO \"NixOS\")" - ''; - - postInstall = '' - find $out/bin -executable -type f -exec \ - patchelf {} --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" \; - '' - + lib.optionalString buildTests '' - mkdir -p $test - mv $out/bin/rdctst_tests $test/bin - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "Simplifies administration and addresses infrastructure challenges in cluster and datacenter environments"; - homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/rdc"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rdc/fix-cmake-cxxflags.patch b/pkgs/development/rocm-modules/rdc/fix-cmake-cxxflags.patch deleted file mode 100644 index bf7f3dbb0eef4..0000000000000 --- a/pkgs/development/rocm-modules/rdc/fix-cmake-cxxflags.patch +++ /dev/null @@ -1,217 +0,0 @@ -From 92f25181dbf722cb749e445851580df4ea779299 Mon Sep 17 00:00:00 2001 -From: Luna Nova -Date: Sun, 21 Dec 2025 08:01:08 -0800 -Subject: [PATCH 1/2] fix(rdc): set CMAKE_CXX_FLAGS after project() to avoid - clobbering env - -CMAKE_CXX_FLAGS' initial value is set from $CXXFLAGS on project() call -so the previous location ignored CXXFLAGS from env or CMake toolchain -config. - -Ref: https://cmake.org/cmake/help/v4.2/variable/CMAKE_LANG_FLAGS_INIT.html -Fixes: 874a7b438f ("CMAKE - Fix build types") ---- - CMakeLists.txt | 48 +++++++++++++++++++------------------ - 1 file changed, 25 insertions(+), 23 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 907c9fbff42..8b386c7be3d 100755 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -55,29 +55,6 @@ set_property( - PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel" - ) - --# Set compile flags --set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64 -msse -msse2") --set(CMAKE_CXX_FLAGS_DEBUG -- "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -DDEBUG" -- CACHE STRING -- "Flags for Debug builds" --) --set(CMAKE_CXX_FLAGS_RELEASE -- "${CMAKE_CXX_FLAGS_RELEASE} -O2 -s -DNDEBUG" -- CACHE STRING -- "Flags for Release builds" --) --set(CMAKE_CXX_FLAGS_RELWITHDEBINFO -- "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG" -- CACHE STRING -- "Flags for RelWithDebInfo builds" --) --set(CMAKE_CXX_FLAGS_MINSIZEREL -- "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG" -- CACHE STRING -- "Flags for MinSizeRel builds" --) -- - set(CMAKE_MODULE_PATH - "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/" - CACHE INTERNAL -@@ -155,6 +132,31 @@ project(${RDC} VERSION "${VERSION_STRING}" HOMEPAGE_URL "https://github.com/Rade - # this must go after project() - include(GNUInstallDirs) - -+# NB: CMAKE__FLAGS are initialized from environment (CXXFLAGS et al.) -+# during project(). Setting them before project() discards env and toolchain -+# defaults. Cf. CMAKE__FLAGS_INIT for toolchain overrides. -+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64 -msse -msse2") -+set(CMAKE_CXX_FLAGS_DEBUG -+ "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -DDEBUG" -+ CACHE STRING -+ "Flags for Debug builds" -+) -+set(CMAKE_CXX_FLAGS_RELEASE -+ "${CMAKE_CXX_FLAGS_RELEASE} -O2 -s -DNDEBUG" -+ CACHE STRING -+ "Flags for Release builds" -+) -+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO -+ "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG" -+ CACHE STRING -+ "Flags for RelWithDebInfo builds" -+) -+set(CMAKE_CXX_FLAGS_MINSIZEREL -+ "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG" -+ CACHE STRING -+ "Flags for MinSizeRel builds" -+) -+ - set(COMMON_DIR "${CMAKE_CURRENT_SOURCE_DIR}/common") - - set(GRPC_ROOT_DEFAULT "/usr") - -From 0c8710c3570963b29c709b1cd1f78b15fd73a950 Mon Sep 17 00:00:00 2001 -From: Luna Nova -Date: Sun, 21 Dec 2025 08:13:04 -0800 -Subject: [PATCH 2/2] fix(rdc): don't reimplement CMake default build type flag - logic - -The previous approach was overly complicated and added nothing. CMake already defaults -similar flags for each of the default supported build types. -Additionally, the previous flags broke AArch64 as -m64 -msse are incompatible. -It's not necessary to explicitly set this with modern toolchains. - -Fixes: 874a7b438f ("CMAKE - Fix build types") -Fixes: bc7f01e992 ("Initial RDC commit") ---- - CMakeLists.txt | 25 +--------------------- - example/CMakeLists.txt | 26 ++--------------------- - tests/example/CMakeLists.txt | 24 +-------------------- - 3 files changed, 4 insertions(+), 71 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 8b386c7be3d..251fcddd653 100755 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -132,30 +132,7 @@ project(${RDC} VERSION "${VERSION_STRING}" HOMEPAGE_URL "https://github.com/Rade - # this must go after project() - include(GNUInstallDirs) - --# NB: CMAKE__FLAGS are initialized from environment (CXXFLAGS et al.) --# during project(). Setting them before project() discards env and toolchain --# defaults. Cf. CMAKE__FLAGS_INIT for toolchain overrides. --set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64 -msse -msse2") --set(CMAKE_CXX_FLAGS_DEBUG -- "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -DDEBUG" -- CACHE STRING -- "Flags for Debug builds" --) --set(CMAKE_CXX_FLAGS_RELEASE -- "${CMAKE_CXX_FLAGS_RELEASE} -O2 -s -DNDEBUG" -- CACHE STRING -- "Flags for Release builds" --) --set(CMAKE_CXX_FLAGS_RELWITHDEBINFO -- "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG" -- CACHE STRING -- "Flags for RelWithDebInfo builds" --) --set(CMAKE_CXX_FLAGS_MINSIZEREL -- "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG" -- CACHE STRING -- "Flags for MinSizeRel builds" --) -+add_compile_options(-Wall -Wextra) - - set(COMMON_DIR "${CMAKE_CURRENT_SOURCE_DIR}/common") - -diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt -index 378a2005818..7c51307ec38 100755 ---- a/example/CMakeLists.txt -+++ b/example/CMakeLists.txt -@@ -31,30 +31,6 @@ cmake_minimum_required(VERSION 3.15) - option(CMAKE_VERBOSE_MAKEFILE "Enable verbose output" ON) - option(CMAKE_EXPORT_COMPILE_COMMANDS "Export compile commands for linters and autocompleters" ON) - --# Set compile flags --set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64 -msse -msse2") --set(CMAKE_CXX_FLAGS_DEBUG -- "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -DDEBUG" -- CACHE STRING -- "Flags for Debug builds" --) --# note: no '-s' here unlike other CMakeLists.txt --set(CMAKE_CXX_FLAGS_RELEASE -- "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG" -- CACHE STRING -- "Flags for Release builds" --) --set(CMAKE_CXX_FLAGS_RELWITHDEBINFO -- "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG" -- CACHE STRING -- "Flags for RelWithDebInfo builds" --) --set(CMAKE_CXX_FLAGS_MINSIZEREL -- "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG" -- CACHE STRING -- "Flags for MinSizeRel builds" --) -- - set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard to use") - set(CMAKE_CXX_STANDARD_REQUIRED ON) - set(CMAKE_CXX_EXTENSIONS OFF) -@@ -66,6 +42,8 @@ endif() - - project(RDC_example) - -+add_compile_options(-Wall -Wextra) -+ - # provides cmake_print_variables(VAR) - include(CMakePrintHelpers) - -diff --git a/tests/example/CMakeLists.txt b/tests/example/CMakeLists.txt -index d5614f387bd..13c2f3857a1 100755 ---- a/tests/example/CMakeLists.txt -+++ b/tests/example/CMakeLists.txt -@@ -22,29 +22,7 @@ message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&") - message(" Cmake Example Lib ") - message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&") - --# Set compile flags --set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64 -msse -msse2") --set(CMAKE_CXX_FLAGS_DEBUG -- "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -DDEBUG" -- CACHE STRING -- "Flags for Debug builds" --) --# note: no '-s' here unlike other CMakeLists.txt --set(CMAKE_CXX_FLAGS_RELEASE -- "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG" -- CACHE STRING -- "Flags for Release builds" --) --set(CMAKE_CXX_FLAGS_RELWITHDEBINFO -- "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG" -- CACHE STRING -- "Flags for RelWithDebInfo builds" --) --set(CMAKE_CXX_FLAGS_MINSIZEREL -- "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG" -- CACHE STRING -- "Flags for MinSizeRel builds" --) -+add_compile_options(-Wall -Wextra) - - # Required Defines first: - diff --git a/pkgs/development/rocm-modules/rdc/fix-libcap-pkgconfig.patch b/pkgs/development/rocm-modules/rdc/fix-libcap-pkgconfig.patch deleted file mode 100644 index 54e7303ce88f3..0000000000000 --- a/pkgs/development/rocm-modules/rdc/fix-libcap-pkgconfig.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 299f2c770ff0abf07b8f394f154168d2aa78aa60 Mon Sep 17 00:00:00 2001 -From: Luna Nova -Date: Sun, 21 Dec 2025 08:23:01 -0800 -Subject: [PATCH] fix(rdc): use pkg-config to find libcap - -If libcap isn't available in system wide FHS include paths building would fail. -Fix this by using pkg-config to find libcap which provides both the library -to link and include dirs. ---- - CMakeLists.txt | 6 +++--- - rdc_libs/rdc/CMakeLists.txt | 2 +- - server/CMakeLists.txt | 2 +- - 3 files changed, 5 insertions(+), 5 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 907c9fbff42..00e0a9dd87d 100755 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -192,9 +192,9 @@ mark_as_advanced( - CPACK_GENERATOR - ) - --# check if libcap exists --# needed for sys/capabilities.h --find_library(LIB_CAP NAMES cap REQUIRED) -+# needed for sys/capability.h -+find_package(PkgConfig REQUIRED) -+pkg_check_modules(LIBCAP REQUIRED IMPORTED_TARGET libcap) - - if(BUILD_STANDALONE AND GRPC_ROOT STREQUAL GRPC_ROOT_DEFAULT) - message( -diff --git a/rdc_libs/rdc/CMakeLists.txt b/rdc_libs/rdc/CMakeLists.txt -index d4e368edca5..f9a3ac4c487 100644 ---- a/rdc_libs/rdc/CMakeLists.txt -+++ b/rdc_libs/rdc/CMakeLists.txt -@@ -71,7 +71,7 @@ set(RDC_LIB_INC_LIST - message("RDC_LIB_INC_LIST=${RDC_LIB_INC_LIST}") - - add_library(${RDC_LIB} SHARED ${RDC_LIB_SRC_LIST} ${RDC_LIB_INC_LIST}) --target_link_libraries(${RDC_LIB} ${BOOTSTRAP_LIB} pthread amd_smi cap) -+target_link_libraries(${RDC_LIB} ${BOOTSTRAP_LIB} pthread amd_smi PkgConfig::LIBCAP) - target_include_directories( - ${RDC_LIB} - PRIVATE "${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/include" "${AMD_SMI_INCLUDE_DIR}" -diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt -index baf0d851c86..0a6e71dda1c 100755 ---- a/server/CMakeLists.txt -+++ b/server/CMakeLists.txt -@@ -97,7 +97,7 @@ target_link_libraries( - pthread - rt - gRPC::grpc++ -- cap -+ PkgConfig::LIBCAP - dl - amd_smi - rdc_bootstrap diff --git a/pkgs/development/rocm-modules/rocalution/default.nix b/pkgs/development/rocm-modules/rocalution/default.nix deleted file mode 100644 index 8fd50e6fc589b..0000000000000 --- a/pkgs/development/rocm-modules/rocalution/default.nix +++ /dev/null @@ -1,122 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - rocblas, - rocsparse, - rocprim, - rocrand, - clr, - pkg-config, - openmp, - openmpi, - gtest, - buildTests ? false, - buildBenchmarks ? false, - buildSamples ? false, - gpuTargets ? clr.localGpuTargets or [ ], # gpuTargets = [ "gfx803" "gfx900:xnack-" "gfx906:xnack-" ... ] -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocalution"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildTests [ - "test" - ] - ++ lib.optionals buildBenchmarks [ - "benchmark" - ] - ++ lib.optionals buildSamples [ - "sample" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocALUTION"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-yPM26e8tGNpPScIriAPRb+6OZfdpX4PgE0E9bmc3FkU="; - }; - - nativeBuildInputs = [ - cmake - rocm-cmake - clr - pkg-config - ]; - - buildInputs = [ - rocblas - rocsparse - rocprim - rocrand - openmp - openmpi - ] - ++ lib.optionals buildTests [ - gtest - ]; - - cmakeFlags = [ - "-DROCM_PATH=${clr}" - "-DHIP_ROOT_DIR=${clr}" - "-DSUPPORT_HIP=ON" - "-DSUPPORT_OMP=ON" - "-DSUPPORT_MPI=ON" - "-DBUILD_CLIENTS_SAMPLES=${if buildSamples then "ON" else "OFF"}" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ] - ++ lib.optionals (gpuTargets != [ ]) [ - "-DAMDGPU_TARGETS=${lib.strings.concatStringsSep ";" gpuTargets}" - "-DGPU_TARGETS=${lib.strings.concatStringsSep ";" gpuTargets}" - ] - ++ lib.optionals buildTests [ - "-DBUILD_CLIENTS_TESTS=ON" - ] - ++ lib.optionals buildBenchmarks [ - "-DBUILD_CLIENTS_BENCHMARKS=ON" - ]; - - postInstall = - lib.optionalString buildTests '' - mkdir -p $test/bin - mv $out/bin/rocalution-test $test/bin - '' - + lib.optionalString buildBenchmarks '' - mkdir -p $benchmark/bin - mv $out/bin/rocalution-bench $benchmark/bin - '' - + lib.optionalString buildSamples '' - mkdir -p $sample/bin - mv clients/staging/* $sample/bin - rm $sample/bin/rocalution-test || true - rm $sample/bin/rocalution-bench || true - - patchelf --set-rpath \ - $out/lib:${lib.makeLibraryPath (finalAttrs.buildInputs ++ [ clr ])} \ - $sample/bin/* - '' - + lib.optionalString (buildTests || buildBenchmarks) '' - rmdir $out/bin - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "Iterative sparse solvers for ROCm"; - homepage = "https://github.com/ROCm/rocALUTION"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocblas/default.nix b/pkgs/development/rocm-modules/rocblas/default.nix deleted file mode 100644 index 0e9d0485a2c6b..0000000000000 --- a/pkgs/development/rocm-modules/rocblas/default.nix +++ /dev/null @@ -1,208 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - fetchpatch, - rocmUpdateScript, - cmake, - rocm-cmake, - clr, - diffutils, - python3, - tensile, - boost, - msgpack-cxx, - libxml2, - gtest, - gfortran, - openmp, - gitMinimal, - amd-blis, - zstd, - roctracer, - hipblas-common, - hipblaslt, - python3Packages, - rocm-smi, - pkg-config, - removeReferencesTo, - buildTensile ? true, - buildTests ? true, - buildBenchmarks ? true, - tensileSepArch ? true, - tensileLazyLib ? true, - withHipBlasLt ? true, - gpuTargets ? (clr.localGpuTargets or clr.gpuTargets), -}: - -let - gpuTargets' = lib.concatStringsSep ";" gpuTargets; -in -stdenv.mkDerivation (finalAttrs: { - pname = "rocblas${clr.gpuArchSuffix}"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/rocblas" - "shared" - ]; - hash = "sha256-wrjcr2ASSF+bk5atjvKfIYSbg+vevo/a2W2ca9Nft/4="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rocblas"; - - outputs = [ "out" ] ++ lib.optional buildBenchmarks "benchmark" ++ lib.optional buildTests "test"; - - nativeBuildInputs = [ - cmake - # no ninja, it buffers console output and nix times out long periods of no output - rocm-cmake - clr - gitMinimal - pkg-config - removeReferencesTo - ] - ++ lib.optionals buildTensile [ - tensile - ]; - - buildInputs = [ - python3 - hipblas-common - roctracer - openmp - amd-blis - ] - ++ lib.optionals withHipBlasLt [ - hipblaslt - ] - ++ lib.optionals buildTensile [ - zstd - msgpack-cxx - libxml2 - python3Packages.msgpack - python3Packages.zstandard - ] - ++ lib.optionals (buildTests || buildBenchmarks) [ - gtest - gfortran - rocm-smi - ] - ++ lib.optionals (buildTensile || buildTests || buildBenchmarks) [ - python3Packages.pyyaml - ]; - - env.CXXFLAGS = "-fopenmp -I${lib.getDev boost}/include -I${hipblas-common}/include -I${roctracer}/include"; - # Fails to link tests with undefined symbol: cblas_* - env.LDFLAGS = - "-Wl,--as-needed -lzstd" + lib.optionalString (buildTests || buildBenchmarks) " -lcblas"; - env.TENSILE_ROCM_ASSEMBLER_PATH = "${stdenv.cc}/bin/clang++"; - - cmakeFlags = [ - (lib.cmakeFeature "Boost_INCLUDE_DIR" "${lib.getDev boost}/include") # msgpack FindBoost fails to find boost - (lib.cmakeFeature "CMAKE_EXECUTE_PROCESS_COMMAND_ECHO" "STDERR") - (lib.cmakeFeature "CMAKE_Fortran_COMPILER" "${lib.getBin gfortran}/bin/gfortran") - (lib.cmakeFeature "CMAKE_Fortran_COMPILER_AR" "${lib.getBin gfortran}/bin/ar") - (lib.cmakeFeature "CMAKE_Fortran_COMPILER_RANLIB" "${lib.getBin gfortran}/bin/ranlib") - (lib.cmakeFeature "python" "python3") - (lib.cmakeFeature "SUPPORTED_TARGETS" gpuTargets') - (lib.cmakeFeature "AMDGPU_TARGETS" gpuTargets') - (lib.cmakeFeature "GPU_TARGETS" gpuTargets') - (lib.cmakeBool "BUILD_WITH_TENSILE" buildTensile) - (lib.cmakeBool "ROCM_SYMLINK_LIBS" false) - (lib.cmakeFeature "ROCBLAS_TENSILE_LIBRARY_DIR" "lib/rocblas") - (lib.cmakeBool "BUILD_WITH_HIPBLASLT" withHipBlasLt) - (lib.cmakeBool "BUILD_CLIENTS_TESTS" buildTests) - (lib.cmakeBool "BUILD_CLIENTS_BENCHMARKS" buildBenchmarks) - (lib.cmakeBool "BUILD_CLIENTS_SAMPLES" buildBenchmarks) - (lib.cmakeBool "BUILD_OFFLOAD_COMPRESS" true) - # # Temporarily set variables to work around upstream CMakeLists issue - # # Can be removed once https://github.com/ROCm/rocm-cmake/issues/121 is fixed - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - "-DCMAKE_INSTALL_LIBDIR=lib" - ] - ++ lib.optionals buildTensile [ - "-DCPACK_SET_DESTDIR=OFF" - "-DLINK_BLIS=ON" - "-DBLAS_LIBRARY=${amd-blis}/lib/libblis-mt.so" - "-DBLIS_INCLUDE_DIR=${amd-blis}/include/blis/" - "-DBLA_PREFER_PKGCONFIG=ON" - "-DTensile_CODE_OBJECT_VERSION=default" - "-DTensile_LOGIC=asm_full" - "-DTensile_LIBRARY_FORMAT=msgpack" - (lib.cmakeBool "BUILD_WITH_PIP" false) - (lib.cmakeBool "Tensile_SEPARATE_ARCHITECTURES" tensileSepArch) - (lib.cmakeBool "Tensile_LAZY_LIBRARY_LOADING" tensileLazyLib) - ]; - - patches = [ - (fetchpatch { - name = "Extend-rocBLAS-HIP-ISA-compatibility.patch"; - url = "https://github.com/GZGavinZhao/rocm-libraries/commit/49f21f3cfe7eb4b8ac724eef81fa2cae97a3c22e.patch"; - hash = "sha256-vAVVpTwt49lGHu2YopR1X68v5LwFOjUYuSC4ucBpFGg="; - relative = "projects/rocblas"; - }) - ]; - - # Pass $NIX_BUILD_CORES to Tensile - postPatch = '' - substituteInPlace cmake/build-options.cmake \ - --replace-fail 'Tensile_CPU_THREADS ""' 'Tensile_CPU_THREADS "$ENV{NIX_BUILD_CORES}"' - '' - # Workaround: libblis detection uses broken absolute paths - # TODO: upstream a proper fix - + '' - substituteInPlace clients/CMakeLists.txt \ - --replace-fail "if ( NOT WIN32 )" "if(OFF)" \ - --replace-fail "else() # WIN32" "elseif(OFF)" - '' - # Fixes sh: line 1: /usr/bin/diff: No such file or directory - # /build/source/clients/gtest/../include/testing_logging.hpp:1117: Failure - + lib.optionalString buildTests '' - substituteInPlace clients/include/testing_logging.hpp \ - --replace-fail "/usr/bin/diff" "${lib.getExe' diffutils "diff"}" - ''; - - postInstall = - # tensile isn't needed at runtime and pulls in ~400MB of python deps - '' - remove-references-to -t ${tensile} \ - "$out/lib/librocblas.so."* - '' - + lib.optionalString buildBenchmarks '' - moveToOutput "bin/*-tune" "$benchmark" - moveToOutput "bin/*-bench" "$benchmark" - moveToOutput "bin/*example*" "$benchmark" - cp "$out/bin/"*.{yaml,txt} "$benchmark/bin" - '' - + lib.optionalString buildTests '' - moveToOutput "bin/*test*" "$test" - cp "$out/bin/"*.{yaml,txt} "$test/bin" - '' - + '' - if [ -d $out/bin ]; then - rm $out/bin/*.{yaml,txt} || true - rmdir $out/bin - fi - ''; - - passthru = { - amdgpu_targets = gpuTargets'; - updateScript = rocmUpdateScript { inherit finalAttrs; }; - }; - - enableParallelBuilding = true; - requiredSystemFeatures = [ "big-parallel" ]; - - meta = { - description = "BLAS implementation for ROCm platform"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocblas"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocblas/hiplaslt-unstable-compat.patch b/pkgs/development/rocm-modules/rocblas/hiplaslt-unstable-compat.patch deleted file mode 100644 index 4d8c885c8d398..0000000000000 --- a/pkgs/development/rocm-modules/rocblas/hiplaslt-unstable-compat.patch +++ /dev/null @@ -1,99 +0,0 @@ -diff --git a/library/src/hipblaslt_host.cpp b/library/src/hipblaslt_host.cpp -index 8080070c..97d5216e 100644 ---- a/library/src/hipblaslt_host.cpp -+++ b/library/src/hipblaslt_host.cpp -@@ -155,22 +155,22 @@ namespace - hipblaslt_compute_type); - - hipblaslt_ext::GemmProblemType problemType; -- problemType.op_a = (hipblasOperation_t)prob.trans_a; -- problemType.op_b = (hipblasOperation_t)prob.trans_b; -- problemType.type_a = hipblaslt_datatype; -- problemType.type_b = hipblaslt_datatype; -- problemType.type_c = hipblaslt_datatype; -- problemType.type_d = hipblaslt_datatype; -- problemType.type_compute = hipblaslt_compute_type; -+ problemType.setOpA((hipblasOperation_t)prob.trans_a); -+ problemType.setOpB((hipblasOperation_t)prob.trans_b); -+ problemType.setTypeA(hipblaslt_datatype); -+ problemType.setTypeB(hipblaslt_datatype); -+ problemType.setTypeC(hipblaslt_datatype); -+ problemType.setTypeD(hipblaslt_datatype); -+ problemType.setTypeCompute(hipblaslt_compute_type); - - hipblaslt_ext::GemmEpilogue epilogue; - hipblaslt_ext::GemmInputs inputs; -- inputs.a = (void*)(prob.A + prob.buffer_offset_a); -- inputs.b = (void*)(prob.B + prob.buffer_offset_b); -- inputs.c = (void*)(prob.C + prob.buffer_offset_c); -- inputs.d = (void*)(prob.D + prob.buffer_offset_d); -- inputs.alpha = (void*)prob.alpha; -- inputs.beta = (void*)prob.beta; -+ inputs.setA((void*)(prob.A + prob.buffer_offset_a)); -+ inputs.setB((void*)(prob.B + prob.buffer_offset_b)); -+ inputs.setC((void*)(prob.C + prob.buffer_offset_c)); -+ inputs.setD((void*)(prob.D + prob.buffer_offset_d)); -+ inputs.setAlpha((void*)prob.alpha); -+ inputs.setBeta((void*)prob.beta); - - gemm.setProblem(prob.m, - prob.n, -@@ -214,13 +214,13 @@ namespace - hipblaslt_compute_type); - - hipblaslt_ext::GemmProblemType problemType; -- problemType.op_a = (hipblasOperation_t)prob.trans_a; -- problemType.op_b = (hipblasOperation_t)prob.trans_b; -- problemType.type_a = hipblaslt_datatype; -- problemType.type_b = hipblaslt_datatype; -- problemType.type_c = hipblaslt_datatype; -- problemType.type_d = hipblaslt_datatype; -- problemType.type_compute = hipblaslt_compute_type; -+ problemType.setOpA((hipblasOperation_t)prob.trans_a); -+ problemType.setOpB((hipblasOperation_t)prob.trans_b); -+ problemType.setTypeA(hipblaslt_datatype); -+ problemType.setTypeB(hipblaslt_datatype); -+ problemType.setTypeC(hipblaslt_datatype); -+ problemType.setTypeD(hipblaslt_datatype); -+ problemType.setTypeCompute(hipblaslt_compute_type); - - std::vector Ms(prob.batch_count); - std::vector Ns(prob.batch_count); -@@ -251,12 +251,12 @@ namespace - stridecs[batch] = prob.batch_stride_c; - strideds[batch] = prob.batch_stride_d; - batch_counts[batch] = 1; -- inputs[batch].a = (void*)(prob.batch_A[batch] + prob.buffer_offset_a); -- inputs[batch].b = (void*)(prob.batch_B[batch] + prob.buffer_offset_b); -- inputs[batch].c = (void*)(prob.batch_C[batch] + prob.buffer_offset_c); -- inputs[batch].d = (void*)(prob.batch_D[batch] + prob.buffer_offset_d); -- inputs[batch].alpha = (void*)prob.alpha; -- inputs[batch].beta = (void*)prob.beta; -+ inputs[batch].setA((void*)(prob.batch_A[batch] + prob.buffer_offset_a)); -+ inputs[batch].setB((void*)(prob.batch_B[batch] + prob.buffer_offset_b)); -+ inputs[batch].setC((void*)(prob.batch_C[batch] + prob.buffer_offset_c)); -+ inputs[batch].setD((void*)(prob.batch_D[batch] + prob.buffer_offset_d)); -+ inputs[batch].setAlpha((void*)prob.alpha); -+ inputs[batch].setBeta((void*)prob.beta); - } - - gemm.setProblem(Ms, -diff --git a/library/src/tensile_host.cpp b/library/src/tensile_host.cpp -index 1b1289f3..ed463725 100644 ---- a/library/src/tensile_host.cpp -+++ b/library/src/tensile_host.cpp -@@ -271,14 +271,6 @@ namespace - { - return Tensile::LazyLoadingInit::gfx90a; - } -- else if(deviceString.find("gfx940") != std::string::npos) -- { -- return Tensile::LazyLoadingInit::gfx940; -- } -- else if(deviceString.find("gfx941") != std::string::npos) -- { -- return Tensile::LazyLoadingInit::gfx941; -- } - else if(deviceString.find("gfx942") != std::string::npos) - { - return Tensile::LazyLoadingInit::gfx942; diff --git a/pkgs/development/rocm-modules/rocdbgapi/default.nix b/pkgs/development/rocm-modules/rocdbgapi/default.nix deleted file mode 100644 index 8cceaa35137b3..0000000000000 --- a/pkgs/development/rocm-modules/rocdbgapi/default.nix +++ /dev/null @@ -1,109 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - rocm-comgr, - rocm-runtime, - hwdata, - texliveSmall, - doxygen, - graphviz, - writableTmpDirAsHomeHook, - buildDocs ? true, -}: - -let - latex = lib.optionalAttrs buildDocs ( - texliveSmall.withPackages ( - ps: with ps; [ - changepage - latexmk - varwidth - multirow - hanging - adjustbox - collectbox - stackengine - enumitem - alphalph - wasysym - sectsty - tocloft - newunicodechar - etoc - helvetic - wasy - courier - tabularray - ltablex - ninecolors - xltabular - ] - ) - ); -in -stdenv.mkDerivation (finalAttrs: { - pname = "rocdbgapi"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildDocs [ - "doc" - ]; - - buildFlags = lib.optionals buildDocs [ "doc" ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "ROCdbgapi"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-KqvhwfIv8pbr8WbnfAKl71fg5yxbwYcpzZcGU9Htdkc="; - }; - - nativeBuildInputs = [ - cmake - rocm-cmake - ] - ++ lib.optionals buildDocs [ - writableTmpDirAsHomeHook - latex - doxygen - graphviz - ]; - - buildInputs = [ - rocm-comgr - rocm-runtime - hwdata - ]; - - cmakeFlags = [ - "-DPCI_IDS_PATH=${hwdata}/share/hwdata" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ]; - - postInstall = lib.optionalString buildDocs '' - mkdir -p $doc/share/doc/amd-dbgapi/ - mv $out/share/html/amd-dbgapi $doc/share/doc/amd-dbgapi/html - rmdir $out/share/html - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "Debugger support for control of execution and inspection state of AMD's GPU architectures"; - homepage = "https://github.com/ROCm/ROCdbgapi"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocfft/default.nix b/pkgs/development/rocm-modules/rocfft/default.nix deleted file mode 100644 index c48529ac5a831..0000000000000 --- a/pkgs/development/rocm-modules/rocfft/default.nix +++ /dev/null @@ -1,170 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - clr, - python3, - rocm-cmake, - sqlite, - boost, - fftw, - fftwFloat, - gtest, - openmp, - rocrand, - hiprand, - gpuTargets ? clr.localGpuTargets or clr.gpuTargets, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocfft${clr.gpuArchSuffix}"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/rocfft" - "shared" - ]; - hash = "sha256-RjWMzLX0nBA8ClweJ8YgRTn+Nzt/VUkOoSw3jMQ3IWg="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rocfft"; - - nativeBuildInputs = [ - cmake - clr - python3 - rocm-cmake - ]; - - buildInputs = [ - sqlite - hiprand - ]; - - patches = [ - # Fixes build timeout due to no log output during rocfft_aot step - ./log-every-n-aot-jobs.patch - ]; - - cmakeFlags = [ - "-DSQLITE_USE_SYSTEM_PACKAGE=ON" - "-DHIP_PLATFORM=amd" - "-DBUILD_CLIENTS=OFF" - "-DBUILD_SHARED_LIBS=ON" - "-DUSE_HIPRAND=ON" - "-DROCFFT_KERNEL_CACHE_ENABLE=ON" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ] - ++ lib.optionals (gpuTargets != [ ]) [ - "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - ]; - - passthru = { - test = stdenv.mkDerivation { - pname = "${finalAttrs.pname}-test"; - inherit (finalAttrs) version src; - - sourceRoot = "${finalAttrs.src.name}/projects/rocfft/clients/tests"; - - nativeBuildInputs = [ - cmake - clr - rocm-cmake - ]; - - buildInputs = [ - boost - fftw - fftwFloat - finalAttrs.finalPackage - gtest - openmp - rocrand - hiprand - ]; - - postInstall = '' - rm -r "$out/lib/fftw" - rmdir "$out/lib" - ''; - }; - - benchmark = stdenv.mkDerivation { - pname = "${finalAttrs.pname}-benchmark"; - inherit (finalAttrs) version src; - - sourceRoot = "${finalAttrs.src.name}/projects/rocfft/clients/rider"; - - nativeBuildInputs = [ - cmake - clr - rocm-cmake - ]; - - buildInputs = [ - boost - finalAttrs.finalPackage - openmp - (python3.withPackages ( - ps: with ps; [ - pandas - scipy - ] - )) - rocrand - ]; - - postInstall = '' - cp -a ../../../scripts/perf "$out/bin" - ''; - }; - - samples = stdenv.mkDerivation { - pname = "${finalAttrs.pname}-samples"; - inherit (finalAttrs) version src; - - sourceRoot = "${finalAttrs.src.name}/projects/rocfft/clients/samples"; - - nativeBuildInputs = [ - cmake - clr - rocm-cmake - ]; - - buildInputs = [ - boost - finalAttrs.finalPackage - openmp - rocrand - ]; - - installPhase = '' - runHook preInstall - mkdir "$out" - cp -a bin "$out" - runHook postInstall - ''; - }; - - updateScript = rocmUpdateScript { inherit finalAttrs; }; - }; - - requiredSystemFeatures = [ "big-parallel" ]; - - meta = { - description = "FFT implementation for ROCm"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocfft"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocfft/log-every-n-aot-jobs.patch b/pkgs/development/rocm-modules/rocfft/log-every-n-aot-jobs.patch deleted file mode 100644 index 266f495d3e7c0..0000000000000 --- a/pkgs/development/rocm-modules/rocfft/log-every-n-aot-jobs.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/library/src/rocfft_aot_helper.cpp b/library/src/rocfft_aot_helper.cpp -index f0a889f4..452eb37f 100644 ---- a/library/src/rocfft_aot_helper.cpp -+++ b/library/src/rocfft_aot_helper.cpp -@@ -771,26 +771,22 @@ int main(int argc, char** argv) - for(size_t i = 0; i < NUM_THREADS; ++i) - { - threads.emplace_back([&queue, &gpu_archs]() { -+ int compile_count = 0; - while(true) - { - auto item = queue.pop(); - if(item.kernel_name.empty()) - break; - -+ if(++compile_count % 16 == 0) -+ std::cerr << "rocfft_aot_helper processing " << item.kernel_name << std::endl << std::flush; - for(const auto& gpu_arch : gpu_archs) - { -- if(item.sol_arch_name.empty()) -+ if(item.sol_arch_name.empty() || gpu_arch.find(item.sol_arch_name) != std::string::npos) - { - RTCCache::cached_compile( - item.kernel_name, gpu_arch, item.generate_src, generator_sum()); - } -- else if(gpu_arch.find(item.sol_arch_name) != std::string::npos) -- { -- // std::cout << "arch: " << gpu_arch -- // << ", solution-kernel: " << item.kernel_name << std::endl; -- RTCCache::cached_compile( -- item.kernel_name, gpu_arch, item.generate_src, generator_sum()); -- } - } - } - }); diff --git a/pkgs/development/rocm-modules/rocgdb/default.nix b/pkgs/development/rocm-modules/rocgdb/default.nix deleted file mode 100644 index 918f624b673d2..0000000000000 --- a/pkgs/development/rocm-modules/rocgdb/default.nix +++ /dev/null @@ -1,113 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - pkg-config, - texinfo, - bison, - flex, - glibc, - zlib, - zstd, - gmp, - mpfr, - ncurses, - expat, - rocdbgapi, - perl, - python3, - babeltrace, - sourceHighlight, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocgdb"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "ROCgdb"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-oml/HLExnnjh7+axeWPZRWecpwK2BnzVOaGvXYhrxKs="; - }; - - nativeBuildInputs = [ - pkg-config - texinfo # For makeinfo - bison - flex - perl # used in mkinstalldirs script during installPhase - python3 - ]; - - buildInputs = [ - zlib - zstd - gmp - mpfr - ncurses - expat - rocdbgapi - python3 - babeltrace - sourceHighlight - ]; - - configureFlags = [ - # Ensure we build the amdgpu target - "--enable-targets=${stdenv.targetPlatform.config},amdgcn-amd-amdhsa" - "--with-amd-dbgapi=yes" - - "--with-iconv-path=${glibc.bin}" - "--enable-tui" - "--with-babeltrace=${babeltrace}" - "--with-python=python3" - "--with-system-zlib" - "--with-system-zstd" - "--enable-64-bit-bfd" - "--with-gmp=${gmp.dev}" - "--with-mpfr=${mpfr.dev}" - "--with-expat=${expat}" - - # So the installed binary is called "rocgdb" instead on plain "gdb" - "--program-prefix=roc" - - # Disable building many components not used or incompatible with the amdgcn target - "--disable-sim" - "--disable-gdbserver" - "--disable-ld" - "--disable-gas" - "--disable-gdbserver" - "--disable-gdbtk" - "--disable-gprofng" - "--disable-shared" - ]; - - postPatch = '' - for file in *; do - if [ -f "$file" ]; then - patchShebangs "$file" - fi - done - ''; - - # The source directory for ROCgdb (based on upstream GDB) contains multiple project - # of GNU’s toolchain (binutils and onther), we only need to install the GDB part. - installPhase = '' - make install-gdb - ''; - - env.CFLAGS = "-Wno-switch -Wno-format-nonliteral -I${zstd.dev}/include -I${zlib.dev}/include -I${expat.dev}/include -I${ncurses.dev}/include"; - env.CXXFLAGS = finalAttrs.env.CFLAGS; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "ROCm source-level debugger for Linux, based on GDB"; - homepage = "https://github.com/ROCm/ROCgdb"; - license = lib.licenses.gpl3Plus; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocm-cmake/default.nix b/pkgs/development/rocm-modules/rocm-cmake/default.nix deleted file mode 100644 index dac12d5d0fccc..0000000000000 --- a/pkgs/development/rocm-modules/rocm-cmake/default.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - rocm-core, - cmake, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocm-cmake"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-cmake"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-gY6jzIIN1pSXGbCMN6y35Q/VJgbIqWDRjD8aI/fc1L0="; - }; - - nativeBuildInputs = [ cmake ]; - - buildInputs = [ rocm-core ]; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "CMake modules for common build tasks for the ROCm stack"; - homepage = "https://github.com/ROCm/rocm-cmake"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.unix; - }; -}) diff --git a/pkgs/development/rocm-modules/rocm-comgr/default.nix b/pkgs/development/rocm-modules/rocm-comgr/default.nix deleted file mode 100644 index e7663a1f7130a..0000000000000 --- a/pkgs/development/rocm-modules/rocm-comgr/default.nix +++ /dev/null @@ -1,88 +0,0 @@ -{ - lib, - stdenv, - fetchpatch, - cmake, - llvm, - python3, - rocm-device-libs, - zlib, - zstd, -}: - -let - llvmNativeTarget = - if stdenv.hostPlatform.isx86_64 then - "X86" - else if stdenv.hostPlatform.isAarch64 then - "AArch64" - else - throw "Unsupported ROCm LLVM platform"; -in -stdenv.mkDerivation (finalAttrs: { - pname = "rocm-comgr"; - # In-tree with ROCm LLVM - inherit (llvm.llvm) version; - src = llvm.llvm.monorepoSrc; - sourceRoot = "${finalAttrs.src.name}/amd/comgr"; - strictDeps = true; - - patches = [ - # [Comgr] Extend ISA compatibility - (fetchpatch { - hash = "sha256-X2VPGigK582J+a/u2Kg74w25/+CTpVWU9D3Eqgnb2PU="; - url = "https://github.com/GZGavinZhao/rocm-llvm-project/commit/7002dc04863d38c57cfd2e6fc60a1cf5a613fd8e.patch"; - relative = "amd/comgr"; - }) - # [Comgr] Extend ISA compatibility for CCOB - (fetchpatch { - hash = "sha256-/50I+PqxL3oaQMqg5vR7+ibUcXO1SvfXBdw/sybRt1o="; - url = "https://github.com/GZGavinZhao/rocm-llvm-project/commit/2c1e44fc3eacadcafdd4ada3e3184a092b6f26c5.patch"; - relative = "amd/comgr"; - }) - # Fix: CCOB compat patch used coerced (featureless) name for output filename, - # causing CLR's code_obj_map key to miss when looking up device ISA with features - ./fix-ccob-compat-output-filename.patch - ]; - - postPatch = - # Fix relative path assumption for libllvm - '' - substituteInPlace cmake/opencl_header.cmake \ - --replace-fail "\''${CLANG_CMAKE_DIR}/../../../" "${llvm.clang-unwrapped.lib}" - '' - # Bake LLVM root for cfg/includes or HIPRTC can't find C++ stdlib headers (e.g. ). - + '' - substituteInPlace src/comgr-env.cpp \ - --replace-fail \ - 'return EnvLLVMPath;' \ - 'return EnvLLVMPath ? EnvLLVMPath : "${llvm.rocm-toolchain}";' - ''; - - nativeBuildInputs = [ - cmake - python3 - ]; - - buildInputs = [ - llvm.llvm - llvm.clang-unwrapped - llvm.lld - rocm-device-libs - zlib - zstd - ]; - - cmakeFlags = [ - "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}" - ]; - - meta = { - description = "APIs for compiling and inspecting AMDGPU code objects"; - homepage = "https://github.com/ROCm/ROCm-CompilerSupport/tree/amd-stg-open/lib/comgr"; - license = lib.licenses.ncsa; - maintainers = with lib.maintainers; [ lovesegfault ]; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocm-comgr/fix-ccob-compat-output-filename.patch b/pkgs/development/rocm-modules/rocm-comgr/fix-ccob-compat-output-filename.patch deleted file mode 100644 index 813f419ef3a9b..0000000000000 --- a/pkgs/development/rocm-modules/rocm-comgr/fix-ccob-compat-output-filename.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/src/comgr-compiler.cpp -+++ b/src/comgr-compiler.cpp -@@ -1425,7 +1425,7 @@ - // Add an output file for each target - SmallString<128> OutputFilePath = OutputDir; - sys::path::append(OutputFilePath, -- OutputPrefix + "-" + CompatEntry + "." + FileExtension); -+ OutputPrefix + "-" + Entry + "." + FileExtension); - - BundlerConfig.TargetNames.emplace_back(CompatEntry); - BundlerConfig.OutputFileNames.emplace_back(OutputFilePath); diff --git a/pkgs/development/rocm-modules/rocm-core/default.nix b/pkgs/development/rocm-modules/rocm-core/default.nix deleted file mode 100644 index 861c6107935ee..0000000000000 --- a/pkgs/development/rocm-modules/rocm-core/default.nix +++ /dev/null @@ -1,95 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - writeText, -}: - -# rocm-core is used by most distros for a few purposes: -# - meta package that all rocm packages depend so `apt-get remove rocm-core` removes all rocm packages -# - provide overall ROCM_PATH -# - provide rocm version info and path to rocm version headers -# only the last usage makes sense in nixpkgs -let - padIfSingle = s: if lib.stringLength s == 1 then "0${s}" else s; -in -stdenv.mkDerivation (finalAttrs: { - pname = "rocm-core"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/rocm-core" - "shared" - ]; - hash = "sha256-Y3WuDwruD5zKN2epwfUCZAGq5vgxCT27awJN8JxmOsY="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rocm-core"; - - patches = [ - ./env-rocm-path.patch - ]; - - nativeBuildInputs = [ cmake ]; - env = { - ROCM_LIBPATCH_VERSION = "${lib.versions.major finalAttrs.version}${padIfSingle (lib.versions.minor finalAttrs.version)}${padIfSingle (lib.versions.patch finalAttrs.version)}"; - BUILD_ID = "nixpkgs-${finalAttrs.env.ROCM_LIBPATCH_VERSION}"; - ROCM_BUILD_ID = "${finalAttrs.env.BUILD_ID}"; - }; - cmakeFlags = [ - "-DROCM_LIBPATCH_VERSION=${finalAttrs.env.ROCM_LIBPATCH_VERSION}" - "-DROCM_VERSION=${finalAttrs.version}" - "-DBUILD_ID=${finalAttrs.env.BUILD_ID}" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_LIBEXECDIR=libexec" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - "-DCMAKE_INSTALL_BINDIR=bin" - ]; - - setupHook = writeText "setupHook.sh" '' - export ROCM_VERSION="${finalAttrs.version}" - export ROCM_LIBPATCH_VERSION="${finalAttrs.env.ROCM_LIBPATCH_VERSION}" - export ROCM_BUILD_ID="${finalAttrs.env.ROCM_BUILD_ID}" - ''; - - doInstallCheck = true; - preInstallCheck = - # Test that the CMake config file can be included and sets expected vars - '' - mkdir test_project - pushd test_project - - echo ' - cmake_minimum_required(VERSION 3.16) - project(test_rocm_core) - find_package(rocm-core REQUIRED) - if(NOT DEFINED ROCM_CORE_INCLUDE_DIR) - message(FATAL_ERROR "ROCM_CORE_INCLUDE_DIR not set") - endif() - message(STATUS "Found ROCM_CORE_INCLUDE_DIR: ''${ROCM_CORE_INCLUDE_DIR}") - message(STATUS "Found ROCM_PATH: ''${ROCM_PATH}") - ' > CMakeLists.txt - - CMAKE_PREFIX_PATH="$out" cmake . - popd - - . $out/nix-support/setup-hook - env | grep '^ROCM' - ''; - - passthru.ROCM_LIBPATCH_VERSION = finalAttrs.env.ROCM_LIBPATCH_VERSION; - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "Utility for getting the ROCm release version"; - homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/rocm-core"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocm-core/env-rocm-path.patch b/pkgs/development/rocm-modules/rocm-core/env-rocm-path.patch deleted file mode 100644 index a40fa33b90cec..0000000000000 --- a/pkgs/development/rocm-modules/rocm-core/env-rocm-path.patch +++ /dev/null @@ -1,22 +0,0 @@ -In FHS distros rocm-core expects to be installed colocated with a full set of ROCM packages. -In nixpkgs contexts, we don't want rocm-core to be a ROCM_PATH root. -diff --git a/cmake_modules/rocm-core-config.cmake.in b/cmake_modules/rocm-core-config.cmake.in -index f5fe07c..9d72c9c 100644 ---- a/cmake_modules/rocm-core-config.cmake.in -+++ b/cmake_modules/rocm-core-config.cmake.in -@@ -11,7 +11,14 @@ set_and_check(rocm_core_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") - set_and_check(ROCM_CORE_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") - set_and_check(rocm_core_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") - set_and_check(ROCM_CORE_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") --set_and_check(ROCM_PATH "${PACKAGE_PREFIX_DIR}") -+# Set ROCM_PATH with priority: existing value > environment variable > package prefix -+if(NOT DEFINED ROCM_PATH) -+ if(DEFINED ENV{ROCM_PATH}) -+ set(ROCM_PATH "$ENV{ROCM_PATH}") -+ else() -+ set_and_check(ROCM_PATH "${PACKAGE_PREFIX_DIR}") -+ endif() -+endif() - - get_filename_component(ROCM_CORE_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) - include("${ROCM_CORE_CMAKE_DIR}/rocmCoreTargets.cmake") diff --git a/pkgs/development/rocm-modules/rocm-device-libs/cmake.patch b/pkgs/development/rocm-modules/rocm-device-libs/cmake.patch deleted file mode 100644 index 500ff37a99052..0000000000000 --- a/pkgs/development/rocm-modules/rocm-device-libs/cmake.patch +++ /dev/null @@ -1,43 +0,0 @@ -diff --git a/cmake/Packages.cmake b/cmake/Packages.cmake -index 07c60eb..c736b3e 100644 ---- a/cmake/Packages.cmake -+++ b/cmake/Packages.cmake -@@ -12,24 +12,29 @@ set_target_properties(${target} PROPERTIES - IMPORTED_LOCATION \"${target_path}\")") - endforeach() - configure_file(AMDDeviceLibsConfig.cmake.in -- ${PACKAGE_PREFIX}/AMDDeviceLibsConfig.cmake -+ lib/cmake/AMDDeviceLibs/AMDDeviceLibsConfig.cmake - @ONLY) - - - set(install_path_suffix "amdgcn/bitcode") - - # Generate the install-tree package. --# We do not know the absolute path to the intall tree until we are installed, --# so we calculate it dynamically in AMD_DEVICE_LIBS_PREFIX_CODE and use --# relative paths in the target imports in AMD_DEVICE_LIBS_TARGET_CODE. --set(AMD_DEVICE_LIBS_PREFIX_CODE " -+if(IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}") -+ set(AMD_DEVICE_LIBS_PREFIX_CODE "set(AMD_DEVICE_LIBS_PREFIX \"${CMAKE_INSTALL_PREFIX}\")") -+else() -+ # We do not know the absolute path to the install tree until we are installed, -+ # so we calculate it dynamically in AMD_DEVICE_LIBS_PREFIX_CODE and use -+ # relative paths in the target imports in AMD_DEVICE_LIBS_TARGET_CODE. -+ set(AMD_DEVICE_LIBS_PREFIX_CODE " - # Derive absolute install prefix from config file path. - get_filename_component(AMD_DEVICE_LIBS_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") --string(REGEX REPLACE "/" ";" count "${PACKAGE_PREFIX}") --foreach(p ${count}) -- set(AMD_DEVICE_LIBS_PREFIX_CODE "${AMD_DEVICE_LIBS_PREFIX_CODE} -+ string(REGEX REPLACE "/" ";" count "${PACKAGE_PREFIX}") -+ foreach(p ${count}) -+ set(AMD_DEVICE_LIBS_PREFIX_CODE "${AMD_DEVICE_LIBS_PREFIX_CODE} - get_filename_component(AMD_DEVICE_LIBS_PREFIX \"\${AMD_DEVICE_LIBS_PREFIX}\" PATH)") --endforeach() -+ endforeach() -+endif() -+ - set(AMD_DEVICE_LIBS_TARGET_CODE) - foreach(target ${AMDGCN_LIB_LIST}) - get_target_property(target_name ${target} ARCHIVE_OUTPUT_NAME) diff --git a/pkgs/development/rocm-modules/rocm-device-libs/default.nix b/pkgs/development/rocm-modules/rocm-device-libs/default.nix deleted file mode 100644 index 41034d2c64803..0000000000000 --- a/pkgs/development/rocm-modules/rocm-device-libs/default.nix +++ /dev/null @@ -1,67 +0,0 @@ -{ - lib, - stdenv, - cmake, - ninja, - zlib, - zstd, - llvm, - python3, -}: - -let - llvmNativeTarget = - if stdenv.hostPlatform.isx86_64 then - "X86" - else if stdenv.hostPlatform.isAarch64 then - "AArch64" - else - throw "Unsupported ROCm LLVM platform"; -in -stdenv.mkDerivation (finalAttrs: { - pname = "rocm-device-libs"; - # In-tree with ROCm LLVM - inherit (llvm.llvm) version; - src = llvm.llvm.monorepoSrc; - sourceRoot = "${finalAttrs.src.name}/amd/device-libs"; - strictDeps = true; - __structuredAttrs = true; - - postPatch = - # Use our sysrooted toolchain instead of direct clang target - '' - substituteInPlace cmake/OCL.cmake \ - --replace-fail '$' "${llvm.rocm-toolchain}/bin/clang" - ''; - - patches = [ - ./cmake.patch - ]; - - nativeBuildInputs = [ - cmake - ninja - python3 - llvm.rocm-toolchain - ]; - - buildInputs = [ - llvm.llvm - llvm.clang-unwrapped - zlib - zstd - ]; - - cmakeFlags = [ - "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}" - ]; - - meta = { - description = "Set of AMD-specific device-side language runtime libraries"; - homepage = "https://github.com/ROCm/ROCm-Device-Libs"; - license = lib.licenses.ncsa; - maintainers = with lib.maintainers; [ lovesegfault ]; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocm-runtime/default.nix b/pkgs/development/rocm-modules/rocm-runtime/default.nix deleted file mode 100644 index 255fce0eb24ec..0000000000000 --- a/pkgs/development/rocm-modules/rocm-runtime/default.nix +++ /dev/null @@ -1,109 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - fetchpatch, - rocmUpdateScript, - pkg-config, - cmake, - xxd, - rocm-device-libs, - rocprofiler-register, - elfutils, - libdrm, - numactl, - llvm, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocm-runtime"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/rocr-runtime" - "shared" - ]; - hash = "sha256-hcyjOLMtoBX/p6r6R9Bl9635DuvI6rTn1KziHMeyYM0="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rocr-runtime"; - - cmakeBuildType = "RelWithDebInfo"; - separateDebugInfo = true; - __structuredAttrs = true; - strictDeps = true; - - nativeBuildInputs = [ - pkg-config - cmake - xxd # used by create_hsaco_ascii_file.sh - llvm.rocm-toolchain - ]; - - buildInputs = [ - llvm.clang-unwrapped - llvm.llvm - elfutils - libdrm - numactl - rocprofiler-register - ]; - - cmakeFlags = [ - "-DBUILD_SHARED_LIBS=ON" - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ]; - - patches = [ - # Vendored upstream PR for fix for segfault when queue allocation fails - # https://github.com/ROCm/rocm-systems/pull/2850 - ./queue-failure.patch - (fetchpatch { - # [PATCH] rocr: Extend HIP ISA compatibility check - hash = "sha256-8r2Lb5lBfFaZC3knCxfXGcnkzNv6JxOKyJn2rD5gus4="; - url = "https://github.com/GZGavinZhao/rocm-systems/commit/dcef23cf896f4dcbc7ed81abeaa4ec2208dcdd8c.patch"; - relative = "projects/rocr-runtime"; - }) - (fetchpatch { - # [PATCH] kfd_ioctl: fix UB due to 1 << 31 - url = "https://github.com/ROCm/ROCR-Runtime/commit/41bfc66aef437a5b349f71105fa4b907cc7e17d5.patch"; - hash = "sha256-A7VhPR3eSsmjq2cTBSjBIz9i//WiNjoXm0EsRKtF+ns="; - }) - # This causes a circular dependency, aqlprofile relies on hsa-runtime64 - # which is part of rocm-runtime - # Worked around by having rocprofiler load aqlprofile directly - ./remove-hsa-aqlprofile-dep.patch - ]; - - postPatch = '' - patchShebangs --build \ - runtime/hsa-runtime/core/runtime/trap_handler/create_trap_handler_header.sh \ - runtime/hsa-runtime/core/runtime/blit_shaders/create_blit_shader_header.sh \ - runtime/hsa-runtime/image/blit_src/create_hsaco_ascii_file.sh - patchShebangs --host image core runtime - - substituteInPlace CMakeLists.txt \ - --replace 'hsa/include/hsa' 'include/hsa' - - substituteInPlace runtime/hsa-runtime/image/blit_src/CMakeLists.txt \ - --replace-fail 'COMMAND clang' "COMMAND ${llvm.rocm-toolchain}/bin/clang" - - export HIP_DEVICE_LIB_PATH="${rocm-device-libs}/amdgcn/bitcode" - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "Platform runtime for ROCm"; - homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/rocr-runtime"; - license = lib.licenses.ncsa; - maintainers = with lib.maintainers; [ lovesegfault ]; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocm-runtime/queue-failure.patch b/pkgs/development/rocm-modules/rocm-runtime/queue-failure.patch deleted file mode 100644 index f9087144bc229..0000000000000 --- a/pkgs/development/rocm-modules/rocm-runtime/queue-failure.patch +++ /dev/null @@ -1,71 +0,0 @@ -From b7717446c85d08b2d7c0c60ba3ac0eff11ee6120 Mon Sep 17 00:00:00 2001 -From: Luna Nova -Date: Tue, 20 Jan 2026 12:55:45 -0800 -Subject: [PATCH 1/2] rocm-runtime: fix crash in QueueCreate due to trying to - free non allocated scratch - -if (scratch.main_queue_base != nullptr) before calling ReleaseQueueMainScratch -because ReleaseQueueMainScratch is only valid if main_queue_base is set -and the scope guard can fire for an error allocating the queue. ---- - .../runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -index 01b01fe869..83db40dacc 100644 ---- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -+++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -@@ -1792,7 +1792,9 @@ hsa_status_t GpuAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type, u - scratch.main_queue_base = nullptr; - scratch.main_queue_process_offset = 0; - -- MAKE_NAMED_SCOPE_GUARD(scratchGuard, [&]() { ReleaseQueueMainScratch(scratch); }); -+ MAKE_NAMED_SCOPE_GUARD(scratchGuard, [&]() { -+ if (scratch.main_queue_base != nullptr) ReleaseQueueMainScratch(scratch); -+ }); - - if (scratch.main_size != 0) { - AcquireQueueMainScratch(scratch); --- -2.52.0 - - -From 9c1746cd76a703e4d2321dc2ffe85fc61bfd2f21 Mon Sep 17 00:00:00 2001 -From: Luna Nova -Date: Tue, 20 Jan 2026 13:00:32 -0800 -Subject: [PATCH 2/2] rocm-runtime: log for errors in QueueCreate - ---- - .../runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -diff --git a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -index 83db40dacc..ae68732eb5 100644 ---- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -+++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -@@ -1799,6 +1799,9 @@ hsa_status_t GpuAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type, u - if (scratch.main_size != 0) { - AcquireQueueMainScratch(scratch); - if (scratch.main_queue_base == nullptr) { -+ LogPrint(HSA_AMD_LOG_FLAG_INFO, -+ "Failed to allocate scratch memory for queue, size=%zu, node=%u", -+ scratch.main_size, node_id()); - return HSA_STATUS_ERROR_OUT_OF_RESOURCES; - } - } -@@ -1827,7 +1830,11 @@ hsa_status_t GpuAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type, u - node_id())); - } - -- if (!shared_queue) return HSA_STATUS_ERROR_OUT_OF_RESOURCES; -+ if (!shared_queue) { -+ LogPrint(HSA_AMD_LOG_FLAG_INFO, -+ "Failed to allocate shared queue descriptor memory, node=%u", node_id()); -+ return HSA_STATUS_ERROR_OUT_OF_RESOURCES; -+ } - - auto aql_queue = new AqlQueue(shared_queue, this, size, node_id(), scratch, event_callback, data, - flags); --- -2.52.0 - diff --git a/pkgs/development/rocm-modules/rocm-runtime/remove-hsa-aqlprofile-dep.patch b/pkgs/development/rocm-modules/rocm-runtime/remove-hsa-aqlprofile-dep.patch deleted file mode 100644 index b8ed57d049bc9..0000000000000 --- a/pkgs/development/rocm-modules/rocm-runtime/remove-hsa-aqlprofile-dep.patch +++ /dev/null @@ -1,27 +0,0 @@ -libhsa-amd-aqlprofile64 library is unfree -Bug: https://github.com/ROCm/ROCm/issues/1781 ---- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -+++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp -@@ -1333,11 +1333,6 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const { - setFlag(HSA_EXTENSION_AMD_PC_SAMPLING); - } - -- if (os::LibHandle lib = os::LoadLib(kAqlProfileLib)) { -- os::CloseLib(lib); -- setFlag(HSA_EXTENSION_AMD_AQLPROFILE); -- } -- - setFlag(HSA_EXTENSION_AMD_PROFILER); - - break; ---- a/runtime/hsa-runtime/core/runtime/hsa.cpp -+++ b/runtime/hsa-runtime/core/runtime/hsa.cpp -@@ -490,7 +490,7 @@ hsa_status_t hsa_system_get_major_extension_table(uint16_t extension, uint16_t v - return HSA_STATUS_SUCCESS; - } - -- if (extension == HSA_EXTENSION_AMD_AQLPROFILE) { -+ if (0) { - if (version_major != hsa_ven_amd_aqlprofile_VERSION_MAJOR) { - debug_print("aqlprofile API incompatible ver %d, current ver %d\n", - version_major, hsa_ven_amd_aqlprofile_VERSION_MAJOR); diff --git a/pkgs/development/rocm-modules/rocm-smi/default.nix b/pkgs/development/rocm-modules/rocm-smi/default.nix deleted file mode 100644 index ad53094199161..0000000000000 --- a/pkgs/development/rocm-modules/rocm-smi/default.nix +++ /dev/null @@ -1,78 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - pkg-config, - libdrm, - cmake, - wrapPython, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocm-smi"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/rocm-smi-lib" - "shared" - ]; - hash = "sha256-Si8SbeVKUBtqk6h2QJ9ssQV68bLq6TvESrYXJuArHd8="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rocm-smi-lib"; - - __structuredAttrs = true; - strictDeps = true; - - propagatedBuildInputs = [ - libdrm - ]; - - nativeBuildInputs = [ - cmake - wrapPython - pkg-config - ]; - - cmakeFlags = [ - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") - (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") - (lib.cmakeFeature "CMAKE_INSTALL_LIBEXECDIR" "libexec") - (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") - ]; - - postInstall = - # wrap python programs, but undo two that need to be importable at that path - '' - wrapPythonProgramsIn $out - mv $out/libexec/rocm_smi/.rsmiBindingsInit.py-wrapped $out/libexec/rocm_smi/rsmiBindingsInit.py - mv $out/libexec/rocm_smi/.rsmiBindings.py-wrapped $out/libexec/rocm_smi/rsmiBindings.py - '' - # workaround: propagate libdrm/ manually - # rocm-toolchain doesn't automatically add buildInputs to isystem include path like - # wrapper based toolchains, cmake files often don't find_package(rocm-smi) so - # can't rely on cmake propagated interface - # upstream have been shipping libdrm copied into /opt/rocm - + '' - ln -s ${libdrm.dev}/include/libdrm/ $out/include/ - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "System management interface for AMD GPUs supported by ROCm"; - homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/rocm-smi-lib"; - changelog = "https://github.com/ROCm/rocm-systems/releases/tag/${finalAttrs.src.tag}"; - license = lib.licenses.mit; - mainProgram = "rocm-smi"; - maintainers = with lib.maintainers; [ lovesegfault ]; - teams = [ lib.teams.rocm ]; - platforms = [ "x86_64-linux" ]; - }; -}) diff --git a/pkgs/development/rocm-modules/rocminfo/default.nix b/pkgs/development/rocm-modules/rocminfo/default.nix deleted file mode 100644 index 1cfbe4ddc9b7e..0000000000000 --- a/pkgs/development/rocm-modules/rocminfo/default.nix +++ /dev/null @@ -1,57 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - rocm-runtime, - busybox, - python3, - gnugrep, -}: - -stdenv.mkDerivation (finalAttrs: { - version = "7.2.4"; - pname = "rocminfo"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/rocminfo" - "shared" - ]; - hash = "sha256-0esRBEXVibC2uzyonpc0ABNNHQ2NAWZrBmmg6p1zP0c="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rocminfo"; - - strictDeps = true; - - nativeBuildInputs = [ - cmake - rocm-cmake - python3 - ]; - - buildInputs = [ rocm-runtime ]; - cmakeFlags = [ "-DROCRTST_BLD_TYPE=Release" ]; - - prePatch = '' - patchShebangs rocm_agent_enumerator - sed 's,lsmod | grep ,${busybox}/bin/lsmod | ${gnugrep}/bin/grep ,' -i rocminfo.cc - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "ROCm Application for Reporting System Info"; - homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/rocminfo"; - license = lib.licenses.ncsa; - mainProgram = "rocminfo"; - maintainers = with lib.maintainers; [ lovesegfault ]; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocmlir/default.nix b/pkgs/development/rocm-modules/rocmlir/default.nix deleted file mode 100644 index 5881ec120eaf6..0000000000000 --- a/pkgs/development/rocm-modules/rocmlir/default.nix +++ /dev/null @@ -1,161 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - clr, - libxml2, - libedit, - rocm-comgr, - rocm-device-libs, - rocm-runtime, - zstd, - zlib, - ncurses, - python3Packages, - buildRockCompiler ? false, - buildTests ? false, # `argument of type 'NoneType' is not iterable` -}: - -# FIXME: rocmlir has an entire separate LLVM build in a subdirectory this is silly -# It seems to be forked from AMD's own LLVM -# If possible reusing the rocmPackages.llvm build would be better -# Would have to confirm it is compatible with ROCm's tagged LLVM. -# Fairly likely it's not given AMD's track record with forking their own software in incompatible ways -# in subdirs - -# Theoretically, we could have our MLIR have an output -# with the source and built objects so that we can just -# use it as the external LLVM repo for this -let - suffix = if buildRockCompiler then "-rock" else ""; - - llvmNativeTarget = - if stdenv.hostPlatform.isx86_64 then - "X86" - else if stdenv.hostPlatform.isAarch64 then - "AArch64" - else - throw "Unsupported ROCm LLVM platform"; -in -stdenv.mkDerivation (finalAttrs: { - pname = "rocmlir${suffix}"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals (!buildRockCompiler) [ - "external" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocMLIR"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-1qADqYI5pilXHr/vrS9SvgmTW6KUWXNpG1G+brwD/HI="; - }; - - nativeBuildInputs = [ - clr - cmake - rocm-cmake - python3Packages.python - python3Packages.tomli - ]; - - buildInputs = [ - libxml2 - libedit - rocm-comgr - rocm-runtime - rocm-device-libs - ]; - - propagatedBuildInputs = [ - zstd - zlib - ncurses - ]; - - cmakeFlags = [ - (lib.cmakeFeature "LLVM_TARGETS_TO_BUILD" "AMDGPU${ - lib.optionalString (!buildRockCompiler) ";${llvmNativeTarget}" - }") - (lib.cmakeFeature "LLVM_USE_LINKER" "lld") - (lib.cmakeFeature "LLVM_ENABLE_ZSTD" "FORCE_ON") - (lib.cmakeFeature "LLVM_ENABLE_ZLIB" "FORCE_ON") - (lib.cmakeBool "LLVM_ENABLE_LIBCXX" true) - (lib.cmakeBool "LLVM_ENABLE_TERMINFO" true) - (lib.cmakeFeature "ROCM_PATH" "${clr}") - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") - (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") - (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") - (lib.cmakeBool "MLIR_ENABLE_ROCM_RUNNER" (!buildRockCompiler)) - (lib.cmakeBool "BUILD_FAT_LIBROCKCOMPILER" buildRockCompiler) - ] - ++ lib.optionals buildRockCompiler [ - (lib.cmakeBool "LLVM_INCLUDE_TESTS" false) - ] - ++ lib.optionals (!buildRockCompiler) [ - (lib.cmakeFeature "ROCM_TEST_CHIPSET" "gfx900") - ]; - - postPatch = '' - patchShebangs mlir - patchShebangs external/llvm-project/mlir/lib/Dialect/GPU/AmdDeviceLibsIncGen.py - - # Fixes mlir/lib/Analysis/BufferDependencyAnalysis.cpp:41:19: error: redefinition of 'read' - substituteInPlace mlir/lib/Analysis/BufferDependencyAnalysis.cpp \ - --replace-fail "enum EffectType { read, write, unknown };" "enum class EffectType { read, write, unknown };" - - substituteInPlace mlir/utils/performance/common/CMakeLists.txt \ - --replace-fail " PATHS /opt/rocm" "" - ''; - - dontBuild = true; - doCheck = true; - - # Certain libs aren't being generated, try enabling tests next update - checkTarget = - if buildRockCompiler then - "librockCompiler" - else if buildTests then - "check-rocmlir" - else - "check-rocmlir-build-only"; - - postInstall = - let - libPath = lib.makeLibraryPath [ - zstd - zlib - ncurses - clr - stdenv.cc.cc - ]; - in - lib.optionalString (!buildRockCompiler) '' - mkdir -p $external/lib - cp -a external/llvm-project/llvm/lib/{*.a*,*.so*} $external/lib - patchelf --set-rpath $external/lib:$out/lib:${libPath} $external/lib/*.so* - patchelf --set-rpath $out/lib:$external/lib:${libPath} $out/{bin/*,lib/*.so*} - ''; - - passthru.updateScript = rocmUpdateScript { - inherit finalAttrs; - page = "tags"; - }; - - meta = { - description = "MLIR-based convolution and GEMM kernel generator"; - homepage = "https://github.com/ROCm/rocMLIR"; - license = lib.licenses.asl20; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocprim/default.nix b/pkgs/development/rocm-modules/rocprim/default.nix deleted file mode 100644 index 577cbfb862014..0000000000000 --- a/pkgs/development/rocm-modules/rocprim/default.nix +++ /dev/null @@ -1,97 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - clr, - gtest, - gbenchmark, - buildTests ? false, - buildBenchmarks ? false, - gpuTargets ? clr.localGpuTargets or [ ], -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocprim"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildTests [ - "test" - ] - ++ lib.optionals buildBenchmarks [ - "benchmark" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/rocprim" - "shared" - ]; - hash = "sha256-e0mZ27OXyblcnXQGv2ex/CvWx9smw6nBbHZIijj7lP8="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rocprim"; - - nativeBuildInputs = [ - cmake - rocm-cmake - clr - ]; - - buildInputs = - lib.optionals buildTests [ - gtest - ] - ++ lib.optionals buildBenchmarks [ - gbenchmark - ]; - - cmakeFlags = [ - "-DHIP_CXX_COMPILER=amdclang++" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ] - ++ lib.optionals (gpuTargets != [ ]) [ - "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - ] - ++ lib.optionals buildTests [ - "-DBUILD_TEST=ON" - ] - ++ lib.optionals buildBenchmarks [ - "-DBUILD_BENCHMARK=ON" - ]; - - postInstall = - lib.optionalString buildTests '' - mkdir -p $test/bin - mv $out/bin/test_* $test/bin - mv $out/bin/rocprim $test/bin - '' - + lib.optionalString buildBenchmarks '' - mkdir -p $benchmark/bin - mv $out/bin/benchmark_* $benchmark/bin - '' - + lib.optionalString (buildTests || buildBenchmarks) '' - rmdir $out/bin - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "ROCm parallel primitives"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocprim"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocprof-trace-decoder/default.nix b/pkgs/development/rocm-modules/rocprof-trace-decoder/default.nix deleted file mode 100644 index edc20bfa33976..0000000000000 --- a/pkgs/development/rocm-modules/rocprof-trace-decoder/default.nix +++ /dev/null @@ -1,86 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocm-comgr, - rocm-runtime, - cmake, - python3, - nlohmann_json, - gtest, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocprof-trace-decoder"; - version = "0.1.7"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-systems"; - # No tags (yet?) - rev = "feeca99950c590e0b8228733405c4a1a10fa4773"; - sparseCheckout = [ - "projects/rocprof-trace-decoder" - "shared" - ]; - hash = "sha256-aJhPiZf5380jj2IeCipgcTEQYogr5R19UnVwKRGnkxo="; - }; - - sourceRoot = "${finalAttrs.src.name}/projects/rocprof-trace-decoder"; - - patches = [ - ./use-system-dependencies.patch - # https://github.com/ROCm/rocm-systems/pull/3800 - ./fix-test-dependency.patch - ]; - - strictDeps = true; - - nativeBuildInputs = [ cmake ]; - - buildInputs = [ - rocm-comgr - rocm-runtime - ]; - - cmakeFlags = [ - (lib.cmakeBool "BUILD_TESTS" finalAttrs.finalPackage.doCheck) - ]; - - nativeCheckInputs = [ - python3 - ]; - - checkInputs = [ - nlohmann_json - gtest - ]; - - preCheck = '' - patchShebangs test - ''; - - checkPhase = - let - # Sanitize tests fail because the UBSan runtime (__ubsan_vptr_type_cache) is not available for - # LD_PRELOAD in the sandbox. - skipPattern = "_sanitize$"; - in - '' - runHook preCheck - - ctest --test-dir . --output-on-failure -E '${skipPattern}' - - runHook postCheck - ''; - - doCheck = true; - - meta = { - description = "Library for decoding ROCm thread trace data"; - homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/rocprof-trace-decoder"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocprof-trace-decoder/fix-test-dependency.patch b/pkgs/development/rocm-modules/rocprof-trace-decoder/fix-test-dependency.patch deleted file mode 100644 index 7278ec688094a..0000000000000 --- a/pkgs/development/rocm-modules/rocprof-trace-decoder/fix-test-dependency.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt -index a923cadce53..95a4d3a807f 100644 ---- a/test/CMakeLists.txt -+++ b/test/CMakeLists.txt -@@ -186,7 +186,9 @@ if(BUILD_INTEGRATION_TESTS) - WORKING_DIRECTORY - ${TEST_BIN_DIR} - FIXTURES_REQUIRED -- unpack_data) -+ unpack_data -+ DEPENDS -+ ${DATA}_execute) - endif() - endforeach(DATA) - endif() diff --git a/pkgs/development/rocm-modules/rocprof-trace-decoder/use-system-dependencies.patch b/pkgs/development/rocm-modules/rocprof-trace-decoder/use-system-dependencies.patch deleted file mode 100644 index 1f821a1110882..0000000000000 --- a/pkgs/development/rocm-modules/rocprof-trace-decoder/use-system-dependencies.patch +++ /dev/null @@ -1,81 +0,0 @@ -diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt -index a923cad..53b0f49 100644 ---- a/test/CMakeLists.txt -+++ b/test/CMakeLists.txt -@@ -34,13 +34,7 @@ if(DISABLE_COMGR) - endif() - - if(NOT APPLE AND BUILD_INTEGRATION_TESTS) -- # Add nlohmann JSON as an external dependency -- include(FetchContent) -- FetchContent_Declare( -- json -- GIT_REPOSITORY https://github.com/nlohmann/json.git -- GIT_TAG v3.11.3) -- FetchContent_MakeAvailable(json) -+ find_package(nlohmann_json REQUIRED) - - add_subdirectory(att-tool) - endif() -diff --git a/test/att-tool/CMakeLists.txt b/test/att-tool/CMakeLists.txt -index 208af16..acd161f 100644 ---- a/test/att-tool/CMakeLists.txt -+++ b/test/att-tool/CMakeLists.txt -@@ -1,7 +1,7 @@ - # - # ATT decoder wrapper library for use by the rocprofv3 tool - # --find_library(COMGR REQUIRED NAMES amd_comgr HINTS /opt/rocm/lib) -+find_library(COMGR REQUIRED NAMES amd_comgr) - - set(ATT_TOOL_SOURCE_FILES - waitcnt/analysis.cpp -@@ -19,8 +19,11 @@ set(ATT_TOOL_SOURCE_FILES - - set(DECODER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../source/) - --set(INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../include/ ${DECODER_SRC} ${CMAKE_CURRENT_SOURCE_DIR} ${json_SOURCE_DIR}/include /opt/rocm/include) --set(LINK_LIBS ${COMGR} pthread) -+set(INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../include/ ${DECODER_SRC} ${CMAKE_CURRENT_SOURCE_DIR}) -+find_path(COMGR_INCLUDE_DIR REQUIRED NAMES amd_comgr.h PATH_SUFFIXES amd_comgr) -+find_path(HSA_INCLUDE_DIR REQUIRED NAMES hsa/amd_hsa_elf.h) -+set(LINK_LIBS ${COMGR} pthread nlohmann_json::nlohmann_json) -+list(APPEND INCLUDE_DIRS ${COMGR_INCLUDE_DIR} ${HSA_INCLUDE_DIR}) - - # Sources re-globbed only for sanitizer builds - file(GLOB ATT_DECODER_V3_FILES -diff --git a/test/att-tool/sdk/disassembly.hpp b/test/att-tool/sdk/disassembly.hpp -index c054143..ec3d6d2 100644 ---- a/test/att-tool/sdk/disassembly.hpp -+++ b/test/att-tool/sdk/disassembly.hpp -@@ -22,7 +22,7 @@ - - #pragma once - --#include -+#include - #include - - #include -diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt -index 8adafc0..9501efe 100644 ---- a/test/unit/CMakeLists.txt -+++ b/test/unit/CMakeLists.txt -@@ -9,16 +9,7 @@ project(att-decoder-unit-tests LANGUAGES CXX) - set(CMAKE_CXX_STANDARD 17) - set(CMAKE_CXX_STANDARD_REQUIRED ON) - --# Fetch GoogleTest --include(FetchContent) --FetchContent_Declare( -- googletest -- GIT_REPOSITORY https://github.com/google/googletest.git -- GIT_TAG v1.14.0) --set(INSTALL_GTEST -- OFF -- CACHE BOOL "" FORCE) --FetchContent_MakeAvailable(googletest) -+find_package(GTest REQUIRED) - - enable_testing() - diff --git a/pkgs/development/rocm-modules/rocprofiler-register/default.nix b/pkgs/development/rocm-modules/rocprofiler-register/default.nix deleted file mode 100644 index 710985790d708..0000000000000 --- a/pkgs/development/rocm-modules/rocprofiler-register/default.nix +++ /dev/null @@ -1,97 +0,0 @@ -{ - lib, - stdenv, - numactl, - libpciaccess, - libxml2, - elfutils, - glog, - fmt, - fetchFromGitHub, - rocmUpdateScript, - cmake, - clang, - python3Packages, - fetchpatch, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocprofiler-register"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/rocprofiler-register" - "shared" - ]; - hash = "sha256-XhxED3LHIjxBcSVyyEC3pgg0fyKyfKtHkF7umExSboM="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rocprofiler-register"; - - patches = [ - (fetchpatch { - # [rocprofiler-sdk][rocprofiler-register] add CPackComponent - url = "https://github.com/ROCm/rocm-systems/commit/ef7253365c420ca486f074b9e9119a222e30fea0.patch"; - hash = "sha256-dwqvZ4AaTcOk2mSnxgHp/NbhjlD8W6KVz1H5ZF4i/Tw="; - relative = "projects/rocprofiler-register"; - }) - (fetchpatch { - # [rocprofiler-register] Fix compilation with system fmt/glog - url = "https://github.com/ROCm/rocm-systems/commit/c8ad2522083c6e00539ce5c1c22df766c20084fb.patch"; - hash = "sha256-VloRKV6kUzIfIInltx/bV1EM0FUfeQZrVAx6qgdsLyg="; - relative = "projects/rocprofiler-register"; - }) - (fetchpatch { - # fix(rocprofiler-sdk): include fmt/format.h instead of fmt/core.h for fmt::format - # fmt 12.2.0 changes the meaning of fmt/core.h so it no longer includes - # fmt::format, so this upstream commit switches to the correct header. - url = "https://github.com/ROCm/rocm-systems/commit/e2f588592ecfb0653ed5b3078753186325adf70a.patch"; - hash = "sha256-ip/s7tmUptcXMen3fyQJYKiZKwoe3SH0XqTVb0YBA7k="; - relative = "projects/rocprofiler-register"; - }) - ]; - - nativeBuildInputs = [ - cmake - clang - ]; - - buildInputs = [ - numactl - libpciaccess - libxml2 - elfutils - glog - fmt - - python3Packages.lxml - python3Packages.cppheaderparser - python3Packages.pyyaml - python3Packages.barectf - python3Packages.pandas - ]; - cmakeFlags = [ - "-DROCPROFILER_REGISTER_BUILD_TESTS=0" - "-DROCPROFILER_REGISTER_BUILD_SAMPLES=0" - "-DROCPROFILER_REGISTER_BUILD_GLOG=OFF" - "-DROCPROFILER_REGISTER_BUILD_FMT=OFF" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ]; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "Profiling with perf-counters and derived metrics"; - homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/rocprofiler-register"; - license = lib.licenses.mit; # mitx11 - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocprofiler-sdk/0001-fix-missing-CPackComponent-cmake-include.patch b/pkgs/development/rocm-modules/rocprofiler-sdk/0001-fix-missing-CPackComponent-cmake-include.patch deleted file mode 100644 index 1e65ac7a76ee5..0000000000000 --- a/pkgs/development/rocm-modules/rocprofiler-sdk/0001-fix-missing-CPackComponent-cmake-include.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 5ae420cc204d0afb1ad388ddbceec237a4164569 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 17:28:05 +1100 -Subject: [PATCH 1/8] fix missing CPackComponent cmake include - ---- - cmake/rocprofiler_config_packaging.cmake | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/cmake/rocprofiler_config_packaging.cmake b/cmake/rocprofiler_config_packaging.cmake -index 84c2ecf230..55d9f58f38 100644 ---- a/cmake/rocprofiler_config_packaging.cmake -+++ b/cmake/rocprofiler_config_packaging.cmake -@@ -126,6 +126,8 @@ endif() - list(APPEND _DEB_PACKAGE_DEPENDS ${ROCPROFILER_CPACK_DEBIAN_PACKAGE_DEPENDS}) - list(APPEND _RPM_PACKAGE_REQUIRES ${ROCPROFILER_CPACK_RPM_PACKAGE_REQUIRES}) - -+include(CPackComponent) -+ - foreach(COMPONENT_GROUP ${ROCPROFILER_COMPONENT_GROUPS}) - set(_DEP "${COMPONENT_DEP_${COMPONENT_GROUP}}") - set(_NAME "${COMPONENT_NAME_${COMPONENT_GROUP}}") --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/rocprofiler-sdk/0002-allow-using-system-yaml-dependency.patch b/pkgs/development/rocm-modules/rocprofiler-sdk/0002-allow-using-system-yaml-dependency.patch deleted file mode 100644 index 3fa335a25eb9a..0000000000000 --- a/pkgs/development/rocm-modules/rocprofiler-sdk/0002-allow-using-system-yaml-dependency.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 0477671140ffc3d1b50e1cca69f107b51112faa8 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 17:29:27 +1100 -Subject: [PATCH 2/8] allow using system yaml dependency - ---- - cmake/rocprofiler_options.cmake | 2 ++ - external/CMakeLists.txt | 29 +++++++++++++++++------------ - 2 files changed, 19 insertions(+), 12 deletions(-) - -diff --git a/cmake/rocprofiler_options.cmake b/cmake/rocprofiler_options.cmake -index 08d1032635..faee11049f 100644 ---- a/cmake/rocprofiler_options.cmake -+++ b/cmake/rocprofiler_options.cmake -@@ -65,6 +65,8 @@ rocprofiler_add_option(ROCPROFILER_BUILD_PYBIND11 - "Enable building pybind11 library internally" ON) - rocprofiler_add_option(ROCPROFILER_BUILD_GOTCHA - "Enable building gotcha library internally" ON) -+rocprofiler_add_option(ROCPROFILER_BUILD_YAML_CPP -+ "Enable building yaml-cpp library internally" ON) - if(ROCPROFILER_BUILD_TESTS) - rocprofiler_add_option( - ROCPROFILER_BUILD_GTEST -diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt -index 5bee3dc032..cab59c07bd 100644 ---- a/external/CMakeLists.txt -+++ b/external/CMakeLists.txt -@@ -131,20 +131,25 @@ if(NOT TARGET PTL::ptl-static) - add_subdirectory(ptl EXCLUDE_FROM_ALL) - endif() - --rocprofiler_checkout_git_submodule( -- RECURSIVE -- RELATIVE_PATH external/yaml-cpp -- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} -- REPO_URL https://github.com/jbeder/yaml-cpp.git -- REPO_BRANCH "master") -+if(ROCPROFILER_BUILD_YAML_CPP) -+ rocprofiler_checkout_git_submodule( -+ RECURSIVE -+ RELATIVE_PATH external/yaml-cpp -+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} -+ REPO_URL https://github.com/jbeder/yaml-cpp.git -+ REPO_BRANCH "master") - --add_subdirectory(yaml-cpp EXCLUDE_FROM_ALL) -+ add_subdirectory(yaml-cpp EXCLUDE_FROM_ALL) - --target_link_libraries(rocprofiler-sdk-yaml-cpp -- INTERFACE $) --target_include_directories( -- rocprofiler-sdk-yaml-cpp -- INTERFACE $) -+ target_link_libraries(rocprofiler-sdk-yaml-cpp -+ INTERFACE $) -+ target_include_directories( -+ rocprofiler-sdk-yaml-cpp -+ INTERFACE $) -+else() -+ find_package(yaml-cpp 0.8.0 REQUIRED) -+ target_link_libraries(rocprofiler-sdk-yaml-cpp INTERFACE yaml-cpp::yaml-cpp) -+endif() - - # checkout submodule if not already checked out or clone repo if no .gitmodules file - rocprofiler_checkout_git_submodule( --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/rocprofiler-sdk/0003-allow-using-system-elfio-dependency.patch b/pkgs/development/rocm-modules/rocprofiler-sdk/0003-allow-using-system-elfio-dependency.patch deleted file mode 100644 index 702f380edb420..0000000000000 --- a/pkgs/development/rocm-modules/rocprofiler-sdk/0003-allow-using-system-elfio-dependency.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 27cec58fefe73c26ccca212ebbc002a0b9c1bfa5 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 17:29:50 +1100 -Subject: [PATCH 3/8] allow using system elfio dependency - ---- - cmake/rocprofiler_options.cmake | 2 ++ - external/CMakeLists.txt | 33 +++++++++++++++++++-------------- - 2 files changed, 21 insertions(+), 14 deletions(-) - -diff --git a/cmake/rocprofiler_options.cmake b/cmake/rocprofiler_options.cmake -index faee11049f..a09af6c2c9 100644 ---- a/cmake/rocprofiler_options.cmake -+++ b/cmake/rocprofiler_options.cmake -@@ -67,6 +67,8 @@ rocprofiler_add_option(ROCPROFILER_BUILD_GOTCHA - "Enable building gotcha library internally" ON) - rocprofiler_add_option(ROCPROFILER_BUILD_YAML_CPP - "Enable building yaml-cpp library internally" ON) -+rocprofiler_add_option(ROCPROFILER_BUILD_ELFIO -+ "Enable building ELFIO library internally" ON) - if(ROCPROFILER_BUILD_TESTS) - rocprofiler_add_option( - ROCPROFILER_BUILD_GTEST -diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt -index cab59c07bd..a75229edf3 100644 ---- a/external/CMakeLists.txt -+++ b/external/CMakeLists.txt -@@ -201,20 +201,25 @@ target_link_libraries( - INTERFACE $) - - # ELFIO --rocprofiler_checkout_git_submodule( -- RECURSIVE -- RELATIVE_PATH external/elfio -- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} -- REPO_URL https://github.com/serge1/ELFIO.git -- REPO_BRANCH "Release_3.12") -- --set(ELFIO_BUILD_EXAMPLES OFF) --set(ELFIO_BUILD_TESTS OFF) --add_subdirectory(elfio EXCLUDE_FROM_ALL) --if(TARGET rocprofiler-sdk-elfio) -- get_target_property(ELFIO_INCLUDE_DIR elfio::elfio INTERFACE_INCLUDE_DIRECTORIES) -- target_include_directories(rocprofiler-sdk-elfio SYSTEM -- INTERFACE ${ELFIO_INCLUDE_DIR}) -+if(ROCPROFILER_BUILD_ELFIO) -+ rocprofiler_checkout_git_submodule( -+ RECURSIVE -+ RELATIVE_PATH external/elfio -+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} -+ REPO_URL https://github.com/serge1/ELFIO.git -+ REPO_BRANCH "Release_3.12") -+ -+ set(ELFIO_BUILD_EXAMPLES OFF) -+ set(ELFIO_BUILD_TESTS OFF) -+ add_subdirectory(elfio EXCLUDE_FROM_ALL) -+ if(TARGET rocprofiler-sdk-elfio) -+ get_target_property(ELFIO_INCLUDE_DIR elfio::elfio INTERFACE_INCLUDE_DIRECTORIES) -+ target_include_directories(rocprofiler-sdk-elfio SYSTEM -+ INTERFACE ${ELFIO_INCLUDE_DIR}) -+ endif() -+else() -+ find_package(elfio REQUIRED GLOBAL) -+ target_link_libraries(rocprofiler-sdk-elfio INTERFACE elfio::elfio) - endif() - - # --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/rocprofiler-sdk/0004-allow-using-system-otf2-dependency.patch b/pkgs/development/rocm-modules/rocprofiler-sdk/0004-allow-using-system-otf2-dependency.patch deleted file mode 100644 index 61a2888f79f8c..0000000000000 --- a/pkgs/development/rocm-modules/rocprofiler-sdk/0004-allow-using-system-otf2-dependency.patch +++ /dev/null @@ -1,54 +0,0 @@ -From d2c8a5872c8d2af1bc8c203ad75f7c1c83cfb919 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 17:30:13 +1100 -Subject: [PATCH 4/8] allow using system otf2 dependency - ---- - cmake/rocprofiler_options.cmake | 2 ++ - external/CMakeLists.txt | 17 +++++++++-------- - 2 files changed, 11 insertions(+), 8 deletions(-) - -diff --git a/cmake/rocprofiler_options.cmake b/cmake/rocprofiler_options.cmake -index a09af6c2c9..19e092df06 100644 ---- a/cmake/rocprofiler_options.cmake -+++ b/cmake/rocprofiler_options.cmake -@@ -69,6 +69,8 @@ rocprofiler_add_option(ROCPROFILER_BUILD_YAML_CPP - "Enable building yaml-cpp library internally" ON) - rocprofiler_add_option(ROCPROFILER_BUILD_ELFIO - "Enable building ELFIO library internally" ON) -+rocprofiler_add_option(ROCPROFILER_BUILD_OTF2 -+ "Enable building OTF2 library internally" ON) - if(ROCPROFILER_BUILD_TESTS) - rocprofiler_add_option( - ROCPROFILER_BUILD_GTEST -diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt -index a75229edf3..e1be3df85e 100644 ---- a/external/CMakeLists.txt -+++ b/external/CMakeLists.txt -@@ -225,14 +225,15 @@ endif() - # - # OTF2 - # --add_subdirectory(otf2) -- --rocprofiler_checkout_git_submodule( -- RECURSIVE -- RELATIVE_PATH external/json -- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} -- REPO_URL https://github.com/nlohmann/json.git -- REPO_BRANCH "develop") -+if(ROCPROFILER_BUILD_OTF2) -+ add_subdirectory(otf2) -+else() -+ find_package(PkgConfig REQUIRED) -+ pkg_check_modules(OTF2 REQUIRED IMPORTED_TARGET otf2) -+ add_library(otf2 INTERFACE) -+ add_library(otf2::otf2 ALIAS otf2) -+ target_link_libraries(otf2 INTERFACE PkgConfig::OTF2) -+endif() - - # - # JSON --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/rocprofiler-sdk/0005-allow-using-system-json-dependency.patch b/pkgs/development/rocm-modules/rocprofiler-sdk/0005-allow-using-system-json-dependency.patch deleted file mode 100644 index b6cb539682c45..0000000000000 --- a/pkgs/development/rocm-modules/rocprofiler-sdk/0005-allow-using-system-json-dependency.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 3c42b2a8491b44fa58940fcd44b45c64f1b43cf1 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 17:30:36 +1100 -Subject: [PATCH 5/8] allow using system json dependency - ---- - cmake/rocprofiler_options.cmake | 2 ++ - external/CMakeLists.txt | 17 +++++++++++++++++ - 2 files changed, 19 insertions(+) - -diff --git a/cmake/rocprofiler_options.cmake b/cmake/rocprofiler_options.cmake -index 19e092df06..b7a7a6cbdd 100644 ---- a/cmake/rocprofiler_options.cmake -+++ b/cmake/rocprofiler_options.cmake -@@ -71,6 +71,8 @@ rocprofiler_add_option(ROCPROFILER_BUILD_ELFIO - "Enable building ELFIO library internally" ON) - rocprofiler_add_option(ROCPROFILER_BUILD_OTF2 - "Enable building OTF2 library internally" ON) -+rocprofiler_add_option(ROCPROFILER_BUILD_JSON -+ "Enable building JSON library internally" ON) - if(ROCPROFILER_BUILD_TESTS) - rocprofiler_add_option( - ROCPROFILER_BUILD_GTEST -diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt -index e1be3df85e..a282232f22 100644 ---- a/external/CMakeLists.txt -+++ b/external/CMakeLists.txt -@@ -243,6 +243,23 @@ target_include_directories( - rocprofiler-sdk-json SYSTEM - INTERFACE $) - -+if(ROCPROFILER_BUILD_JSON) -+ rocprofiler_checkout_git_submodule( -+ RECURSIVE -+ RELATIVE_PATH external/json -+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} -+ REPO_URL https://github.com/nlohmann/json.git -+ REPO_BRANCH "develop") -+ -+ add_subdirectory(json) -+ target_include_directories( -+ rocprofiler-sdk-json SYSTEM -+ INTERFACE $) -+else() -+ find_package(nlohmann_json REQUIRED GLOBAL) -+ target_link_libraries(rocprofiler-sdk-json INTERFACE nlohmann_json::nlohmann_json) -+endif() -+ - # - # SQLite3 - # --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/rocprofiler-sdk/0006-fix-amd-comgr-resolution.patch b/pkgs/development/rocm-modules/rocprofiler-sdk/0006-fix-amd-comgr-resolution.patch deleted file mode 100644 index 03103ec734619..0000000000000 --- a/pkgs/development/rocm-modules/rocprofiler-sdk/0006-fix-amd-comgr-resolution.patch +++ /dev/null @@ -1,154 +0,0 @@ -From 9977c287e106d9c494546212a3544e238363e219 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 16:52:24 +1100 -Subject: [PATCH 6/8] fix amd-comgr resolution - ---- - .../lib/att-tool/waitcnt/tests/CMakeLists.txt | 1 + - source/lib/python/utilities.cmake | 3 ++- - .../counters/tests/CMakeLists.txt | 2 ++ - .../pc_sampling/parser/tests/CMakeLists.txt | 20 ++++++++++++++----- - .../lib/rocprofiler-sdk/tests/CMakeLists.txt | 2 ++ - .../thread_trace/tests/CMakeLists.txt | 1 + - 6 files changed, 23 insertions(+), 6 deletions(-) - -diff --git a/source/lib/att-tool/waitcnt/tests/CMakeLists.txt b/source/lib/att-tool/waitcnt/tests/CMakeLists.txt -index 8a13e80cbe..48b3debc93 100644 ---- a/source/lib/att-tool/waitcnt/tests/CMakeLists.txt -+++ b/source/lib/att-tool/waitcnt/tests/CMakeLists.txt -@@ -10,6 +10,7 @@ target_link_libraries( - rocprofiler-sdk::rocprofiler-sdk-common-library - rocprofiler-sdk::rocprofiler-sdk-glog - rocprofiler-sdk::rocprofiler-sdk-static-library -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr - GTest::gtest - GTest::gtest_main) - target_sources(att-decoder-waitcnt-test PRIVATE att_decoder_waitcnt_test.cpp) -diff --git a/source/lib/python/utilities.cmake b/source/lib/python/utilities.cmake -index 1bc9171a3e..21bc9cfb3d 100644 ---- a/source/lib/python/utilities.cmake -+++ b/source/lib/python/utilities.cmake -@@ -209,7 +209,8 @@ function(rocprofiler_rocpd_python_bindings _VERSION) - rocprofiler-sdk::rocprofiler-sdk-gotcha - rocprofiler-sdk::rocprofiler-sdk-dw - rocprofiler-sdk::rocprofiler-sdk-static-library -- rocprofiler-sdk::rocprofiler-sdk-rocpd-library) -+ rocprofiler-sdk::rocprofiler-sdk-rocpd-library -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr) - - # if "Development" is specified instead of "Development.Module", we need to link to - # python libraries -diff --git a/source/lib/rocprofiler-sdk/counters/tests/CMakeLists.txt b/source/lib/rocprofiler-sdk/counters/tests/CMakeLists.txt -index 5e0d73e0f0..38251a7acc 100644 ---- a/source/lib/rocprofiler-sdk/counters/tests/CMakeLists.txt -+++ b/source/lib/rocprofiler-sdk/counters/tests/CMakeLists.txt -@@ -51,6 +51,7 @@ target_sources( - target_link_libraries( - counter_test_constants - PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr - rocprofiler-sdk::rocprofiler-sdk-static-library - rocprofiler-sdk::rocprofiler-sdk-hip - rocprofiler-sdk::rocprofiler-sdk-hsa-runtime) -@@ -73,6 +74,7 @@ target_link_libraries( - rocprofiler-sdk::rocprofiler-sdk-hsa-runtime - rocprofiler-sdk::rocprofiler-sdk-hip - rocprofiler-sdk::rocprofiler-sdk-common-library -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr - rocprofiler-sdk::rocprofiler-sdk-static-library - GTest::gtest - GTest::gtest_main) -diff --git a/source/lib/rocprofiler-sdk/pc_sampling/parser/tests/CMakeLists.txt b/source/lib/rocprofiler-sdk/pc_sampling/parser/tests/CMakeLists.txt -index 1c512054d6..3bb64572e1 100644 ---- a/source/lib/rocprofiler-sdk/pc_sampling/parser/tests/CMakeLists.txt -+++ b/source/lib/rocprofiler-sdk/pc_sampling/parser/tests/CMakeLists.txt -@@ -30,7 +30,9 @@ target_include_directories(pcs_gfx9_test PRIVATE ${PCTEST_INCLUDE_DIR}) - target_link_libraries( - pcs_gfx9_test - PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library -- rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr -+ rocprofiler-sdk::rocprofiler-sdk-static-library -+ GTest::gtest - GTest::gtest_main) - - gtest_add_tests( -@@ -52,7 +54,9 @@ target_include_directories(pcs_id_test PRIVATE ${PCTEST_INCLUDE_DIR}) - target_link_libraries( - pcs_id_test - PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library -- rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr -+ rocprofiler-sdk::rocprofiler-sdk-static-library -+ GTest::gtest - GTest::gtest_main) - - gtest_add_tests( -@@ -75,7 +79,9 @@ target_include_directories(pcs_bench_test PRIVATE ${PCTEST_INCLUDE_DIR}) - target_link_libraries( - pcs_bench_test - PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library -- rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr -+ rocprofiler-sdk::rocprofiler-sdk-static-library -+ GTest::gtest - GTest::gtest_main) - - add_executable(pcs_thread_test) -@@ -88,7 +94,9 @@ target_include_directories(pcs_thread_test PRIVATE ${PCTEST_INCLUDE_DIR}) - target_link_libraries( - pcs_thread_test - PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library -- rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr -+ rocprofiler-sdk::rocprofiler-sdk-static-library -+ GTest::gtest - GTest::gtest_main) - - gtest_add_tests( -@@ -111,7 +119,9 @@ target_include_directories(pcs_gfx12_test PRIVATE ${PCTEST_INCLUDE_DIR}) - target_link_libraries( - pcs_gfx12_test - PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library -- rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr -+ rocprofiler-sdk::rocprofiler-sdk-static-library -+ GTest::gtest - GTest::gtest_main) - - gtest_add_tests( -diff --git a/source/lib/rocprofiler-sdk/tests/CMakeLists.txt b/source/lib/rocprofiler-sdk/tests/CMakeLists.txt -index d71aa7c297..70dfe3376d 100644 ---- a/source/lib/rocprofiler-sdk/tests/CMakeLists.txt -+++ b/source/lib/rocprofiler-sdk/tests/CMakeLists.txt -@@ -28,6 +28,7 @@ target_sources(rocprofiler-sdk-lib-tests PRIVATE ${rocprofiler_lib_sources} - target_link_libraries( - rocprofiler-sdk-lib-tests - PRIVATE rocprofiler-sdk::rocprofiler-sdk-static-library -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr - rocprofiler-sdk::rocprofiler-sdk-common-library - rocprofiler-sdk::counter-test-constants - rocprofiler-sdk::rocprofiler-sdk-hsa-runtime -@@ -59,6 +60,7 @@ target_sources(rocprofiler-sdk-lib-tests-shared PRIVATE ${rocprofiler_shared_lib - target_link_libraries( - rocprofiler-sdk-lib-tests-shared - PRIVATE rocprofiler-sdk::rocprofiler-sdk-shared-library -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr - rocprofiler-sdk::rocprofiler-sdk-common-library - rocprofiler-sdk::rocprofiler-sdk-hsa-runtime - rocprofiler-sdk::rocprofiler-sdk-drm -diff --git a/source/lib/rocprofiler-sdk/thread_trace/tests/CMakeLists.txt b/source/lib/rocprofiler-sdk/thread_trace/tests/CMakeLists.txt -index 62acae39fb..7e867ba0a7 100644 ---- a/source/lib/rocprofiler-sdk/thread_trace/tests/CMakeLists.txt -+++ b/source/lib/rocprofiler-sdk/thread_trace/tests/CMakeLists.txt -@@ -14,6 +14,7 @@ target_link_libraries( - rocprofiler-sdk::rocprofiler-sdk-glog - rocprofiler-sdk::rocprofiler-sdk-hsa-runtime - rocprofiler-sdk::rocprofiler-sdk-hip -+ rocprofiler-sdk::rocprofiler-sdk-amd-comgr - rocprofiler-sdk::rocprofiler-sdk-common-library - GTest::gtest - GTest::gtest_main --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/rocprofiler-sdk/0007-fix-missing-includes-and-api-changes-with-fmt-v12.2..patch b/pkgs/development/rocm-modules/rocprofiler-sdk/0007-fix-missing-includes-and-api-changes-with-fmt-v12.2..patch deleted file mode 100644 index 970e2a89b67d4..0000000000000 --- a/pkgs/development/rocm-modules/rocprofiler-sdk/0007-fix-missing-includes-and-api-changes-with-fmt-v12.2..patch +++ /dev/null @@ -1,260 +0,0 @@ -From eb68d5d6dcdb085dc3d8d18576fee7cf998f6512 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 16:59:59 +1100 -Subject: [PATCH 7/8] fix missing includes and api changes with fmt v12.2.0 - ---- - source/lib/common/logging.cpp | 1 + - source/lib/output/generateRocpd.cpp | 1 + - source/lib/output/generateStats.cpp | 1 + - source/lib/output/metadata.cpp | 1 - - source/lib/output/metadata.hpp | 2 +- - source/lib/output/sql/common.hpp | 1 + - source/lib/python/rocpd/libpyrocpd.cpp | 1 + - source/lib/python/rocpd/source/serialization/sql.cpp | 3 +++ - source/lib/python/rocpd/source/sql_generator.hpp | 3 +++ - source/lib/rocprofiler-sdk-tool/tool.cpp | 3 ++- - source/lib/rocprofiler-sdk/counters/tests/device_counting.cpp | 1 + - source/lib/rocprofiler-sdk/counters/tests/dimension.cpp | 1 + - source/lib/rocprofiler-sdk/hip/details/format.hpp | 4 ++-- - source/lib/rocprofiler-sdk/hsa/aql_packet.cpp | 2 +- - source/lib/rocprofiler-sdk/hsa/details/fmt.hpp | 3 +++ - source/lib/rocprofiler-sdk/ompt.cpp | 2 +- - .../pc_sampling/parser/pc_record_interface.cpp | 2 ++ - source/lib/tests/common/parse.cpp | 1 + - 18 files changed, 26 insertions(+), 7 deletions(-) - -diff --git a/source/lib/common/logging.cpp b/source/lib/common/logging.cpp -index 6c07322b06..24aecbc23d 100644 ---- a/source/lib/common/logging.cpp -+++ b/source/lib/common/logging.cpp -@@ -25,6 +25,7 @@ - #include "lib/common/filesystem.hpp" - - #include -+#include - #include - #include - -diff --git a/source/lib/output/generateRocpd.cpp b/source/lib/output/generateRocpd.cpp -index 564a9bd45f..65d9a5d7cf 100644 ---- a/source/lib/output/generateRocpd.cpp -+++ b/source/lib/output/generateRocpd.cpp -@@ -56,6 +56,7 @@ - #include - - #include -+#include - #include - #include - -diff --git a/source/lib/output/generateStats.cpp b/source/lib/output/generateStats.cpp -index 22c1a7f425..3860be129b 100644 ---- a/source/lib/output/generateStats.cpp -+++ b/source/lib/output/generateStats.cpp -@@ -33,6 +33,7 @@ - #include - - #include -+#include - - #include - #include -diff --git a/source/lib/output/metadata.cpp b/source/lib/output/metadata.cpp -index abe9e00b50..f68d46de5b 100644 ---- a/source/lib/output/metadata.cpp -+++ b/source/lib/output/metadata.cpp -@@ -41,7 +41,6 @@ - #include - #include - --#include - #include - - #include -diff --git a/source/lib/output/metadata.hpp b/source/lib/output/metadata.hpp -index 069401f962..a283896f29 100644 ---- a/source/lib/output/metadata.hpp -+++ b/source/lib/output/metadata.hpp -@@ -45,7 +45,7 @@ - #include - #include - --#include -+#include - - #include - #include -diff --git a/source/lib/output/sql/common.hpp b/source/lib/output/sql/common.hpp -index 40fb8df9a8..97f96e06c4 100644 ---- a/source/lib/output/sql/common.hpp -+++ b/source/lib/output/sql/common.hpp -@@ -29,6 +29,7 @@ - #include "lib/common/units.hpp" - - #include -+#include - #include - - #include -diff --git a/source/lib/python/rocpd/libpyrocpd.cpp b/source/lib/python/rocpd/libpyrocpd.cpp -index 009afd694b..8ad4eb3458 100644 ---- a/source/lib/python/rocpd/libpyrocpd.cpp -+++ b/source/lib/python/rocpd/libpyrocpd.cpp -@@ -55,6 +55,7 @@ - #include - - #include -+#include - #include - #include - #include -diff --git a/source/lib/python/rocpd/source/serialization/sql.cpp b/source/lib/python/rocpd/source/serialization/sql.cpp -index d10e878be5..9192abc45b 100644 ---- a/source/lib/python/rocpd/source/serialization/sql.cpp -+++ b/source/lib/python/rocpd/source/serialization/sql.cpp -@@ -23,6 +23,9 @@ - #include "lib/python/rocpd/source/serialization/sql.hpp" - #include "lib/output/sql/common.hpp" - -+#include -+#include -+ - namespace cereal - { - SQLite3InputArchive::SQLite3InputArchive(sqlite3* conn, -diff --git a/source/lib/python/rocpd/source/sql_generator.hpp b/source/lib/python/rocpd/source/sql_generator.hpp -index 6284857afb..881ad23a72 100644 ---- a/source/lib/python/rocpd/source/sql_generator.hpp -+++ b/source/lib/python/rocpd/source/sql_generator.hpp -@@ -38,6 +38,9 @@ - #include - #include - -+#include -+#include -+ - namespace rocpd - { - namespace tool = ::rocprofiler::tool; -diff --git a/source/lib/rocprofiler-sdk-tool/tool.cpp b/source/lib/rocprofiler-sdk-tool/tool.cpp -index 7b03fa3eb8..6ddb2274e5 100644 ---- a/source/lib/rocprofiler-sdk-tool/tool.cpp -+++ b/source/lib/rocprofiler-sdk-tool/tool.cpp -@@ -78,7 +78,8 @@ - #include - #include - --#include -+#include -+#include - - #include - #include -diff --git a/source/lib/rocprofiler-sdk/counters/tests/device_counting.cpp b/source/lib/rocprofiler-sdk/counters/tests/device_counting.cpp -index 9587b219f3..d82a6ec40b 100644 ---- a/source/lib/rocprofiler-sdk/counters/tests/device_counting.cpp -+++ b/source/lib/rocprofiler-sdk/counters/tests/device_counting.cpp -@@ -39,6 +39,7 @@ - #include - - #include -+#include - #include - #include - #include -diff --git a/source/lib/rocprofiler-sdk/counters/tests/dimension.cpp b/source/lib/rocprofiler-sdk/counters/tests/dimension.cpp -index 387c167bd0..22fcda9bf7 100644 ---- a/source/lib/rocprofiler-sdk/counters/tests/dimension.cpp -+++ b/source/lib/rocprofiler-sdk/counters/tests/dimension.cpp -@@ -39,6 +39,7 @@ - #include - - #include -+#include - #include - #include - #include -diff --git a/source/lib/rocprofiler-sdk/hip/details/format.hpp b/source/lib/rocprofiler-sdk/hip/details/format.hpp -index f65cf016a6..46f734d65d 100644 ---- a/source/lib/rocprofiler-sdk/hip/details/format.hpp -+++ b/source/lib/rocprofiler-sdk/hip/details/format.hpp -@@ -31,8 +31,8 @@ - #include - #include - --#include "fmt/core.h" --#include "fmt/ranges.h" -+#include -+#include - - #define ROCP_SDK_HIP_FORMATTER(TYPE, ...) \ - template <> \ -diff --git a/source/lib/rocprofiler-sdk/hsa/aql_packet.cpp b/source/lib/rocprofiler-sdk/hsa/aql_packet.cpp -index f1c0c3a56e..389a182e9d 100644 ---- a/source/lib/rocprofiler-sdk/hsa/aql_packet.cpp -+++ b/source/lib/rocprofiler-sdk/hsa/aql_packet.cpp -@@ -21,7 +21,7 @@ - // THE SOFTWARE. - - #include "lib/rocprofiler-sdk/hsa/aql_packet.hpp" --#include -+#include - #include - #include - #include "lib/common/logging.hpp" -diff --git a/source/lib/rocprofiler-sdk/hsa/details/fmt.hpp b/source/lib/rocprofiler-sdk/hsa/details/fmt.hpp -index c136a2739c..f0d7d9e94f 100644 ---- a/source/lib/rocprofiler-sdk/hsa/details/fmt.hpp -+++ b/source/lib/rocprofiler-sdk/hsa/details/fmt.hpp -@@ -22,6 +22,9 @@ - - #include "lib/rocprofiler-sdk/hsa/queue.hpp" - -+#include -+#include -+ - namespace fmt - { - template <> -diff --git a/source/lib/rocprofiler-sdk/ompt.cpp b/source/lib/rocprofiler-sdk/ompt.cpp -index a9ccc571c8..0d7166465a 100644 ---- a/source/lib/rocprofiler-sdk/ompt.cpp -+++ b/source/lib/rocprofiler-sdk/ompt.cpp -@@ -31,7 +31,7 @@ - #include - #include - --#include -+#include - #include - #include - -diff --git a/source/lib/rocprofiler-sdk/pc_sampling/parser/pc_record_interface.cpp b/source/lib/rocprofiler-sdk/pc_sampling/parser/pc_record_interface.cpp -index 8d418df50e..a4163529c1 100644 ---- a/source/lib/rocprofiler-sdk/pc_sampling/parser/pc_record_interface.cpp -+++ b/source/lib/rocprofiler-sdk/pc_sampling/parser/pc_record_interface.cpp -@@ -24,6 +24,8 @@ - - #include "lib/common/utility.hpp" - -+#include -+ - template <> - uint64_t - PCSamplingParserContext::alloc( -diff --git a/source/lib/tests/common/parse.cpp b/source/lib/tests/common/parse.cpp -index 5e3b63c85f..ccfc0912bc 100644 ---- a/source/lib/tests/common/parse.cpp -+++ b/source/lib/tests/common/parse.cpp -@@ -23,6 +23,7 @@ - #include - - #include -+#include - #include - - #include --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/rocprofiler-sdk/0008-fix-compilation-errors-from-missing-includes.patch b/pkgs/development/rocm-modules/rocprofiler-sdk/0008-fix-compilation-errors-from-missing-includes.patch deleted file mode 100644 index ab694273ab2c2..0000000000000 --- a/pkgs/development/rocm-modules/rocprofiler-sdk/0008-fix-compilation-errors-from-missing-includes.patch +++ /dev/null @@ -1,93 +0,0 @@ -From 3346d7d75513445c19f04a9e972216522752e469 Mon Sep 17 00:00:00 2001 -From: Anund -Date: Sun, 11 Oct 2026 17:00:20 +1100 -Subject: [PATCH 8/8] fix compilation errors from missing includes - ---- - source/lib/att-tool/att_lib_wrapper.hpp | 2 ++ - source/lib/att-tool/wave.hpp | 1 + - source/lib/rocprofiler-sdk-rocpd/sql.cpp | 1 + - source/lib/rocprofiler-sdk/counters/metrics.cpp | 1 + - source/lib/rocprofiler-sdk/counters/metrics.hpp | 1 + - source/lib/rocprofiler-sdk/tests/status.cpp | 1 + - 6 files changed, 7 insertions(+) - -diff --git a/source/lib/att-tool/att_lib_wrapper.hpp b/source/lib/att-tool/att_lib_wrapper.hpp -index e7e58c5991..7dcd000a43 100644 ---- a/source/lib/att-tool/att_lib_wrapper.hpp -+++ b/source/lib/att-tool/att_lib_wrapper.hpp -@@ -28,9 +28,11 @@ - #include - - #include -+#include - #include - #include - #include -+#include - #include - - namespace rocprofiler -diff --git a/source/lib/att-tool/wave.hpp b/source/lib/att-tool/wave.hpp -index 1a7b1adda6..65686d8ea3 100644 ---- a/source/lib/att-tool/wave.hpp -+++ b/source/lib/att-tool/wave.hpp -@@ -29,6 +29,7 @@ - #include "waitcnt/analysis.hpp" - #include "wstates.hpp" - -+#include - #include - #include - #include -diff --git a/source/lib/rocprofiler-sdk-rocpd/sql.cpp b/source/lib/rocprofiler-sdk-rocpd/sql.cpp -index b052ec51c3..7e8742686e 100644 ---- a/source/lib/rocprofiler-sdk-rocpd/sql.cpp -+++ b/source/lib/rocprofiler-sdk-rocpd/sql.cpp -@@ -39,6 +39,7 @@ - #include - - #include -+#include - #include - #include - -diff --git a/source/lib/rocprofiler-sdk/counters/metrics.cpp b/source/lib/rocprofiler-sdk/counters/metrics.cpp -index 201ae4fd25..4780a0ba31 100644 ---- a/source/lib/rocprofiler-sdk/counters/metrics.cpp -+++ b/source/lib/rocprofiler-sdk/counters/metrics.cpp -@@ -45,6 +45,7 @@ - #include // for dladdr - #include - #include -+#include - #include - #include - -diff --git a/source/lib/rocprofiler-sdk/counters/metrics.hpp b/source/lib/rocprofiler-sdk/counters/metrics.hpp -index 7915bc8805..a893c2c9b3 100644 ---- a/source/lib/rocprofiler-sdk/counters/metrics.hpp -+++ b/source/lib/rocprofiler-sdk/counters/metrics.hpp -@@ -35,6 +35,7 @@ - #include - #include - #include -+#include - - namespace rocprofiler - { -diff --git a/source/lib/rocprofiler-sdk/tests/status.cpp b/source/lib/rocprofiler-sdk/tests/status.cpp -index a5a492101d..b01f511b99 100644 ---- a/source/lib/rocprofiler-sdk/tests/status.cpp -+++ b/source/lib/rocprofiler-sdk/tests/status.cpp -@@ -25,6 +25,7 @@ - - #include - -+#include - #include - - TEST(rocprofiler_lib, error_string) --- -2.55.0 - diff --git a/pkgs/development/rocm-modules/rocprofiler-sdk/0009-rocprofiler-sdk-guard-ompt-auto-start.patch b/pkgs/development/rocm-modules/rocprofiler-sdk/0009-rocprofiler-sdk-guard-ompt-auto-start.patch deleted file mode 100644 index 147d79483318e..0000000000000 --- a/pkgs/development/rocm-modules/rocprofiler-sdk/0009-rocprofiler-sdk-guard-ompt-auto-start.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 502d2df0ddd84f0f2fa718b9a02ee0f01f36dac1 Mon Sep 17 00:00:00 2001 -From: Luna Nova -Date: Tue, 2 Jun 2026 01:31:05 -0700 -Subject: [PATCH] [rocprofiler-sdk] don't auto-start OMPT tool before glog is - initialized - -The OpenMP runtime resolves its weak ompt_start_tool to the strong symbol we -export and calls it during OpenMP init. That can fire from an unrelated -library's constructor (observed: OpenBLAS calling omp_get_num_places) while -librocprofiler-sdk is still being dlopen'd. init_logging() then dereferences -glog's gflags FLAGS_vmodule, whose backing pointer is still null until glog's -static initializers run, and the process segfaults on `import torch`. - -The init order is not reliably fixable from here: a dependency cycle among the -ROCm libraries makes the loader run our constructors before libglog's, so a -flag set by our own constructor does not imply glog is ready. Instead gate the -tool start on glog itself, by testing whether gflags has populated FLAGS_vmodule -yet; reading the raw pointer is safe even before construction. It is read via an -asm label because the gflags header only exposes it as a reference, which the -compiler assumes is never null. Declining (nullptr) when glog is not yet ready -is a valid OMPT "no tool" response; deliberate profiling (rocprofv3 preloads the -tool early, before such constructors) is unaffected. ---- - source/lib/rocprofiler-sdk/ompt.cpp | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/source/lib/rocprofiler-sdk/ompt.cpp b/source/lib/rocprofiler-sdk/ompt.cpp -index a9ccc57..3231087 100644 ---- a/source/lib/rocprofiler-sdk/ompt.cpp -+++ b/source/lib/rocprofiler-sdk/ompt.cpp -@@ -199,6 +199,8 @@ finalize_ompt() - } // namespace ompt - } // namespace rocprofiler - -+extern void* const rocprofiler_glog_vmodule_flag asm("_ZN3fLS13FLAGS_vmoduleB5cxx11E"); -+ - extern "C" { - - rocprofiler_status_t -@@ -245,6 +247,8 @@ ompt_start_tool(unsigned int omp_version, const char* runtime_version) ROCPROFIL - ompt_start_tool_result_t* - ompt_start_tool(unsigned int omp_version, const char* runtime_version) - { -+ if(rocprofiler_glog_vmodule_flag == nullptr) return nullptr; -+ - ::rocprofiler::registration::init_logging(); - ::rocprofiler::registration::initialize(); - return rocprofiler_ompt_start_tool(omp_version, runtime_version); --- -2.54.0 diff --git a/pkgs/development/rocm-modules/rocprofiler-sdk/default.nix b/pkgs/development/rocm-modules/rocprofiler-sdk/default.nix deleted file mode 100644 index a93c5e93c4e3e..0000000000000 --- a/pkgs/development/rocm-modules/rocprofiler-sdk/default.nix +++ /dev/null @@ -1,226 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - cmake, - ninja, - pkg-config, - clr, - rocm-cmake, - rocm-runtime, - rocprofiler-register, - rocprof-trace-decoder, - aqlprofile, - rocm-comgr, - rocmUpdateScript, - rccl, - python3, - python3Packages, - libdrm, - elfutils, - sqlite, - otf2, - zlib, - zstd, - xz, - numactl, - fmt, - glog, - gtest, - fetchpatch, - yaml-cpp, - elfio, - nlohmann_json, - makeWrapper, - gpuTargets ? (clr.localGpuTargets or clr.gpuTargets), - buildTests ? false, - buildSamples ? false, -}: - -# FIXME: devendor remaining git submodules: -# external/cereal -> https://github.com/jrmadsen/cereal -# external/gotcha -> https://github.com/jrmadsen/GOTCHA -# external/perfetto -> https://github.com/google/perfetto -# external/ptl -> https://github.com/jrmadsen/PTL - -# rocprofiler-sdk is the home of rocprofv3 -stdenv.mkDerivation (finalAttrs: { - pname = "rocprofiler-sdk"; - version = "7.2.4"; - - outputs = [ - "out" - "dev" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-7XCxu917Mgp3SQAKlTWj3ympgwOYW3aJFcOv/GhPk1c="; - fetchSubmodules = true; - sparseCheckout = [ - "projects/rocprofiler-sdk" - ]; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rocprofiler-sdk"; - - strictDeps = true; - - nativeBuildInputs = [ - cmake - ninja - pkg-config - clr - python3 - makeWrapper - ]; - - buildInputs = [ - clr - rocm-cmake - rocm-runtime - rocprofiler-register - aqlprofile - rocm-comgr - libdrm - elfutils - sqlite - otf2 - zlib - zstd - xz - numactl - fmt - glog - gtest - yaml-cpp - elfio - nlohmann_json - rccl - python3Packages.pybind11 - ]; - - patches = [ - (fetchpatch { - # Fix missing amd_comgr linkage in pc-sampling integration test - url = "https://github.com/ROCm/rocm-systems/commit/94a4595a5d02bc066f7a32e1b2134a99a5231213.patch"; - hash = "sha256-86Fx0bKL0pvXTwVN8QJL+yzCbMYkmMaKzcU4PYcW6ig="; - relative = "projects/rocprofiler-sdk"; - }) - ] - ++ [ - # Just the missing CPackComponent reference sourced from this commit: - # https://github.com/ROCm/rocm-systems/commit/86ee7b2eb2273adaf1181ef9a6b2091465c6f0c7 - ./0001-fix-missing-CPackComponent-cmake-include.patch - ] - ++ [ - # Can be removed when a release contains the changes found in this pr: - # https://github.com/ROCm/rocm-systems/pull/4721 - ./0002-allow-using-system-yaml-dependency.patch - ./0003-allow-using-system-elfio-dependency.patch - ./0004-allow-using-system-otf2-dependency.patch - ./0005-allow-using-system-json-dependency.patch - ./0006-fix-amd-comgr-resolution.patch - ] - ++ [ - # Sourced from several commits that address issues with fmt, dropping conflicting changes no longer needed to build - # https://github.com/ROCm/rocm-systems/commit/36d9d33d90879bfbd406498011070ebd929a56b1 - # https://github.com/ROCm/rocm-systems/commit/e2f588592ecfb0653ed5b3078753186325adf70a - # https://github.com/ROCm/rocm-systems/commit/86ee7b2eb2273adaf1181ef9a6b2091465c6f0c7 (just the fmt changes) - ./0007-fix-missing-includes-and-api-changes-with-fmt-v12.2..patch - ] - ++ [ - # One new import failure added to source commit: - # https://github.com/ROCm/rocm-systems/pull/4721/changes/f7f24a54cbe55425fbefc87c7a3d0f4c85224948 - # which is also part of https://github.com/ROCm/rocm-systems/pull/4721 - ./0008-fix-compilation-errors-from-missing-includes.patch - ] - ++ [ - # Prevent a segfault on `import torch` (and other consumers that link - # librocprofiler-sdk for tracing) when OpenMP auto-discovers our - # ompt_start_tool before glog is initialized. Upstream incidentally fixes - # this by dropping glog in rocm-systems d80117889b3f - # "[rocprofiler-sdk] Migrate from glog to Abseil Logging (#4668)", which - # is too invasive (40 files + new abseil submodule) to backport. - ./0009-rocprofiler-sdk-guard-ompt-auto-start.patch - ]; - - postPatch = '' - # NixOS' ROCm distribution does not support libomptarget yet - substituteInPlace samples/CMakeLists.txt \ - --replace-fail 'add_subdirectory(openmp_target)' '# add_subdirectory(openmp_target)' - substituteInPlace tests/CMakeLists.txt \ - --replace-fail 'add_subdirectory(openmp-tools)' '# add_subdirectory(openmp-tools)' - substituteInPlace tests/bin/CMakeLists.txt \ - --replace-fail 'add_subdirectory(openmp)' '# add_subdirectory(openmp)' - - # This requires building perfetto's trace-processor-shell via a weird external script - substituteInPlace tests/CMakeLists.txt \ - --replace-fail 'add_subdirectory(pytest-packages)' "" - - patchShebangs source/libexec/rocprofiler-sdk/rocprofiler-sdk-launch-compiler/rocprofiler-sdk-launch-compiler.sh - ''; - - cmakeFlags = [ - (lib.cmakeBool "ROCPROFILER_BUILD_GHC_FS" false) - (lib.cmakeBool "ROCPROFILER_BUILD_FMT" false) - (lib.cmakeBool "ROCPROFILER_BUILD_GLOG" false) - (lib.cmakeBool "ROCPROFILER_BUILD_GTEST" false) - (lib.cmakeBool "ROCPROFILER_BUILD_PYBIND11" false) - (lib.cmakeBool "ROCPROFILER_BUILD_YAML_CPP" false) - (lib.cmakeBool "ROCPROFILER_BUILD_ELFIO" false) - (lib.cmakeBool "ROCPROFILER_BUILD_OTF2" false) - (lib.cmakeBool "ROCPROFILER_BUILD_JSON" false) - (lib.cmakeBool "ROCPROFILER_BUILD_TESTS" buildTests) - (lib.cmakeBool "ROCPROFILER_BUILD_SAMPLES" buildSamples) - (lib.cmakeBool "ROCPROFILER_BUILD_BENCHMARK" false) - (lib.cmakeBool "ROCPROFILER_BUILD_WERROR" false) - # rocprofiler-sdk's CMake file doesn't add this dependency properly. - "-DCMAKE_HIP_FLAGS=-I${rocm-runtime}/include" - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - # Required for rocprofiler-sdk-launch-compiler.sh - "-DCMAKE_INSTALL_LIBEXECDIR=libexec" - "--debug-find-pkg=amd_comgr" - "--trace-source=tests/pc_sampling/CMakeLists.txt" - "--trace-expand" - ] - ++ lib.optionals (buildTests || buildSamples) [ - # rocprofiler-sdk normally doesn't depend on which GPU is in the system, only when - # building tests or samples. - (lib.cmakeFeature "GPU_TARGETS" (lib.concatStringsSep ";" gpuTargets)) - ]; - cxxCMakeFlags = [ - "-Wno-unused-variable" - ]; - - doCheck = false; # Requires GPU - - postFixup = '' - patchelf $out/lib/*.so \ - --add-rpath ${aqlprofile}/lib \ - --add-needed libhsa-amd-aqlprofile64.so - - wrapProgram $out/bin/rocprofv3 --add-flags "--att-library-path ${ - lib.makeLibraryPath [ rocprof-trace-decoder ] - }" - ''; - - postInstall = '' - mkdir -p $dev/lib $dev/share/rocprofiler-sdk - mv $out/lib/cmake $dev/lib/ - mv $out/share/rocprofiler-sdk/{samples,tests} $dev/share/rocprofiler-sdk/ - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "ROCm GPU performance analysis SDK"; - homepage = "https://github.com/ROCm/rocprofiler-sdk"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocprofiler/default.nix b/pkgs/development/rocm-modules/rocprofiler/default.nix deleted file mode 100644 index 02500210e2d2b..0000000000000 --- a/pkgs/development/rocm-modules/rocprofiler/default.nix +++ /dev/null @@ -1,141 +0,0 @@ -{ - 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.localGpuTargets or 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.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-systems"; - tag = "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_ - # 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 = lib.licenses.mit; # mitx11 - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocr-debug-agent/default.nix b/pkgs/development/rocm-modules/rocr-debug-agent/default.nix deleted file mode 100644 index a153ff75e2847..0000000000000 --- a/pkgs/development/rocm-modules/rocr-debug-agent/default.nix +++ /dev/null @@ -1,55 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - python3, - clr, - rocdbgapi, - elfutils, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocr-debug-agent"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocr_debug_agent"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-w2Zg4kpuKy68DkVGsBTUsjRZoV/Y/Z3Q8s0oSIR3Ask="; - }; - - nativeBuildInputs = [ - cmake - clr - python3 # TODO: check for scripts that need patchShebangs in output - ]; - - buildInputs = [ - rocdbgapi - elfutils - ]; - - cmakeFlags = [ - "-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip" - "-DHIP_ROOT_DIR=${clr}" - "-DHIP_PATH=${clr}" - ]; - - # Weird install target - postInstall = '' - rm -rf $out/src - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "Library that provides some debugging functionality for ROCr"; - homepage = "https://github.com/ROCm/rocr_debug_agent"; - license = lib.licenses.ncsa; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocrand/default.nix b/pkgs/development/rocm-modules/rocrand/default.nix deleted file mode 100644 index cefff33fafd63..0000000000000 --- a/pkgs/development/rocm-modules/rocrand/default.nix +++ /dev/null @@ -1,98 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - clr, - gtest, - gbenchmark, - buildTests ? false, - buildBenchmarks ? false, - gpuTargets ? clr.localGpuTargets or [ ], -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocrand${clr.gpuArchSuffix}"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildTests [ - "test" - ] - ++ lib.optionals buildBenchmarks [ - "benchmark" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/rocrand" - "shared" - ]; - hash = "sha256-tl++h7LSEXf0jWe007+RIRwYHdB6TKPDpzipj1Emew8="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rocrand"; - - nativeBuildInputs = [ - cmake - rocm-cmake - clr - ]; - - buildInputs = - lib.optionals buildTests [ - gtest - ] - ++ lib.optionals buildBenchmarks [ - gbenchmark - ]; - - cmakeFlags = [ - "-DHIP_ROOT_DIR=${clr}" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ] - ++ lib.optionals (gpuTargets != [ ]) [ - "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - ] - ++ lib.optionals buildTests [ - "-DBUILD_TEST=ON" - ] - ++ lib.optionals buildBenchmarks [ - "-DBUILD_BENCHMARK=ON" - ]; - - postInstall = - lib.optionalString buildTests '' - mkdir -p $test/bin - mv $out/bin/test_* $test/bin - '' - + lib.optionalString buildBenchmarks '' - mkdir -p $benchmark/bin - mv $out/bin/benchmark_* $benchmark/bin - '' - + lib.optionalString (buildTests || buildBenchmarks) '' - rm -r $out/bin/rocRAND - # Fail if bin/ isn't actually empty - rmdir $out/bin - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "Generate pseudo-random and quasi-random numbers"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocrand"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocshmem/default.nix b/pkgs/development/rocm-modules/rocshmem/default.nix deleted file mode 100644 index 33c8f4cce5a46..0000000000000 --- a/pkgs/development/rocm-modules/rocshmem/default.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - rocm-core, - rocm-runtime, - clr, - mpi, - useMpi ? true, - useReverseOffload ? useMpi, - buildExamples ? false, - gpuTargets ? (clr.localGpuTargets or [ ]), -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocshmem${clr.gpuArchSuffix}"; - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocSHMEM"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-7TiUABwCVPvosoLdR8zN+QGiX+OD7iD+HKMLnGMmRYA="; - }; - - nativeBuildInputs = [ - cmake - rocm-cmake - clr - ]; - - buildInputs = [ - rocm-runtime - ] - ++ lib.optionals useMpi [ - mpi - ]; - - cmakeFlags = [ - (lib.cmakeBool "CMAKE_POSITION_INDEPENDENT_CODE" true) - (lib.cmakeFeature "CMAKE_CXX_COMPILER" "hipcc") - (lib.cmakeFeature "ROCM_PATH" "${clr}") - (lib.cmakeFeature "ROCM_VERSION" rocm-core.ROCM_LIBPATCH_VERSION) - (lib.cmakeBool "USE_IPC" true) - (lib.cmakeBool "USE_RO" useReverseOffload) - (lib.cmakeBool "USE_SINGLE_NODE" (!useMpi)) - (lib.cmakeBool "USE_EXTERNAL_MPI" useMpi) - (lib.cmakeBool "BUILD_EXAMPLES" buildExamples) - (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") - (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") - (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") - ] - ++ lib.optionals (gpuTargets != [ ]) [ - (lib.cmakeFeature "GPU_TARGETS" (lib.concatStringsSep ";" gpuTargets)) - ]; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "The ROCm OpenSHMEM (rocSHMEM) runtime"; - homepage = "https://github.com/ROCm/rocSHMEM"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocsolver/default.nix b/pkgs/development/rocm-modules/rocsolver/default.nix deleted file mode 100644 index a70d06e30efc7..0000000000000 --- a/pkgs/development/rocm-modules/rocsolver/default.nix +++ /dev/null @@ -1,135 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - rocblas, - rocprim, - rocsparse, - clr, - fmt, - gtest, - gfortran, - lapack-reference, - buildTests ? false, - buildBenchmarks ? false, - gpuTargets ? ( - clr.localGpuTargets or [ - "gfx900" - "gfx906" - "gfx908" - "gfx90a" - "gfx942" - "gfx1010" - "gfx1030" - "gfx1100" - "gfx1101" - "gfx1102" - "gfx1150" - "gfx1151" - "gfx1200" - "gfx1201" - ] - ), -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocsolver${clr.gpuArchSuffix}"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildTests [ - "test" - ] - ++ lib.optionals buildBenchmarks [ - "benchmark" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/rocsolver" - "shared" - ]; - hash = "sha256-n+Y8RheA0UYeSfpvOw5zfwe4VAW5hsKjlCXtBceGhf0="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rocsolver"; - - nativeBuildInputs = [ - cmake - # no ninja, it buffers console output and nix times out long periods of no output - rocm-cmake - clr - ] - ++ lib.optionals (buildTests || buildBenchmarks) [ - gfortran - ]; - - buildInputs = [ - # FIXME: rocblas and rocsolver can't build in parallel - # but rocsolver doesn't need rocblas' offload builds at build time - # could we build against a rocblas-minimal? - rocblas - rocprim - rocsparse - fmt - ] - ++ lib.optionals buildTests [ - gtest - ] - ++ lib.optionals (buildTests || buildBenchmarks) [ - lapack-reference - ]; - - cmakeFlags = [ - "-DHIP_CLANG_NUM_PARALLEL_JOBS=4" - "-DCMAKE_VERBOSE_MAKEFILE=ON" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ] - ++ lib.optionals (gpuTargets != [ ]) [ - "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - ] - ++ lib.optionals buildTests [ - "-DBUILD_CLIENTS_TESTS=ON" - ] - ++ lib.optionals buildBenchmarks [ - "-DBUILD_CLIENTS_BENCHMARKS=ON" - ]; - - postInstall = - lib.optionalString buildTests '' - mkdir -p $test/bin - mv $out/bin/rocsolver-test $test/bin - '' - + lib.optionalString buildBenchmarks '' - mkdir -p $benchmark/bin - mv $out/bin/rocsolver-bench $benchmark/bin - '' - + lib.optionalString (buildTests || buildBenchmarks) '' - rmdir $out/bin - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - requiredSystemFeatures = [ "big-parallel" ]; - - meta = { - description = "ROCm LAPACK implementation"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocsolver"; - license = lib.licenses.bsd2; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - timeout = 14400; # 4 hours - maxSilent = 14400; # 4 hours - }; -}) diff --git a/pkgs/development/rocm-modules/rocsparse/default.nix b/pkgs/development/rocm-modules/rocsparse/default.nix deleted file mode 100644 index db7b0b156850a..0000000000000 --- a/pkgs/development/rocm-modules/rocsparse/default.nix +++ /dev/null @@ -1,159 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - fetchzip, - rocmUpdateScript, - cmake, - rocm-cmake, - rocprim, - rocblas, - clr, - gfortran, - gtest, - boost, - python3Packages, - buildTests ? false, - buildBenchmarks ? false, # Seems to depend on tests - gpuTargets ? clr.localGpuTargets or clr.gpuTargets, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocsparse${clr.gpuArchSuffix}"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals (buildTests || buildBenchmarks) [ - "test" - ] - ++ lib.optionals buildBenchmarks [ - "benchmark" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/rocsparse" - "shared" - ]; - hash = "sha256-hkfBTcLig39al2w8zFTSQQnouaou9wlD6VlvIyFTNMg="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rocsparse"; - - nativeBuildInputs = [ - cmake - # no ninja, it buffers console output and nix times out long periods of no output - rocm-cmake - clr - gfortran - ]; - - buildInputs = [ - rocprim - rocblas - ] - ++ lib.optionals (buildTests || buildBenchmarks) [ - gtest - boost - python3Packages.python - python3Packages.pyyaml - ]; - - cmakeFlags = [ - "-DCMAKE_CXX_COMPILER=amdclang++" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ] - ++ lib.optionals (gpuTargets != [ ]) [ - "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - ] - ++ lib.optionals (buildTests || buildBenchmarks) [ - "-DBUILD_CLIENTS_TESTS=ON" - "-DCMAKE_MATRICES_DIR=/build/source/matrices" - "-Dpython=python3" - ] - ++ lib.optionals buildBenchmarks [ - "-DBUILD_CLIENTS_BENCHMARKS=ON" - ]; - - # We have to manually generate the matrices - postPatch = lib.optionalString (buildTests || buildBenchmarks) '' - mkdir -p matrices - - ln -s ${finalAttrs.passthru.matrices.matrix-01}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-02}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-03}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-04}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-05}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-06}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-07}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-08}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-09}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-10}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-11}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-12}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-13}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-14}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-15}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-16}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-17}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-18}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-19}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-20}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-21}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-22}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-23}/*.mtx matrices - ln -s ${finalAttrs.passthru.matrices.matrix-24}/*.mtx matrices - - # Not used by the original cmake, causes an error - rm matrices/*_b.mtx - - echo "deps/convert.cpp -> deps/mtx2csr" - hipcc deps/convert.cpp -O3 -o deps/mtx2csr - - for mat in $(ls -1 matrices | cut -d "." -f 1); do - echo "mtx2csr: $mat.mtx -> $mat.csr" - deps/mtx2csr matrices/$mat.mtx matrices/$mat.csr - unlink matrices/$mat.mtx - done - ''; - - postInstall = - lib.optionalString buildBenchmarks '' - mkdir -p $benchmark/bin - cp -a $out/bin/* $benchmark/bin - rm $benchmark/bin/rocsparse-test - '' - + lib.optionalString (buildTests || buildBenchmarks) '' - mkdir -p $test/bin - mv $out/bin/* $test/bin - rm $test/bin/rocsparse-bench || true - mv /build/source/matrices $test - rmdir $out/bin - ''; - - passthru = { - matrices = import ./deps.nix { - inherit fetchzip; - mirror1 = "https://sparse.tamu.edu/MM"; - mirror2 = "https://www.cise.ufl.edu/research/sparse/MM"; - }; - - updateScript = rocmUpdateScript { inherit finalAttrs; }; - }; - - meta = { - description = "ROCm SPARSE implementation"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocsparse"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocsparse/deps.nix b/pkgs/development/rocm-modules/rocsparse/deps.nix deleted file mode 100644 index 00096ca4bf7ba..0000000000000 --- a/pkgs/development/rocm-modules/rocsparse/deps.nix +++ /dev/null @@ -1,223 +0,0 @@ -{ - fetchzip, - mirror1, - mirror2, -}: - -{ - matrix-01 = fetchzip { - hash = "sha256-AHur5ZIDZTFRrO2GV0ieXrffq4KUiGWiZ59pv0fUtEQ="; - - urls = [ - "${mirror1}/SNAP/amazon0312.tar.gz" - "${mirror2}/SNAP/amazon0312.tar.gz" - ]; - }; - - matrix-02 = fetchzip { - hash = "sha256-0rSxaN4lQcdaCLsvlgicG70FXUxXeERPiEmQ4MzbRdE="; - - urls = [ - "${mirror1}/Muite/Chebyshev4.tar.gz" - "${mirror2}/Muite/Chebyshev4.tar.gz" - ]; - }; - - matrix-03 = fetchzip { - hash = "sha256-hDzDWDUnHEyFedX/tMNq83ZH8uWyM4xtZYUUAD3rizo="; - - urls = [ - "${mirror1}/FEMLAB/sme3Dc.tar.gz" - "${mirror2}/FEMLAB/sme3Dc.tar.gz" - ]; - }; - - matrix-04 = fetchzip { - hash = "sha256-GmN2yOt/MoX01rKe05aTyB3ypUP4YbQGOITZ0BqPmC0="; - - urls = [ - "${mirror1}/Williams/webbase-1M.tar.gz" - "${mirror2}/Williams/webbase-1M.tar.gz" - ]; - }; - - matrix-05 = fetchzip { - hash = "sha256-gQNjfVyWzNM9RwImJGhkhahRmZz74LzDs1oijL7mI7k="; - - urls = [ - "${mirror1}/Williams/mac_econ_fwd500.tar.gz" - "${mirror2}/Williams/mac_econ_fwd500.tar.gz" - ]; - }; - - matrix-06 = fetchzip { - hash = "sha256-87cdZjntNcTuz5BtO59irhcuRbPllWSbhCEX3Td02qc="; - - urls = [ - "${mirror1}/Williams/mc2depi.tar.gz" - "${mirror2}/Williams/mc2depi.tar.gz" - ]; - }; - - matrix-07 = fetchzip { - hash = "sha256-WRamuJX3D8Tm+k0q67RjUDG3DeNAxhKiaPkk5afY5eU="; - - urls = [ - "${mirror1}/Bova/rma10.tar.gz" - "${mirror2}/Bova/rma10.tar.gz" - ]; - }; - - matrix-08 = fetchzip { - hash = "sha256-5dhkm293Mc3lzakKxHy5W5XIn4Rw+gihVh7gyrjEHXo="; - - urls = [ - "${mirror1}/JGD_BIBD/bibd_22_8.tar.gz" - "${mirror2}/JGD_BIBD/bibd_22_8.tar.gz" - ]; - }; - - matrix-09 = fetchzip { - hash = "sha256-czjLWCjXAjZCk5TGYHaEkwSAzQu3TQ3QyB6eNKR4G88="; - - urls = [ - "${mirror1}/Hamm/scircuit.tar.gz" - "${mirror2}/Hamm/scircuit.tar.gz" - ]; - }; - - matrix-10 = fetchzip { - hash = "sha256-bYuLnJViAIcIejAkh69/bsNAVIDU4wfTLtD+nmHd6FM="; - - urls = [ - "${mirror1}/Sandia/ASIC_320k.tar.gz" - "${mirror2}/Sandia/ASIC_320k.tar.gz" - ]; - }; - - matrix-11 = fetchzip { - hash = "sha256-aDwn8P1khYjo2Agbq5m9ZBInJUxf/knJNvyptt0fak0="; - - urls = [ - "${mirror1}/GHS_psdef/bmwcra_1.tar.gz" - "${mirror2}/GHS_psdef/bmwcra_1.tar.gz" - ]; - }; - - matrix-12 = fetchzip { - hash = "sha256-8OJqA/byhlAZd869TPUzZFdsOiwOoRGfKyhM+RMjXoY="; - - urls = [ - "${mirror1}/HB/nos1.tar.gz" - "${mirror2}/HB/nos1.tar.gz" - ]; - }; - - matrix-13 = fetchzip { - hash = "sha256-FS0rKqmg+uHwsM/yGfQLBdd7LH/rUrdutkNGBD/Mh1I="; - - urls = [ - "${mirror1}/HB/nos2.tar.gz" - "${mirror2}/HB/nos2.tar.gz" - ]; - }; - - matrix-14 = fetchzip { - hash = "sha256-DANnlrNJikrI7Pst9vRedtbuxepyHmCIu2yhltc4Qcs="; - - urls = [ - "${mirror1}/HB/nos3.tar.gz" - "${mirror2}/HB/nos3.tar.gz" - ]; - }; - - matrix-15 = fetchzip { - hash = "sha256-21mUgqjWGUfYgiWwSrKh9vH8Vdt3xzcefmqYNYRpxiY="; - - urls = [ - "${mirror1}/HB/nos4.tar.gz" - "${mirror2}/HB/nos4.tar.gz" - ]; - }; - - matrix-16 = fetchzip { - hash = "sha256-FOuXvGqBBFNkVS6cexmkluret54hCfCOdK+DOZllE4c="; - - urls = [ - "${mirror1}/HB/nos5.tar.gz" - "${mirror2}/HB/nos5.tar.gz" - ]; - }; - - matrix-17 = fetchzip { - hash = "sha256-+7NI1rA/qQxYPpjXKHvAaCZ+LSaAJ4xuJvMRMBEUYxg="; - - urls = [ - "${mirror1}/HB/nos6.tar.gz" - "${mirror2}/HB/nos6.tar.gz" - ]; - }; - - matrix-18 = fetchzip { - hash = "sha256-q3NxJjbwGGcFiQ9nhWfUKgZmdVwCfPmgQoqy0AqOsNc="; - - urls = [ - "${mirror1}/HB/nos7.tar.gz" - "${mirror2}/HB/nos7.tar.gz" - ]; - }; - - matrix-19 = fetchzip { - hash = "sha256-0GAN6qmVfD+tprIigzuUUUwm5KVhkN9X65wMEvFltDY="; - - urls = [ - "${mirror1}/DNVS/shipsec1.tar.gz" - "${mirror2}/DNVS/shipsec1.tar.gz" - ]; - }; - - matrix-20 = fetchzip { - hash = "sha256-f28Du/Urxsiq5NkRmRO10Zz9vvGRjEchquzHzbZpZ7U="; - - urls = [ - "${mirror1}/Cote/mplate.tar.gz" - "${mirror2}/Cote/mplate.tar.gz" - ]; - }; - - matrix-21 = fetchzip { - hash = "sha256-O+Wy0NfCU1hVUOfNR1dJpvDHLBwwa301IRJDrQJnhak="; - - urls = [ - "${mirror1}/Bai/qc2534.tar.gz" - "${mirror2}/Bai/qc2534.tar.gz" - ]; - }; - - matrix-22 = fetchzip { - hash = "sha256-oxMnt8U5Cf1ILWcBdU6W9jdSMMm+U6bIVl8nm3n3+OA="; - - urls = [ - "${mirror1}/Chevron/Chevron2.tar.gz" - "${mirror2}/Chevron/Chevron2.tar.gz" - ]; - }; - - matrix-23 = fetchzip { - hash = "sha256-MFD9BxFI/3IS7yatW121BAI04fbqrXpgYDT5UKjeKcU="; - - urls = [ - "${mirror1}/Chevron/Chevron3.tar.gz" - "${mirror2}/Chevron/Chevron3.tar.gz" - ]; - }; - - matrix-24 = fetchzip { - hash = "sha256-ikS8O51pe1nt3BNyhvfvqCbVL0+bg/da9bqGqeBDkTg="; - - urls = [ - "${mirror1}/Chevron/Chevron4.tar.gz" - "${mirror2}/Chevron/Chevron4.tar.gz" - ]; - }; -} diff --git a/pkgs/development/rocm-modules/rocthrust/default.nix b/pkgs/development/rocm-modules/rocthrust/default.nix deleted file mode 100644 index 653498cb85653..0000000000000 --- a/pkgs/development/rocm-modules/rocthrust/default.nix +++ /dev/null @@ -1,93 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - rocprim, - clr, - gtest, - buildTests ? false, - buildBenchmarks ? false, - gpuTargets ? clr.localGpuTargets or [ ], -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocthrust"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildTests [ - "test" - ] - ++ lib.optionals buildBenchmarks [ - "benchmark" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/rocthrust" - "shared" - ]; - hash = "sha256-wHEgpmBZCYtvp+OyebrRyfoFz3WQyKWfHPrdzQVL8lY="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rocthrust"; - - nativeBuildInputs = [ - cmake - rocm-cmake - rocprim - clr - ]; - - buildInputs = lib.optionals buildTests [ - gtest - ]; - - cmakeFlags = [ - "-DHIP_ROOT_DIR=${clr}" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ] - ++ lib.optionals (gpuTargets != [ ]) [ - "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - ] - ++ lib.optionals buildTests [ - "-DBUILD_TEST=ON" - ] - ++ lib.optionals buildBenchmarks [ - "-DBUILD_BENCHMARKS=ON" - ]; - - postInstall = - lib.optionalString buildTests '' - mkdir -p $test/bin - mv $out/bin/{test_*,*.hip} $test/bin - '' - + lib.optionalString buildBenchmarks '' - mkdir -p $benchmark/bin - mv $out/bin/benchmark_* $benchmark/bin - '' - + lib.optionalString (buildTests || buildBenchmarks) '' - rm -rf $out/bin - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "ROCm parallel algorithm library"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocthrust"; - license = lib.licenses.asl20; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/roctracer/default.nix b/pkgs/development/rocm-modules/roctracer/default.nix deleted file mode 100644 index 6cc979eb3648e..0000000000000 --- a/pkgs/development/rocm-modules/roctracer/default.nix +++ /dev/null @@ -1,118 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - clr, - rocm-device-libs, - libxml2, - doxygen, - graphviz, - gcc-unwrapped, - libbacktrace, - rocm-runtime, - python3Packages, - buildDocs ? false, # Nothing seems to be generated, so not making the output - buildTests ? false, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "roctracer"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals buildDocs [ - "doc" - ] - ++ lib.optionals buildTests [ - "test" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-systems"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/roctracer" - "shared" - ]; - hash = "sha256-Ps9b/MMdxXthGV96ZDg0kZGPdmn7Sy5if1a/Fjx2fEE="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/roctracer"; - - nativeBuildInputs = [ - cmake - clr - ] - ++ lib.optionals buildDocs [ - doxygen - graphviz - ]; - - buildInputs = [ - libxml2 - libbacktrace - python3Packages.python - python3Packages.cppheaderparser - ]; - - cmakeFlags = [ - "-DCMAKE_MODULE_PATH=${clr}/hip/cmake" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ]; - - env.NIX_CFLAGS_COMPILE = toString [ - # Needed with GCC 12 - "-Wno-error=array-bounds" - ]; - - postPatch = '' - export HIP_DEVICE_LIB_PATH=${rocm-device-libs}/amdgcn/bitcode - '' - + lib.optionalString (!buildTests) '' - substituteInPlace CMakeLists.txt \ - --replace "add_subdirectory(test)" "" - ''; - - # Tests always fail, probably need GPU - # doCheck = buildTests; - - postInstall = - lib.optionalString buildDocs '' - mkdir -p $doc - '' - + lib.optionalString buildTests '' - mkdir -p $test/bin - # Not sure why this is an install target - find $out/test -executable -type f -exec mv {} $test/bin \; - rm $test/bin/{*.sh,*.py} - patchelf --set-rpath $out/lib:${ - lib.makeLibraryPath ( - finalAttrs.buildInputs - ++ [ - clr - gcc-unwrapped.lib - rocm-runtime - ] - ) - } $test/bin/* - rm -rf $out/test - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "Tracer callback/activity library"; - homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/roctracer"; - license = lib.licenses.mit; # mitx11 - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rocwmma/0000-dont-fetch-googletest.patch b/pkgs/development/rocm-modules/rocwmma/0000-dont-fetch-googletest.patch deleted file mode 100644 index fa47a3c42249b..0000000000000 --- a/pkgs/development/rocm-modules/rocwmma/0000-dont-fetch-googletest.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt -index 0d00883..86ce282 100644 ---- a/test/CMakeLists.txt -+++ b/test/CMakeLists.txt -@@ -30,30 +30,6 @@ cmake_dependent_option( ROCWMMA_BUILD_VALIDATION_TESTS "Build validation tests" - cmake_dependent_option( ROCWMMA_BUILD_BENCHMARK_TESTS "Build benchmarking tests" OFF "ROCWMMA_BUILD_TESTS" OFF ) - cmake_dependent_option( ROCWMMA_BUILD_EXTENDED_TESTS "Build extended test parameter coverage" OFF "ROCWMMA_BUILD_TESTS" OFF ) - --# Test/benchmark requires additional dependencies --include( FetchContent ) -- --FetchContent_Declare( -- googletest -- GIT_REPOSITORY https://github.com/google/googletest.git -- GIT_TAG release-1.12.1 --) --FetchContent_GetProperties(googletest) --if(NOT googletest_POPULATED) -- -- # Fetch the content using default details -- FetchContent_Populate(googletest) -- # Save the shared libs setting, then force to static libs -- set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS}) -- set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build SHARED libraries" FORCE) -- -- # Add gtest targets as static libs -- add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) -- -- # Restore shared libs setting -- set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD} CACHE INTERNAL "Build SHARED libraries" FORCE) --endif() -- - set(ROCWMMA_TEST_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) - set(ROCWMMA_COMMON_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hip_device.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rocwmma_gtest_main.cpp) diff --git a/pkgs/development/rocm-modules/rocwmma/default.nix b/pkgs/development/rocm-modules/rocwmma/default.nix deleted file mode 100644 index 454cced2a0fdd..0000000000000 --- a/pkgs/development/rocm-modules/rocwmma/default.nix +++ /dev/null @@ -1,116 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - rocm-smi, - clr, - openmp, - gtest, - rocblas, - buildTests ? false, # Will likely fail building because wavefront shifts are not supported for certain archs - buildExtendedTests ? false, - buildBenchmarks ? false, - buildSamples ? false, - gpuTargets ? clr.localGpuTargets or [ ], -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rocwmma"; - version = "7.2.4"; - - outputs = [ - "out" - ] - ++ lib.optionals (buildTests || buildBenchmarks) [ - "test" - ] - ++ lib.optionals buildBenchmarks [ - "benchmark" - ] - ++ lib.optionals buildSamples [ - "sample" - ]; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "projects/rocwmma" - "shared" - ]; - hash = "sha256-eoF8a7zknpgvDOSDzolOrdtszUJ5tC7Ur2sRShiQEO0="; - }; - sourceRoot = "${finalAttrs.src.name}/projects/rocwmma"; - - patches = lib.optionals (buildTests || buildBenchmarks) [ - ./0000-dont-fetch-googletest.patch - ]; - - nativeBuildInputs = [ - cmake - rocm-cmake - clr - ]; - - buildInputs = [ - openmp - ] - ++ lib.optionals (buildTests || buildBenchmarks) [ - rocm-smi - gtest - rocblas - ]; - - cmakeFlags = [ - "-DROCWMMA_BUILD_TESTS=${if buildTests || buildBenchmarks then "ON" else "OFF"}" - "-DROCWMMA_BUILD_SAMPLES=${if buildSamples then "ON" else "OFF"}" - # Manually define CMAKE_INSTALL_ - # See: https://github.com/NixOS/nixpkgs/pull/197838 - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - ] - ++ lib.optionals (gpuTargets != [ ]) [ - "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - ] - ++ lib.optionals buildExtendedTests [ - "-DROCWMMA_BUILD_EXTENDED_TESTS=ON" - ] - ++ lib.optionals buildBenchmarks [ - "-DROCWMMA_BUILD_BENCHMARK_TESTS=ON" - "-DROCWMMA_BENCHMARK_WITH_ROCBLAS=ON" - ]; - - postInstall = - lib.optionalString (buildTests || buildBenchmarks) '' - mkdir -p $test/bin - mv $out/bin/{*_test,*-validate} $test/bin - '' - + lib.optionalString buildBenchmarks '' - mkdir -p $benchmark/bin - mv $out/bin/*-bench $benchmark/bin - '' - + lib.optionalString buildSamples '' - mkdir -p $sample/bin - mv $out/bin/sgemmv $sample/bin - mv $out/bin/simple_gemm $sample/bin - mv $out/bin/simple_dlrm $sample/bin - '' - + lib.optionalString (buildTests || buildBenchmarks || buildSamples) '' - rm -rf $out/bin - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "Mixed precision matrix multiplication and accumulation"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/projects/rocwmma"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/rpp/default.nix b/pkgs/development/rocm-modules/rpp/default.nix deleted file mode 100644 index f43c630e470ed..0000000000000 --- a/pkgs/development/rocm-modules/rpp/default.nix +++ /dev/null @@ -1,77 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - rocmUpdateScript, - cmake, - rocm-cmake, - rocm-docs-core, - half, - clr, - openmp, - boost, - python3Packages, - buildDocs ? false, # Needs internet - useCPU ? false, - gpuTargets ? clr.localGpuTargets or [ ], -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "rpp-${if useCPU then "cpu" else "hip"}"; - - version = "7.2.4"; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rpp"; - tag = "rocm-${finalAttrs.version}"; - hash = "sha256-6e4JHKFC2dvtSGo9xbQKzIdUwlHB09pr5C/5xHwP3l4="; - }; - - nativeBuildInputs = [ - cmake - rocm-cmake - clr - ] - ++ lib.optionals buildDocs [ - rocm-docs-core - python3Packages.python - ]; - - buildInputs = [ - half - openmp - boost - ]; - - cmakeFlags = [ - "-DROCM_PATH=${clr}" - "-DCMAKE_INSTALL_BINDIR=bin" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DCMAKE_INSTALL_INCLUDEDIR=include" - "-DBACKEND=${if useCPU then "CPU" else "HIP"}" - ] - ++ lib.optionals (gpuTargets != [ ]) [ - "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - ]; - - postPatch = lib.optionalString (!useCPU) '' - # Bad path - substituteInPlace CMakeLists.txt \ - --replace "COMPILER_FOR_HIP \''${ROCM_PATH}/llvm/bin/clang++" "COMPILER_FOR_HIP ${clr}/bin/hipcc" - ''; - - postBuild = lib.optionalString buildDocs '' - python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en ../docs _build/html - ''; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "Comprehensive high-performance computer vision library for AMD processors"; - homepage = "https://github.com/ROCm/rpp"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/tensile/default.nix b/pkgs/development/rocm-modules/tensile/default.nix deleted file mode 100644 index ee84ccc4eabe0..0000000000000 --- a/pkgs/development/rocm-modules/tensile/default.nix +++ /dev/null @@ -1,96 +0,0 @@ -{ - lib, - fetchFromGitHub, - fetchpatch, - rocmUpdateScript, - buildPythonPackage, - pytestCheckHook, - setuptools, - distro, - pyyaml, - msgpack, - pandas, - joblib, - filelock, - clr, - rich, -}: - -buildPythonPackage (finalAttrs: { - pname = "tensile"; - version = "7.2.4"; - pyproject = true; - - src = fetchFromGitHub { - owner = "ROCm"; - repo = "rocm-libraries"; - tag = "rocm-${finalAttrs.version}"; - sparseCheckout = [ - "shared/tensile" - "shared" - ]; - hash = "sha256-sYudPiEPGeZLmf6+3XfQDZqRXiKgRsGPucApzYwlGV8="; - }; - sourceRoot = "${finalAttrs.src.name}/shared/tensile"; - - # TODO: It should be possible to run asm caps test ONCE for all supported arches - # We currently disable the test because it's slow and runs each time tensile launches - postPatch = '' - substituteInPlace Tensile/Common.py \ - --replace-fail 'if globalParameters["AssemblerPath"] is not None:' "if False:" - # Add an assert that the fallback 9,0,0 is supported before setting the kernel to it - # If it's not detected as supported we have an issue with compiler paths or the compiler is broken - # and it's better to stop immediately - substituteInPlace Tensile/KernelWriter.py \ - --replace-fail '= (9,0,0)' '= (9,0,0);assert(globalParameters["AsmCaps"][(9,0,0)]["SupportedISA"])' - find . -type f -iname "*.sh" -exec chmod +x {} \; - patchShebangs Tensile - ''; - - buildInputs = [ setuptools ]; - - propagatedBuildInputs = [ - pyyaml - msgpack - pandas - joblib - distro - rich - ]; - - patches = [ - ./tensile-solutionstructs-perf-fix.diff - ./tensile-create-library-dont-copy-twice.diff - (fetchpatch { - # [PATCH] Extend Tensile HIP ISA compatibility - hash = "sha256-ZHXNYSeLkhhNDaIfdqQm68Pxmh1shUL7mAVmh8/I6Xk="; - url = "https://github.com/GZGavinZhao/rocm-libraries/commit/1f7135dfc0cdb175c8f0e5eb71b2d24699942873.patch"; - relative = "shared/tensile"; - }) - ]; - - doCheck = false; # Too many errors, not sure how to set this up properly - - nativeCheckInputs = [ - pytestCheckHook - filelock - clr - ]; - - env = { - dontCheckPythonMetadata = true; - ROCM_PATH = "${clr}"; - }; - - pythonImportsCheck = [ "Tensile" ]; - - passthru.updateScript = rocmUpdateScript { inherit finalAttrs; }; - - meta = { - description = "GEMMs and tensor contractions"; - homepage = "https://github.com/ROCm/rocm-libraries/tree/develop/shared/tensile"; - license = lib.licenses.mit; - teams = [ lib.teams.rocm ]; - platforms = lib.platforms.linux; - }; -}) diff --git a/pkgs/development/rocm-modules/tensile/tensile-create-library-dont-copy-twice.diff b/pkgs/development/rocm-modules/tensile/tensile-create-library-dont-copy-twice.diff deleted file mode 100644 index 2b680241d9e4e..0000000000000 --- a/pkgs/development/rocm-modules/tensile/tensile-create-library-dont-copy-twice.diff +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/Tensile/TensileCreateLibrary.py b/Tensile/TensileCreateLibrary.py -index a1644606..c6ca2882 100644 ---- a/Tensile/TensileCreateLibrary.py -+++ b/Tensile/TensileCreateLibrary.py -@@ -852,9 +852,14 @@ def copyStaticFiles(outputPath=None): - "KernelHeader.h", - ] - -+ import filecmp - for fileName in libraryStaticFiles: - # copy file -- shutil.copy(os.path.join(globalParameters["SourcePath"], fileName), outputPath) -+ # no need to copy twice if it has already been copied -+ src = os.path.join(globalParameters["SourcePath"], fileName) -+ dst = os.path.join(outputPath, os.path.basename(src)) -+ if not os.path.isfile(dst) or not filecmp.cmp(src, dst): -+ shutil.copyfile(src, dst) - - return libraryStaticFiles - diff --git a/pkgs/development/rocm-modules/tensile/tensile-solutionstructs-perf-fix.diff b/pkgs/development/rocm-modules/tensile/tensile-solutionstructs-perf-fix.diff deleted file mode 100644 index 7157238042ece..0000000000000 --- a/pkgs/development/rocm-modules/tensile/tensile-solutionstructs-perf-fix.diff +++ /dev/null @@ -1,48 +0,0 @@ -diff --git a/Tensile/SolutionStructs.py b/Tensile/SolutionStructs.py -index f663c6f1..17bcf897 100644 ---- a/Tensile/SolutionStructs.py -+++ b/Tensile/SolutionStructs.py -@@ -4828,24 +4828,26 @@ class Solution(collections.abc.Mapping): - # create a dictionary of lists of parameter values - @staticmethod - def getSerialNaming(objs): -+ valid_params = sorted(validParameters.keys()) - data = {} -- for objIdx in range(0, len(objs)): -- obj = objs[objIdx] -- for paramName in sorted(obj.keys()): -- if paramName in list(validParameters.keys()): -- paramValue = obj[paramName] -- if paramName in data: -- if paramValue not in data[paramName]: -- data[paramName].append(paramValue) -- else: -- data[paramName] = [ paramValue ] -- maxObjs = 1 -- for paramName in data: -- if not isinstance(data[paramName][0],dict): -- data[paramName] = sorted(data[paramName]) -- maxObjs *= len(data[paramName]) -- numDigits = len(str(maxObjs)) -- return [ data, numDigits ] -+ -+ objs = [getattr(obj, "_state", obj) for obj in objs] -+ -+ for param in valid_params: -+ d = [] -+ for obj in objs: -+ if param in obj: -+ v = obj[param] -+ if v not in d: -+ d.append(v) -+ if len(d): -+ if not isinstance(d[0], dict): d.sort() -+ data[param] = d -+ -+ # Calculate max objects using prod() from math module -+ max_objs = math.prod(len(values) for values in data.values()) -+ num_digits = len(str(max_objs)) -+ return data, num_digits - - ######################################## - # Get Name Serial \ No newline at end of file From 804d44fe2175d22674a8516bc519f5f06f5b7e5a Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:59 -0700 Subject: [PATCH 75/79] torch: add libdrm for ROCm 10 find_package(Torch) runs Caffe2's LoadHIP, which loads ROCm 10's rocm_smi-config.cmake; that calls pkg_check_modules(libdrm). Add libdrm to the ROCm build inputs and propagate its dev output to C++ consumers through cxxdev, so builds against torch (OpenSplat) find libdrm.pc as well. cxxdev's propagated-build-inputs is written from plain store paths, so the default output would not carry the .pc file. Assisted-by: Claude Code (claude-opus-5-5) --- .../python-modules/torch/source/default.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/torch/source/default.nix b/pkgs/development/python-modules/torch/source/default.nix index bfa46e21f05e7..dc086b32c6b50 100644 --- a/pkgs/development/python-modules/torch/source/default.nix +++ b/pkgs/development/python-modules/torch/source/default.nix @@ -58,6 +58,7 @@ openssl, numactl, llvmPackages, + libdrm, # dependencies filelock, @@ -646,6 +647,7 @@ buildPythonPackage.override { inherit stdenv; } (finalAttrs: { ++ lib.optionals rocmSupport [ rocmtoolkit_joined rocmPackages.clr # Added separately so setup hook applies + libdrm ]; dependencies = [ @@ -673,7 +675,13 @@ buildPythonPackage.override { inherit stdenv; } (finalAttrs: { ]; propagatedCxxBuildInputs = - [ ] ++ lib.optionals MPISupport [ mpi ] ++ lib.optionals rocmSupport [ rocmtoolkit_joined ]; + [ ] + ++ lib.optionals MPISupport [ mpi ] + ++ lib.optionals rocmSupport [ + rocmtoolkit_joined + # cxxdev records plain store paths, so name the output with libdrm.pc + (lib.getDev libdrm) + ]; # Tests take a long time and may be flaky, so just sanity-check imports doCheck = false; From 6a719c5957f5c46fe2d08042a845a21b23a516d0 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Sun, 25 Oct 2026 15:55:55 -0700 Subject: [PATCH 76/79] torch: add hipfile for ROCm 10 torch 2.14's cmake/public/LoadHIP.cmake runs find_package(hipfile REQUIRED) when ROCM_VERSION_DEV is 7.14 or later ("hipFile is Linux-only and ships with ROCm 7.14 and later, where it is required"), so configuring against ROCm 10.1 failed. Add rocmPackages.hipfile to rocmtoolkit_joined, which torch's CMake searches and cxxdev propagates to C++ consumers (OpenSplat, torchcodec), whose find_package(Torch) runs the same LoadHIP. With hipfile found, USE_CUFILE stays on (Dependencies.cmake turns it off only when hipfile is missing). Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/python-modules/torch/source/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/development/python-modules/torch/source/default.nix b/pkgs/development/python-modules/torch/source/default.nix index dc086b32c6b50..acf87c6f362a9 100644 --- a/pkgs/development/python-modules/torch/source/default.nix +++ b/pkgs/development/python-modules/torch/source/default.nix @@ -237,6 +237,8 @@ let rocprofiler-sdk rocprofiler-sdk.dev amdsmi + # LoadHIP requires hipfile from ROCm 7.14 on + hipfile ] ++ lib.optionals (!vendorComposableKernel) [ composable_kernel From 1cd2ff7fc682ee86416b30406dfd72ae20aa48bc Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Sun, 25 Oct 2026 23:30:17 -0700 Subject: [PATCH 77/79] python3Packages.vllm: add hipfile for ROCm 10 vLLM's CMakeLists.txt runs find_package(Torch), and torch 2.14's LoadHIP.cmake requires hipfile from ROCm 7.14 on, so configuring against ROCm 10.1 failed with "Could not find a package configuration file provided by hipfile". vLLM lists its ROCm libraries itself rather than taking them from torch's cxxdev, so add hipfile there. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/development/python-modules/vllm/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/development/python-modules/vllm/default.nix b/pkgs/development/python-modules/vllm/default.nix index 54f7c55f8ad62..f0f908ebb79c8 100644 --- a/pkgs/development/python-modules/vllm/default.nix +++ b/pkgs/development/python-modules/vllm/default.nix @@ -539,6 +539,8 @@ buildPythonPackage.override { stdenv = torch.stdenv; } (finalAttrs: { rocshmem rocm-smi hipsparselt + # torch's LoadHIP requires hipfile from ROCm 7.14 on + hipfile ] ) ++ lib.optionals stdenv.cc.isClang [ From 66e9a66e891bc8c78d2aaf5db13c7092c538769c Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:19:59 -0700 Subject: [PATCH 78/79] ollama: use the rocm_v7_2 backend with ROCm 10 cmake/local.cmake only knows the rocm_v7_1 and rocm_v7_2 backend labels, so deriving the label from the ROCm version fails with "Unknown ROCm backend" on ROCm 10. The label only selects ollama's build preset; the runner links the ROCm in buildInputs. Assisted-by: Claude Code (claude-opus-5-5) --- pkgs/by-name/ol/ollama/package.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/ol/ollama/package.nix b/pkgs/by-name/ol/ollama/package.nix index 48ce97ec8b4d9..59000f20c6ffc 100644 --- a/pkgs/by-name/ol/ollama/package.nix +++ b/pkgs/by-name/ol/ollama/package.nix @@ -259,13 +259,12 @@ goBuild (finalAttrs: { # ship without `libggml-cuda.so` and fall back to CPU at runtime. # The accepted values map to cmake/local.cmake's elseif chain # (cuda_v12 / cuda_v13 / rocm_v7_1 / rocm_v7_2 / vulkan / cuda_jetpack*). - rocmMajorVersion = lib.versions.major rocmPackages.clr.version; - rocmMinorVersion = lib.versions.minor rocmPackages.clr.version; llamaBackend = if enableCuda then "cuda_v${cudaMajorVersion}" else if enableRocm then - "rocm_v${rocmMajorVersion}_${rocmMinorVersion}" + # TODO: switch to a ROCm 10 backend once ollama has one. + "rocm_v7_2" else if enableVulkan then "vulkan" else From 41c5e067d967d494100d08152a58b74675bb5d60 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Thu, 22 Oct 2026 07:20:00 -0700 Subject: [PATCH 79/79] nixos/doc/manual/release-notes: note ROCm 10.1 update Describe the ROCm 7.2.4 -> 10.1 update: ABI/API breaks, LLVM 24, rocmlir replaced by rocmlir-triton, the new hipfile package that torch 2.14 requires, dropped gfx900/gfx906 support in composable_kernel and MIOpen's CK solvers, and the disabled hipconv backend. Assisted-by: Claude Code (claude-opus-5-5) --- .../manual/release-notes/rl-2611.section.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/nixos/doc/manual/release-notes/rl-2611.section.md b/nixos/doc/manual/release-notes/rl-2611.section.md index 06d6aeab3660b..cba8545e6f556 100644 --- a/nixos/doc/manual/release-notes/rl-2611.section.md +++ b/nixos/doc/manual/release-notes/rl-2611.section.md @@ -634,3 +634,30 @@ The above example can be migrated via the following structured code block: - `services.photoprism` installations that are upgrading to version `260919-28c46a116` or later are advised to [migrate their library](https://docs.photoprism.app/user-guide/ai/face-recognition/#upgrading-an-existing-library) to take advantage of the newer face detection and embedding models. This can be done by using the `photoprism-manage` script. - `rocmPackages.rocm-bandwidth-test` has been removed; upstream retired it. + +- `rocmPackages` has been updated from ROCm 7.2.4 to ROCm 10.1. AMD skipped + the 8.x and 9.x series. ROCm 10 breaks ABI and API: + `amdsmi` moves to the 27.0.0 ABI (`libamd_smi.so.27`, several clock/throttle + APIs removed), `rocsparse` drops `rocsparse_indextype_u16`, `hipcub` removes + its deprecated iterators and operators, and `miopen` drops its OpenCL backend. + Update out-of-tree packages that compile against `rocmPackages` for these + changes. The ROCm LLVM toolchain is now LLVM 24. + + `rocmPackages.rocmlir` has been removed: `ROCm/rocMLIR` has no ROCm 10 + release. MIGraphX uses `rocmPackages.rocmlir-triton`, the fork that + AMDMIGraphX 10.1 pins. MIOpen 10.1 is built without MLIR, following + upstream's new default. + + `rocmPackages.hipfile` is new: hipFile, ROCm's direct-to-GPU file I/O + library (the counterpart of cuFile). PyTorch 2.14 requires it with ROCm 7.14 + and later, so `torch` with `rocmSupport` now builds against it. + + `composable_kernel`, the `miopen` CK solvers, and `vllm` no longer support + `gfx900`/`gfx906` (Vega / MI25 / MI50 / Radeon VII) on ROCm 10. + `rocblas`/`hipblas`-only consumers such as `llama-cpp` and `ollama` still + build for those targets. To stay on ROCm 7.2.x, use the NixOS 26.05 + stable channel. + + The versioned `rocmPackages_10` attribute remains available. MIOpen's hipconv + backend is disabled because its cdna4 kernels fail to compile with the ROCm + LLVM 24 toolchain.