Unverified Commit 32d957e0 authored by Masum Reza's avatar Masum Reza Committed by GitHub
Browse files

rocmPackages: clean up, reduce closure sizes (#444860)

parents 45716e15 c1cfcf38
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -203,8 +203,8 @@ stdenv.mkDerivation (finalAttrs: {
    # Can't easily apply the PR as a patch because we rely on the tarball with pregenerated
    # hipified files ∴ fetchpatch of the PR will apply cleanly but fail to build
    (strings.cmakeFeature "ROCM_CORE" "${rocmPackages.clr}")
    (strings.cmakeFeature "CMAKE_C_COMPILER" "${rocmPackages.clr}/bin/clang")
    (strings.cmakeFeature "CMAKE_CXX_COMPILER" "${rocmPackages.clr}/bin/clang++")
    (strings.cmakeFeature "CMAKE_C_COMPILER" "${rocmPackages.clang}/bin/clang")
    (strings.cmakeFeature "CMAKE_CXX_COMPILER" "${rocmPackages.clang}/bin/clang++")
  ];

  # Magma doesn't have a test suite we can easily run, just loose executables, all of which require a GPU.
+21 −4
Original line number Diff line number Diff line
@@ -13,10 +13,12 @@
  rocm-device-libs,
  rocm-comgr,
  rocm-runtime,
  rocm-toolchain,
  rocm-core,
  roctracer,
  rocminfo,
  rocm-smi,
  symlinkJoin,
  numactl,
  libffi,
  zstd,
@@ -25,7 +27,7 @@
  libxml2,
  libX11,
  python3Packages,
  rocm-merged-llvm,
  llvm,
  khronos-ocl-icd-loader,
  gcc-unwrapped,
  writeShellScriptBin,
@@ -34,7 +36,20 @@

let
  inherit (rocm-core) ROCM_LIBPATCH_VERSION;
  hipClang = rocm-merged-llvm;
  # 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"
@@ -83,6 +98,7 @@ stdenv.mkDerivation (finalAttrs: {
  ];

  buildInputs = [
    llvm.llvm
    numactl
    libGL
    libxml2
@@ -100,6 +116,7 @@ stdenv.mkDerivation (finalAttrs: {
    rocm-comgr
    rocm-runtime
    rocminfo
    hipClangPath
  ];

  cmakeBuildType = "RelWithDebInfo";
@@ -162,7 +179,8 @@ stdenv.mkDerivation (finalAttrs: {
      --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/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/";' \
@@ -206,7 +224,6 @@ stdenv.mkDerivation (finalAttrs: {
    ln -s ${rocm-core}/.info/ $out/.info

    ln -s ${hipClang} $out/llvm
    ln -s ${hipClang}/bin/{ld.lld,lld,clang-offload-bundler,llvm-objcopy,clang,clang++} $out/bin/
  '';

  disallowedRequisites = [
+1 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
  rocmUpdateScript,
  cmake,
  rocm-cmake,
  rocm-merged-llvm,
  llvm,
  clr,
  rocminfo,
  python3,
@@ -85,7 +85,6 @@ stdenv.mkDerivation (finalAttrs: {
  strictDeps = true;
  enableParallelBuilding = true;
  env.ROCM_PATH = clr;
  env.HIP_CLANG_PATH = "${rocm-merged-llvm}/bin";

  cmakeFlags = [
    "-DCMAKE_MODULE_PATH=${clr}/hip/cmake"
+2 −2
Original line number Diff line number Diff line
@@ -3,9 +3,9 @@
  python,
  composable_kernel,
  lib,
  rocm-toolchain,
  setuptools,
  setuptools-scm,
  rocm-merged-llvm,
}:
buildPythonPackage {
  pyproject = true;
@@ -25,7 +25,7 @@ buildPythonPackage {
  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-merged-llvm
    rocm-toolchain
  ];
  checkPhase = ''
    if [ ! -d "$out/${python.sitePackages}/ck4inductor" ]; then
+22 −21
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ let
      buildTests = false;
      buildBenchmarks = false;

      rocmPath = self.callPackage ./rocm-path { };
      rocmUpdateScript = self.callPackage ./update.nix { };

      ## ROCm ##
@@ -41,26 +40,19 @@ let
          inherit (self) rocm-device-libs;
        }
      );
      inherit (self.llvm) rocm-merged-llvm clang openmp;
      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 {
        stdenv = origStdenv;
        inherit (llvm) rocm-merged-llvm;
      };
      rocm-device-libs = self.callPackage ./rocm-device-libs { };

      rocm-runtime = self.callPackage ./rocm-runtime {
        stdenv = origStdenv;
        inherit (llvm) rocm-merged-llvm;
      };

      rocm-comgr = self.callPackage ./rocm-comgr {
        stdenv = origStdenv;
        inherit (llvm) rocm-merged-llvm;
      };
      rocm-comgr = self.callPackage ./rocm-comgr { };

      rocminfo = self.callPackage ./rocminfo { stdenv = origStdenv; };

@@ -80,10 +72,7 @@ let

      hip-common = self.callPackage ./hip-common { };

      hipcc = self.callPackage ./hipcc {
        stdenv = origStdenv;
        inherit (llvm) rocm-merged-llvm;
      };
      hipcc = self.callPackage ./hipcc { stdenv = origStdenv; };

      # Replaces hip, opencl-runtime, and rocclr
      clr = self.callPackage ./clr { };
@@ -92,10 +81,6 @@ let

      hipify = self.callPackage ./hipify {
        stdenv = origStdenv;
        inherit (llvm)
          clang
          rocm-merged-llvm
          ;
      };

      # hsakmt was merged into rocm-runtime
@@ -179,8 +164,7 @@ let
      composable_kernel = self.callPackage ./composable_kernel { };

      ck4inductor = pyPackages.callPackage ./composable_kernel/ck4inductor.nix {
        inherit (self) composable_kernel;
        inherit (llvm) rocm-merged-llvm;
        inherit (self) composable_kernel rocm-toolchain;
      };

      half = self.callPackage ./half { };
@@ -443,6 +427,23 @@ let
      };
    }
    // lib.optionalAttrs config.allowAliases {
      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 '$<TARGET_FILE:clang>' 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
Loading