From 785ed480aafdde6cbbffb7605f1cd988f8524dab Mon Sep 17 00:00:00 2001 From: Madoura Date: Mon, 12 Dec 2022 17:36:53 -0600 Subject: [PATCH] rocm-related: standardize rocminfo: standardize rocm-thunk: standardize rocm-opencl-icd: standardize rocclr: standardize rocm-device-libs: standardize rocm-comgr: standardize rocm-opencl-runtime: standardize rocm-runtime: standardize clang-ocl: standardize composable_kernel: standardize hipcub: standardize hipsparse: standardize miopengemm: standardize rccl: standardize rocfft: standardize rocprim: standardize rocsparse: standardize rocmlir: standardize rocrand: standardize tensile: standardize rocm-cmake: standardize rocm-smi: standardize miopen: standardize --- .../libraries/clang-ocl/default.nix | 13 +-- .../libraries/composable_kernel/default.nix | 6 +- pkgs/development/libraries/hipcub/default.nix | 6 -- .../libraries/hipsparse/default.nix | 6 -- pkgs/development/libraries/miopen/default.nix | 21 ++--- .../libraries/miopengemm/default.nix | 6 +- pkgs/development/libraries/rccl/default.nix | 6 -- pkgs/development/libraries/rocclr/default.nix | 11 ++- pkgs/development/libraries/rocfft/default.nix | 10 +-- .../libraries/rocm-comgr/default.nix | 35 ++++---- .../libraries/rocm-device-libs/default.nix | 29 ++++--- .../libraries/rocm-opencl-icd/default.nix | 10 ++- .../libraries/rocm-opencl-runtime/default.nix | 37 +++------ .../libraries/rocm-runtime/default.nix | 42 ++++++---- .../libraries/rocm-thunk/default.nix | 38 +++++---- .../development/libraries/rocmlir/default.nix | 64 +++++++++++++-- .../development/libraries/rocprim/default.nix | 9 +- .../development/libraries/rocrand/default.nix | 9 +- .../libraries/rocsparse/default.nix | 6 -- .../development/libraries/tensile/default.nix | 1 + .../build-managers/rocm-cmake/default.nix | 1 + pkgs/development/tools/rocminfo/default.nix | 33 ++++---- pkgs/tools/system/rocm-smi/default.nix | 1 + pkgs/top-level/all-packages.nix | 82 +++++++++++++------ 24 files changed, 258 insertions(+), 224 deletions(-) diff --git a/pkgs/development/libraries/clang-ocl/default.nix b/pkgs/development/libraries/clang-ocl/default.nix index 3341bc680fb0..8cbace27d4fb 100644 --- a/pkgs/development/libraries/clang-ocl/default.nix +++ b/pkgs/development/libraries/clang-ocl/default.nix @@ -5,7 +5,6 @@ , cmake , rocm-cmake , rocm-device-libs -, clang }: stdenv.mkDerivation (finalAttrs: { @@ -22,17 +21,9 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ cmake rocm-cmake - clang ]; - buildInputs = [ - rocm-device-libs - ]; - - cmakeFlags = [ - "-DCMAKE_C_COMPILER=clang" - "-DCMAKE_CXX_COMPILER=clang++" - ]; + buildInputs = [ rocm-device-libs ]; passthru.updateScript = rocmUpdateScript { name = finalAttrs.pname; @@ -45,6 +36,6 @@ stdenv.mkDerivation (finalAttrs: { homepage = "https://github.com/RadeonOpenCompute/clang-ocl"; license = with licenses; [ mit ]; maintainers = teams.rocm.members; - broken = finalAttrs.version != clang.version; + broken = finalAttrs.version != stdenv.cc.cc.version; }; }) diff --git a/pkgs/development/libraries/composable_kernel/default.nix b/pkgs/development/libraries/composable_kernel/default.nix index f41a97b99ad7..82419873cbeb 100644 --- a/pkgs/development/libraries/composable_kernel/default.nix +++ b/pkgs/development/libraries/composable_kernel/default.nix @@ -6,6 +6,7 @@ , rocm-cmake , hip , openmp +, clang-tools-extra , gtest , buildTests ? false , buildExamples ? false @@ -37,6 +38,7 @@ stdenv.mkDerivation (finalAttrs: { cmake rocm-cmake hip + clang-tools-extra ]; buildInputs = [ @@ -85,8 +87,8 @@ stdenv.mkDerivation (finalAttrs: { homepage = "https://github.com/ROCmSoftwarePlatform/composable_kernel"; license = with licenses; [ mit ]; maintainers = teams.rocm.members; - # Several tests seem to either not compile or have a race condition - # Undefined reference to symbol '_ZTIN7testing4TestE' + # Well, at least we're getting something that makes sense now + # undefined symbol: testing::Message::Message() # Try removing this next update broken = buildTests; }; diff --git a/pkgs/development/libraries/hipcub/default.nix b/pkgs/development/libraries/hipcub/default.nix index 68f31e991d61..8a6ea0ca43c2 100644 --- a/pkgs/development/libraries/hipcub/default.nix +++ b/pkgs/development/libraries/hipcub/default.nix @@ -4,9 +4,6 @@ , rocmUpdateScript , cmake , rocm-cmake -, rocm-runtime -, rocm-device-libs -, rocm-comgr , rocprim , hip , gtest @@ -42,9 +39,6 @@ stdenv.mkDerivation (finalAttrs: { ]; buildInputs = [ - rocm-runtime - rocm-device-libs - rocm-comgr rocprim ] ++ lib.optionals buildTests [ gtest diff --git a/pkgs/development/libraries/hipsparse/default.nix b/pkgs/development/libraries/hipsparse/default.nix index fc1e62e65208..a1582a4ee484 100644 --- a/pkgs/development/libraries/hipsparse/default.nix +++ b/pkgs/development/libraries/hipsparse/default.nix @@ -4,9 +4,6 @@ , rocmUpdateScript , cmake , rocm-cmake -, rocm-runtime -, rocm-device-libs -, rocm-comgr , rocsparse , hip , gfortran @@ -41,9 +38,6 @@ stdenv.mkDerivation (finalAttrs: { ]; buildInputs = [ - rocm-runtime - rocm-device-libs - rocm-comgr rocsparse git ] ++ lib.optionals buildTests [ diff --git a/pkgs/development/libraries/miopen/default.nix b/pkgs/development/libraries/miopen/default.nix index d48adb09a04c..513b492ee981 100644 --- a/pkgs/development/libraries/miopen/default.nix +++ b/pkgs/development/libraries/miopen/default.nix @@ -6,14 +6,10 @@ , pkg-config , cmake , rocm-cmake -, rocm-runtime -, rocm-device-libs -, rocm-comgr -, rocm-opencl-runtime , rocblas , rocmlir , hip -, clang +, clang-tools-extra , clang-ocl , llvm , miopengemm @@ -84,15 +80,11 @@ in stdenv.mkDerivation (finalAttrs: { cmake rocm-cmake hip - clang - llvm + clang-tools-extra ]; buildInputs = [ - rocm-runtime - rocm-device-libs - rocm-comgr - rocm-opencl-runtime + llvm rocblas rocmlir clang-ocl @@ -126,8 +118,6 @@ in stdenv.mkDerivation (finalAttrs: { "-DCMAKE_CXX_COMPILER=hipcc" "-DMIOPEN_BACKEND=HIP" ] ++ lib.optionals useOpenCL [ - "-DCMAKE_C_COMPILER=${clang}/bin/clang" - "-DCMAKE_CXX_COMPILER=${clang}/bin/clang++" "-DMIOPEN_BACKEND=OpenCL" ] ++ lib.optionals buildTests [ "-DBUILD_TESTS=ON" @@ -148,8 +138,7 @@ in stdenv.mkDerivation (finalAttrs: { --replace "3 REQUIRED PATHS /opt/rocm)" "3 REQUIRED PATHS ${hip})" \ --replace "hip REQUIRED PATHS /opt/rocm" "hip REQUIRED PATHS ${hip}" \ --replace "rocblas REQUIRED PATHS /opt/rocm" "rocblas REQUIRED PATHS ${rocblas}" \ - --replace "miopengemm PATHS /opt/rocm" "miopengemm PATHS ${miopengemm}" \ - --replace "set(MIOPEN_TIDY_ERRORS ALL)" "" # Fix clang-tidy at some point + --replace "miopengemm PATHS /opt/rocm" "miopengemm PATHS ${miopengemm}" '' + lib.optionalString (!buildTests) '' substituteInPlace CMakeLists.txt \ --replace "add_subdirectory(test)" "" @@ -180,7 +169,7 @@ in stdenv.mkDerivation (finalAttrs: { '' + lib.optionalString buildTests '' mkdir -p $test/bin mv bin/test_* $test/bin - patchelf --set-rpath ${lib.makeLibraryPath (finalAttrs.buildInputs ++ [ hip ])}:$out/lib $test/bin/* + patchelf --set-rpath $out/lib:${lib.makeLibraryPath (finalAttrs.buildInputs ++ [ hip ])} $test/bin/* ''; passthru.updateScript = rocmUpdateScript { diff --git a/pkgs/development/libraries/miopengemm/default.nix b/pkgs/development/libraries/miopengemm/default.nix index ecc5ba09aad8..03d30906f94a 100644 --- a/pkgs/development/libraries/miopengemm/default.nix +++ b/pkgs/development/libraries/miopengemm/default.nix @@ -5,7 +5,6 @@ , cmake , rocm-cmake , rocm-opencl-runtime -, clang , texlive , doxygen , sphinx @@ -54,7 +53,6 @@ in stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ cmake rocm-cmake - clang ]; buildInputs = [ @@ -70,8 +68,6 @@ in stdenv.mkDerivation (finalAttrs: { ]; cmakeFlags = [ - "-DCMAKE_C_COMPILER=clang" - "-DCMAKE_CXX_COMPILER=clang++" # Manually define CMAKE_INSTALL_ # See: https://github.com/NixOS/nixpkgs/pull/197838 "-DCMAKE_INSTALL_BINDIR=bin" @@ -121,6 +117,6 @@ in stdenv.mkDerivation (finalAttrs: { homepage = "https://github.com/ROCmSoftwarePlatform/MIOpenGEMM"; license = with licenses; [ mit ]; maintainers = teams.rocm.members; - broken = finalAttrs.version != clang.version; + broken = finalAttrs.version != stdenv.cc.version; }; }) diff --git a/pkgs/development/libraries/rccl/default.nix b/pkgs/development/libraries/rccl/default.nix index 6a9b48545749..4a8df477e15e 100644 --- a/pkgs/development/libraries/rccl/default.nix +++ b/pkgs/development/libraries/rccl/default.nix @@ -4,9 +4,6 @@ , rocmUpdateScript , cmake , rocm-cmake -, rocm-runtime -, rocm-device-libs -, rocm-comgr , rocm-smi , hip , gtest @@ -38,9 +35,6 @@ stdenv.mkDerivation (finalAttrs: { ]; buildInputs = [ - rocm-runtime - rocm-device-libs - rocm-comgr rocm-smi gtest ] ++ lib.optionals buildTests [ diff --git a/pkgs/development/libraries/rocclr/default.nix b/pkgs/development/libraries/rocclr/default.nix index 2837f57897e7..bd0eb6bafbb6 100644 --- a/pkgs/development/libraries/rocclr/default.nix +++ b/pkgs/development/libraries/rocclr/default.nix @@ -1,4 +1,5 @@ -{ lib, stdenv +{ lib +, stdenv , fetchFromGitHub , fetchpatch , rocmUpdateScript @@ -26,18 +27,19 @@ stdenv.mkDerivation (finalAttrs: { }) ]; - prePatch = '' + postPatch = '' substituteInPlace device/comgrctx.cpp \ --replace "libamd_comgr.so" "${rocm-comgr}/lib/libamd_comgr.so" ''; - buildPhase = ""; + dontConfigure = true; + dontBuild = true; installPhase = '' runHook preInstall mkdir -p $out - cp -r * $out/ + cp -a * $out/ runHook postInstall ''; @@ -57,5 +59,6 @@ stdenv.mkDerivation (finalAttrs: { # to be supported yet by the build infrastructure. Recheck in # the future. platforms = [ "x86_64-linux" ]; + broken = finalAttrs.version != stdenv.cc.version; }; }) diff --git a/pkgs/development/libraries/rocfft/default.nix b/pkgs/development/libraries/rocfft/default.nix index 8dbf5f16a447..b71f0dc5b07f 100644 --- a/pkgs/development/libraries/rocfft/default.nix +++ b/pkgs/development/libraries/rocfft/default.nix @@ -4,17 +4,14 @@ , rocmUpdateScript , cmake , rocm-cmake -, rocm-runtime -, rocm-device-libs -, rocm-comgr , hip +, openmp , sqlite , python3 , gtest , boost , fftw , fftwFloat -, llvmPackages , buildTests ? false , buildBenchmarks ? false }: @@ -45,9 +42,6 @@ stdenv.mkDerivation (finalAttrs: { ]; buildInputs = [ - rocm-runtime - rocm-device-libs - rocm-comgr sqlite python3 ] ++ lib.optionals buildTests [ @@ -56,7 +50,7 @@ stdenv.mkDerivation (finalAttrs: { boost fftw fftwFloat - llvmPackages.openmp + openmp ]; propogatedBuildInputs = lib.optionals buildTests [ diff --git a/pkgs/development/libraries/rocm-comgr/default.nix b/pkgs/development/libraries/rocm-comgr/default.nix index 2d26f72fc1b0..93c56f5178d8 100644 --- a/pkgs/development/libraries/rocm-comgr/default.nix +++ b/pkgs/development/libraries/rocm-comgr/default.nix @@ -3,12 +3,17 @@ , fetchFromGitHub , rocmUpdateScript , cmake -, clang +, rocm-cmake , rocm-device-libs -, llvm +, libxml2 }: -stdenv.mkDerivation (finalAttrs: { +let + llvmNativeTarget = + if stdenv.isx86_64 then "X86" + else if stdenv.isAarch64 then "AArch64" + else throw "Unsupported ROCm LLVM platform"; +in stdenv.mkDerivation (finalAttrs: { pname = "rocm-comgr"; version = "5.4.0"; @@ -19,21 +24,20 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-qLsrBTeSop7lIQv8gZDwgpvGZJOAq90zsvMi1QpfbAs="; }; - sourceRoot = "source/lib/comgr"; + patches = [ ./cmake.patch ]; + sourceRoot = "${finalAttrs.src.name}/lib/comgr"; - nativeBuildInputs = [ cmake ]; - - buildInputs = [ clang rocm-device-libs llvm ]; - - cmakeFlags = [ - "-DCMAKE_C_COMPILER=${clang}/bin/clang" - "-DCMAKE_CXX_COMPILER=${clang}/bin/clang++" - "-DCMAKE_PREFIX_PATH=${llvm}/lib/cmake/llvm" - "-DLLD_INCLUDE_DIRS=${llvm}/include" - "-DLLVM_TARGETS_TO_BUILD=\"AMDGPU;X86\"" + nativeBuildInputs = [ + cmake + rocm-cmake ]; - patches = [ ./cmake.patch ]; + buildInputs = [ + rocm-device-libs + libxml2 + ]; + + cmakeFlags = [ "-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86" ]; passthru.updateScript = rocmUpdateScript { name = finalAttrs.pname; @@ -47,5 +51,6 @@ stdenv.mkDerivation (finalAttrs: { license = licenses.ncsa; maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; platforms = platforms.linux; + broken = finalAttrs.version != stdenv.cc.version; }; }) diff --git a/pkgs/development/libraries/rocm-device-libs/default.nix b/pkgs/development/libraries/rocm-device-libs/default.nix index b6245eea8449..e37baad6f891 100644 --- a/pkgs/development/libraries/rocm-device-libs/default.nix +++ b/pkgs/development/libraries/rocm-device-libs/default.nix @@ -1,12 +1,18 @@ -{ lib, stdenv +{ lib +, stdenv , fetchFromGitHub , rocmUpdateScript , cmake -, clang -, llvm +, rocm-cmake +, libxml2 }: -stdenv.mkDerivation (finalAttrs: { +let + llvmNativeTarget = + if stdenv.isx86_64 then "X86" + else if stdenv.isAarch64 then "AArch64" + else throw "Unsupported ROCm LLVM platform"; +in stdenv.mkDerivation (finalAttrs: { pname = "rocm-device-libs"; version = "5.4.0"; @@ -17,17 +23,15 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-8gxvgy2GlROxM5qKtZVu5Lxa1FmTIVlBTpfp8rxhNhk="; }; - nativeBuildInputs = [ cmake ]; + patches = [ ./cmake.patch ]; - buildInputs = [ clang llvm ]; - - cmakeFlags = [ - "-DCMAKE_PREFIX_PATH=${llvm}/lib/cmake/llvm;${llvm}/lib/cmake/clang" - "-DLLVM_TARGETS_TO_BUILD='AMDGPU;X86'" - "-DCLANG=${clang}/bin/clang" + nativeBuildInputs = [ + cmake + rocm-cmake ]; - patches = [ ./cmake.patch ]; + buildInputs = [ libxml2 ]; + cmakeFlags = [ "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}" ]; passthru.updateScript = rocmUpdateScript { name = finalAttrs.pname; @@ -41,5 +45,6 @@ stdenv.mkDerivation (finalAttrs: { license = licenses.ncsa; maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; platforms = platforms.linux; + broken = finalAttrs.version != stdenv.cc.version; }; }) diff --git a/pkgs/development/libraries/rocm-opencl-icd/default.nix b/pkgs/development/libraries/rocm-opencl-icd/default.nix index fb78c4f04dd0..4602d3646e47 100644 --- a/pkgs/development/libraries/rocm-opencl-icd/default.nix +++ b/pkgs/development/libraries/rocm-opencl-icd/default.nix @@ -1,4 +1,8 @@ -{ lib, callPackage, stdenv, rocm-opencl-runtime }: +{ lib +, stdenv +, callPackage +, rocm-opencl-runtime +}: stdenv.mkDerivation rec { pname = "rocm-opencl-icd"; @@ -11,12 +15,12 @@ stdenv.mkDerivation rec { echo "${rocm-opencl-runtime}/lib/libamdocl64.so" > $out/etc/OpenCL/vendors/amdocl64.icd ''; - passthru.impureTests = { rocm-opencl = callPackage ./test.nix {}; }; + passthru.impureTests = { rocm-opencl = callPackage ./test.nix { }; }; meta = with lib; { description = "OpenCL ICD definition for AMD GPUs using the ROCm stack"; license = licenses.mit; - maintainers = with maintainers; [ lovesegfault ]; + maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; platforms = platforms.linux; }; } diff --git a/pkgs/development/libraries/rocm-opencl-runtime/default.nix b/pkgs/development/libraries/rocm-opencl-runtime/default.nix index 1d250195c23c..ee588999a1b1 100644 --- a/pkgs/development/libraries/rocm-opencl-runtime/default.nix +++ b/pkgs/development/libraries/rocm-opencl-runtime/default.nix @@ -1,23 +1,15 @@ -{ stdenv -, lib +{ lib +, stdenv , fetchFromGitHub , rocmUpdateScript , addOpenGLRunpath , cmake -, rocm-cmake -, clang -, glew -, libglvnd -, libX11 -, llvm -, mesa -, numactl -, python3 -, rocclr , rocm-comgr -, rocm-device-libs , rocm-runtime -, rocm-thunk +, rocclr +, glew +, libX11 +, numactl }: stdenv.mkDerivation (finalAttrs: { @@ -31,27 +23,19 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-E1+Y/fgp5b+7H1LN+O1fwVi0/XRCgvsiSxTY3u/q+8I="; }; - nativeBuildInputs = [ cmake rocm-cmake ]; + nativeBuildInputs = [ cmake ]; buildInputs = [ - clang - glew - libglvnd - libX11 - llvm - mesa - numactl - python3 rocm-comgr - rocm-device-libs rocm-runtime - rocm-thunk + glew + libX11 + numactl ]; cmakeFlags = [ "-DAMD_OPENCL_PATH=${finalAttrs.src}" "-DROCCLR_PATH=${rocclr}" - "-DCPACK_PACKAGING_INSTALL_PREFIX=/opt/rocm/opencl" ]; dontStrip = true; @@ -80,5 +64,6 @@ stdenv.mkDerivation (finalAttrs: { license = with licenses; [ asl20 mit ]; maintainers = with maintainers; [ acowley lovesegfault ] ++ teams.rocm.members; platforms = platforms.linux; + broken = finalAttrs.version != stdenv.cc.version; }; }) diff --git a/pkgs/development/libraries/rocm-runtime/default.nix b/pkgs/development/libraries/rocm-runtime/default.nix index 86ddf5b77038..b7e1212fd1b1 100644 --- a/pkgs/development/libraries/rocm-runtime/default.nix +++ b/pkgs/development/libraries/rocm-runtime/default.nix @@ -1,17 +1,18 @@ -{ stdenv -, lib +{ lib +, stdenv , fetchFromGitHub , rocmUpdateScript -, addOpenGLRunpath -, cmake , pkg-config +, cmake , xxd -, elfutils -, libdrm -, llvm -, numactl , rocm-device-libs -, rocm-thunk }: +, rocm-thunk +, libelf +, libdrm +, numactl +, valgrind +, libxml2 +}: stdenv.mkDerivation (finalAttrs: { pname = "rocm-runtime"; @@ -24,13 +25,22 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-M9kv1Oe5ZZfd9H/+KUJUoK9L1EdyS2qRp2mJDK0dnPE="; }; - sourceRoot = "source/src"; + sourceRoot = "${finalAttrs.src.name}/src"; - nativeBuildInputs = [ cmake pkg-config xxd ]; + nativeBuildInputs = [ + pkg-config + cmake + xxd + ]; - buildInputs = [ elfutils libdrm llvm numactl ]; - - cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${rocm-thunk}" ]; + buildInputs = [ + rocm-thunk + libelf + libdrm + numactl + valgrind + libxml2 + ]; postPatch = '' patchShebangs image/blit_src/create_hsaco_ascii_file.sh @@ -45,7 +55,8 @@ stdenv.mkDerivation (finalAttrs: { ''; fixupPhase = '' - rm -rf $out/hsa + rm -rf $out/hsa/* + ln -s $out/{include,lib} $out/hsa ''; passthru.updateScript = rocmUpdateScript { @@ -59,5 +70,6 @@ stdenv.mkDerivation (finalAttrs: { homepage = "https://github.com/RadeonOpenCompute/ROCR-Runtime"; license = with licenses; [ ncsa ]; maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; + broken = finalAttrs.version != stdenv.cc.version; }; }) diff --git a/pkgs/development/libraries/rocm-thunk/default.nix b/pkgs/development/libraries/rocm-thunk/default.nix index 6bca7a89fc48..bc966e501268 100644 --- a/pkgs/development/libraries/rocm-thunk/default.nix +++ b/pkgs/development/libraries/rocm-thunk/default.nix @@ -2,10 +2,12 @@ , stdenv , fetchFromGitHub , rocmUpdateScript -, cmake , pkg-config +, cmake +, rocm-cmake , libdrm , numactl +, valgrind }: stdenv.mkDerivation (finalAttrs: { @@ -19,24 +21,25 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-EU5toaKzVeZpdm/YhaQ0bXq0eoYwYQ5qGLUJzxgZVjE="; }; - preConfigure = '' - export cmakeFlags="$cmakeFlags " - ''; + nativeBuildInputs = [ + pkg-config + cmake + rocm-cmake + ]; - nativeBuildInputs = [ cmake pkg-config ]; + buildInputs = [ + libdrm + numactl + valgrind + ]; - buildInputs = [ libdrm numactl ]; - - # https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface/issues/75 - postPatch = '' - substituteInPlace libhsakmt.pc.in \ - --replace '$'{prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@ \ - --replace '$'{prefix}/@CMAKE_INSTALL_INCLUDEDIR@ @CMAKE_INSTALL_FULL_INCLUDEDIR@ - ''; - - postInstall = '' - cp -r $src/include $out - ''; + 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" + ]; passthru.updateScript = rocmUpdateScript { name = finalAttrs.pname; @@ -49,5 +52,6 @@ stdenv.mkDerivation (finalAttrs: { homepage = "https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"; license = with licenses; [ bsd2 mit ]; maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; + broken = finalAttrs.version != stdenv.cc.version; }; }) diff --git a/pkgs/development/libraries/rocmlir/default.nix b/pkgs/development/libraries/rocmlir/default.nix index e40eb1b813c1..90bb1ad211ce 100644 --- a/pkgs/development/libraries/rocmlir/default.nix +++ b/pkgs/development/libraries/rocmlir/default.nix @@ -3,17 +3,36 @@ , fetchFromGitHub , rocmUpdateScript , cmake -, clang +, ninja +, hip +, rocminfo , git , libxml2 , libedit +, zlib +, ncurses , python3 +, buildRockCompiler ? false }: -stdenv.mkDerivation (finalAttrs: { +# 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 + llvmNativeTarget = + if stdenv.isx86_64 then "X86" + else if stdenv.isAarch64 then "AArch64" + else throw "Unsupported ROCm LLVM platform"; +in stdenv.mkDerivation (finalAttrs: { pname = "rocmlir"; version = "5.4.0"; + outputs = [ + "out" + ] ++ lib.optionals (!buildRockCompiler) [ + "external" + ]; + src = fetchFromGitHub { owner = "ROCmSoftwarePlatform"; repo = "rocMLIR"; @@ -23,7 +42,9 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ cmake - clang + ninja + ] ++ lib.optionals (!buildRockCompiler) [ + hip ]; buildInputs = [ @@ -33,12 +54,39 @@ stdenv.mkDerivation (finalAttrs: { python3 ]; - cmakeFlags = [ - "-DCMAKE_C_COMPILER=clang" - "-DCMAKE_CXX_COMPILER=clang++" - "-DBUILD_FAT_LIBROCKCOMPILER=ON" + propagatedBuildInputs = [ + zlib + ncurses ]; + cmakeFlags = [ + "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}" + "-DLLVM_ENABLE_ZLIB=ON" + "-DLLVM_ENABLE_TERMINFO=ON" + ] ++ lib.optionals buildRockCompiler [ + "-DBUILD_FAT_LIBROCKCOMPILER=ON" + ] ++ lib.optionals (!buildRockCompiler) [ + "-DROCM_PATH=${rocminfo}" + "-DROCM_TEST_CHIPSET=gfx000" + ]; + + dontBuild = true; + doCheck = true; + + # Certain libs aren't being generated, try enabling tests next update + checkTarget = if buildRockCompiler + then "librockCompiler" + else "check-mlir-miopen-build-only"; + + postInstall = let + libPath = lib.makeLibraryPath [ zlib ncurses hip stdenv.cc.cc ]; + in lib.optionals (!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 { name = finalAttrs.pname; owner = finalAttrs.src.owner; @@ -52,6 +100,6 @@ stdenv.mkDerivation (finalAttrs: { homepage = "https://github.com/ROCmSoftwarePlatform/rocMLIR"; license = with licenses; [ asl20 ]; maintainers = teams.rocm.members; - broken = finalAttrs.version != clang.version; + broken = finalAttrs.version != stdenv.cc.version; }; }) diff --git a/pkgs/development/libraries/rocprim/default.nix b/pkgs/development/libraries/rocprim/default.nix index 9b5fabf0fb00..3ad3871bbd3d 100644 --- a/pkgs/development/libraries/rocprim/default.nix +++ b/pkgs/development/libraries/rocprim/default.nix @@ -4,9 +4,6 @@ , rocmUpdateScript , cmake , rocm-cmake -, rocm-runtime -, rocm-device-libs -, rocm-comgr , hip , gtest , gbenchmark @@ -39,11 +36,7 @@ stdenv.mkDerivation (finalAttrs: { hip ]; - buildInputs = [ - rocm-runtime - rocm-device-libs - rocm-comgr - ] ++ lib.optionals buildTests [ + buildInputs = lib.optionals buildTests [ gtest ] ++ lib.optionals buildBenchmarks [ gbenchmark diff --git a/pkgs/development/libraries/rocrand/default.nix b/pkgs/development/libraries/rocrand/default.nix index f0b1cb3e69b6..a06615ec4122 100644 --- a/pkgs/development/libraries/rocrand/default.nix +++ b/pkgs/development/libraries/rocrand/default.nix @@ -4,9 +4,6 @@ , rocmUpdateScript , cmake , rocm-cmake -, rocm-runtime -, rocm-device-libs -, rocm-comgr , hip , gtest , gbenchmark @@ -40,11 +37,7 @@ stdenv.mkDerivation (finalAttrs: { hip ]; - buildInputs = [ - rocm-runtime - rocm-device-libs - rocm-comgr - ] ++ lib.optionals buildTests [ + buildInputs = lib.optionals buildTests [ gtest ] ++ lib.optionals buildBenchmarks [ gbenchmark diff --git a/pkgs/development/libraries/rocsparse/default.nix b/pkgs/development/libraries/rocsparse/default.nix index 0edee46cfeb3..c0ee717d4bfc 100644 --- a/pkgs/development/libraries/rocsparse/default.nix +++ b/pkgs/development/libraries/rocsparse/default.nix @@ -5,9 +5,6 @@ , rocmUpdateScript , cmake , rocm-cmake -, rocm-runtime -, rocm-device-libs -, rocm-comgr , rocprim , hip , gfortran @@ -46,9 +43,6 @@ stdenv.mkDerivation (finalAttrs: { ]; buildInputs = [ - rocm-runtime - rocm-device-libs - rocm-comgr rocprim git ] ++ lib.optionals (buildTests || buildBenchmarks) [ diff --git a/pkgs/development/libraries/tensile/default.nix b/pkgs/development/libraries/tensile/default.nix index df3b580c059f..c45b15134f5f 100644 --- a/pkgs/development/libraries/tensile/default.nix +++ b/pkgs/development/libraries/tensile/default.nix @@ -36,5 +36,6 @@ buildPythonPackage rec { homepage = "https://github.com/ROCmSoftwarePlatform/Tensile"; license = with licenses; [ mit ]; maintainers = teams.rocm.members; + broken = version != stdenv.cc.version; }; } diff --git a/pkgs/development/tools/build-managers/rocm-cmake/default.nix b/pkgs/development/tools/build-managers/rocm-cmake/default.nix index 0a3e44e02299..0d7913543f10 100644 --- a/pkgs/development/tools/build-managers/rocm-cmake/default.nix +++ b/pkgs/development/tools/build-managers/rocm-cmake/default.nix @@ -30,5 +30,6 @@ stdenv.mkDerivation (finalAttrs: { license = licenses.mit; maintainers = teams.rocm.members; platforms = platforms.unix; + broken = finalAttrs.version != stdenv.cc.version; }; }) diff --git a/pkgs/development/tools/rocminfo/default.nix b/pkgs/development/tools/rocminfo/default.nix index 34dcb52526bd..2a714829d91c 100644 --- a/pkgs/development/tools/rocminfo/default.nix +++ b/pkgs/development/tools/rocminfo/default.nix @@ -1,13 +1,12 @@ -{ stdenv -, lib +{ lib +, stdenv , fetchFromGitHub , rocmUpdateScript -, fetchpatch , cmake -, rocm-runtime -, python3 , rocm-cmake +, rocm-runtime , busybox +, python3 , gnugrep # rocminfo requires that the calling user have a password and be in # the video group. If we let rocm_agent_enumerator rely upon @@ -29,25 +28,21 @@ stdenv.mkDerivation (finalAttrs: { sha256 = "sha256-4wZTm5AZgG8xEd6uYqxWq4bWZgcSYZ2WYA1z4RAPF8U="; }; - enableParallelBuilding = true; - nativeBuildInputs = [ cmake ]; - buildInputs = [ rocm-cmake rocm-runtime ]; - - cmakeFlags = [ - "-DROCM_DIR=${rocm-runtime}" - "-DROCRTST_BLD_TYPE=Release" + nativeBuildInputs = [ + cmake + rocm-cmake ]; + buildInputs = [ rocm-runtime ]; + propagatedBuildInputs = [ python3 ]; + cmakeFlags = [ "-DROCRTST_BLD_TYPE=Release" ]; + prePatch = '' - sed 's,#!/usr/bin/env python3,#!${python3}/bin/python,' -i rocm_agent_enumerator + patchShebangs rocm_agent_enumerator sed 's,lsmod | grep ,${busybox}/bin/lsmod | ${gnugrep}/bin/grep ,' -i rocminfo.cc ''; - installPhase = '' - mkdir -p $out/bin - cp rocminfo $out/bin - cp rocm_agent_enumerator $out/bin - '' + lib.optionalString (defaultTargets != []) '' + postInstall = lib.optionalString (defaultTargets != [ ]) '' echo '${lib.concatStringsSep "\n" defaultTargets}' > $out/bin/target.lst ''; @@ -63,6 +58,6 @@ stdenv.mkDerivation (finalAttrs: { license = licenses.ncsa; maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; platforms = platforms.linux; - broken = stdenv.isAarch64; + broken = stdenv.isAarch64 || finalAttrs.version != stdenv.cc.version; }; }) diff --git a/pkgs/tools/system/rocm-smi/default.nix b/pkgs/tools/system/rocm-smi/default.nix index 33bda1e56455..0f303cc78531 100644 --- a/pkgs/tools/system/rocm-smi/default.nix +++ b/pkgs/tools/system/rocm-smi/default.nix @@ -37,5 +37,6 @@ stdenv.mkDerivation (finalAttrs: { license = with licenses; [ mit ]; maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; platforms = [ "x86_64-linux" ]; + broken = finalAttrs.version != stdenv.cc.version; }; }) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 22c43b4d3451..511f5b705e08 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15133,66 +15133,100 @@ with pkgs; rml = callPackage ../development/compilers/rml { }; composable_kernel = callPackage ../development/libraries/composable_kernel { - inherit (llvmPackages) openmp; + inherit (llvmPackages_rocm) openmp clang-tools-extra; + stdenv = rocmClangStdenv; }; clang-ocl = callPackage ../development/libraries/clang-ocl { - inherit (llvmPackages_rocm) clang; + stdenv = rocmClangStdenv; }; rgxg = callPackage ../tools/text/rgxg { }; - rocclr = callPackage ../development/libraries/rocclr { }; + rocclr = callPackage ../development/libraries/rocclr { + stdenv = rocmClangStdenv; + }; hip = callPackage ../development/compilers/hip { inherit (llvmPackages_rocm) clang llvm; }; - hipcub = callPackage ../development/libraries/hipcub { }; + hipcub = callPackage ../development/libraries/hipcub { + stdenv = rocmClangStdenv; + }; - hipsparse = callPackage ../development/libraries/hipsparse { }; + hipsparse = callPackage ../development/libraries/hipsparse { + stdenv = rocmClangStdenv; + }; - rccl = callPackage ../development/libraries/rccl { }; + rccl = callPackage ../development/libraries/rccl { + stdenv = rocmClangStdenv; + }; - rocm-cmake = callPackage ../development/tools/build-managers/rocm-cmake { }; + rocm-cmake = callPackage ../development/tools/build-managers/rocm-cmake { + stdenv = rocmClangStdenv; + }; rocm-comgr = callPackage ../development/libraries/rocm-comgr { - inherit (llvmPackages_rocm) clang llvm; + stdenv = rocmClangStdenv; }; rocm-device-libs = callPackage ../development/libraries/rocm-device-libs { - inherit (llvmPackages_rocm) clang llvm; + stdenv = rocmClangStdenv; }; - rocm-opencl-icd = callPackage ../development/libraries/rocm-opencl-icd { }; + rocm-opencl-icd = callPackage ../development/libraries/rocm-opencl-icd { + stdenv = rocmClangStdenv; + }; rocm-opencl-runtime = callPackage ../development/libraries/rocm-opencl-runtime { - inherit (llvmPackages_rocm) clang llvm; + stdenv = rocmClangStdenv; }; rocm-runtime = callPackage ../development/libraries/rocm-runtime { - inherit (llvmPackages_rocm) llvm; + stdenv = rocmClangStdenv; }; - rocm-smi = python3Packages.callPackage ../tools/system/rocm-smi { }; + rocm-smi = python3Packages.callPackage ../tools/system/rocm-smi { + stdenv = rocmClangStdenv; + }; - rocm-thunk = callPackage ../development/libraries/rocm-thunk { }; + rocm-thunk = callPackage ../development/libraries/rocm-thunk { + stdenv = rocmClangStdenv; + }; - rocminfo = callPackage ../development/tools/rocminfo { }; + rocminfo = callPackage ../development/tools/rocminfo { + stdenv = rocmClangStdenv; + }; rocmlir = callPackage ../development/libraries/rocmlir { - inherit (llvmPackages_rocm) clang; + stdenv = rocmClangStdenv; }; - rocprim = callPackage ../development/libraries/rocprim { }; + rocmlir-rock = rocmlir.override { + buildRockCompiler = true; + }; - rocsparse = callPackage ../development/libraries/rocsparse { }; + rocprim = callPackage ../development/libraries/rocprim { + stdenv = rocmClangStdenv; + }; - rocfft = callPackage ../development/libraries/rocfft { }; + rocsparse = callPackage ../development/libraries/rocsparse { + stdenv = rocmClangStdenv; + }; - rocrand = callPackage ../development/libraries/rocrand { }; + rocfft = callPackage ../development/libraries/rocfft { + inherit (llvmPackages_rocm) openmp; + stdenv = rocmClangStdenv; + }; - tensile = python3Packages.callPackage ../development/libraries/tensile { }; + rocrand = callPackage ../development/libraries/rocrand { + stdenv = rocmClangStdenv; + }; + + tensile = python3Packages.callPackage ../development/libraries/tensile { + stdenv = rocmClangStdenv; + }; rocwmma = callPackage ../development/libraries/rocwmma { inherit (llvmPackages) openmp; @@ -15203,13 +15237,15 @@ with pkgs; }; miopengemm = callPackage ../development/libraries/miopengemm { - inherit (llvmPackages_rocm) clang; + stdenv = rocmClangStdenv; }; rocthrust = callPackage ../development/libraries/rocthrust { }; miopen = callPackage ../development/libraries/miopen { - inherit (llvmPackages_rocm) clang llvm; + inherit (llvmPackages_rocm) llvm clang-tools-extra; + stdenv = rocmClangStdenv; + rocmlir = rocmlir-rock; boost = boost.override { enableStatic = true; }; };