From 61ac4200206f23026e198aa98779f28ae05ba389 Mon Sep 17 00:00:00 2001 From: Madoura Date: Sun, 18 Dec 2022 02:02:35 -0600 Subject: [PATCH 01/21] sphinx-automodapi: fix tests --- pkgs/development/python-modules/sphinx-automodapi/default.nix | 3 +++ pkgs/top-level/python-packages.nix | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/sphinx-automodapi/default.nix b/pkgs/development/python-modules/sphinx-automodapi/default.nix index c8b586d0fc6e..9145cc416e79 100644 --- a/pkgs/development/python-modules/sphinx-automodapi/default.nix +++ b/pkgs/development/python-modules/sphinx-automodapi/default.nix @@ -36,6 +36,9 @@ buildPythonPackage rec { postPatch = '' substituteInPlace "sphinx_automodapi/tests/helpers.py" \ --replace '[0]), None)' "[0]), (None, '${testInventory}'))" + + substituteInPlace "sphinx_automodapi/tests/test_cases.py" \ + --replace '[0]), None)' "[0]), (None, '${testInventory}'))" ''; checkInputs = [ diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 077c04a8c2f1..b01fe6539998 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -10571,7 +10571,9 @@ self: super: with self; { spinners = callPackage ../development/python-modules/spinners { }; - sphinx-automodapi = callPackage ../development/python-modules/sphinx-automodapi { }; + sphinx-automodapi = callPackage ../development/python-modules/sphinx-automodapi { + graphviz = pkgs.graphviz; + }; sphinx-better-theme = callPackage ../development/python-modules/sphinx-better-theme { }; From 7f864b4a32f0c556e85400d6b0a7659576c48045 Mon Sep 17 00:00:00 2001 From: Madoura Date: Sun, 11 Dec 2022 20:28:53 -0600 Subject: [PATCH 02/21] lit: 14.0.0 -> 15.0.6 --- pkgs/development/tools/misc/lit/default.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/development/tools/misc/lit/default.nix b/pkgs/development/tools/misc/lit/default.nix index aa991e8ea978..5a255df46806 100644 --- a/pkgs/development/tools/misc/lit/default.nix +++ b/pkgs/development/tools/misc/lit/default.nix @@ -2,11 +2,11 @@ python3.pkgs.buildPythonApplication rec { pname = "lit"; - version = "14.0.0"; + version = "15.0.6"; src = python3.pkgs.fetchPypi { inherit pname version; - sha256 = "45e08ce87b0ea56ab632aa02fa857418a5dd241a711c7c756878b73a130c3efe"; + hash = "sha256-S06OQfDmDyutls21HxyQ016ku3FTTsDOP8Di67d9f+k="; }; passthru = { @@ -14,6 +14,9 @@ python3.pkgs.buildPythonApplication rec { }; # Non-standard test suite. Needs custom checkPhase. + # Needs LLVM's `FileCheck` and `not`: `$out/bin/lit tests` + # There should be `llvmPackages.lit` since older LLVM versions may + # have the possibility of not correctly interfacing with newer lit versions doCheck = false; meta = { From 8be466f7444daaef4d308a46dae2671c006a9cdb Mon Sep 17 00:00:00 2001 From: Madoura Date: Mon, 12 Dec 2022 04:42:41 -0600 Subject: [PATCH 03/21] spirv-llvm-translator: allow rocm versioning --- .../compilers/spirv-llvm-translator/default.nix | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkgs/development/compilers/spirv-llvm-translator/default.nix b/pkgs/development/compilers/spirv-llvm-translator/default.nix index 971b3e8399df..052df63aecb0 100644 --- a/pkgs/development/compilers/spirv-llvm-translator/default.nix +++ b/pkgs/development/compilers/spirv-llvm-translator/default.nix @@ -10,12 +10,14 @@ let llvmMajor = lib.versions.major llvm.version; + isROCm = lib.hasPrefix "rocm" llvm.pname; + # ROCm will always be at the latest version branch = - if llvmMajor == "15" then rec { + if llvmMajor == "15" || isROCm then rec { version = "15.0.0"; rev = "v${version}"; - hash = "sha256-111yL6Wh8hykoGz1QmT1F7lfGDEmG4U3iqmqrJxizOg="; + hash = "sha256-OsDohXRxovtEXaWiRGp8gJ0dXmoALyO+ZimeSO8aPVI="; } else if llvmMajor == "14" then rec{ version = "14.0.0"; rev = "v${version}"; @@ -36,15 +38,17 @@ stdenv.mkDerivation { inherit (branch) rev hash; }; - nativeBuildInputs = [ pkg-config cmake llvm.dev spirv-tools ]; + nativeBuildInputs = [ pkg-config cmake spirv-tools ] + ++ (if isROCm then [ llvm ] else [ llvm.dev ]); - buildInputs = [ spirv-headers llvm ]; + buildInputs = [ spirv-headers ] + ++ lib.optionals (!isROCm) [ llvm ]; checkInputs = [ lit ]; cmakeFlags = [ "-DLLVM_INCLUDE_TESTS=ON" - "-DLLVM_DIR=${llvm.dev}" + "-DLLVM_DIR=${(if isROCm then llvm else llvm.dev)}" "-DBUILD_SHARED_LIBS=YES" "-DLLVM_SPIRV_BUILD_EXTERNAL=YES" # RPATH of binary /nix/store/.../bin/llvm-spirv contains a forbidden reference to /build/ From 3b271b7ebc25648daa08997e7758dad11e321d21 Mon Sep 17 00:00:00 2001 From: Madoura Date: Mon, 12 Dec 2022 16:50:22 -0600 Subject: [PATCH 04/21] python3Packages: sphinx-markdown-tables: init at 0.0.17 --- .../sphinx-markdown-tables/default.nix | 30 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 ++ 2 files changed, 32 insertions(+) create mode 100644 pkgs/development/python-modules/sphinx-markdown-tables/default.nix diff --git a/pkgs/development/python-modules/sphinx-markdown-tables/default.nix b/pkgs/development/python-modules/sphinx-markdown-tables/default.nix new file mode 100644 index 000000000000..55fb0b41f43e --- /dev/null +++ b/pkgs/development/python-modules/sphinx-markdown-tables/default.nix @@ -0,0 +1,30 @@ +{ lib +, buildPythonPackage +, fetchPypi +, sphinx +, markdown +}: + +buildPythonPackage rec { + pname = "sphinx-markdown-tables"; + version = "0.0.17"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-a8bT1ADqzP7r0ohEa8CN2DCDNnxYuF1A/mwS1371kvE="; + }; + + propagatedBuildInputs = [ + sphinx + markdown + ]; + + pythonImportsCheck = [ "sphinx_markdown_tables" ]; + + meta = with lib; { + description = "Sphinx extension for rendering tables written in markdown"; + homepage = "https://github.com/ryanfox/sphinx-markdown-tables"; + maintainers = with maintainers; [ Madouura ]; + license = licenses.gpl3; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index b01fe6539998..b14d5cd23b8b 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -10679,6 +10679,8 @@ self: super: with self; { sphinx-markdown-parser = callPackage ../development/python-modules/sphinx-markdown-parser { }; + sphinx-markdown-tables = callPackage ../development/python-modules/sphinx-markdown-tables { }; + sphinx-material = callPackage ../development/python-modules/sphinx-material { }; sphinx-navtree = callPackage ../development/python-modules/sphinx-navtree { }; From 0ee533a8e00d7131b7a7d5d6d5f605f18af07426 Mon Sep 17 00:00:00 2001 From: Madoura Date: Sat, 10 Dec 2022 13:31:55 -0600 Subject: [PATCH 05/21] rocm-llvm: rewrite and separate --- .../compilers/llvm/rocm/0000-fix-openmp.patch | 18 + .../compilers/llvm/rocm/default.nix | 620 ++++++++++++++++-- pkgs/development/compilers/llvm/rocm/llvm.nix | 202 ++++-- pkgs/top-level/all-packages.nix | 1 + 4 files changed, 737 insertions(+), 104 deletions(-) create mode 100644 pkgs/development/compilers/llvm/rocm/0000-fix-openmp.patch diff --git a/pkgs/development/compilers/llvm/rocm/0000-fix-openmp.patch b/pkgs/development/compilers/llvm/rocm/0000-fix-openmp.patch new file mode 100644 index 000000000000..2811df7d29f7 --- /dev/null +++ b/pkgs/development/compilers/llvm/rocm/0000-fix-openmp.patch @@ -0,0 +1,18 @@ +diff --git a/libomptarget/plugins/amdgpu/impl/impl.cpp b/libomptarget/plugins/amdgpu/impl/impl.cpp +index 80e024789..3a14e0889 100644 +--- a/libomptarget/plugins/amdgpu/impl/impl.cpp ++++ b/libomptarget/plugins/amdgpu/impl/impl.cpp +@@ -21,10 +21,11 @@ bool is_locked(void *ptr, hsa_status_t *err_p, void **agentBaseAddress) { + info.size = sizeof(hsa_amd_pointer_info_t); + err = hsa_amd_pointer_info(ptr, &info, nullptr, nullptr, nullptr); + +- if (err != HSA_STATUS_SUCCESS) ++ if (err != HSA_STATUS_SUCCESS) { + DP("Error when getting pointer info\n"); +- else ++ } else { + is_locked = (info.type == HSA_EXT_POINTER_TYPE_LOCKED); ++ } + + if (is_locked && agentBaseAddress != nullptr) { + // When user passes in a basePtr+offset we need to fix the diff --git a/pkgs/development/compilers/llvm/rocm/default.nix b/pkgs/development/compilers/llvm/rocm/default.nix index 7ff3c4bfa110..4f96c567a631 100644 --- a/pkgs/development/compilers/llvm/rocm/default.nix +++ b/pkgs/development/compilers/llvm/rocm/default.nix @@ -1,54 +1,600 @@ -{ stdenv, lib, buildPackages, fetchFromGitHub, callPackage, wrapCCWith, overrideCC }: +{ lib +, stdenv +, callPackage +, overrideCC +, wrapCCWith +, wrapBintoolsWith +, runCommand +, lit +, glibc +, spirv-llvm-translator +, xz +, swig +, lua5_3 +, gtest +, hipcc +, rocm-comgr +, vulkan-loader +, vulkan-headers +, glslang +, shaderc +, perl +, rocm-device-libs +, rocm-runtime +, elfutils +, python3Packages +}: let - version = "5.4.0"; - src = fetchFromGitHub { - owner = "RadeonOpenCompute"; - repo = "llvm-project"; - rev = "rocm-${version}"; - hash = "sha256-rlVo77h344PLGj/mIzsw+/ndWywsBsiKDXsEDpWSUno="; + # Stage 1 + # Base + llvm = callPackage ./llvm.nix { }; + + # Projects + clang-unwrapped = callPackage ./llvm.nix rec { + targetName = "clang"; + targetDir = targetName; + extraBuildInputs = [ llvm ]; + + extraCMakeFlags = [ + "-DCMAKE_POLICY_DEFAULT_CMP0116=NEW" + "-DCLANG_INCLUDE_DOCS=ON" + "-DCLANG_INCLUDE_TESTS=ON" + ]; + + extraPostPatch = '' + # Looks like they forgot to add finding libedit to the standalone build + ln -s ../cmake/Modules/FindLibEdit.cmake cmake/modules + + substituteInPlace CMakeLists.txt \ + --replace "include(CheckIncludeFile)" "include(CheckIncludeFile)''\nfind_package(LibEdit)" + + # `No such file or directory: '/build/source/clang/tools/scan-build/bin/scan-build'` + rm test/Analysis/scan-build/*.test + rm test/Analysis/scan-build/rebuild_index/rebuild_index.test + + # `does not depend on a module exporting 'baz.h'` + rm test/Modules/header-attribs.cpp + + # `fatal error: 'stdio.h' file not found` + rm test/OpenMP/amdgcn_emit_llvm.c + ''; + + extraPostInstall = '' + mv bin/clang-tblgen $out/bin + ''; }; + + lld = callPackage ./llvm.nix rec { + buildMan = false; # No man pages to build + targetName = "lld"; + targetDir = targetName; + extraBuildInputs = [ llvm ]; + extraCMakeFlags = [ "-DCMAKE_POLICY_DEFAULT_CMP0116=NEW" ]; + checkTargets = [ "check-lld" ]; + }; + + # Runtimes + runtimes = callPackage ./llvm.nix { + buildDocs = false; + buildMan = false; + buildTests = false; + targetDir = "runtimes"; + + targetRuntimes = [ + # "libc" https://github.com/llvm/llvm-project/issues/57719 + "libunwind" + "libcxxabi" + "libcxx" + "compiler-rt" + ]; + + extraBuildInputs = [ llvm ]; + + extraCMakeFlags = [ + "-DCMAKE_POLICY_DEFAULT_CMP0114=NEW" + "-DLIBCXX_INCLUDE_BENCHMARKS=OFF" + "-DLIBCXX_CXX_ABI=libcxxabi" + ]; + + extraLicenses = [ lib.licenses.mit ]; + }; + + # Stage 2 + # Helpers + rStdenv = overrideCC stdenv (wrapCCWith rec { + inherit bintools; + libcxx = runtimes; + cc = clang-unwrapped; + + extraPackages = [ + llvm + lld + ]; + + nixSupport.cc-cflags = [ + "-resource-dir=$out/resource-root" + "-fuse-ld=lld" + "-rtlib=compiler-rt" + "-unwindlib=libunwind" + "-Wno-unused-command-line-argument" + ]; + + extraBuildCommands = '' + clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"` + mkdir -p $out/resource-root + ln -s ${cc}/lib/clang/$clang_version/include $out/resource-root + ln -s ${runtimes}/lib $out/resource-root + ''; + }); + + bintools = wrapBintoolsWith { bintools = bintools-unwrapped; }; + + bintools-unwrapped = runCommand "rocm-llvm-binutils-${llvm.version}" { preferLocalBuild = true; } '' + mkdir -p $out/bin + + for prog in ${lld}/bin/*; do + ln -s $prog $out/bin/$(basename $prog) + done + + for prog in ${llvm}/bin/*; do + ln -sf $prog $out/bin/$(basename $prog) + done + + ln -s ${llvm}/bin/llvm-ar $out/bin/ar + ln -s ${llvm}/bin/llvm-as $out/bin/as + ln -s ${llvm}/bin/llvm-dwp $out/bin/dwp + ln -s ${llvm}/bin/llvm-nm $out/bin/nm + ln -s ${llvm}/bin/llvm-objcopy $out/bin/objcopy + ln -s ${llvm}/bin/llvm-objdump $out/bin/objdump + ln -s ${llvm}/bin/llvm-ranlib $out/bin/ranlib + ln -s ${llvm}/bin/llvm-readelf $out/bin/readelf + ln -s ${llvm}/bin/llvm-size $out/bin/size + ln -s ${llvm}/bin/llvm-strip $out/bin/strip + ln -s ${lld}/bin/lld $out/bin/ld + ''; in rec { + inherit + llvm + clang-unwrapped + lld + bintools + bintools-unwrapped; + + # Runtimes + libc = callPackage ./llvm.nix rec { + stdenv = rStdenv; + targetName = "libc"; + targetDir = "runtimes"; + targetRuntimes = [ targetName ]; + isBroken = true; # https://github.com/llvm/llvm-project/issues/57719 + }; + + libunwind = callPackage ./llvm.nix rec { + stdenv = rStdenv; + buildMan = false; # No man pages to build + targetName = "libunwind"; + targetDir = "runtimes"; + targetRuntimes = [ targetName ]; + + extraCMakeFlags = [ + "-DLIBUNWIND_INCLUDE_DOCS=ON" + "-DLIBUNWIND_INCLUDE_TESTS=ON" + "-DLIBUNWIND_USE_COMPILER_RT=ON" + ]; + }; + + libcxxabi = callPackage ./llvm.nix rec { + stdenv = rStdenv; + buildDocs = false; # No documentation to build + buildMan = false; # No man pages to build + targetName = "libcxxabi"; + targetDir = "runtimes"; + + targetRuntimes = [ + "libunwind" + targetName + "libcxx" + ]; + + extraCMakeFlags = [ + "-DLIBCXXABI_INCLUDE_TESTS=ON" + "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" + "-DLIBCXXABI_USE_COMPILER_RT=ON" + + # Workaround having to build combined + "-DLIBUNWIND_INCLUDE_DOCS=OFF" + "-DLIBUNWIND_INCLUDE_TESTS=OFF" + "-DLIBUNWIND_USE_COMPILER_RT=ON" + "-DLIBUNWIND_INSTALL_LIBRARY=OFF" + "-DLIBUNWIND_INSTALL_HEADERS=OFF" + "-DLIBCXX_INCLUDE_DOCS=OFF" + "-DLIBCXX_INCLUDE_TESTS=OFF" + "-DLIBCXX_USE_COMPILER_RT=ON" + "-DLIBCXX_CXX_ABI=libcxxabi" + "-DLIBCXX_INSTALL_LIBRARY=OFF" + "-DLIBCXX_INSTALL_HEADERS=OFF" + ]; + }; + + libcxx = callPackage ./llvm.nix rec { + stdenv = rStdenv; + buildMan = false; # No man pages to build + targetName = "libcxx"; + targetDir = "runtimes"; + + targetRuntimes = [ + "libunwind" + "libcxxabi" + targetName + ]; + + extraCMakeFlags = [ + "-DLIBCXX_INCLUDE_DOCS=ON" + "-DLIBCXX_INCLUDE_TESTS=ON" + "-DLIBCXX_USE_COMPILER_RT=ON" + "-DLIBCXX_CXX_ABI=libcxxabi" + + # Workaround having to build combined + "-DLIBUNWIND_INCLUDE_DOCS=OFF" + "-DLIBUNWIND_INCLUDE_TESTS=OFF" + "-DLIBUNWIND_USE_COMPILER_RT=ON" + "-DLIBUNWIND_INSTALL_LIBRARY=OFF" + "-DLIBUNWIND_INSTALL_HEADERS=OFF" + "-DLIBCXXABI_INCLUDE_TESTS=OFF" + "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" + "-DLIBCXXABI_USE_COMPILER_RT=ON" + "-DLIBCXXABI_INSTALL_LIBRARY=OFF" + "-DLIBCXXABI_INSTALL_HEADERS=OFF" + ]; + + # Most of these can't find `bash` or `mkdir`, might just be hard-coded paths, or PATH is altered + extraPostPatch = '' + chmod +w -R ../libcxx/test/{libcxx,std} + rm -rf ../libcxx/test/libcxx/input.output/filesystems + rm ../libcxx/test/libcxx/selftest/remote-substitutions.sh.cpp + rm ../libcxx/test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp + rm ../libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpp + rm ../libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp + rm ../libcxx/test/std/utilities/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp + rm -rf ../libcxx/test/std/utilities/optional/optional.object/optional.object.ctor + rm -rf ../libcxx/test/std/input.output/filesystems/{class.directory_entry,class.directory_iterator,class.rec.dir.itr,fs.op.funcs} + ''; + }; + + compiler-rt = callPackage ./llvm.nix rec { + stdenv = rStdenv; + buildDocs = false; # No documentation to build + buildMan = false; # No man pages to build + targetName = "compiler-rt"; + targetDir = "runtimes"; + + targetRuntimes = [ + "libunwind" + "libcxxabi" + "libcxx" + targetName + ]; + + extraCMakeFlags = [ + "-DCMAKE_POLICY_DEFAULT_CMP0114=NEW" + "-DCOMPILER_RT_INCLUDE_TESTS=ON" + "-DCOMPILER_RT_USE_LLVM_UNWINDER=ON" + "-DCOMPILER_RT_CXX_LIBRARY=libcxx" + "-DCOMPILER_RT_CAN_EXECUTE_TESTS=OFF" # We can't run most of these + + # Workaround having to build combined + "-DLIBUNWIND_INCLUDE_DOCS=OFF" + "-DLIBUNWIND_INCLUDE_TESTS=OFF" + "-DLIBUNWIND_USE_COMPILER_RT=ON" + "-DLIBUNWIND_INSTALL_LIBRARY=OFF" + "-DLIBUNWIND_INSTALL_HEADERS=OFF" + "-DLIBCXXABI_INCLUDE_TESTS=OFF" + "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" + "-DLIBCXXABI_USE_COMPILER_RT=ON" + "-DLIBCXXABI_INSTALL_LIBRARY=OFF" + "-DLIBCXXABI_INSTALL_HEADERS=OFF" + "-DLIBCXX_INCLUDE_DOCS=OFF" + "-DLIBCXX_INCLUDE_TESTS=OFF" + "-DLIBCXX_USE_COMPILER_RT=ON" + "-DLIBCXX_CXX_ABI=libcxxabi" + "-DLIBCXX_INSTALL_LIBRARY=OFF" + "-DLIBCXX_INSTALL_HEADERS=OFF" + ]; + + extraPostPatch = '' + # `No such file or directory: 'ldd'` + substituteInPlace ../compiler-rt/test/lit.common.cfg.py \ + --replace "'ldd'," "'${glibc.bin}/bin/ldd'," + + # We can run these + substituteInPlace ../compiler-rt/test/CMakeLists.txt \ + --replace "endfunction()" "endfunction()''\nadd_subdirectory(builtins)''\nadd_subdirectory(shadowcallstack)" + ''; + + extraLicenses = [ lib.licenses.mit ]; + }; + + # Stage 3 + # Helpers + rocmClangStdenv = overrideCC stdenv clang; + clang = wrapCCWith rec { - cc = llvm; + # inherit libc libcxx bintools; + inherit libcxx bintools; + + # We do this to avoid HIP pathing problems, and mimic a monolithic install + cc = stdenv.mkDerivation (finalAttrs: { + inherit (clang-unwrapped) pname version; + dontUnpack = true; + + installPhase = '' + runHook preInstall + + clang_version=`${clang-unwrapped}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"` + mkdir -p $out/{bin,include/c++/v1,lib/{cmake,clang/$clang_version/{include,lib}},libexec,share} + + for path in ${llvm} ${clang-unwrapped} ${lld} ${libunwind} ${libcxxabi} ${libcxx} ${compiler-rt}; do + cp -as $path/* $out + chmod +w $out/{*,include/c++/v1,lib/{clang/$clang_version/include,cmake}} + rm -f $out/lib/libc++.so + done + + ln -s $out/lib/* $out/lib/clang/$clang_version/lib + ln -s $out/include/* $out/lib/clang/$clang_version/include + + runHook postInstall + ''; + + passthru.isClang = true; + }); + + extraPackages = [ + llvm + lld + libunwind + libcxxabi + compiler-rt + ]; + + nixSupport.cc-cflags = [ + "-resource-dir=$out/resource-root" + "-fuse-ld=lld" + "-rtlib=compiler-rt" + "-unwindlib=libunwind" + "-Wno-unused-command-line-argument" + ]; + extraBuildCommands = '' clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"` - rsrc="$out/resource-root" - mkdir "$rsrc" - ln -s "${cc}/lib/clang/$clang_version/include" "$rsrc" - ln -s "${cc}/lib/clang/$clang_version/lib" "$rsrc/lib" - echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags - echo "--gcc-toolchain=${stdenv.cc.cc}" >> $out/nix-support/cc-cflags + mkdir -p $out/resource-root + ln -s ${cc}/lib/clang/$clang_version/{include,lib} $out/resource-root + + # Not sure why, but hardening seems to make things break rm $out/nix-support/add-hardening.sh touch $out/nix-support/add-hardening.sh - # GPU compilation uses builtin lld - substituteInPlace $out/bin/clang \ - --replace '-MM) dontLink=1 ;;' $'-MM | --cuda-device-only) dontLink=1 ;;\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;' - substituteInPlace $out/bin/clang++ \ - --replace '-MM) dontLink=1 ;;' $'-MM | --cuda-device-only) dontLink=1 ;;\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;' + + # GPU compilation uses builtin `lld` + substituteInPlace $out/bin/{clang,clang++} \ + --replace "-MM) dontLink=1 ;;" "-MM | --cuda-device-only) dontLink=1 ;;''\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;" ''; }; - clangNoCompilerRt = wrapCCWith rec { - cc = llvm; - extraBuildCommands = '' - clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"` - rsrc="$out/resource-root" - mkdir "$rsrc" - ln -s "${cc}/lib/clang/$clang_version/include" "$rsrc" - echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags - echo "--gcc-toolchain=${stdenv.cc.cc}" >> $out/nix-support/cc-cflags - rm $out/nix-support/add-hardening.sh - touch $out/nix-support/add-hardening.sh - # GPU compilation uses builtin lld - substituteInPlace $out/bin/clang \ - --replace '-MM) dontLink=1 ;;' $'-MM | --cuda-device-only) dontLink=1 ;;\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;' - substituteInPlace $out/bin/clang++ \ - --replace '-MM) dontLink=1 ;;' $'-MM | --cuda-device-only) dontLink=1 ;;\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;' + # Base + # Unfortunately, we cannot build `clang-tools-extra` separately. + clang-tools-extra = callPackage ./llvm.nix { + stdenv = rocmClangStdenv; + buildTests = false; # `invalid operands to binary expression ('std::basic_stringstream' and 'const llvm::StringRef')` + targetName = "clang-tools-extra"; + + targetProjects = [ + "clang" + "clang-tools-extra" + ]; + + extraBuildInputs = [ gtest ]; + + extraCMakeFlags = [ + "-DLLVM_INCLUDE_DOCS=OFF" + "-DLLVM_INCLUDE_TESTS=OFF" + "-DCLANG_INCLUDE_DOCS=OFF" + "-DCLANG_INCLUDE_TESTS=ON" + "-DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=ON" + ]; + + extraPostInstall = '' + # Remove LLVM and Clang + for path in `find ${llvm} ${clang-unwrapped}`; do + if [ $path != ${llvm} ] && [ $path != ${clang-unwrapped} ]; then + rm -f $out''${path#${llvm}} $out''${path#${clang-unwrapped}} || true + fi + done + + # Cleanup empty directories + find $out -type d -empty -delete ''; }; - llvm = callPackage ./llvm.nix { - inherit src version; + # Projects + libclc = let + spirv = (spirv-llvm-translator.override { inherit llvm; }); + in callPackage ./llvm.nix rec { + stdenv = rocmClangStdenv; + buildDocs = false; # No documentation to build + buildMan = false; # No man pages to build + targetName = "libclc"; + targetDir = targetName; + extraBuildInputs = [ spirv ]; + + # `spirv-mesa3d` isn't compiling with LLVM 15.0.0, it does with LLVM 14.0.0 + # Try removing the `spirv-mesa3d` and `clspv` patches next update + # `clspv` tests fail, unresolved calls + extraPostPatch = '' + substituteInPlace CMakeLists.txt \ + --replace "find_program( LLVM_CLANG clang PATHS \''${LLVM_BINDIR} NO_DEFAULT_PATH )" \ + "find_program( LLVM_CLANG clang PATHS \"${clang}/bin\" NO_DEFAULT_PATH )" \ + --replace "find_program( LLVM_SPIRV llvm-spirv PATHS \''${LLVM_BINDIR} NO_DEFAULT_PATH )" \ + "find_program( LLVM_SPIRV llvm-spirv PATHS \"${spirv}/bin\" NO_DEFAULT_PATH )" \ + --replace " spirv-mesa3d-" "" \ + --replace " spirv64-mesa3d-" "" \ + --replace "NOT \''${t} MATCHES" \ + "NOT \''${ARCH} STREQUAL \"clspv\" AND NOT \''${ARCH} STREQUAL \"clspv64\" AND NOT \''${t} MATCHES" + ''; + + checkTargets = [ ]; + }; + + lldb = callPackage ./llvm.nix rec { + stdenv = rocmClangStdenv; + buildTests = false; # ld.lld: error: unable to find library -lllvm_gtest_main + targetName = "lldb"; + targetDir = targetName; + extraNativeBuildInputs = [ python3Packages.sphinx-automodapi ]; + + extraBuildInputs = [ + xz + swig + lua5_3 + gtest + ]; + + extraCMakeFlags = [ + "-DLLVM_EXTERNAL_LIT=${lit}/bin/.lit-wrapped" + "-DLLDB_INCLUDE_TESTS=ON" + "-DLLDB_INCLUDE_UNITTESTS=ON" + ]; + }; + + mlir = callPackage ./llvm.nix rec { + stdenv = rocmClangStdenv; + buildDocs = false; # No decent way to hack this to work + buildMan = false; # No man pages to build + targetName = "mlir"; + targetDir = targetName; + extraNativeBuildInputs = [ hipcc ]; + + extraBuildInputs = [ + rocm-comgr + vulkan-headers + vulkan-loader + glslang + shaderc + ]; + + extraCMakeFlags = [ + "-DCMAKE_POLICY_DEFAULT_CMP0116=NEW" + "-DMLIR_INCLUDE_DOCS=ON" + "-DMLIR_INCLUDE_TESTS=ON" + "-DMLIR_ENABLE_ROCM_RUNNER=ON" + "-DMLIR_ENABLE_SPIRV_CPU_RUNNER=ON" + "-DMLIR_ENABLE_VULKAN_RUNNER=ON" + "-DROCM_TEST_CHIPSET=gfx000" # CPU runner + ]; + + extraPostPatch = '' + chmod +w ../llvm + mkdir -p ../llvm/build/bin + ln -s ${lit}/bin/lit ../llvm/build/bin/llvm-lit + + substituteInPlace test/CMakeLists.txt \ + --replace "FileCheck count not" "" \ + --replace "list(APPEND MLIR_TEST_DEPENDS mlir_rocm_runtime)" "" + + substituteInPlace lib/ExecutionEngine/CMakeLists.txt \ + --replace "return()" "" + + # Remove problematic tests + rm test/CAPI/execution_engine.c + rm test/Target/LLVMIR/llvmir-intrinsics.mlir + rm test/Target/LLVMIR/llvmir.mlir + rm test/Target/LLVMIR/openmp-llvm.mlir + rm test/mlir-cpu-runner/*.mlir + rm test/mlir-vulkan-runner/*.mlir + ''; + + extraPostInstall = '' + mkdir -p $out/bin + mv bin/mlir-tblgen $out/bin + ''; + + checkTargets = [ "check-${targetName}" ]; + }; + + polly = callPackage ./llvm.nix rec { + stdenv = rocmClangStdenv; + targetName = "polly"; + targetDir = targetName; + checkTargets = [ "check-${targetName}" ]; + }; + + flang = callPackage ./llvm.nix rec { + stdenv = rocmClangStdenv; + buildTests = false; # `Executable "flang1" doesn't exist!` + targetName = "flang"; + targetDir = targetName; + extraNativeBuildInputs = [ python3Packages.sphinx-markdown-tables ]; + extraBuildInputs = [ mlir ]; + + extraCMakeFlags = [ + "-DCMAKE_POLICY_DEFAULT_CMP0116=NEW" + "-DCLANG_DIR=${clang-unwrapped}/lib/cmake/clang" + "-DFLANG_INCLUDE_TESTS=OFF" + "-DMLIR_TABLEGEN_EXE=${mlir}/bin/mlir-tblgen" + ]; + + extraPostPatch = '' + substituteInPlace test/CMakeLists.txt \ + --replace "FileCheck" "" \ + --replace "count" "" \ + --replace "not" "" + + substituteInPlace docs/CMakeLists.txt \ + --replace "CLANG_TABLEGEN_EXE clang-tblgen" "CLANG_TABLEGEN_EXE ${clang-unwrapped}/bin/clang-tblgen" + ''; + }; + + openmp = callPackage ./llvm.nix rec { + stdenv = rocmClangStdenv; + buildTests = false; # Too many failures, most pass + targetName = "openmp"; + targetDir = targetName; + extraPatches = [ ./0000-fix-openmp.patch ]; + extraNativeBuildInputs = [ perl ]; + + extraBuildInputs = [ + rocm-device-libs + rocm-runtime + elfutils + ]; + + extraCMakeFlags = [ + "-DCMAKE_MODULE_PATH=/build/source/llvm/cmake/modules" # For docs + "-DCLANG_TOOL=${clang}/bin/clang" + "-DCLANG_OFFLOAD_BUNDLER_TOOL=${clang-unwrapped}/bin/clang-offload-bundler" + "-DOPENMP_LLVM_TOOLS_DIR=${llvm}/bin" + "-DOPENMP_LLVM_LIT_EXECUTABLE=${lit}/bin/.lit-wrapped" + "-DDEVICELIBS_ROOT=${rocm-device-libs.src}" + ]; + + extraPostPatch = '' + # We can't build this target at the moment + substituteInPlace libomptarget/DeviceRTL/CMakeLists.txt \ + --replace "gfx1010" "" + ''; + + checkTargets = [ "check-${targetName}" ]; + extraLicenses = [ lib.licenses.mit ]; + }; + + # Runtimes + pstl = callPackage ./llvm.nix rec { + stdenv = rocmClangStdenv; + buildDocs = false; # No documentation to build + buildMan = false; # No man pages to build + buildTests = false; # Too many errors + targetName = "pstl"; + targetDir = "runtimes"; + targetRuntimes = [ targetName ]; + checkTargets = [ "check-${targetName}" ]; }; } diff --git a/pkgs/development/compilers/llvm/rocm/llvm.nix b/pkgs/development/compilers/llvm/rocm/llvm.nix index b148b936ca56..82aee79cfe4a 100644 --- a/pkgs/development/compilers/llvm/rocm/llvm.nix +++ b/pkgs/development/compilers/llvm/rocm/llvm.nix @@ -1,22 +1,44 @@ -{ stdenv -, lib -, fetchgit +{ lib +, stdenv , fetchFromGitHub -, writeScript +, rocmUpdateScript +, pkg-config , cmake , ninja -, python3 +, git +, doxygen +, sphinx +, lit , libxml2 -, libffi -, libbfd , libxcrypt -, ncurses +, libedit +, libffi +, mpfr , zlib -, debugVersion ? false -, enableManpages ? false - -, version -, src +, ncurses +, python3Packages +, buildDocs ? true +, buildMan ? true +, buildTests ? true +, targetName ? "llvm" +, targetDir ? "llvm" +, targetProjects ? [ ] +, targetRuntimes ? [ ] +, extraPatches ? [ ] +, extraNativeBuildInputs ? [ ] +, extraBuildInputs ? [ ] +, extraCMakeFlags ? [ ] +, extraPostPatch ? "" +, checkTargets ? [( + lib.optionalString buildTests ( + if targetDir == "runtimes" + then "check-runtimes" + else "check-all" + ) +)] +, extraPostInstall ? "" +, extraLicenses ? [ ] +, isBroken ? false }: let @@ -25,73 +47,119 @@ let else if stdenv.isAarch64 then "AArch64" else throw "Unsupported ROCm LLVM platform"; in stdenv.mkDerivation (finalAttrs: { - inherit src version; + pname = "rocm-llvm-${targetName}"; + version = "5.4.0"; - pname = "rocm-llvm"; - - sourceRoot = "${src.name}/llvm"; - - nativeBuildInputs = [ cmake ninja python3 ]; - - buildInputs = [ libxml2 libxcrypt ]; - - propagatedBuildInputs = [ ncurses zlib ]; - - cmakeFlags = with stdenv; [ - "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" - "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc - "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}" - "-DLLVM_ENABLE_PROJECTS=clang;lld;compiler-rt" - ] - ++ lib.optionals enableManpages [ - "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" - "-DLLVM_BUILD_DOCS=ON" - "-DLLVM_ENABLE_SPHINX=ON" - "-DSPHINX_OUTPUT_MAN=ON" - "-DSPHINX_OUTPUT_HTML=OFF" - "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + outputs = [ + "out" + ] ++ lib.optionals buildDocs [ + "doc" + ] ++ lib.optionals buildMan [ + "man" + "info" # Avoid `attribute 'info' missing` when using with wrapCC ]; - postPatch = '' + patches = extraPatches; + + src = fetchFromGitHub { + owner = "RadeonOpenCompute"; + repo = "llvm-project"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-rlVo77h344PLGj/mIzsw+/ndWywsBsiKDXsEDpWSUno="; + }; + + nativeBuildInputs = [ + pkg-config + cmake + ninja + git + python3Packages.python + ] ++ lib.optionals (buildDocs || buildMan) [ + doxygen + sphinx + python3Packages.recommonmark + ] ++ lib.optionals (buildTests && !finalAttrs.passthru.isLLVM) [ + lit + ] ++ extraNativeBuildInputs; + + buildInputs = [ + libxml2 + libxcrypt + libedit + libffi + mpfr + ] ++ extraBuildInputs; + + propagatedBuildInputs = lib.optionals finalAttrs.passthru.isLLVM [ + zlib + ncurses + ]; + + sourceRoot = "${finalAttrs.src.name}/${targetDir}"; + + cmakeFlags = [ + "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}" + ] ++ lib.optionals (finalAttrs.passthru.isLLVM && targetProjects != [ ]) [ + "-DLLVM_ENABLE_PROJECTS=${lib.concatStringsSep ";" targetProjects}" + ] ++ lib.optionals ((finalAttrs.passthru.isLLVM || targetDir == "runtimes") && targetRuntimes != [ ]) [ + "-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" targetRuntimes}" + ] ++ lib.optionals (finalAttrs.passthru.isLLVM || finalAttrs.passthru.isClang) [ + "-DLLVM_ENABLE_RTTI=ON" + "-DLLVM_ENABLE_EH=ON" + ] ++ lib.optionals (buildDocs || buildMan) [ + "-DLLVM_INCLUDE_DOCS=ON" + "-DLLVM_BUILD_DOCS=ON" + # "-DLLVM_ENABLE_DOXYGEN=ON" Way too slow, only uses one core + "-DLLVM_ENABLE_SPHINX=ON" + "-DLLVM_ENABLE_OCAMLDOC=OFF" + "-DSPHINX_OUTPUT_HTML=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ] ++ lib.optionals buildTests [ + "-DLLVM_INCLUDE_TESTS=ON" + "-DLLVM_BUILD_TESTS=ON" + ] ++ lib.optionals (buildTests && !finalAttrs.passthru.isLLVM) [ + "-DLLVM_EXTERNAL_LIT=${lit}/bin/.lit-wrapped" + ] ++ extraCMakeFlags; + + postPatch = lib.optionalString finalAttrs.passthru.isLLVM '' patchShebangs lib/OffloadArch/make_generated_offload_arch_h.sh - substituteInPlace ../clang/cmake/modules/CMakeLists.txt \ - --replace 'FILES_MATCHING' 'NO_SOURCE_PERMISSIONS FILES_MATCHING' - ''; + '' + lib.optionalString (buildTests && finalAttrs.passthru.isLLVM) '' + # FileSystem permissions tests fail with various special bits + rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test + rm unittests/Support/Path.cpp + + substituteInPlace unittests/Support/CMakeLists.txt \ + --replace "Path.cpp" "" + '' + extraPostPatch; + + doCheck = buildTests; + checkTarget = lib.concatStringsSep " " checkTargets; + + postInstall = lib.optionalString finalAttrs.passthru.isLLVM '' + # `lit` expects these for some test suites + mv bin/{FileCheck,not,count,yaml2obj,obj2yaml} $out/bin + '' + lib.optionalString buildMan '' + mkdir -p $info + '' + extraPostInstall; passthru = { - isClang = true; + isLLVM = targetDir == "llvm"; + isClang = targetDir == "clang" || builtins.elem "clang" targetProjects; - updateScript = writeScript "update.sh" '' - #!/usr/bin/env nix-shell - #!nix-shell -i bash -p curl jq common-updater-scripts nix-prefetch-github - - version="$(curl ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \ - -sL "https://api.github.com/repos/RadeonOpenCompute/llvm-project/releases?per_page=1" | jq '.[0].tag_name | split("-") | .[1]' --raw-output)" - - IFS='.' read -a version_arr <<< "$version" - - if [ "''${#version_arr[*]}" == 2 ]; then - version="''${version}.0" - fi - - current_version="$(grep "version =" pkgs/development/compilers/llvm/rocm/default.nix | cut -d'"' -f2)" - if [[ "$version" != "$current_version" ]]; then - tarball_meta="$(nix-prefetch-github RadeonOpenCompute llvm-project --rev "rocm-$version")" - tarball_hash="$(nix to-base64 sha256-$(jq -r '.sha256' <<< "$tarball_meta"))" - sed -i "pkgs/development/compilers/llvm/rocm/default.nix" \ - -e 's,version = "\(.*\)",version = "'"$version"'",' \ - -e 's,hash = "\(.*\)",hash = "sha256-'"$tarball_hash"'",' - else - echo rocm-llvm already up-to-date - fi - ''; + updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; }; + }; meta = with lib; { description = "ROCm fork of the LLVM compiler infrastructure"; homepage = "https://github.com/RadeonOpenCompute/llvm-project"; - license = with licenses; [ ncsa ]; + license = with licenses; [ ncsa ] ++ extraLicenses; maintainers = with maintainers; [ acowley lovesegfault ] ++ teams.rocm.members; platforms = platforms.linux; + broken = isBroken; }; }) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d55ddeeca6f9..22c43b4d3451 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -13843,6 +13843,7 @@ with pkgs; clangStdenv = if stdenv.cc.isClang then stdenv else lowPrio llvmPackages.stdenv; clang-sierraHack-stdenv = overrideCC stdenv buildPackages.clang-sierraHack; libcxxStdenv = if stdenv.isDarwin then stdenv else lowPrio llvmPackages.libcxxStdenv; + rocmClangStdenv = llvmPackages_rocm.rocmClangStdenv; clasp-common-lisp = callPackage ../development/compilers/clasp { llvmPackages = llvmPackages_6; From 785ed480aafdde6cbbffb7605f1cd988f8524dab Mon Sep 17 00:00:00 2001 From: Madoura Date: Mon, 12 Dec 2022 17:36:53 -0600 Subject: [PATCH 06/21] 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; }; }; From fb8a7b62bb3f0c3e381761eb3332c8abefbbd9e6 Mon Sep 17 00:00:00 2001 From: Madoura Date: Fri, 16 Dec 2022 00:51:10 -0600 Subject: [PATCH 07/21] rocm-related: standardize and fix tests/benchmarks rocblas: standardize and fix test/benchmarks rocthrust: standardize and fix test/benchmarks rocwmma: standardize and fix tests/benchmarks --- .../development/libraries/rocblas/default.nix | 55 ++++++++++--------- .../libraries/rocthrust/default.nix | 49 +++++++---------- .../rocwmma/0000-dont-fetch-googletest.patch | 28 +++++++--- .../development/libraries/rocwmma/default.nix | 36 +++++++----- pkgs/top-level/all-packages.nix | 10 +++- 5 files changed, 98 insertions(+), 80 deletions(-) diff --git a/pkgs/development/libraries/rocblas/default.nix b/pkgs/development/libraries/rocblas/default.nix index 24ead8242005..41c0b188318c 100644 --- a/pkgs/development/libraries/rocblas/default.nix +++ b/pkgs/development/libraries/rocblas/default.nix @@ -2,20 +2,17 @@ , stdenv , fetchFromGitHub , rocmUpdateScript -, fetchpatch , cmake , rocm-cmake -, rocm-runtime -, rocm-device-libs -, rocm-comgr , hip , python3 , tensile , msgpack , libxml2 -, llvm , gtest , gfortran +, openmp +, amd-blis , python3Packages , buildTensile ? true , buildTests ? false @@ -32,6 +29,14 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocblas"; version = "5.4.0"; + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + src = fetchFromGitHub { owner = "ROCmSoftwarePlatform"; repo = "rocBLAS"; @@ -39,16 +44,6 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-4art8/KwH2KDLwSYcyzn/m/xwdg5wQQvgHks73aB+60="; }; - # We currently need this patch due to faulty toolchain includes - # See: https://github.com/ROCmSoftwarePlatform/rocBLAS/issues/1277 - patches = [ - (fetchpatch { - name = "only-std_norm-from-rocblas_complex.patch"; - url = "https://github.com/ROCmSoftwarePlatform/rocBLAS/commit/44b99c6df26002139ca9ec68ee1fc8899c7b001f.patch"; - hash = "sha256-vSZkVYY951fqfOThKFqnYBasWMblS6peEJZ6sFMCk9k="; - }) - ]; - nativeBuildInputs = [ cmake rocm-cmake @@ -56,19 +51,19 @@ stdenv.mkDerivation (finalAttrs: { ]; buildInputs = [ - rocm-runtime - rocm-device-libs - rocm-comgr python3 ] ++ lib.optionals buildTensile [ msgpack libxml2 - llvm - python3Packages.pyyaml python3Packages.msgpack ] ++ lib.optionals buildTests [ gtest + ] ++ lib.optionals (buildTests || buildBenchmarks) [ gfortran + openmp + amd-blis + ] ++ lib.optionals (buildTensile || buildTests || buildBenchmarks) [ + python3Packages.pyyaml ]; cmakeFlags = [ @@ -95,12 +90,12 @@ stdenv.mkDerivation (finalAttrs: { "-DBUILD_CLIENTS_TESTS=ON" ] ++ lib.optionals buildBenchmarks [ "-DBUILD_CLIENTS_BENCHMARKS=ON" + ] ++ lib.optionals (buildTests || buildBenchmarks) [ + "-DCMAKE_CXX_FLAGS=-I${amd-blis}/include/blis" ]; # Tensile REALLY wants to write to the nix directory if we include it normally - # We need to manually fixup the path so tensile will generate .co and .dat files postPatch = lib.optionalString buildTensile '' - export PATH=${llvm}/bin:$PATH cp -a ${tensile} tensile chmod +w -R tensile @@ -113,6 +108,18 @@ stdenv.mkDerivation (finalAttrs: { --replace "virtualenv_install(\''${Tensile_TEST_LOCAL_PATH})" "" ''; + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + cp -a $out/bin/* $test/bin + rm $test/bin/*-bench || true + '' + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + cp -a $out/bin/* $benchmark/bin + rm $benchmark/bin/*-test || true + '' + lib.optionalString (buildTests || buildBenchmarks ) '' + rm -rf $out/bin + ''; + passthru.updateScript = rocmUpdateScript { name = finalAttrs.pname; owner = finalAttrs.src.owner; @@ -124,8 +131,6 @@ stdenv.mkDerivation (finalAttrs: { homepage = "https://github.com/ROCmSoftwarePlatform/rocBLAS"; license = with licenses; [ mit ]; maintainers = teams.rocm.members; - # Tests and benchmarks are a can of worms that I will tackle in a different PR - # It involves completely rewriting the amd-blis derivation - broken = finalAttrs.version != hip.version || buildTests || buildBenchmarks; + broken = finalAttrs.version != hip.version; }; }) diff --git a/pkgs/development/libraries/rocthrust/default.nix b/pkgs/development/libraries/rocthrust/default.nix index 281620780832..7a45a794ad2d 100644 --- a/pkgs/development/libraries/rocthrust/default.nix +++ b/pkgs/development/libraries/rocthrust/default.nix @@ -4,9 +4,6 @@ , rocmUpdateScript , cmake , rocm-cmake -, rocm-runtime -, rocm-device-libs -, rocm-comgr , rocprim , hip , gtest @@ -18,14 +15,13 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocthrust"; version = "5.4.0"; - # Comment out these outputs until tests/benchmarks are fixed (upstream?) - # outputs = [ - # "out" - # ] ++ lib.optionals buildTests [ - # "test" - # ] ++ lib.optionals buildBenchmarks [ - # "benchmark" - # ]; + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; src = fetchFromGitHub { owner = "ROCmSoftwarePlatform"; @@ -41,11 +37,7 @@ stdenv.mkDerivation (finalAttrs: { hip ]; - buildInputs = [ - rocm-runtime - rocm-device-libs - rocm-comgr - ] ++ lib.optionals buildTests [ + buildInputs = lib.optionals buildTests [ gtest ]; @@ -61,18 +53,19 @@ stdenv.mkDerivation (finalAttrs: { "-DBUILD_TEST=ON" ] ++ lib.optionals buildBenchmarks [ "-DBUILD_BENCHMARKS=ON" + ] ++ lib.optionals (buildTests || buildBenchmarks) [ + "-DCMAKE_CXX_FLAGS=-Wno-deprecated-builtins" # Too much spam ]; - # Comment out these outputs until tests/benchmarks are fixed (upstream?) - # 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 - # ''; + 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 { name = finalAttrs.pname; @@ -85,8 +78,6 @@ stdenv.mkDerivation (finalAttrs: { homepage = "https://github.com/ROCmSoftwarePlatform/rocThrust"; license = with licenses; [ asl20 ]; maintainers = teams.rocm.members; - # Tests/Benchmarks don't seem to work, thousands of errors compiling with no clear fix - # Is this an upstream issue? We don't seem to be missing dependencies - broken = finalAttrs.version != hip.version || buildTests || buildBenchmarks; + broken = finalAttrs.version != hip.version; }; }) diff --git a/pkgs/development/libraries/rocwmma/0000-dont-fetch-googletest.patch b/pkgs/development/libraries/rocwmma/0000-dont-fetch-googletest.patch index 7208d20a2127..cee603679758 100644 --- a/pkgs/development/libraries/rocwmma/0000-dont-fetch-googletest.patch +++ b/pkgs/development/libraries/rocwmma/0000-dont-fetch-googletest.patch @@ -1,19 +1,31 @@ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt -index 7e0f2c8..db54eab 100644 +index e1160bb..2a5462e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt -@@ -31,14 +31,6 @@ cmake_dependent_option( ROCWMMA_BUILD_BENCHMARK_TESTS "Build benchmarking tests" +@@ -30,26 +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 +-# Test/benchmark requires additional dependencies -include( FetchContent ) - -FetchContent_Declare( - googletest -- URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip +- GIT_REPOSITORY https://github.com/google/googletest.git +- GIT_TAG 609281088cfefc76f9d0ce82e1ff6c30cc3591e5 -) --FetchContent_MakeAvailable(googletest) -- - include(GoogleTest) +-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_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + set(ROCWMMA_TEST_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) + set(ROCWMMA_COMMON_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hip_device.cpp diff --git a/pkgs/development/libraries/rocwmma/default.nix b/pkgs/development/libraries/rocwmma/default.nix index 786d48ee80ca..818d915cc133 100644 --- a/pkgs/development/libraries/rocwmma/default.nix +++ b/pkgs/development/libraries/rocwmma/default.nix @@ -14,6 +14,8 @@ , python3Packages , buildDocs ? true , buildTests ? false +, buildExtendedTests ? false +, buildBenchmarks ? false , buildSamples ? false , gpuTargets ? [ ] # gpuTargets = [ "gfx908:xnack-" "gfx90a:xnack-" "gfx90a:xnack+" ... ] }: @@ -40,8 +42,10 @@ in stdenv.mkDerivation (finalAttrs: { "out" ] ++ lib.optionals buildDocs [ "doc" - ] ++ lib.optionals buildTests [ + ] ++ lib.optionals (buildTests || buildBenchmarks) [ "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" ] ++ lib.optionals buildSamples [ "sample" ]; @@ -53,7 +57,7 @@ in stdenv.mkDerivation (finalAttrs: { hash = "sha256-HUJPb6IahBgl/v+W4kXludBTNAjRm8k6v0jxKAX+qZM="; }; - patches = lib.optionals buildTests [ + patches = lib.optionals (buildTests || buildBenchmarks) [ ./0000-dont-fetch-googletest.patch ]; @@ -65,7 +69,7 @@ in stdenv.mkDerivation (finalAttrs: { buildInputs = [ openmp - ] ++ lib.optionals buildTests [ + ] ++ lib.optionals (buildTests || buildBenchmarks) [ gtest rocblas ] ++ lib.optionals buildDocs [ @@ -78,8 +82,10 @@ in stdenv.mkDerivation (finalAttrs: { cmakeFlags = [ "-DCMAKE_CXX_COMPILER=hipcc" - "-DROCWMMA_BUILD_TESTS=${if buildTests then "ON" else "OFF"}" + "-DROCWMMA_BUILD_TESTS=${if buildTests || buildBenchmarks then "ON" else "OFF"}" + "-DROCWMMA_BUILD_VALIDATION_TESTS=ON" "-DROCWMMA_BUILD_SAMPLES=${if buildSamples then "ON" else "OFF"}" + "-DROCWMMA_VALIDATE_WITH_ROCBLAS=ON" # Manually define CMAKE_INSTALL_ # See: https://github.com/NixOS/nixpkgs/pull/197838 "-DCMAKE_INSTALL_BINDIR=bin" @@ -87,11 +93,10 @@ in stdenv.mkDerivation (finalAttrs: { "-DCMAKE_INSTALL_INCLUDEDIR=include" ] ++ lib.optionals (gpuTargets != [ ]) [ "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" - ] ++ lib.optionals buildTests [ - "-DROCWMMA_BUILD_VALIDATION_TESTS=ON" - "-DROCWMMA_BUILD_BENCHMARK_TESTS=ON" + ] ++ lib.optionals buildExtendedTests [ "-DROCWMMA_BUILD_EXTENDED_TESTS=ON" - "-DROCWMMA_VALIDATE_WITH_ROCBLAS=ON" + ] ++ lib.optionals buildBenchmarks [ + "-DROCWMMA_BUILD_BENCHMARK_TESTS=ON" "-DROCWMMA_BENCHMARK_WITH_ROCBLAS=ON" ]; @@ -109,16 +114,19 @@ in stdenv.mkDerivation (finalAttrs: { postInstall = lib.optionalString buildDocs '' mv ../docs/source/_build/html $out/share/doc/rocwmma mv ../docs/source/_build/latex/rocWMMA.pdf $out/share/doc/rocwmma - '' + lib.optionalString buildTests '' + '' + lib.optionalString (buildTests || buildBenchmarks) '' mkdir -p $test/bin - mv $out/bin/*_test* $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 || buildSamples) '' - rmdir $out/bin + '' + lib.optionalString (buildTests || buildBenchmarks || buildSamples) '' + rm -rf $out/bin ''; passthru.updateScript = rocmUpdateScript { @@ -132,8 +140,6 @@ in stdenv.mkDerivation (finalAttrs: { homepage = "https://github.com/ROCmSoftwarePlatform/rocWMMA"; license = with licenses; [ mit ]; maintainers = teams.rocm.members; - # Building tests isn't working for now - # undefined reference to symbol '_ZTIN7testing4TestE' - broken = finalAttrs.version != hip.version || buildTests; + broken = finalAttrs.version != hip.version; }; }) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 511f5b705e08..d128b3ca725d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15229,18 +15229,22 @@ with pkgs; }; rocwmma = callPackage ../development/libraries/rocwmma { - inherit (llvmPackages) openmp; + inherit (llvmPackages_rocm) openmp; + stdenv = rocmClangStdenv; }; rocblas = callPackage ../development/libraries/rocblas { - inherit (llvmPackages_rocm) llvm; + inherit (llvmPackages_rocm) openmp; + stdenv = rocmClangStdenv; }; miopengemm = callPackage ../development/libraries/miopengemm { stdenv = rocmClangStdenv; }; - rocthrust = callPackage ../development/libraries/rocthrust { }; + rocthrust = callPackage ../development/libraries/rocthrust { + stdenv = rocmClangStdenv; + }; miopen = callPackage ../development/libraries/miopen { inherit (llvmPackages_rocm) llvm clang-tools-extra; From f6e28e20587fbfef6b84cedb13afe25860cb33b8 Mon Sep 17 00:00:00 2001 From: Madoura Date: Wed, 14 Dec 2022 02:04:14 -0600 Subject: [PATCH 08/21] hip: rewrite and separate hip-common: init at 5.4.0 hipcc: init at 5.4.1 --- .../hip-common/0000-fixup-paths.patch | 129 ++++++++ .../compilers/hip-common/default.nix | 59 ++++ .../compilers/hip/0000-fixup-paths.patch | 62 ++++ pkgs/development/compilers/hip/default.nix | 302 ++++++++---------- .../compilers/hip/hip-config-paths.patch | 35 -- .../compilers/hip/hipamd-config-paths.patch | 73 ----- .../compilers/hipcc/0000-fixup-paths.patch | 130 ++++++++ pkgs/development/compilers/hipcc/default.nix | 62 ++++ .../compilers/llvm/rocm/default.nix | 4 +- pkgs/top-level/all-packages.nix | 22 +- 10 files changed, 595 insertions(+), 283 deletions(-) create mode 100644 pkgs/development/compilers/hip-common/0000-fixup-paths.patch create mode 100644 pkgs/development/compilers/hip-common/default.nix create mode 100644 pkgs/development/compilers/hip/0000-fixup-paths.patch delete mode 100644 pkgs/development/compilers/hip/hip-config-paths.patch delete mode 100644 pkgs/development/compilers/hip/hipamd-config-paths.patch create mode 100644 pkgs/development/compilers/hipcc/0000-fixup-paths.patch create mode 100644 pkgs/development/compilers/hipcc/default.nix diff --git a/pkgs/development/compilers/hip-common/0000-fixup-paths.patch b/pkgs/development/compilers/hip-common/0000-fixup-paths.patch new file mode 100644 index 000000000000..f3fd73255520 --- /dev/null +++ b/pkgs/development/compilers/hip-common/0000-fixup-paths.patch @@ -0,0 +1,129 @@ +diff --git a/bin/hipcc.pl b/bin/hipcc.pl +index da9559b..7aaa540 100755 +--- a/bin/hipcc.pl ++++ b/bin/hipcc.pl +@@ -185,7 +185,7 @@ if ($HIP_PLATFORM eq "amd") { + chomp($HIP_CLANG_TARGET); + + if (! defined $HIP_CLANG_INCLUDE_PATH) { +- $HIP_CLANG_INCLUDE_PATH = abs_path("$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/include"); ++ $HIP_CLANG_INCLUDE_PATH = abs_path("@clang@/resource-root/include"); + } + if (! defined $HIP_INCLUDE_PATH) { + $HIP_INCLUDE_PATH = "$HIP_PATH/include"; +@@ -206,8 +206,8 @@ if ($HIP_PLATFORM eq "amd") { + print ("HIP_CLANG_TARGET=$HIP_CLANG_TARGET\n"); + } + +- $HIPCXXFLAGS .= " -isystem \"$HIP_CLANG_INCLUDE_PATH/..\""; +- $HIPCFLAGS .= " -isystem \"$HIP_CLANG_INCLUDE_PATH/..\""; ++ $HIPCXXFLAGS .= " -isystem \"$HIP_CLANG_INCLUDE_PATH\""; ++ $HIPCFLAGS .= " -isystem \"$HIP_CLANG_INCLUDE_PATH\""; + $HIPLDFLAGS .= " -L\"$HIP_LIB_PATH\""; + if ($isWindows) { + $HIPLDFLAGS .= " -lamdhip64"; +@@ -625,7 +625,7 @@ if($HIP_PLATFORM eq "amd"){ + $targetsStr = $ENV{HCC_AMDGPU_TARGET}; + } elsif (not $isWindows) { + # Else try using rocm_agent_enumerator +- $ROCM_AGENT_ENUM = "${ROCM_PATH}/bin/rocm_agent_enumerator"; ++ $ROCM_AGENT_ENUM = "@rocminfo@/bin/rocm_agent_enumerator"; + $targetsStr = `${ROCM_AGENT_ENUM} -t GPU`; + $targetsStr =~ s/\n/,/g; + } +@@ -724,16 +724,16 @@ if ($HIP_PLATFORM eq "amd") { + + if (not $isWindows and not $compileOnly) { + if ($linkType eq 0) { +- $toolArgs = " -L$HIP_LIB_PATH -lamdhip64 -L$ROCM_PATH/lib -lhsa-runtime64 -ldl -lnuma " . ${toolArgs}; ++ $toolArgs = " -L$HIP_LIB_PATH -lamdhip64 -L@rocm_runtime@/lib -lhsa-runtime64 -ldl -lnuma " . ${toolArgs}; + } else { + $toolArgs = ${toolArgs} . " -Wl,-rpath=$HIP_LIB_PATH:$ROCM_PATH/lib -lamdhip64 "; + } + # To support __fp16 and _Float16, explicitly link with compiler-rt +- $HIP_CLANG_BUILTIN_LIB="$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/lib/$HIP_CLANG_TARGET/libclang_rt.builtins.a"; ++ $HIP_CLANG_BUILTIN_LIB="@clang@/resource-root/lib/$HIP_CLANG_TARGET/libclang_rt.builtins.a"; + if (-e $HIP_CLANG_BUILTIN_LIB) { +- $toolArgs .= " -L$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/lib/$HIP_CLANG_TARGET -lclang_rt.builtins " ++ $toolArgs .= " -L@clang@/resource-root/lib/$HIP_CLANG_TARGET -lclang_rt.builtins " + } else { +- $toolArgs .= " -L$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/lib/linux -lclang_rt.builtins-x86_64 " ++ $toolArgs .= " -L@clang@/resource-root/lib/linux -lclang_rt.builtins-x86_64 " + } + } + } +diff --git a/bin/hipconfig.pl b/bin/hipconfig.pl +index 5ddb8e9..6a76a2e 100755 +--- a/bin/hipconfig.pl ++++ b/bin/hipconfig.pl +@@ -77,7 +77,7 @@ if ($HIP_COMPILER eq "clang") { + $CPP_CONFIG = " -D__HIP_PLATFORM_HCC__= -D__HIP_PLATFORM_AMD__="; + + $HIP_PATH_INCLUDE = $HIP_PATH."/include"; +- $HIP_CLANG_INCLUDE = $HIP_CLANG_PATH."/../lib/clang/".$HIP_CLANG_VERSION; ++ $HIP_CLANG_INCLUDE = "@clang@/resource-root/include"; + if($isWindows) { + $CPP_CONFIG .= " -I\"$HIP_PATH_INCLUDE\" -I\"$HIP_CLANG_INCLUDE\""; + } else { +@@ -168,7 +168,7 @@ if (!$printed or $p_full) { + print ("HIP_CLANG_PATH : $HIP_CLANG_PATH\n"); + if ($isWindows) { + system("\"$HIP_CLANG_PATH/clang++\" --version"); +- system("\"$HIP_CLANG_PATH/llc\" --version"); ++ system("\"@llvm@/bin/llc\" --version"); + printf("hip-clang-cxxflags : "); + $win_output = `perl \"$HIP_PATH/bin/hipcc\" --cxxflags`; + printf("$win_output \n"); +@@ -177,7 +177,7 @@ if (!$printed or $p_full) { + printf("$win_output \n"); + } else { + system("$HIP_CLANG_PATH/clang++ --version"); +- system("$HIP_CLANG_PATH/llc --version"); ++ system("@llvm@/bin/llc --version"); + print ("hip-clang-cxxflags : "); + system("$HIP_PATH/bin/hipcc --cxxflags"); + printf("\n"); +@@ -219,8 +219,8 @@ if (!$printed or $p_full) { + system ("uname -a"); + } + +- if (-e "/usr/bin/lsb_release") { +- system ("/usr/bin/lsb_release -a"); ++ if (-e "@lsb_release@/bin/lsb_release") { ++ system ("@lsb_release@/bin/lsb_release -a"); + } + + print "\n" ; +diff --git a/hip-lang-config.cmake.in b/hip-lang-config.cmake.in +index 9250a68..f6e27b7 100644 +--- a/hip-lang-config.cmake.in ++++ b/hip-lang-config.cmake.in +@@ -71,8 +71,8 @@ get_filename_component(_IMPORT_PREFIX "${_DIR}/../../../" REALPATH) + + + #need _IMPORT_PREFIX to be set #FILE_REORG_BACKWARD_COMPATIBILITY +-file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS "${_IMPORT_PREFIX}/../llvm/lib/clang/*/include") +-file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG "${_IMPORT_PREFIX}/llvm/lib/clang/*/include") ++file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS "@clang@/resource-root/include") ++file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG "@clang@/resource-root/include") + find_path(HIP_CLANG_INCLUDE_PATH __clang_cuda_math.h + HINTS ${HIP_CLANG_INCLUDE_SEARCH_PATHS} + ${HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG} +@@ -89,7 +89,7 @@ find_path(HSA_HEADER hsa/hsa.h + PATHS + "${_IMPORT_PREFIX}/../include" #FILE_REORG_BACKWARD_COMPATIBILITY + "${_IMPORT_PREFIX}/include" +- "${ROCM_PATH}/include" ++ "@rocm_runtime@/include" + ) + + if (NOT HSA_HEADER) +@@ -97,7 +97,7 @@ if (NOT HSA_HEADER) + endif() + + get_filename_component(HIP_COMPILER_INSTALL_PATH ${CMAKE_HIP_COMPILER} DIRECTORY) +-file(GLOB HIP_CLANGRT_LIB_SEARCH_PATHS "${HIP_COMPILER_INSTALL_PATH}/../lib/clang/*/lib/*") ++file(GLOB HIP_CLANGRT_LIB_SEARCH_PATHS "@clang@/resource-root/lib/*") + find_library(CLANGRT_BUILTINS + NAMES + clang_rt.builtins diff --git a/pkgs/development/compilers/hip-common/default.nix b/pkgs/development/compilers/hip-common/default.nix new file mode 100644 index 000000000000..a6343c920376 --- /dev/null +++ b/pkgs/development/compilers/hip-common/default.nix @@ -0,0 +1,59 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, substituteAll +, llvm +, rocm-runtime +, rocminfo +, lsb-release +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "hip-common"; + version = "5.4.0"; + + src = fetchFromGitHub { + owner = "ROCm-Developer-Tools"; + repo = "HIP"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-34SJM2n3jZWIS2uwpboWOXVFhaVWGK5ELPKD/cJc1zw="; + }; + + patches = [ + (substituteAll { + src = ./0000-fixup-paths.patch; + inherit llvm rocminfo; + clang = stdenv.cc; + rocm_runtime = rocm-runtime; + lsb_release = lsb-release; + }) + ]; + + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + + mkdir -p $out + mv * $out + + runHook postInstall + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "C++ Heterogeneous-Compute Interface for Portability"; + homepage = "https://github.com/ROCm-Developer-Tools/HIP"; + license = with licenses; [ mit ]; + maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; + platforms = platforms.linux; + broken = finalAttrs.version != stdenv.cc.version; + }; +}) diff --git a/pkgs/development/compilers/hip/0000-fixup-paths.patch b/pkgs/development/compilers/hip/0000-fixup-paths.patch new file mode 100644 index 000000000000..423857218ee7 --- /dev/null +++ b/pkgs/development/compilers/hip/0000-fixup-paths.patch @@ -0,0 +1,62 @@ +diff --git a/hip-config.cmake.in b/hip-config.cmake.in +index 89d1224..dc9ba05 100755 +--- a/hip-config.cmake.in ++++ b/hip-config.cmake.in +@@ -142,7 +142,7 @@ if(HIP_COMPILER STREQUAL "clang") + file(TO_CMAKE_PATH "${HIP_PATH}/../lc" HIP_CLANG_ROOT) + endif() + else() +- set(HIP_CLANG_ROOT "${ROCM_PATH}/llvm") ++ set(HIP_CLANG_ROOT "@clang@") + endif() + if(NOT HIP_CXX_COMPILER) + set(HIP_CXX_COMPILER ${CMAKE_CXX_COMPILER}) +@@ -171,7 +171,7 @@ if(HIP_COMPILER STREQUAL "clang") + get_filename_component(_HIP_CLANG_BIN_PATH "${_HIP_CLANG_REAL_PATH}" DIRECTORY) + get_filename_component(HIP_CLANG_ROOT "${_HIP_CLANG_BIN_PATH}" DIRECTORY) + endif() +- file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS ${HIP_CLANG_ROOT}/lib/clang/*/include) ++ file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS "@clang@/resource-root/include") + find_path(HIP_CLANG_INCLUDE_PATH stddef.h + HINTS + ${HIP_CLANG_INCLUDE_SEARCH_PATHS} +@@ -209,7 +209,7 @@ if(NOT WIN32) + "${_IMPORT_PREFIX}/include" + #FILE_REORG_BACKWARD_COMPATIBILITY ${_IMPORT_PREFIX}/../include is for Backward compatibility + "${_IMPORT_PREFIX}/../include" +- ${ROCM_PATH}/include ++ "@rocm_runtime@/include" + ) + + if (NOT HSA_HEADER) +@@ -291,7 +291,7 @@ if(HIP_COMPILER STREQUAL "clang") + endif() + endif() + +- file(GLOB HIP_CLANGRT_LIB_SEARCH_PATHS "${HIP_CLANG_ROOT}/lib/clang/*/lib/*") ++ file(GLOB HIP_CLANGRT_LIB_SEARCH_PATHS "@clang@/resource-root/lib/*") + find_library(CLANGRT_BUILTINS + NAMES + clang_rt.builtins +diff --git a/src/hip_embed_pch.sh b/src/hip_embed_pch.sh +index 0a1572b..2feb19a 100755 +--- a/src/hip_embed_pch.sh ++++ b/src/hip_embed_pch.sh +@@ -149,7 +149,7 @@ EOF + + $LLVM_DIR/bin/clang -cc1 -O3 -emit-pch -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -std=c++17 -fgnuc-version=4.2.1 -o $tmp/hip_wave64.pch -x hip-cpp-output - <$tmp/pch_wave64.cui && + +- $LLVM_DIR/bin/llvm-mc -o hip_pch.o $tmp/hip_pch.mcin --filetype=obj && ++ @llvm@/bin/llvm-mc -o hip_pch.o $tmp/hip_pch.mcin --filetype=obj && + + rm -rf $tmp + } +@@ -195,7 +195,7 @@ EOF + set -x + $LLVM_DIR/bin/clang -O3 --rocm-path=$HIP_INC_DIR/.. -std=c++14 -nogpulib --hip-version=4.4 -isystem $HIP_INC_DIR -isystem $HIP_BUILD_INC_DIR -isystem $HIP_AMD_INC_DIR --cuda-device-only -D__HIPCC_RTC__ -x hip $tmp/hipRTC_header.h -E -o $tmp/hiprtc && + cat $macroFile >> $tmp/hiprtc && +- $LLVM_DIR/bin/llvm-mc -o $tmp/hiprtc_header.o $tmp/hipRTC_header.mcin --filetype=obj && ++ @llvm@/bin/llvm-mc -o $tmp/hiprtc_header.o $tmp/hipRTC_header.mcin --filetype=obj && + $LLVM_DIR/bin/clang $tmp/hiprtc_header.o -o $rtc_shared_lib_out -shared && + $LLVM_DIR/bin/clang -O3 --rocm-path=$HIP_INC_DIR/.. -std=c++14 -nogpulib -nogpuinc -emit-llvm -c -o $tmp/tmp.bc --cuda-device-only -D__HIPCC_RTC__ --offload-arch=gfx906 -x hip-cpp-output $tmp/hiprtc && + rm -rf $tmp diff --git a/pkgs/development/compilers/hip/default.nix b/pkgs/development/compilers/hip/default.nix index 066fd906984d..ecb763cea83f 100644 --- a/pkgs/development/compilers/hip/default.nix +++ b/pkgs/development/compilers/hip/default.nix @@ -1,114 +1,62 @@ -{ stdenv -, binutils-unwrapped -, clang -, cmake +{ lib +, stdenv , fetchFromGitHub , fetchpatch -, file -, lib -, libglvnd -, libX11 -, libxml2 -, llvm +, rocmUpdateScript +, substituteAll , makeWrapper -, numactl -, perl -, python3 -, python3Packages +, hip-common +, hipcc , rocclr +, roctracer +, cmake +, perl +, llvm +, rocminfo +, rocm-thunk , rocm-comgr , rocm-device-libs -, rocm-opencl-runtime , rocm-runtime -, rocm-thunk -, rocminfo -, substituteAll -, writeScript -, writeText +, rocm-opencl-runtime +, cudatoolkit +, numactl +, libxml2 +, libX11 +, libglvnd +, doxygen +, graphviz +, fontconfig +, python3Packages +, buildDocs ? true +, buildTests ? false +, useNVIDIA ? false }: let - hip = stdenv.mkDerivation (finalAttrs: { - pname = "hip"; - version = "5.4.0"; + hipPlatform = if useNVIDIA then "nvidia" else "amd"; - src = fetchFromGitHub { - owner = "ROCm-Developer-Tools"; - repo = "HIP"; - rev = "rocm-${finalAttrs.version}"; - hash = "sha256-34SJM2n3jZWIS2uwpboWOXVFhaVWGK5ELPKD/cJc1zw="; - }; - - patches = [ - (substituteAll { - src = ./hip-config-paths.patch; - inherit llvm; - rocm_runtime = rocm-runtime; - }) - ]; - - # - fix bash paths - # - fix path to rocm_agent_enumerator - # - fix hcc path - # - fix hcc version parsing - # - add linker flags for libhsa-runtime64 and hc_am since libhip_hcc - # refers to them. - prePatch = '' - for f in $(find bin -type f); do - sed -e 's,#!/usr/bin/perl,#!${perl}/bin/perl,' \ - -e 's,#!/bin/bash,#!${stdenv.shell},' \ - -i "$f" - done - - sed 's,#!/usr/bin/python,#!${python3.interpreter},' -i hip_prof_gen.py - - sed -e 's,$ROCM_AGENT_ENUM = "''${ROCM_PATH}/bin/rocm_agent_enumerator";,$ROCM_AGENT_ENUM = "${rocminfo}/bin/rocm_agent_enumerator";,' \ - -e 's,^\($DEVICE_LIB_PATH=\).*$,\1"${rocm-device-libs}/amdgcn/bitcode";,' \ - -e 's,^\($HIP_COMPILER=\).*$,\1"clang";,' \ - -e 's,^\($HIP_RUNTIME=\).*$,\1"ROCclr";,' \ - -e 's,^\([[:space:]]*$HSA_PATH=\).*$,\1"${rocm-runtime}";,'g \ - -e 's,^\([[:space:]]*\)$HIP_CLANG_INCLUDE_PATH = abs_path("$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/include");,\1$HIP_CLANG_INCLUDE_PATH = "${llvm}/lib/clang/$HIP_CLANG_VERSION/include";,' \ - -e 's,^\([[:space:]]*$HIPCXXFLAGS .= " -isystem \\"$HIP_CLANG_INCLUDE_PATH/..\\"\)";,\1 -isystem ${rocm-runtime}/include";,' \ - -e 's,$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION,$HIP_CLANG_PATH/../resource-root,g' \ - -e 's,`file,`${file}/bin/file,g' \ - -e 's,`readelf,`${binutils-unwrapped}/bin/readelf,' \ - -e 's, ar , ${binutils-unwrapped}/bin/ar ,g' \ - -i bin/hipcc.pl - - sed -e 's,^\($HSA_PATH=\).*$,\1"${rocm-runtime}";,' \ - -e 's,^\($HIP_CLANG_PATH=\).*$,\1"${clang}/bin";,' \ - -e 's,^\($HIP_PLATFORM=\).*$,\1"amd";,' \ - -e 's,$HIP_CLANG_PATH/llc,${llvm}/bin/llc,' \ - -e 's, abs_path, Cwd::abs_path,' \ - -i bin/hipconfig.pl - - sed -e 's, abs_path, Cwd::abs_path,' -i bin/hipvars.pm - ''; - - buildPhase = ""; - - installPhase = '' - runHook preInstall - - mkdir -p $out - cp -r * $out/ - - runHook postInstall - ''; - - meta = with lib; { - description = "C++ Heterogeneous-Compute Interface for Portability"; - homepage = "https://github.com/ROCm-Developer-Tools/HIP"; - license = licenses.mit; - maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; - platforms = platforms.linux; - }; - }); -in -stdenv.mkDerivation (finalAttrs: { - pname = "hip"; + wrapperArgs = [ + "--prefix PATH : $out/bin" + "--prefix LD_LIBRARY_PATH : ${rocm-runtime}" + "--set HIP_PLATFORM ${hipPlatform}" + "--set HIP_PATH $out" + "--set HIP_CLANG_PATH ${stdenv.cc}/bin" + "--set DEVICE_LIB_PATH ${rocm-device-libs}/amdgcn/bitcode" + "--set HSA_PATH ${rocm-runtime}" + "--set ROCM_PATH $out" + ] ++ lib.optionals useNVIDIA [ + "--set CUDA_PATH ${cudatoolkit}" + ]; +in stdenv.mkDerivation (finalAttrs: { + pname = "hip-${hipPlatform}"; version = "5.4.0"; + outputs = [ + "out" + ] ++ lib.optionals buildDocs [ + "doc" + ]; + src = fetchFromGitHub { owner = "ROCm-Developer-Tools"; repo = "hipamd"; @@ -116,105 +64,115 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-VL0vZVv099pZPX0J2pXPFvrhkVO/b6X+ZZDaD9B1hYI="; }; - nativeBuildInputs = [ cmake python3 makeWrapper perl ]; - buildInputs = [ libxml2 numactl libglvnd libX11 python3Packages.cppheaderparser ]; - propagatedBuildInputs = [ - clang - llvm - rocm-comgr - rocm-device-libs - rocm-runtime - rocm-thunk - rocminfo - ]; - patches = [ (substituteAll { - src = ./hipamd-config-paths.patch; - inherit clang llvm hip; + src = ./0000-fixup-paths.patch; + inherit llvm; + clang = stdenv.cc; rocm_runtime = rocm-runtime; }) + + # https://github.com/ROCm-Developer-Tools/hipamd/commit/be33ec55acc104a59d01df5912261d007c7f3ee9 + (fetchpatch { + url = "https://github.com/ROCm-Developer-Tools/hipamd/commit/be33ec55acc104a59d01df5912261d007c7f3ee9.patch"; + hash = "sha256-eTC4mUIN1FwRce1n38uDOlITFL/vpcOhvnaZTo5R7lo="; + }) ]; - prePatch = '' - sed -e 's,#!/bin/bash,#!${stdenv.shell},' \ - -i src/hip_embed_pch.sh - ''; + nativeBuildInputs = [ + makeWrapper + cmake + perl + python3Packages.python + python3Packages.cppheaderparser + ] ++ lib.optionals buildDocs [ + doxygen + graphviz + fontconfig + ]; - preConfigure = '' - export HIP_CLANG_PATH=${clang}/bin - export DEVICE_LIB_PATH=${rocm-device-libs}/lib - ''; + buildInputs = [ + numactl + libxml2 + libX11 + libglvnd + ]; + + propagatedBuildInputs = [ + stdenv.cc + llvm + rocminfo + rocm-thunk + rocm-comgr + rocm-device-libs + rocm-runtime + rocm-opencl-runtime + ] ++ lib.optionals useNVIDIA [ + cudatoolkit + ]; cmakeFlags = [ - "-DHIP_PLATFORM=amd" - "-DAMD_OPENCL_PATH=${rocm-opencl-runtime.src}" - "-DHIP_COMMON_DIR=${hip}" + "-DROCM_PATH=${rocminfo}" + "-DHIP_PLATFORM=${hipPlatform}" + "-DHIP_COMMON_DIR=${hip-common}" + "-DHIPCC_BIN_DIR=${hipcc}/bin" + "-DHIP_LLVM_ROOT=${stdenv.cc}" "-DROCCLR_PATH=${rocclr}" - "-DHIP_VERSION_BUILD_ID=0" + "-DAMD_OPENCL_PATH=${rocm-opencl-runtime.src}" + "-DPROF_API_HEADER_PATH=${roctracer.src}/inc/ext" # Temporarily set variables to work around upstream CMakeLists issue # Can be removed once https://github.com/ROCm-Developer-Tools/hipamd/issues/55 is fixed "-DCMAKE_INSTALL_BINDIR=bin" "-DCMAKE_INSTALL_INCLUDEDIR=include" "-DCMAKE_INSTALL_LIBDIR=lib" + ] ++ lib.optionals buildTests [ + "-DHIP_CATCH_TEST=1" ]; + postPatch = '' + export HIP_CLANG_PATH=${stdenv.cc}/bin + patchShebangs src + '' + lib.optionalString buildDocs '' + export HOME=$(mktemp -d) + export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf + ''; + + doCheck = buildTests; + checkTarget = "build_tests"; + + preCheck = lib.optionalString buildTests '' + export ROCM_PATH=$PWD + export DEVICE_LIB_PATH=${rocm-device-libs}/amdgcn/bitcode + patchShebangs bin + ''; + postInstall = '' patchShebangs $out/bin - wrapProgram $out/bin/hipcc --set HIP_PATH $out --set HSA_PATH ${rocm-runtime} --set HIP_CLANG_PATH ${clang}/bin --prefix PATH : ${llvm}/bin --set ROCM_PATH $out - wrapProgram $out/bin/hipconfig --set HIP_PATH $out --set HSA_PATH ${rocm-runtime} --set HIP_CLANG_PATH ${clang}/bin + cp -a $out/bin/hipcc $out/bin/hipcc-pl + cp -a $out/bin/hipconfig $out/bin/hipconfig-pl + wrapProgram $out/bin/hipcc --set HIP_USE_PERL_SCRIPTS 0 + wrapProgram $out/bin/hipconfig --set HIP_USE_PERL_SCRIPTS 0 + wrapProgram $out/bin/hipcc.bin ${lib.concatStringsSep " " wrapperArgs} + wrapProgram $out/bin/hipconfig.bin ${lib.concatStringsSep " " wrapperArgs} + wrapProgram $out/bin/hipcc-pl --set HIP_USE_PERL_SCRIPTS 1 + wrapProgram $out/bin/hipconfig-pl --set HIP_USE_PERL_SCRIPTS 1 + wrapProgram $out/bin/hipcc.pl ${lib.concatStringsSep " " wrapperArgs} + wrapProgram $out/bin/hipconfig.pl ${lib.concatStringsSep " " wrapperArgs} ''; - # TODO: Separate HIP and hipamd into separate derivations - passthru.updateScript = writeScript "update.sh" '' - #!/usr/bin/env nix-shell - #!nix-shell -i bash -p curl jq common-updater-scripts nix-prefetch-github - version="$(curl ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \ - -sL "https://api.github.com/repos/ROCm-Developer-Tools/HIP/releases?per_page=1" | jq '.[0].tag_name | split("-") | .[1]' --raw-output)" - - IFS='.' read -a version_arr <<< "$version" - - if [ "''${#version_arr[*]}" == 2 ]; then - version="''${version}.0" - fi - - current_version="$(grep "version =" pkgs/development/compilers/hip/default.nix | head -n1 | cut -d'"' -f2)" - if [[ "$version" != "$current_version" ]]; then - tarball_meta="$(nix-prefetch-github ROCm-Developer-Tools HIP --rev "rocm-$version")" - tarball_hash="$(nix to-base64 sha256-$(jq -r '.sha256' <<< "$tarball_meta"))" - sed -i -z "pkgs/development/compilers/hip/default.nix" \ - -e 's,version = "[^'"'"'"]*",version = "'"$version"'",1' \ - -e 's,hash = "[^'"'"'"]*",hash = "sha256-'"$tarball_hash"'",1' - else - echo hip already up-to-date - fi - - version="$(curl ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \ - -sL "https://api.github.com/repos/ROCm-Developer-Tools/hipamd/releases?per_page=1" | jq '.[0].tag_name | split("-") | .[1]' --raw-output)" - - IFS='.' read -a version_arr <<< "$version" - - if [ "''${#version_arr[*]}" == 2 ]; then - version="''${version}.0" - fi - - current_version="$(grep "version =" pkgs/development/compilers/hip/default.nix | tail -n1 | cut -d'"' -f2)" - if [[ "$version" != "$current_version" ]]; then - tarball_meta="$(nix-prefetch-github ROCm-Developer-Tools hipamd --rev "rocm-$version")" - tarball_hash="$(nix to-base64 sha256-$(jq -r '.sha256' <<< "$tarball_meta"))" - sed -i -z "pkgs/development/compilers/hip/default.nix" \ - -e 's,version = "[^'"'"'"]*",version = "'"$version"'",2' \ - -e 's,hash = "[^'"'"'"]*",hash = "sha256-'"$tarball_hash"'",2' - else - echo hipamd already up-to-date - fi - ''; + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; meta = with lib; { - description = "C++ Heterogeneous-Compute Interface for Portability"; + description = "C++ Heterogeneous-Compute Interface for Portability specifically for AMD platform"; homepage = "https://github.com/ROCm-Developer-Tools/hipamd"; - license = licenses.mit; + license = with licenses; [ mit ]; maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; platforms = platforms.linux; + # Tests require GPU, also include issues + broken = finalAttrs.version != hip-common.version || finalAttrs.version != hipcc.version || buildTests; }; }) diff --git a/pkgs/development/compilers/hip/hip-config-paths.patch b/pkgs/development/compilers/hip/hip-config-paths.patch deleted file mode 100644 index 25fa3b8da95a..000000000000 --- a/pkgs/development/compilers/hip/hip-config-paths.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/hip-lang-config.cmake.in b/hip-lang-config.cmake.in -index 1a72643a..7f35031f 100644 ---- a/hip-lang-config.cmake.in -+++ b/hip-lang-config.cmake.in -@@ -71,8 +71,8 @@ get_filename_component(_IMPORT_PREFIX "${_DIR}/../../../" REALPATH) - - - #need _IMPORT_PREFIX to be set #FILE_REORG_BACKWARD_COMPATIBILITY --file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS "${_IMPORT_PREFIX}/../llvm/lib/clang/*/include") --file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG "${_IMPORT_PREFIX}/llvm/lib/clang/*/include") -+file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS "@llvm@/lib/clang/*/include") -+file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG "@llvm@/lib/clang/*/include") - find_path(HIP_CLANG_INCLUDE_PATH __clang_cuda_math.h - HINTS ${HIP_CLANG_INCLUDE_SEARCH_PATHS} - ${HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG} -@@ -87,9 +87,7 @@ endif() - #if HSA is not under ROCm then provide CMAKE_PREFIX_PATH= - find_path(HSA_HEADER hsa/hsa.h - PATHS -- "${_IMPORT_PREFIX}/../include" #FILE_REORG_BACKWARD_COMPATIBILITY -- "${_IMPORT_PREFIX}/include" -- "${ROCM_PATH}/include" -+ "@rocm_runtime@/include" - ) - - if (NOT HSA_HEADER) -@@ -97,7 +94,7 @@ if (HSA_HEADER-NOTFOUND) - endif() - - get_filename_component(HIP_COMPILER_INSTALL_PATH ${CMAKE_HIP_COMPILER} DIRECTORY) --file(GLOB HIP_CLANGRT_LIB_SEARCH_PATHS "${HIP_COMPILER_INSTALL_PATH}/../lib/clang/*/lib/*") -+file(GLOB HIP_CLANGRT_LIB_SEARCH_PATHS "@llvm@/lib/clang/*/lib/*") - find_library(CLANGRT_BUILTINS - NAMES - clang_rt.builtins diff --git a/pkgs/development/compilers/hip/hipamd-config-paths.patch b/pkgs/development/compilers/hip/hipamd-config-paths.patch deleted file mode 100644 index 78838836e9aa..000000000000 --- a/pkgs/development/compilers/hip/hipamd-config-paths.patch +++ /dev/null @@ -1,73 +0,0 @@ -diff --git a/hip-config.cmake.in b/hip-config.cmake.in -index 89d1224e..120b68c6 100755 ---- a/hip-config.cmake.in -+++ b/hip-config.cmake.in -@@ -142,7 +142,7 @@ if(HIP_COMPILER STREQUAL "clang") - file(TO_CMAKE_PATH "${HIP_PATH}/../lc" HIP_CLANG_ROOT) - endif() - else() -- set(HIP_CLANG_ROOT "${ROCM_PATH}/llvm") -+ set(HIP_CLANG_ROOT "@clang@") - endif() - if(NOT HIP_CXX_COMPILER) - set(HIP_CXX_COMPILER ${CMAKE_CXX_COMPILER}) -@@ -206,10 +206,7 @@ if(NOT WIN32) - #if HSA is not under ROCm then provide CMAKE_PREFIX_PATH= - find_path(HSA_HEADER hsa/hsa.h - PATHS -- "${_IMPORT_PREFIX}/include" -- #FILE_REORG_BACKWARD_COMPATIBILITY ${_IMPORT_PREFIX}/../include is for Backward compatibility -- "${_IMPORT_PREFIX}/../include" -- ${ROCM_PATH}/include -+ "@rocm_runtime@/include" - ) - - if (NOT HSA_HEADER) -@@ -224,8 +221,8 @@ set_target_properties(hip::host PROPERTIES - - if(HIP_RUNTIME MATCHES "rocclr") - set_target_properties(hip::amdhip64 PROPERTIES -- INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${HSA_HEADER}" -- INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${HSA_HEADER}" -+ INTERFACE_INCLUDE_DIRECTORIES "@hip@/include;${HSA_HEADER}" -+ INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "@hip@/include;${HSA_HEADER}" - ) - - get_target_property(amdhip64_type hip::amdhip64 TYPE) -@@ -233,8 +230,8 @@ if(HIP_RUNTIME MATCHES "rocclr") - - if(NOT WIN32) - set_target_properties(hip::device PROPERTIES -- INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" -- INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" -+ INTERFACE_INCLUDE_DIRECTORIES "@hip@/include" -+ INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "@hip@/include" - ) - endif() - endif() -diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 83866d83..4125d3aa 100644 ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -178,7 +178,7 @@ if(__HIP_ENABLE_PCH) - ${ROCM_PATH}/llvm) - # find_package(LLVM) returns the lib/cmake/llvm location. We require the root. - if(NOT DEFINED HIP_LLVM_ROOT) -- set(HIP_LLVM_ROOT "${LLVM_DIR}/../../..") -+ set(HIP_LLVM_ROOT "@clang@") - endif() - - execute_process(COMMAND sh -c "${CMAKE_CURRENT_SOURCE_DIR}/hip_embed_pch.sh ${HIP_COMMON_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/include ${HIP_LLVM_ROOT}" COMMAND_ECHO STDERR RESULT_VARIABLE EMBED_PCH_RC) -diff --git a/src/hip_embed_pch.sh b/src/hip_embed_pch.sh -index 0a1572b2..aa855d63 100755 ---- a/src/hip_embed_pch.sh -+++ b/src/hip_embed_pch.sh -@@ -149,7 +149,7 @@ EOF - - $LLVM_DIR/bin/clang -cc1 -O3 -emit-pch -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -std=c++17 -fgnuc-version=4.2.1 -o $tmp/hip_wave64.pch -x hip-cpp-output - <$tmp/pch_wave64.cui && - -- $LLVM_DIR/bin/llvm-mc -o hip_pch.o $tmp/hip_pch.mcin --filetype=obj && -+ @llvm@/bin/llvm-mc -o hip_pch.o $tmp/hip_pch.mcin --filetype=obj && - - rm -rf $tmp - } diff --git a/pkgs/development/compilers/hipcc/0000-fixup-paths.patch b/pkgs/development/compilers/hipcc/0000-fixup-paths.patch new file mode 100644 index 000000000000..4f52c1ad11aa --- /dev/null +++ b/pkgs/development/compilers/hipcc/0000-fixup-paths.patch @@ -0,0 +1,130 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c21f247..5bd3e45 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -17,6 +17,6 @@ if (NOT WIN32) # C++17 does not require the std lib linking + target_link_libraries(hipconfig.bin ${LINK_LIBS} ) # for hipconfig.bin + endif() + +-set(HIP_VERSION_MAJOR 4 PARENT_SCOPE) +-set(HIP_VERSION_MINOR 4 PARENT_SCOPE) +-set(HIP_VERSION_PATCH 4 PARENT_SCOPE) ++set(HIP_VERSION_MAJOR @version_major@) ++set(HIP_VERSION_MINOR @version_minor@) ++set(HIP_VERSION_PATCH @version_patch@) +diff --git a/src/hipBin_amd.h b/src/hipBin_amd.h +index f94e4a5..f0b1b83 100644 +--- a/src/hipBin_amd.h ++++ b/src/hipBin_amd.h +@@ -207,7 +207,7 @@ void HipBinAmd::initializeHipCXXFlags() { + hipClangIncludePath = getCompilerIncludePath(); + hipCXXFlags += " -isystem \"" + hipClangIncludePath; + fs::path hipCXXFlagsTempFs = hipCXXFlags; +- hipCXXFlagsTempFs /= "..\""; ++ hipCXXFlagsTempFs /= "\""; + hipCXXFlags = hipCXXFlagsTempFs.string(); + const EnvVariables& var = getEnvVariables(); + // Allow __fp16 as function parameter and return type. +@@ -266,7 +266,7 @@ void HipBinAmd::printCompilerInfo() const { + string cmd = hipClangPath + "/clang++ --version"; + system(cmd.c_str()); // hipclang version + cout << "llc-version :" << endl; +- cmd = hipClangPath + "/llc --version"; ++ cmd = "@llvm@/bin/llc --version"; + system(cmd.c_str()); // llc version + cout << "hip-clang-cxxflags :" << endl; + cmd = hipPath + "/bin/hipcc --cxxflags"; +@@ -278,7 +278,7 @@ void HipBinAmd::printCompilerInfo() const { + } else { + string cmd = hipClangPath + "/clang++ --version"; + system(cmd.c_str()); // hipclang version +- cmd = hipClangPath + "/llc --version"; ++ cmd = "@llvm@/bin/llc --version"; + system(cmd.c_str()); // llc version + cout << "hip-clang-cxxflags :" << endl; + cmd = hipPath + "/bin/hipcc --cxxflags"; +@@ -331,10 +331,7 @@ string HipBinAmd::getCppConfig() { + hipPathInclude /= "include"; + + const string& compilerPath = getCompilerPath(); +- hipClangInclude = compilerPath; +- hipClangInclude = hipClangInclude.parent_path(); +- hipClangInclude /= "lib/clang/"; +- hipClangInclude /= compilerVersion; ++ hipClangInclude = "@clang@/resource-root/include"; + string hipClangPath = hipClangInclude.string(); + + const OsType& osInfo = getOSInfo(); +@@ -442,17 +439,7 @@ string HipBinAmd::getHipCC() const { + + + string HipBinAmd::getCompilerIncludePath() { +- string hipClangVersion, includePath, compilerIncludePath; +- const string& hipClangPath = getCompilerPath(); +- hipClangVersion = getCompilerVersion(); +- fs::path includePathfs = hipClangPath; +- includePathfs = includePathfs.parent_path(); +- includePathfs /= "lib/clang/"; +- includePathfs /= hipClangVersion; +- includePathfs /= "include"; +- includePathfs = fs::absolute(includePathfs).string(); +- compilerIncludePath = includePathfs.string(); +- return compilerIncludePath; ++ return "@clang@/resource-root/include"; + } + + +@@ -506,8 +493,8 @@ void HipBinAmd::printFull() { + cout << endl << "== Envirnoment Variables" << endl; + printEnvironmentVariables(); + getSystemInfo(); +- if (fs::exists("/usr/bin/lsb_release")) +- system("/usr/bin/lsb_release -a"); ++ if (fs::exists("@lsb_release@/bin/lsb_release")) ++ system("@lsb_release@/bin/lsb_release -a"); + cout << endl; + } + +@@ -993,7 +980,7 @@ void HipBinAmd::executeHipCCCmd(vector argv) { + } else if (os != windows) { + // Else try using rocm_agent_enumerator + string ROCM_AGENT_ENUM; +- ROCM_AGENT_ENUM = roccmPath + "/bin/rocm_agent_enumerator"; ++ ROCM_AGENT_ENUM = "@rocminfo@/bin/rocm_agent_enumerator"; + targetsStr = ROCM_AGENT_ENUM +" -t GPU"; + SystemCmdOut sysOut = hipBinUtilPtr_->exec(targetsStr.c_str()); + regex toReplace("\n+"); +@@ -1097,7 +1084,7 @@ void HipBinAmd::executeHipCCCmd(vector argv) { + string hipClangVersion, toolArgTemp; + if (linkType == 0) { + toolArgTemp = " -L"+ hipLibPath + "-lamdhip64 -L" + +- roccmPath+ "/lib -lhsa-runtime64 -ldl -lnuma " + toolArgs; ++ "@rocm_runtime@/lib -lhsa-runtime64 -ldl -lnuma " + toolArgs; + toolArgs = toolArgTemp; + } else { + toolArgTemp = toolArgs + " -Wl,--enable-new-dtags -Wl,-rpath=" + hipLibPath + ":" +@@ -1107,8 +1094,7 @@ void HipBinAmd::executeHipCCCmd(vector argv) { + + hipClangVersion = getCompilerVersion(); + // To support __fp16 and _Float16, explicitly link with compiler-rt +- toolArgs += " -L" + hipClangPath + "/../lib/clang/" + +- hipClangVersion + "/lib/linux -lclang_rt.builtins-x86_64 "; ++ toolArgs += " -L@clang@/resource-root/lib/linux -lclang_rt.builtins-x86_64 "; + } + if (!var.hipccCompileFlagsAppendEnv_.empty()) { + HIPCXXFLAGS += " " + var.hipccCompileFlagsAppendEnv_ + " "; +diff --git a/src/hipBin_nvidia.h b/src/hipBin_nvidia.h +index 6feb315..b61739d 100644 +--- a/src/hipBin_nvidia.h ++++ b/src/hipBin_nvidia.h +@@ -157,8 +157,8 @@ void HipBinNvidia::printFull() { + cout << endl << "== Envirnoment Variables" << endl; + printEnvironmentVariables(); + getSystemInfo(); +- if (fs::exists("/usr/bin/lsb_release")) +- system("/usr/bin/lsb_release -a"); ++ if (fs::exists("@lsb_release@/bin/lsb_release")) ++ system("@lsb_release@/bin/lsb_release -a"); + } + + // returns hip include diff --git a/pkgs/development/compilers/hipcc/default.nix b/pkgs/development/compilers/hipcc/default.nix new file mode 100644 index 000000000000..8351e3a29123 --- /dev/null +++ b/pkgs/development/compilers/hipcc/default.nix @@ -0,0 +1,62 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, substituteAll +, cmake +, llvm +, rocm-runtime +, rocminfo +, lsb-release +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "hipcc"; + version = "5.4.1"; + + src = fetchFromGitHub { + owner = "ROCm-Developer-Tools"; + repo = "HIPCC"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-PEwue4O43MiMkF8UmTeHsmlikBG2V3/nFQLKmtHrRWQ="; + }; + + patches = [ + (substituteAll { + src = ./0000-fixup-paths.patch; + inherit llvm rocminfo; + version_major = lib.versions.major finalAttrs.version; + version_minor = lib.versions.minor finalAttrs.version; + version_patch = lib.versions.patch finalAttrs.version; + clang = stdenv.cc; + rocm_runtime = rocm-runtime; + lsb_release = lsb-release; + }) + ]; + + nativeBuildInputs = [ cmake ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + mv *.bin $out/bin + + runHook postInstall + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Compiler driver utility that calls clang or nvcc"; + homepage = "https://github.com/ROCm-Developer-Tools/HIPCC"; + license = with licenses; [ mit ]; + maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; + platforms = platforms.linux; + broken = finalAttrs.version != stdenv.cc.version; + }; +}) diff --git a/pkgs/development/compilers/llvm/rocm/default.nix b/pkgs/development/compilers/llvm/rocm/default.nix index 4f96c567a631..75314a4b4633 100644 --- a/pkgs/development/compilers/llvm/rocm/default.nix +++ b/pkgs/development/compilers/llvm/rocm/default.nix @@ -12,7 +12,7 @@ , swig , lua5_3 , gtest -, hipcc +, hip , rocm-comgr , vulkan-loader , vulkan-headers @@ -471,7 +471,7 @@ in rec { buildMan = false; # No man pages to build targetName = "mlir"; targetDir = targetName; - extraNativeBuildInputs = [ hipcc ]; + extraNativeBuildInputs = [ hip ]; extraBuildInputs = [ rocm-comgr diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d128b3ca725d..08f3d9f25ba2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15147,8 +15147,28 @@ with pkgs; stdenv = rocmClangStdenv; }; + hip-common = callPackage ../development/compilers/hip-common { + inherit (llvmPackages_rocm) llvm; + stdenv = rocmClangStdenv; + }; + + hipcc = callPackage ../development/compilers/hipcc { + inherit (llvmPackages_rocm) llvm; + stdenv = rocmClangStdenv; + }; + hip = callPackage ../development/compilers/hip { - inherit (llvmPackages_rocm) clang llvm; + inherit (llvmPackages_rocm) llvm; + inherit (cudaPackages) cudatoolkit; + stdenv = rocmClangStdenv; + }; + + hip-amd = hip.override { + useNVIDIA = false; + }; + + hip-nvidia = hip.override { + useNVIDIA = true; }; hipcub = callPackage ../development/libraries/hipcub { From b943545109674c85163b9e034a6f4798262ef3c3 Mon Sep 17 00:00:00 2001 From: Madoura Date: Fri, 16 Dec 2022 03:27:28 -0600 Subject: [PATCH 09/21] rocprofiler: init at 5.4.0 --- ...0000-dont-require-hsa_amd_aqlprofile.patch | 20 ++++++ .../libraries/rocprofiler/default.nix | 65 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 ++ 3 files changed, 89 insertions(+) create mode 100644 pkgs/development/libraries/rocprofiler/0000-dont-require-hsa_amd_aqlprofile.patch create mode 100644 pkgs/development/libraries/rocprofiler/default.nix diff --git a/pkgs/development/libraries/rocprofiler/0000-dont-require-hsa_amd_aqlprofile.patch b/pkgs/development/libraries/rocprofiler/0000-dont-require-hsa_amd_aqlprofile.patch new file mode 100644 index 000000000000..b70163b08e48 --- /dev/null +++ b/pkgs/development/libraries/rocprofiler/0000-dont-require-hsa_amd_aqlprofile.patch @@ -0,0 +1,20 @@ +diff --git a/src/util/hsa_rsrc_factory.cpp b/src/util/hsa_rsrc_factory.cpp +index 643ff16..c08d98f 100644 +--- a/src/util/hsa_rsrc_factory.cpp ++++ b/src/util/hsa_rsrc_factory.cpp +@@ -127,15 +127,6 @@ HsaRsrcFactory::HsaRsrcFactory(bool initialize_hsa) : initialize_hsa_(initialize + if (cpu_pool_ == NULL) CHECK_STATUS("CPU memory pool is not found", HSA_STATUS_ERROR); + if (kern_arg_pool_ == NULL) CHECK_STATUS("Kern-arg memory pool is not found", HSA_STATUS_ERROR); + +- // Get AqlProfile API table +- aqlprofile_api_ = {0}; +-#ifdef ROCP_LD_AQLPROFILE +- status = LoadAqlProfileLib(&aqlprofile_api_); +-#else +- status = hsa_api_.hsa_system_get_major_extension_table(HSA_EXTENSION_AMD_AQLPROFILE, hsa_ven_amd_aqlprofile_VERSION_MAJOR, sizeof(aqlprofile_api_), &aqlprofile_api_); +-#endif +- CHECK_STATUS("aqlprofile API table load failed", status); +- + // Get Loader API table + loader_api_ = {0}; + status = hsa_api_.hsa_system_get_major_extension_table(HSA_EXTENSION_AMD_LOADER, 1, sizeof(loader_api_), &loader_api_); diff --git a/pkgs/development/libraries/rocprofiler/default.nix b/pkgs/development/libraries/rocprofiler/default.nix new file mode 100644 index 000000000000..0d0639edbe53 --- /dev/null +++ b/pkgs/development/libraries/rocprofiler/default.nix @@ -0,0 +1,65 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-runtime +, rocm-thunk +, roctracer +, numactl +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocprofiler"; + version = "5.4.0"; + + src = fetchFromGitHub { + owner = "ROCm-Developer-Tools"; + repo = "rocprofiler"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-CpD/+soMN8WTeSb5X7dsnZ596PMkw+4EVsVSvFtKCak="; + }; + + patches = [ ./0000-dont-require-hsa_amd_aqlprofile.patch ]; + nativeBuildInputs = [ cmake ]; + + buildInputs = [ + rocm-thunk + rocm-runtime + numactl + ]; + + cmakeFlags = [ + "-DPROF_API_HEADER_PATH=${roctracer.src}/inc/ext" + # 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 bin test + + substituteInPlace cmake_modules/env.cmake \ + --replace "FATAL_ERROR \"AQL_PROFILE" "WARNING \"AQL_PROFILE" + ''; + + postInstall = '' + patchelf --set-rpath $out/lib:${lib.makeLibraryPath finalAttrs.buildInputs} $out/lib/rocprofiler/librocprof-tool.so + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Profiling with perf-counters and derived metrics"; + homepage = "https://github.com/ROCm-Developer-Tools/rocprofiler"; + license = with licenses; [ mit ]; # mitx11 + maintainers = teams.rocm.members; + broken = finalAttrs.version != stdenv.cc.version; + }; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 08f3d9f25ba2..228dc4a6b4d6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15137,6 +15137,10 @@ with pkgs; stdenv = rocmClangStdenv; }; + rocprofiler = callPackage ../development/libraries/rocprofiler { + stdenv = rocmClangStdenv; + }; + clang-ocl = callPackage ../development/libraries/clang-ocl { stdenv = rocmClangStdenv; }; From 5b74e4ef126b19831cdcaa6f3b7052fb4d637162 Mon Sep 17 00:00:00 2001 From: Madoura Date: Fri, 16 Dec 2022 03:28:05 -0600 Subject: [PATCH 10/21] roctracer: init at 5.4.0 --- .../libraries/roctracer/default.nix | 97 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 5 + 2 files changed, 102 insertions(+) create mode 100644 pkgs/development/libraries/roctracer/default.nix diff --git a/pkgs/development/libraries/roctracer/default.nix b/pkgs/development/libraries/roctracer/default.nix new file mode 100644 index 000000000000..b8d1902d468d --- /dev/null +++ b/pkgs/development/libraries/roctracer/default.nix @@ -0,0 +1,97 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, clang +, hip +, rocm-device-libs +, rocprofiler +, libxml2 +, doxygen +, graphviz +, python3Packages +, buildDocs ? false # Nothing seems to be generated, so not making the output +, buildTests ? false +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "roctracer"; + version = "5.4.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildDocs [ + "doc" + ] ++ lib.optionals buildTests [ + "test" + ]; + + src = fetchFromGitHub { + owner = "ROCm-Developer-Tools"; + repo = "roctracer"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-hDo/tz39/m6lKqLg3UJi3LWWF7/QUtVDymZY1O8L4IQ="; + }; + + nativeBuildInputs = [ + cmake + clang + hip + ] ++ lib.optionals buildDocs [ + doxygen + graphviz + ]; + + buildInputs = [ + rocm-device-libs + rocprofiler + libxml2 + python3Packages.python + python3Packages.cppheaderparser + ]; + + cmakeFlags = [ + "-DCMAKE_MODULE_PATH=${hip}/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" + ]; + + 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 ++ [ hip ])} $test/bin/* + rm -rf $out/test + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Tracer callback/activity library"; + homepage = "https://github.com/ROCm-Developer-Tools/roctracer"; + license = with licenses; [ mit ]; # mitx11 + maintainers = teams.rocm.members; + broken = finalAttrs.version != hip.version; + }; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 228dc4a6b4d6..f08c9638029f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15287,6 +15287,11 @@ with pkgs; rocmUpdateScript = callPackage ../development/rocm-modules/update-script { }; + # Requires GCC + roctracer = callPackage ../development/libraries/roctracer { + inherit (llvmPackages_rocm) clang; + }; + rtags = callPackage ../development/tools/rtags { inherit (darwin) apple_sdk; }; From ecaaa49b651b8385ba86e9ede313a8e337289d93 Mon Sep 17 00:00:00 2001 From: Madoura Date: Fri, 16 Dec 2022 06:00:57 -0600 Subject: [PATCH 11/21] rocsolver: init at 5.4.0 --- .../libraries/rocsolver/default.nix | 92 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 + 2 files changed, 96 insertions(+) create mode 100644 pkgs/development/libraries/rocsolver/default.nix diff --git a/pkgs/development/libraries/rocsolver/default.nix b/pkgs/development/libraries/rocsolver/default.nix new file mode 100644 index 000000000000..dfb09f49cddc --- /dev/null +++ b/pkgs/development/libraries/rocsolver/default.nix @@ -0,0 +1,92 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, rocblas +, hip +, fmt +, gtest +, gfortran +, lapack-reference +, buildTests ? false +, buildBenchmarks ? false +, gpuTargets ? [ ] # gpuTargets = [ "gfx803" "gfx900" "gfx906:xnack-" ] +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocsolver"; + version = "5.4.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "rocSOLVER"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-UHUcA9CVPuYFpE2DTvRrRMMj51yNPo5wMTKnByL2RTg="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + ] ++ lib.optionals (buildTests || buildBenchmarks) [ + gfortran + ]; + + buildInputs = [ + rocblas + fmt + ] ++ 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" + ] ++ 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 { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "ROCm LAPACK implementation"; + homepage = "https://github.com/ROCmSoftwarePlatform/rocSOLVER"; + license = with licenses; [ bsd2 ]; + maintainers = teams.rocm.members; + broken = finalAttrs.version != hip.version; + }; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f08c9638029f..ae593144acc9 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15203,6 +15203,10 @@ with pkgs; stdenv = rocmClangStdenv; }; + rocsolver = callPackage ../development/libraries/rocsolver { + stdenv = rocmClangStdenv; + }; + rocm-opencl-runtime = callPackage ../development/libraries/rocm-opencl-runtime { stdenv = rocmClangStdenv; }; From f69c8df2f3b6f64e4432e5feeb0be12afc158f6a Mon Sep 17 00:00:00 2001 From: Madoura Date: Fri, 16 Dec 2022 07:21:53 -0600 Subject: [PATCH 12/21] rocalution: init at 5.4.0 --- .../libraries/rocalution/default.nix | 114 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 5 + 2 files changed, 119 insertions(+) create mode 100644 pkgs/development/libraries/rocalution/default.nix diff --git a/pkgs/development/libraries/rocalution/default.nix b/pkgs/development/libraries/rocalution/default.nix new file mode 100644 index 000000000000..00d117f00fa9 --- /dev/null +++ b/pkgs/development/libraries/rocalution/default.nix @@ -0,0 +1,114 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, rocblas +, rocsparse +, rocprim +, rocrand +, hip +, git +, openmp +, openmpi +, gtest +, buildTests ? false +, buildBenchmarks ? false +, buildSamples ? false +, gpuTargets ? [ ] # gpuTargets = [ "gfx803" "gfx900:xnack-" "gfx906:xnack-" ... ] +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocalution"; + version = "5.4.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ] ++ lib.optionals buildSamples [ + "sample" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "rocALUTION"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-jovhodhNa7tr1bSqpZCKI/9xF7Ie96JB+giqAEfis2k="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + git + ]; + + buildInputs = [ + rocblas + rocsparse + rocprim + rocrand + openmp + openmpi + ] ++ lib.optionals buildTests [ + gtest + ]; + + cmakeFlags = [ + "-DCMAKE_CXX_COMPILER=hipcc" + "-DROCM_PATH=${hip}" + "-DHIP_ROOT_DIR=${hip}" + "-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}" + ] ++ 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 ++ [ hip ])} \ + $sample/bin/* + '' + lib.optionalString (buildTests || buildBenchmarks) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Iterative sparse solvers for ROCm"; + homepage = "https://github.com/ROCmSoftwarePlatform/rocALUTION"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + broken = finalAttrs.version != hip.version; + }; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ae593144acc9..6765d94fb98a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15195,6 +15195,11 @@ with pkgs; stdenv = rocmClangStdenv; }; + rocalution = callPackage ../development/libraries/rocalution { + inherit (llvmPackages_rocm) openmp; + stdenv = rocmClangStdenv; + }; + rocm-device-libs = callPackage ../development/libraries/rocm-device-libs { stdenv = rocmClangStdenv; }; From 9e0472e20658de07cbb16b3af6476ffde98fbf4f Mon Sep 17 00:00:00 2001 From: Madoura Date: Fri, 16 Dec 2022 15:24:05 +0000 Subject: [PATCH 13/21] =?UTF-8?q?rocm-related:=205.4.0=20=E2=86=92=205.4.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clang-ocl: 5.4.0 → 5.4.1 hipsparse: 5.4.0 → 5.4.1 composable_kernel: unstable-2022-12-08 → unstable-2022-12-15 llvmPackages_rocm.llvm: 5.4.0 → 5.4.1 miopen: 5.4.0 → 5.4.1 miopengemm: 5.4.0 → 5.4.1 rccl: 5.4.0 → 5.4.1 rocalution: 5.4.0 → 5.4.1 hipcub: 5.4.0 → 5.4.1 rocclr: 5.4.0 → 5.4.1 rocfft: 5.4.0 → 5.4.1 rocm-cmake: 5.4.0 → 5.4.1 rocm-comgr: 5.4.0 → 5.4.1 rocm-device-libs: 5.4.0 → 5.4.1 hip: 5.4.0 → 5.4.1 rocblas: 5.4.0 → 5.4.1 rocm-runtime: 5.4.0 → 5.4.1 rocm-opencl-runtime: 5.4.0 → 5.4.1 rocm-thunk: 5.4.0 → 5.4.1 rocprim: 5.4.0 → 5.4.1 rocm-smi: 5.4.0 → 5.4.1 rocminfo: 5.4.0 → 5.4.1 rocsolver: 5.4.0 → 5.4.1 rocrand: 5.4.0 → 5.4.1 rocthrust: 5.4.0 → 5.4.1 rocprofiler: 5.4.0 → 5.4.1 rocwmma: 5.4.0 → 5.4.1 roctracer: 5.4.0 → 5.4.1 rocsparse: 5.4.0 → 5.4.1 tensile: 5.4.0 → 5.4.1 --- pkgs/development/compilers/hip-common/default.nix | 4 ++-- pkgs/development/compilers/hip/default.nix | 2 +- pkgs/development/compilers/llvm/rocm/llvm.nix | 2 +- pkgs/development/libraries/clang-ocl/default.nix | 2 +- pkgs/development/libraries/composable_kernel/default.nix | 6 +++--- pkgs/development/libraries/hipcub/default.nix | 2 +- pkgs/development/libraries/hipsparse/default.nix | 2 +- pkgs/development/libraries/miopen/default.nix | 4 ++-- pkgs/development/libraries/miopengemm/default.nix | 2 +- pkgs/development/libraries/rccl/default.nix | 4 ++-- pkgs/development/libraries/rocalution/default.nix | 2 +- pkgs/development/libraries/rocblas/default.nix | 2 +- pkgs/development/libraries/rocclr/default.nix | 2 +- pkgs/development/libraries/rocfft/default.nix | 4 ++-- pkgs/development/libraries/rocm-comgr/default.nix | 2 +- pkgs/development/libraries/rocm-device-libs/default.nix | 2 +- pkgs/development/libraries/rocm-opencl-runtime/default.nix | 2 +- pkgs/development/libraries/rocm-runtime/default.nix | 4 ++-- pkgs/development/libraries/rocm-thunk/default.nix | 2 +- pkgs/development/libraries/rocprim/default.nix | 2 +- pkgs/development/libraries/rocprofiler/default.nix | 2 +- pkgs/development/libraries/rocrand/default.nix | 2 +- pkgs/development/libraries/rocsolver/default.nix | 2 +- pkgs/development/libraries/rocsparse/default.nix | 2 +- pkgs/development/libraries/rocthrust/default.nix | 2 +- pkgs/development/libraries/roctracer/default.nix | 4 ++-- pkgs/development/libraries/rocwmma/default.nix | 2 +- pkgs/development/libraries/tensile/default.nix | 2 +- .../development/tools/build-managers/rocm-cmake/default.nix | 2 +- pkgs/development/tools/rocminfo/default.nix | 2 +- pkgs/tools/system/rocm-smi/default.nix | 2 +- 31 files changed, 39 insertions(+), 39 deletions(-) diff --git a/pkgs/development/compilers/hip-common/default.nix b/pkgs/development/compilers/hip-common/default.nix index a6343c920376..fc5e09a45982 100644 --- a/pkgs/development/compilers/hip-common/default.nix +++ b/pkgs/development/compilers/hip-common/default.nix @@ -11,13 +11,13 @@ stdenv.mkDerivation (finalAttrs: { pname = "hip-common"; - version = "5.4.0"; + version = "5.4.1"; src = fetchFromGitHub { owner = "ROCm-Developer-Tools"; repo = "HIP"; rev = "rocm-${finalAttrs.version}"; - hash = "sha256-34SJM2n3jZWIS2uwpboWOXVFhaVWGK5ELPKD/cJc1zw="; + hash = "sha256-JpHWTsR2Z8pXp1gNjO29pDYvH/cJvd5Dlpeig33UD28="; }; patches = [ diff --git a/pkgs/development/compilers/hip/default.nix b/pkgs/development/compilers/hip/default.nix index ecb763cea83f..5b3d2c8e0273 100644 --- a/pkgs/development/compilers/hip/default.nix +++ b/pkgs/development/compilers/hip/default.nix @@ -49,7 +49,7 @@ let ]; in stdenv.mkDerivation (finalAttrs: { pname = "hip-${hipPlatform}"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" diff --git a/pkgs/development/compilers/llvm/rocm/llvm.nix b/pkgs/development/compilers/llvm/rocm/llvm.nix index 82aee79cfe4a..731c0557bf2e 100644 --- a/pkgs/development/compilers/llvm/rocm/llvm.nix +++ b/pkgs/development/compilers/llvm/rocm/llvm.nix @@ -48,7 +48,7 @@ let else throw "Unsupported ROCm LLVM platform"; in stdenv.mkDerivation (finalAttrs: { pname = "rocm-llvm-${targetName}"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" diff --git a/pkgs/development/libraries/clang-ocl/default.nix b/pkgs/development/libraries/clang-ocl/default.nix index 8cbace27d4fb..1e844157e419 100644 --- a/pkgs/development/libraries/clang-ocl/default.nix +++ b/pkgs/development/libraries/clang-ocl/default.nix @@ -9,7 +9,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "clang-ocl"; - version = "5.4.0"; + version = "5.4.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; diff --git a/pkgs/development/libraries/composable_kernel/default.nix b/pkgs/development/libraries/composable_kernel/default.nix index 82419873cbeb..9d2abbdf37ba 100644 --- a/pkgs/development/libraries/composable_kernel/default.nix +++ b/pkgs/development/libraries/composable_kernel/default.nix @@ -15,7 +15,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "composable_kernel"; - version = "unstable-2022-12-08"; + version = "unstable-2022-12-15"; outputs = [ "out" @@ -30,8 +30,8 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "ROCmSoftwarePlatform"; repo = "composable_kernel"; - rev = "d58b7f5155b44c8b608f3edc6a6eab314493ec1a"; - hash = "sha256-4nzyaWhPnY/0TygcoJAqVzdgfXOkf+o/BE2V9N+Bm7Q="; + rev = "0345963eef4f92e9c5eab608bb8557b5463a1dcb"; + hash = "sha256-IJbUZ3/UIPbYO9H+BUPP6T2HyUnC+FVbVPXQE5bEjRg="; }; nativeBuildInputs = [ diff --git a/pkgs/development/libraries/hipcub/default.nix b/pkgs/development/libraries/hipcub/default.nix index 8a6ea0ca43c2..d0c7d9a1b053 100644 --- a/pkgs/development/libraries/hipcub/default.nix +++ b/pkgs/development/libraries/hipcub/default.nix @@ -15,7 +15,7 @@ # CUB can also be used as a backend instead of rocPRIM. stdenv.mkDerivation (finalAttrs: { pname = "hipcub"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" diff --git a/pkgs/development/libraries/hipsparse/default.nix b/pkgs/development/libraries/hipsparse/default.nix index a1582a4ee484..def3466a952d 100644 --- a/pkgs/development/libraries/hipsparse/default.nix +++ b/pkgs/development/libraries/hipsparse/default.nix @@ -15,7 +15,7 @@ # This can also use cuSPARSE as a backend instead of rocSPARSE stdenv.mkDerivation (finalAttrs: { pname = "hipsparse"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" diff --git a/pkgs/development/libraries/miopen/default.nix b/pkgs/development/libraries/miopen/default.nix index 513b492ee981..deed581b2fac 100644 --- a/pkgs/development/libraries/miopen/default.nix +++ b/pkgs/development/libraries/miopen/default.nix @@ -58,7 +58,7 @@ let }; in stdenv.mkDerivation (finalAttrs: { pname = "miopen"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" @@ -72,7 +72,7 @@ in stdenv.mkDerivation (finalAttrs: { owner = "ROCmSoftwarePlatform"; repo = "MIOpen"; rev = "rocm-${finalAttrs.version}"; - hash = "sha256-EOe3LUafOeVLzRoahPdS6DMZ/+6WWeVI7jG25zfPrx8="; + hash = "sha256-GfXPCXiVJVve3d8sQCQcFLb/vEnKkVEn7xYUhHkEEVI="; }; nativeBuildInputs = [ diff --git a/pkgs/development/libraries/miopengemm/default.nix b/pkgs/development/libraries/miopengemm/default.nix index 03d30906f94a..45c83021162c 100644 --- a/pkgs/development/libraries/miopengemm/default.nix +++ b/pkgs/development/libraries/miopengemm/default.nix @@ -31,7 +31,7 @@ let }; in stdenv.mkDerivation (finalAttrs: { pname = "miopengemm"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" diff --git a/pkgs/development/libraries/rccl/default.nix b/pkgs/development/libraries/rccl/default.nix index 4a8df477e15e..f501d0e8ced5 100644 --- a/pkgs/development/libraries/rccl/default.nix +++ b/pkgs/development/libraries/rccl/default.nix @@ -13,7 +13,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rccl"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" @@ -25,7 +25,7 @@ stdenv.mkDerivation (finalAttrs: { owner = "ROCmSoftwarePlatform"; repo = "rccl"; rev = "rocm-${finalAttrs.version}"; - hash = "sha256-NbHzRmrUe4kJwkHZtZ+zHjIy2uk+dpN9caE0L5hUnbc="; + hash = "sha256-y9gTGk8LyX7owb2xdtb6VlnIXu/CYHOjnNa/wrNl02g="; }; nativeBuildInputs = [ diff --git a/pkgs/development/libraries/rocalution/default.nix b/pkgs/development/libraries/rocalution/default.nix index 00d117f00fa9..30d61391ec99 100644 --- a/pkgs/development/libraries/rocalution/default.nix +++ b/pkgs/development/libraries/rocalution/default.nix @@ -21,7 +21,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocalution"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" diff --git a/pkgs/development/libraries/rocblas/default.nix b/pkgs/development/libraries/rocblas/default.nix index 41c0b188318c..2d79024c94c9 100644 --- a/pkgs/development/libraries/rocblas/default.nix +++ b/pkgs/development/libraries/rocblas/default.nix @@ -27,7 +27,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocblas"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" diff --git a/pkgs/development/libraries/rocclr/default.nix b/pkgs/development/libraries/rocclr/default.nix index bd0eb6bafbb6..01c1522636af 100644 --- a/pkgs/development/libraries/rocclr/default.nix +++ b/pkgs/development/libraries/rocclr/default.nix @@ -8,7 +8,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocclr"; - version = "5.4.0"; + version = "5.4.1"; src = fetchFromGitHub { owner = "ROCm-Developer-Tools"; diff --git a/pkgs/development/libraries/rocfft/default.nix b/pkgs/development/libraries/rocfft/default.nix index b71f0dc5b07f..aad49db494e6 100644 --- a/pkgs/development/libraries/rocfft/default.nix +++ b/pkgs/development/libraries/rocfft/default.nix @@ -18,7 +18,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocfft"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" @@ -32,7 +32,7 @@ stdenv.mkDerivation (finalAttrs: { owner = "ROCmSoftwarePlatform"; repo = "rocFFT"; rev = "rocm-${finalAttrs.version}"; - hash = "sha256-XlpWT6PS+VpJjA4iG8yaiFRxE63kugNG1ZyQXoQVJL8="; + hash = "sha256-NsYeEoBQ/0z31ZQ32l7N+qavWEVkH37snkTHntot7nE="; }; nativeBuildInputs = [ diff --git a/pkgs/development/libraries/rocm-comgr/default.nix b/pkgs/development/libraries/rocm-comgr/default.nix index 93c56f5178d8..fee10be5db50 100644 --- a/pkgs/development/libraries/rocm-comgr/default.nix +++ b/pkgs/development/libraries/rocm-comgr/default.nix @@ -15,7 +15,7 @@ let else throw "Unsupported ROCm LLVM platform"; in stdenv.mkDerivation (finalAttrs: { pname = "rocm-comgr"; - version = "5.4.0"; + version = "5.4.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; diff --git a/pkgs/development/libraries/rocm-device-libs/default.nix b/pkgs/development/libraries/rocm-device-libs/default.nix index e37baad6f891..6ed70a6565ac 100644 --- a/pkgs/development/libraries/rocm-device-libs/default.nix +++ b/pkgs/development/libraries/rocm-device-libs/default.nix @@ -14,7 +14,7 @@ let else throw "Unsupported ROCm LLVM platform"; in stdenv.mkDerivation (finalAttrs: { pname = "rocm-device-libs"; - version = "5.4.0"; + version = "5.4.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; diff --git a/pkgs/development/libraries/rocm-opencl-runtime/default.nix b/pkgs/development/libraries/rocm-opencl-runtime/default.nix index ee588999a1b1..5d37c8ad9f25 100644 --- a/pkgs/development/libraries/rocm-opencl-runtime/default.nix +++ b/pkgs/development/libraries/rocm-opencl-runtime/default.nix @@ -14,7 +14,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocm-opencl-runtime"; - version = "5.4.0"; + version = "5.4.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; diff --git a/pkgs/development/libraries/rocm-runtime/default.nix b/pkgs/development/libraries/rocm-runtime/default.nix index b7e1212fd1b1..7b4bd6c11ae5 100644 --- a/pkgs/development/libraries/rocm-runtime/default.nix +++ b/pkgs/development/libraries/rocm-runtime/default.nix @@ -16,13 +16,13 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocm-runtime"; - version = "5.4.0"; + version = "5.4.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "ROCR-Runtime"; rev = "rocm-${finalAttrs.version}"; - hash = "sha256-M9kv1Oe5ZZfd9H/+KUJUoK9L1EdyS2qRp2mJDK0dnPE="; + hash = "sha256-JkTXTQmdESHSFbA6HZdMK3pYEApz9aoAlMzdXayzdyY="; }; sourceRoot = "${finalAttrs.src.name}/src"; diff --git a/pkgs/development/libraries/rocm-thunk/default.nix b/pkgs/development/libraries/rocm-thunk/default.nix index bc966e501268..b5825996a44d 100644 --- a/pkgs/development/libraries/rocm-thunk/default.nix +++ b/pkgs/development/libraries/rocm-thunk/default.nix @@ -12,7 +12,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocm-thunk"; - version = "5.4.0"; + version = "5.4.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; diff --git a/pkgs/development/libraries/rocprim/default.nix b/pkgs/development/libraries/rocprim/default.nix index 3ad3871bbd3d..88fad249b8c3 100644 --- a/pkgs/development/libraries/rocprim/default.nix +++ b/pkgs/development/libraries/rocprim/default.nix @@ -13,7 +13,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocprim"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" diff --git a/pkgs/development/libraries/rocprofiler/default.nix b/pkgs/development/libraries/rocprofiler/default.nix index 0d0639edbe53..d51e5de6966e 100644 --- a/pkgs/development/libraries/rocprofiler/default.nix +++ b/pkgs/development/libraries/rocprofiler/default.nix @@ -11,7 +11,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocprofiler"; - version = "5.4.0"; + version = "5.4.1"; src = fetchFromGitHub { owner = "ROCm-Developer-Tools"; diff --git a/pkgs/development/libraries/rocrand/default.nix b/pkgs/development/libraries/rocrand/default.nix index a06615ec4122..a3742a5d9725 100644 --- a/pkgs/development/libraries/rocrand/default.nix +++ b/pkgs/development/libraries/rocrand/default.nix @@ -13,7 +13,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocrand"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" diff --git a/pkgs/development/libraries/rocsolver/default.nix b/pkgs/development/libraries/rocsolver/default.nix index dfb09f49cddc..5b3ad6ce24c4 100644 --- a/pkgs/development/libraries/rocsolver/default.nix +++ b/pkgs/development/libraries/rocsolver/default.nix @@ -17,7 +17,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocsolver"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" diff --git a/pkgs/development/libraries/rocsparse/default.nix b/pkgs/development/libraries/rocsparse/default.nix index c0ee717d4bfc..0edb0bd14e5e 100644 --- a/pkgs/development/libraries/rocsparse/default.nix +++ b/pkgs/development/libraries/rocsparse/default.nix @@ -18,7 +18,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocsparse"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" diff --git a/pkgs/development/libraries/rocthrust/default.nix b/pkgs/development/libraries/rocthrust/default.nix index 7a45a794ad2d..0fc3726761a7 100644 --- a/pkgs/development/libraries/rocthrust/default.nix +++ b/pkgs/development/libraries/rocthrust/default.nix @@ -13,7 +13,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocthrust"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" diff --git a/pkgs/development/libraries/roctracer/default.nix b/pkgs/development/libraries/roctracer/default.nix index b8d1902d468d..c0655aaf7d4e 100644 --- a/pkgs/development/libraries/roctracer/default.nix +++ b/pkgs/development/libraries/roctracer/default.nix @@ -17,7 +17,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "roctracer"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" @@ -31,7 +31,7 @@ stdenv.mkDerivation (finalAttrs: { owner = "ROCm-Developer-Tools"; repo = "roctracer"; rev = "rocm-${finalAttrs.version}"; - hash = "sha256-hDo/tz39/m6lKqLg3UJi3LWWF7/QUtVDymZY1O8L4IQ="; + hash = "sha256-5vYUNczylB2ehlvhq1u/H8KUXt8ku2E+jawKrKsU7LY="; }; nativeBuildInputs = [ diff --git a/pkgs/development/libraries/rocwmma/default.nix b/pkgs/development/libraries/rocwmma/default.nix index 818d915cc133..ecd802612550 100644 --- a/pkgs/development/libraries/rocwmma/default.nix +++ b/pkgs/development/libraries/rocwmma/default.nix @@ -36,7 +36,7 @@ let }; in stdenv.mkDerivation (finalAttrs: { pname = "rocwmma"; - version = "5.4.0"; + version = "5.4.1"; outputs = [ "out" diff --git a/pkgs/development/libraries/tensile/default.nix b/pkgs/development/libraries/tensile/default.nix index c45b15134f5f..bfef4716e127 100644 --- a/pkgs/development/libraries/tensile/default.nix +++ b/pkgs/development/libraries/tensile/default.nix @@ -10,7 +10,7 @@ buildPythonPackage rec { pname = "tensile"; - version = "5.4.0"; + version = "5.4.1"; src = fetchFromGitHub { owner = "ROCmSoftwarePlatform"; diff --git a/pkgs/development/tools/build-managers/rocm-cmake/default.nix b/pkgs/development/tools/build-managers/rocm-cmake/default.nix index 0d7913543f10..6fd4c2b58868 100644 --- a/pkgs/development/tools/build-managers/rocm-cmake/default.nix +++ b/pkgs/development/tools/build-managers/rocm-cmake/default.nix @@ -7,7 +7,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocm-cmake"; - version = "5.4.0"; + version = "5.4.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; diff --git a/pkgs/development/tools/rocminfo/default.nix b/pkgs/development/tools/rocminfo/default.nix index 2a714829d91c..64368fa0c95a 100644 --- a/pkgs/development/tools/rocminfo/default.nix +++ b/pkgs/development/tools/rocminfo/default.nix @@ -18,7 +18,7 @@ }: stdenv.mkDerivation (finalAttrs: { - version = "5.4.0"; + version = "5.4.1"; pname = "rocminfo"; src = fetchFromGitHub { diff --git a/pkgs/tools/system/rocm-smi/default.nix b/pkgs/tools/system/rocm-smi/default.nix index 0f303cc78531..6b67ef13128b 100644 --- a/pkgs/tools/system/rocm-smi/default.nix +++ b/pkgs/tools/system/rocm-smi/default.nix @@ -8,7 +8,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "rocm-smi"; - version = "5.4.0"; + version = "5.4.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; From 187452f58e6c5b0d4f50ca155c1a4b912006d630 Mon Sep 17 00:00:00 2001 From: Madoura Date: Fri, 16 Dec 2022 09:32:53 -0600 Subject: [PATCH 14/21] rocmlir: don't enable broken as long as minor version is the same --- pkgs/development/libraries/rocmlir/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/rocmlir/default.nix b/pkgs/development/libraries/rocmlir/default.nix index 90bb1ad211ce..98843fecfcc7 100644 --- a/pkgs/development/libraries/rocmlir/default.nix +++ b/pkgs/development/libraries/rocmlir/default.nix @@ -100,6 +100,7 @@ in stdenv.mkDerivation (finalAttrs: { homepage = "https://github.com/ROCmSoftwarePlatform/rocMLIR"; license = with licenses; [ asl20 ]; maintainers = teams.rocm.members; - broken = finalAttrs.version != stdenv.cc.version; + # Once again, they haven't updated the tags... + broken = lib.versions.minor finalAttrs.version != lib.versions.minor stdenv.cc.version; }; }) From 93ec556b19a9cddc7798231536c7eed470e9da64 Mon Sep 17 00:00:00 2001 From: Madoura Date: Sat, 17 Dec 2022 23:22:27 -0600 Subject: [PATCH 15/21] rocmUpdateScript: fix llvmPackages_rocm updating --- pkgs/development/rocm-modules/update-script/default.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/development/rocm-modules/update-script/default.nix b/pkgs/development/rocm-modules/update-script/default.nix index 1d2b268a34b6..6188587de31a 100644 --- a/pkgs/development/rocm-modules/update-script/default.nix +++ b/pkgs/development/rocm-modules/update-script/default.nix @@ -1,4 +1,4 @@ -{ runtimeShell +{ lib , writeScript }: @@ -10,6 +10,11 @@ }: let + pname = + if lib.hasPrefix "rocm-llvm-" name + then "llvmPackages_rocm.${lib.removePrefix "rocm-llvm-" name}" + else name; + updateScript = writeScript "update.sh" '' #!/usr/bin/env nix-shell #!nix-shell -i bash -p curl jq common-updater-scripts @@ -22,6 +27,6 @@ let version="''${version}.0" fi - update-source-version ${name} "$version" --ignore-same-hash + update-source-version ${pname} "$version" --ignore-same-hash ''; in [ updateScript ] From f84b81a23c4483f1b6b3309e9be5dedf6b22535b Mon Sep 17 00:00:00 2001 From: Madoura Date: Sun, 18 Dec 2022 00:28:59 -0600 Subject: [PATCH 16/21] composable_kernel: fix tests, disable examples --- .../libraries/composable_kernel/default.nix | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/pkgs/development/libraries/composable_kernel/default.nix b/pkgs/development/libraries/composable_kernel/default.nix index 9d2abbdf37ba..2e74d8ba2765 100644 --- a/pkgs/development/libraries/composable_kernel/default.nix +++ b/pkgs/development/libraries/composable_kernel/default.nix @@ -43,8 +43,6 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ openmp - ] ++ lib.optionals buildTests [ - gtest ]; cmakeFlags = [ @@ -52,16 +50,12 @@ stdenv.mkDerivation (finalAttrs: { "-DCMAKE_CXX_COMPILER=hipcc" ] ++ lib.optionals (gpuTargets != [ ]) [ "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ] ++ lib.optionals buildTests [ + "-DGOOGLETEST_DIR=${gtest.src}" # Custom linker names ]; # No flags to build selectively it seems... - postPatch = '' - substituteInPlace test/CMakeLists.txt \ - --replace "include(googletest)" "" - - substituteInPlace CMakeLists.txt \ - --replace "enable_testing()" "" - '' + lib.optionalString (!buildTests) '' + postPatch = lib.optionalString (!buildTests) '' substituteInPlace CMakeLists.txt \ --replace "add_subdirectory(test)" "" '' + lib.optionalString (!buildExamples) '' @@ -69,15 +63,12 @@ stdenv.mkDerivation (finalAttrs: { --replace "add_subdirectory(example)" "" ''; - postInstall = '' - mkdir -p $out/bin - mv bin/ckProfiler $out/bin - '' + lib.optionalString buildTests '' + postInstall = lib.optionalString buildTests '' mkdir -p $test/bin - mv bin/test_* $test/bin + mv $out/bin/test_* $test/bin '' + lib.optionalString buildExamples '' mkdir -p $example/bin - mv bin/example_* $example/bin + mv $out/bin/example_* $example/bin ''; passthru.updateScript = unstableGitUpdater { }; @@ -87,9 +78,6 @@ stdenv.mkDerivation (finalAttrs: { homepage = "https://github.com/ROCmSoftwarePlatform/composable_kernel"; license = with licenses; [ mit ]; maintainers = teams.rocm.members; - # Well, at least we're getting something that makes sense now - # undefined symbol: testing::Message::Message() - # Try removing this next update - broken = buildTests; + broken = buildExamples; # bin/example_grouped_gemm_xdl_bfp16] Error 139 }; }) From e86c679d092b06e5edfd324eecc66b37f61b6d98 Mon Sep 17 00:00:00 2001 From: Madoura Date: Sun, 18 Dec 2022 05:25:16 -0600 Subject: [PATCH 17/21] miopen: fixup, enable kdbs by default, symlink for hydra --- pkgs/development/libraries/miopen/default.nix | 43 +++++++++---------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/pkgs/development/libraries/miopen/default.nix b/pkgs/development/libraries/miopen/default.nix index deed581b2fac..0e9b9c2dc02b 100644 --- a/pkgs/development/libraries/miopen/default.nix +++ b/pkgs/development/libraries/miopen/default.nix @@ -23,17 +23,11 @@ , doxygen , sphinx , zlib +, gtest , python3Packages , buildDocs ? true , buildTests ? false -# LFS isn't working, so we will manually fetch these -# This isn't strictly required, but is recommended to enable -# https://github.com/ROCmSoftwarePlatform/MIOpen/issues/1373 -# -# MIOpen will produce a very large output due to KDBs fetched -# Also possibly in the future because of KDB generation -# This is disabled by default so we can cache on hydra -, fetchKDBs ? false +, fetchKDBs ? true , useOpenCL ? false }: @@ -127,36 +121,35 @@ in stdenv.mkDerivation (finalAttrs: { "-DMIOPEN_TEST_GFX908=ON" "-DMIOPEN_TEST_GFX90A=ON" "-DMIOPEN_TEST_GFX103X=ON" + "-DGOOGLETEST_DIR=${gtest.src}" # Custom linker names ]; postPatch = '' substituteInPlace CMakeLists.txt \ --replace "enable_testing()" "" \ --replace "MIOPEN_HIP_COMPILER MATCHES \".*clang\\\\+\\\\+$\"" "true" \ - --replace "/opt/rocm/hip" "${hip}" \ - --replace "/opt/rocm/llvm" "${llvm}" \ - --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)" "" # error: missing required key 'key' + '' + lib.optionalString buildTests '' + substituteInPlace test/gtest/CMakeLists.txt \ + --replace "enable_testing()" "" '' + lib.optionalString (!buildTests) '' substituteInPlace CMakeLists.txt \ --replace "add_subdirectory(test)" "" '' + lib.optionalString fetchKDBs '' - cp -a ${kdbs.gfx1030_36} src/kernels/gfx1030_36.kdb - cp -a ${kdbs.gfx900_56} src/kernels/gfx900_56.kdb - cp -a ${kdbs.gfx900_64} src/kernels/gfx900_64.kdb - cp -a ${kdbs.gfx906_60} src/kernels/gfx906_60.kdb - cp -a ${kdbs.gfx906_64} src/kernels/gfx906_64.kdb - cp -a ${kdbs.gfx90878} src/kernels/gfx90878.kdb - cp -a ${kdbs.gfx90a68} src/kernels/gfx90a68.kdb - cp -a ${kdbs.gfx90a6e} src/kernels/gfx90a6e.kdb + ln -sf ${kdbs.gfx1030_36} src/kernels/gfx1030_36.kdb + ln -sf ${kdbs.gfx900_56} src/kernels/gfx900_56.kdb + ln -sf ${kdbs.gfx900_64} src/kernels/gfx900_64.kdb + ln -sf ${kdbs.gfx906_60} src/kernels/gfx906_60.kdb + ln -sf ${kdbs.gfx906_64} src/kernels/gfx906_64.kdb + ln -sf ${kdbs.gfx90878} src/kernels/gfx90878.kdb + ln -sf ${kdbs.gfx90a68} src/kernels/gfx90a68.kdb + ln -sf ${kdbs.gfx90a6e} src/kernels/gfx90a6e.kdb ''; # Unfortunately, it seems like we have to call make on these manually postBuild = lib.optionalString buildDocs '' export HOME=$(mktemp -d) - make doc + make -j$NIX_BUILD_CORES doc '' + lib.optionalString buildTests '' make -j$NIX_BUILD_CORES check ''; @@ -170,6 +163,10 @@ in stdenv.mkDerivation (finalAttrs: { mkdir -p $test/bin mv bin/test_* $test/bin patchelf --set-rpath $out/lib:${lib.makeLibraryPath (finalAttrs.buildInputs ++ [ hip ])} $test/bin/* + '' + lib.optionalString fetchKDBs '' + # Apparently gfx1030_40 wasn't generated so the developers suggest just renaming gfx1030_36 to it + # Should be fixed in the next miopen kernel generation batch + ln -s ${kdbs.gfx1030_36} $out/share/miopen/db/gfx1030_40.kdb ''; passthru.updateScript = rocmUpdateScript { From 8de23957e97b7bb04978829e62f53a4b848a500b Mon Sep 17 00:00:00 2001 From: Madoura Date: Sun, 18 Dec 2022 12:41:25 -0600 Subject: [PATCH 18/21] rocm-related: add release notes --- .../from_md/release-notes/rl-2305.section.xml | 18 ++++++++++++++++++ .../manual/release-notes/rl-2305.section.md | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml index a3b711d1388e..eaeeed9c676c 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml @@ -138,6 +138,17 @@ or configure your firewall. + + + llvmPackages_rocm.llvm will not contain + clang or compiler-rt. + llvmPackages_rocm.clang will not contain + llvm. + llvmPackages_rocm.clangNoCompilerRt has + been removed in favor of using + llvmPackages_rocm.clang-unwrapped. + + The EC2 image module previously detected and automatically @@ -276,6 +287,13 @@ option. + + + hip has been separated into + hip, hip-common and + hipcc. + + Resilio sync secret keys can now be provided using a secrets diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md index d2cc43a5dffc..3573fcb79554 100644 --- a/nixos/doc/manual/release-notes/rl-2305.section.md +++ b/nixos/doc/manual/release-notes/rl-2305.section.md @@ -43,6 +43,8 @@ In addition to numerous new and upgraded packages, this release has the followin - The [services.unifi-video.openFirewall](#opt-services.unifi-video.openFirewall) module option default value has been changed from `true` to `false`. You will need to explicitly set this option to `true`, or configure your firewall. +- `llvmPackages_rocm.llvm` will not contain `clang` or `compiler-rt`. `llvmPackages_rocm.clang` will not contain `llvm`. `llvmPackages_rocm.clangNoCompilerRt` has been removed in favor of using `llvmPackages_rocm.clang-unwrapped`. + - The EC2 image module previously detected and automatically mounted ext3-formatted instance store devices and partitions in stage-1 (initramfs), storing `/tmp` on the first discovered device. This behaviour, which only catered to very specific use cases and could not be disabled, has been removed. Users relying on this should provide their own implementation, and probably use ext4 and perform the mount in stage-2. - The EC2 image module previously detected and activated swap-formatted instance store devices and partitions in stage-1 (initramfs). This behaviour has been removed. Users relying on this should provide their own implementation. @@ -80,6 +82,8 @@ In addition to numerous new and upgraded packages, this release has the followin - Enabling global redirect in `services.nginx.virtualHosts` now allows one to add exceptions with the `locations` option. +- `hip` has been separated into `hip`, `hip-common` and `hipcc`. + - Resilio sync secret keys can now be provided using a secrets file at runtime, preventing these secrets from ending up in the Nix store. - The `services.fwupd` module now allows arbitrary daemon settings to be configured in a structured manner ([`services.fwupd.daemonSettings`](#opt-services.fwupd.daemonSettings)). From 8e80bc7dd2179cbb4733edfde76b00e103bae363 Mon Sep 17 00:00:00 2001 From: Madoura Date: Sun, 18 Dec 2022 21:15:54 -0600 Subject: [PATCH 19/21] hipsparse: fixup samples --- pkgs/development/libraries/hipsparse/default.nix | 13 +++++++++++++ pkgs/top-level/all-packages.nix | 1 + 2 files changed, 14 insertions(+) diff --git a/pkgs/development/libraries/hipsparse/default.nix b/pkgs/development/libraries/hipsparse/default.nix index def3466a952d..a4f8a212310a 100644 --- a/pkgs/development/libraries/hipsparse/default.nix +++ b/pkgs/development/libraries/hipsparse/default.nix @@ -9,7 +9,9 @@ , gfortran , git , gtest +, openmp , buildTests ? false +, buildSamples ? false }: # This can also use cuSPARSE as a backend instead of rocSPARSE @@ -21,6 +23,8 @@ stdenv.mkDerivation (finalAttrs: { "out" ] ++ lib.optionals buildTests [ "test" + ] ++ lib.optionals buildSamples [ + "sample" ]; src = fetchFromGitHub { @@ -42,10 +46,14 @@ stdenv.mkDerivation (finalAttrs: { git ] ++ lib.optionals buildTests [ gtest + ] ++ lib.optionals (buildTests || buildSamples) [ + openmp ]; cmakeFlags = [ + "-DCMAKE_C_COMPILER=hipcc" "-DCMAKE_CXX_COMPILER=hipcc" + "-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" @@ -104,6 +112,11 @@ stdenv.mkDerivation (finalAttrs: { 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 ++ [ hip gfortran.cc ])} $sample/bin/example_* ''; passthru.updateScript = rocmUpdateScript { diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6765d94fb98a..72178e65432f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15180,6 +15180,7 @@ with pkgs; }; hipsparse = callPackage ../development/libraries/hipsparse { + inherit (llvmPackages_rocm) openmp; stdenv = rocmClangStdenv; }; From ce1fd653e3e02ba3420b1edfe5d2374b44b70e5c Mon Sep 17 00:00:00 2001 From: Madoura Date: Sun, 18 Dec 2022 21:32:59 -0600 Subject: [PATCH 20/21] miopen: fixup tests --- pkgs/development/libraries/miopen/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/miopen/default.nix b/pkgs/development/libraries/miopen/default.nix index 0e9b9c2dc02b..1e93c149da8c 100644 --- a/pkgs/development/libraries/miopen/default.nix +++ b/pkgs/development/libraries/miopen/default.nix @@ -24,6 +24,7 @@ , sphinx , zlib , gtest +, rocm-comgr , python3Packages , buildDocs ? true , buildTests ? false @@ -162,7 +163,8 @@ in stdenv.mkDerivation (finalAttrs: { '' + lib.optionalString buildTests '' mkdir -p $test/bin mv bin/test_* $test/bin - patchelf --set-rpath $out/lib:${lib.makeLibraryPath (finalAttrs.buildInputs ++ [ hip ])} $test/bin/* + patchelf --set-rpath $out/lib:${lib.makeLibraryPath (finalAttrs.buildInputs ++ + [ hip rocm-comgr ])} $test/bin/* '' + lib.optionalString fetchKDBs '' # Apparently gfx1030_40 wasn't generated so the developers suggest just renaming gfx1030_36 to it # Should be fixed in the next miopen kernel generation batch From 3690ec3a8d4385cc34edbee0aab3828bc2f74656 Mon Sep 17 00:00:00 2001 From: Madoura Date: Sun, 18 Dec 2022 21:42:33 -0600 Subject: [PATCH 21/21] roctracer: fixup tests --- pkgs/development/libraries/roctracer/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/roctracer/default.nix b/pkgs/development/libraries/roctracer/default.nix index c0655aaf7d4e..6b5b23fae9f5 100644 --- a/pkgs/development/libraries/roctracer/default.nix +++ b/pkgs/development/libraries/roctracer/default.nix @@ -10,6 +10,8 @@ , libxml2 , doxygen , graphviz +, gcc-unwrapped +, rocm-runtime , python3Packages , buildDocs ? false # Nothing seems to be generated, so not making the output , buildTests ? false @@ -77,7 +79,8 @@ stdenv.mkDerivation (finalAttrs: { # 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 ++ [ hip ])} $test/bin/* + patchelf --set-rpath $out/lib:${lib.makeLibraryPath ( + finalAttrs.buildInputs ++ [ hip gcc-unwrapped.lib rocm-runtime ])} $test/bin/* rm -rf $out/test '';