diff --git a/dev-util/hip/Manifest b/dev-util/hip/Manifest index d14b6335a6b11..caba3f57f87f7 100644 --- a/dev-util/hip/Manifest +++ b/dev-util/hip/Manifest @@ -1,6 +1,9 @@ DIST hip-6.3.3.tar.gz 1486598 BLAKE2B 998b28786c0b156cd1c23a01ce284206d1ad5cad1f207676b9d40994dc4f60d16a1f0804cfa287622826d78871ee19d2b5aa78dc29a69fe54ab50f08652bfd26 SHA512 70544467c5c262fab1e9415f5e77d0ec3b4635b6fa104de5d7ab2da0e2ca88fe40ce716068e50eaa17a807516cd41e2c0af22bcada3a1f7de50aa88283850e38 DIST hip-6.4.3.tar.gz 1755257 BLAKE2B 3db2d35a71ca2802e95043c5ef6d50db56b3e1412dcdb08ba7083675cccb898d2b06c2afdfc0e0f53648d09d2aa84f91cca00ecf297caa2784d07aae4b3573b6 SHA512 1fa32ca7f9f2024e66cbe0bd8faaeeaf5240ce2f962f5bfa29815ff7bdcf5c4c4dac2d0d0354c3a5215df6ebec1e1b32bc10e560d9292a0bd019da1773724e54 +DIST hip-7.0.2.tar.gz 1855072 BLAKE2B 7ec17fda250019cb333bb41342e2d13141df39ba14f769881c3b85c1c0bf4e90d8e744a748731f8dfb12f3c004ba92486c5f48354d24141733fa90eb19c6ac59 SHA512 d2b0124a35a56f3b58b6decad670e9a06849de0760f4cc4e72acb1fcf32a84b694ceea9024db101e323e86d0f7fde5559ee815322ed95b3d3c9648a34b4c3754 DIST hip-test-6.3.3.tar.gz 1446849 BLAKE2B 474194bd7cef54af85eab0bc8fdfbe2360a9a22ab27f9014ebbb22f03952bfc014d682e2a0cbf90fcd365b4295df266a64419deebbce38aa7b5b7af9c979cc20 SHA512 65bde402804e95a09142bc2a9866bbef14068b63d09236d70086e15c3927ef29fb75d0859a90aa4bc75ebe03f94da85284b233fb41b95246bb45d1d8fee172ed DIST hip-test-6.4.3.tar.gz 1570417 BLAKE2B 5b6bd3d1fcaaf724061ed686b6edc08b7ba308557ae0cb22785a04bc17b48aace50225a5e3c756a28bc741bb8fcaac8bff18b17f99a4458427b3489fef7dcd44 SHA512 5eed7da562f3807bb6ea8d737115dd45b775c2588c4131f2a19206d125b2b53d8adccbe189953219dd1091f18f08badec81cba524951b8a69626df9075db7a1c +DIST hip-test-7.0.2.tar.gz 1639664 BLAKE2B f1fa00927901d282870f80fbd438280d8b66d67834796b7713244ea09ee7179bac3732442d591a3c8a7cbae3e86cbfa9dce64315d78b11b010a8fd4a76df448a SHA512 524fc1311db2f4c5ed6cb7a97c72e7dd8808344e61ab493a8be407d4682e27c4c7239aec8eac32adfcc4cb01f34efb935d62cb6d4d4ba797b210c64cf4c61d02 DIST rocm-clr-6.3.3.tar.gz 2095704 BLAKE2B bdb315fc9f1f9c76aa2a345bd48a600c81f3b72eb68fee8862b5e155e7519bef6f6421698a43358c6fe0200bb0b6924ff819860d9a91a5c07fc3e9d44eeb1b16 SHA512 94d2959b981b324e0dae2d06e86c72cd01fa495de081666bcec2445c02bada22aa60e94ecac0ee63e70e52275f92caeefcb6dc96a3f0fba593896be7b0d8ab42 DIST rocm-clr-6.4.3.tar.gz 2126045 BLAKE2B eadeaa050e684373883faadfbf42d6b4152979154587afb1a2583bf9ddfb3ff9ab9787a433c8f380ac52012732ff2f68892ab256ec76f32557c164e9551745af SHA512 38daec86ea9c8e60f420b4eec5e96d88a4e51585dcbb7352bec27f0c712f4b856f413c42e2585c031a81e8046065d76763c624500ba786ae0e9133278f00418c +DIST rocm-clr-7.0.2.tar.gz 2171932 BLAKE2B b14c1e7f42e7bf0e7b3514095495524ae572f65fa28780ef74853540d2f2952f97e0d82be09f70756a860592e7ae0ef738239a34715dee79d9a293d02ce7337e SHA512 eb80cd47c8a3e3fa8948cc58c6b8b158b2e2ae49f70a63f7040fe59a309bdd4f29334f6edc7950d13932c50162884288e27e2308b85293f68739402547d7ad36 diff --git a/dev-util/hip/files/hip-7.0.2-fix-libcxx-noinline.patch b/dev-util/hip/files/hip-7.0.2-fix-libcxx-noinline.patch new file mode 100644 index 0000000000000..28f8e7e55d112 --- /dev/null +++ b/dev-util/hip/files/hip-7.0.2-fix-libcxx-noinline.patch @@ -0,0 +1,17 @@ +Unsetting __noinline__ before inclusion of libc++ __config breaks libc++ headers. +--- a/hipamd/include/hip/amd_detail/host_defines.h ++++ b/hipamd/include/hip/amd_detail/host_defines.h +@@ -257,6 +257,13 @@ typedef __hip_internal::int64_t __hip_int64_t; + + #define __global__ + ++// __config in libc++ fails on `__has_attribute(__noinline__)` if __noinline__ is emptied ++#if defined(__cplusplus) && defined(__has_include) ++# if __has_include(<__config>) ++# include <__config> ++# endif ++#endif ++ + #define __noinline__ + #define __forceinline__ inline + diff --git a/dev-util/hip/hip-7.0.2.ebuild b/dev-util/hip/hip-7.0.2.ebuild new file mode 100644 index 0000000000000..4e90c13c7a81f --- /dev/null +++ b/dev-util/hip/hip-7.0.2.ebuild @@ -0,0 +1,248 @@ +# Copyright 1999-2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DOCS_BUILDER="doxygen" +DOCS_DEPEND="media-gfx/graphviz" +ROCM_SKIP_GLOBALS=1 + +LLVM_COMPAT=( 20 ) + +inherit cmake docs flag-o-matic llvm-r1 rocm + +TEST_PV=${PV} + +DESCRIPTION="C++ Heterogeneous-Compute Interface for Portability" +HOMEPAGE="https://github.com/ROCm/rocm-systems/tree/develop/projects/clr" +if [[ ${PV} == 9999 ]]; then + inherit git-r3 + EGIT_SUBMODULES=() + EGIT_REPO_URI="https://github.com/ROCm/rocm-systems.git" + S="${WORKDIR}/${P}/projects/clr" + TEST_S="${WORKDIR}/${P}/projects/hip-tests" + HIP_S="${WORKDIR}/${P}/projects/hip" + SLOT="0/7.0" +else + SRC_URI=" + https://github.com/ROCm/clr/archive/refs/tags/rocm-${PV}.tar.gz -> rocm-clr-${PV}.tar.gz + https://github.com/ROCm/HIP/archive/refs/tags/rocm-${PV}.tar.gz -> hip-${PV}.tar.gz + test? ( + https://github.com/ROCm/hip-tests/archive/refs/tags/rocm-${TEST_PV}.tar.gz -> hip-test-${TEST_PV}.tar.gz + ) + " + S="${WORKDIR}/clr-rocm-${PV}/" + TEST_S="${WORKDIR}/hip-tests-rocm-${TEST_PV}/catch" + HIP_S="${WORKDIR}/hip-rocm-${PV}" + KEYWORDS="~amd64" + SLOT="0/$(ver_cut 1-2)" +fi + +LICENSE="MIT" + +IUSE="debug +hip numa opencl test video_cards_amdgpu video_cards_nvidia" + +# many tests are broken +RESTRICT="test" + +REQUIRED_USE=" + || ( hip opencl ) + ^^ ( video_cards_amdgpu video_cards_nvidia ) +" + +DEPEND=" + video_cards_amdgpu? ( + dev-util/rocminfo:${SLOT} + dev-libs/rocm-comgr:${SLOT} + dev-libs/rocr-runtime:${SLOT} + ) + video_cards_nvidia? ( dev-libs/hipother:${SLOT} ) + x11-base/xorg-proto + virtual/opengl[X] + numa? ( sys-process/numactl ) +" +BDEPEND=" + video_cards_amdgpu? ( + dev-util/hipcc:${SLOT} + ) + test? ( + media-libs/freeglut + ) +" +RDEPEND="${DEPEND} + ~dev-libs/rocm-core-${PV} + opencl? ( + !dev-libs/opencl-icd-loader + !dev-libs/rocm-opencl-runtime + !dev-util/clinfo + !dev-util/opencl-headers + ) + video_cards_amdgpu? ( + dev-util/hipcc:${SLOT} + dev-libs/rocm-device-libs:${SLOT} + dev-libs/roct-thunk-interface:${SLOT} + ) +" + +PATCHES=( + "${FILESDIR}/${PN}-6.1.1-fix-musl.patch" + "${FILESDIR}/${PN}-6.3.0-no-isystem-usr-include.patch" + "${FILESDIR}/${PN}-6.3.0-clr-fix-libcxx.patch" + "${FILESDIR}/${PN}-6.4.1-no-glibcxx-assert.patch" + "${FILESDIR}/${PN}-7.0.2-fix-libcxx-noinline.patch" +) + +QA_FLAGS_IGNORED="usr/lib.*/libhiprtc-builtins.*" + +hip_test_wrapper() { + local CMAKE_USE_DIR="${TEST_S}" + local BUILD_DIR="${TEST_S}_build" + cd "${TEST_S}" || die + "${@}" +} + +src_prepare() { + pushd "${HIP_S}" >/dev/null || die + + # hipamd is itself built by cmake, and should never provide a + # FindHIP.cmake module. But the reality is some package relies on it. + # Set HIP and HIP Clang paths directly, don't search using heuristics + sed -e "s:# Search for HIP installation:set(HIP_ROOT_DIR \"${EPREFIX}/usr\"):" \ + -e "s:#Set HIP_CLANG_PATH:set(HIP_CLANG_PATH \"$(get_llvm_prefix -d)/bin\"):" \ + -i "cmake/FindHIP.cmake" || die + popd >/dev/null || die + + sed -e "s/ -Werror//g" -i "hipamd/src/CMakeLists.txt" || die + + # do not install /usr/share/doc/${P}-asan + sed -e "/asan COMPONENT asan/d" -i hipamd/packaging/CMakeLists.txt || die + + sed -e "s/@HIP_INSTALLS_HIPCC@/ON/g" -i hipamd/hip-config.cmake.in || die + + # skip installation of hipcc: installed via dev-util/hipcc + sed -e "s/NOT \${HIPCC_BIN_DIR}/INSTALL_HIPCC AND NOT \${HIPCC_BIN_DIR}/" \ + -i "hipamd/CMakeLists.txt" || die + + sed -e "/cmake_minimum_required/ s/3\.[35]/3.10/" \ + -i "hipamd/src/hiprtc/cmake/hiprtc-config.cmake.in" \ + -i opencl/khronos/icd/CMakeLists.txt \ + -i opencl/khronos/headers/opencl2.2/tests/CMakeLists.txt || die + + cmake_src_prepare + + if use test; then + local PATCHES=( + "${FILESDIR}"/hip-test-5.7.1-remove-incompatible-flag.patch + "${FILESDIR}"/hip-test-6.1.1-fix-musl.patch + ) + sed -e "s/-Werror //" -e "s/-Wall -Wextra //" -i "${TEST_S}/CMakeLists.txt" || die + + # policy not supported by CMake 4.0; and not needed + sed -e '/cmake_policy(SET CMP0037 OLD)/d' -i "${TEST_S}/CMakeLists.txt" || die + + hip_test_wrapper cmake_src_prepare + fi +} + +src_configure() { + # -Werror=strict-aliasing + # https://bugs.gentoo.org/858383 + # https://github.com/ROCm/clr/issues/64 + # + # Do not trust it for LTO either + append-flags -fno-strict-aliasing + filter-lto + + use debug && CMAKE_BUILD_TYPE="Debug" + + # Fix ld.lld linker error: https://github.com/ROCm/HIP/issues/3382 + # See also: https://github.com/gentoo/gentoo/pull/29097 + append-ldflags $(test-flags-CCLD -Wl,--undefined-version) + + local mycmakeargs=( + -DCMAKE_PREFIX_PATH="$(get_llvm_prefix)" + -DCMAKE_SKIP_RPATH=ON + -D__HIP_ENABLE_PCH=OFF + + -DCLR_BUILD_HIP="$(usex hip)" + -DCLR_BUILD_OCL="$(usex opencl)" + + -DHIP_COMMON_DIR="${HIP_S}" + -DHIP_ENABLE_ROCPROFILER_REGISTER=OFF + -DHIPCC_BIN_DIR="${EPREFIX}/usr/bin" + -DROCM_PATH="${EPREFIX}/usr" + -DUSE_PROF_API=OFF + + -DOpenGL_GL_PREFERENCE="GLVND" + -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON + -DCMAKE_DISABLE_FIND_PACKAGE_NUMA="$(usex !numa)" + -DCMAKE_REQUIRE_FIND_PACKAGE_NUMA="$(usex numa)" + ) + + if use video_cards_amdgpu; then + mycmakeargs+=( + -DHIP_PLATFORM="amd" + ) + elif use video_cards_nvidia; then + mycmakeargs+=( + -DHIPNV_DIR="${EPREFIX}/usr" + -DHIP_PLATFORM="nvidia" + ) + fi + + cmake_src_configure + + if use test; then + local mycmakeargs=( + -DCMAKE_MODULE_PATH="${TEST_S}/external/Catch2/cmake/Catch2" + -DROCM_PATH="${EPREFIX}/usr" + -DCMAKE_NO_SYSTEM_FROM_IMPORTED=ON + -Wno-dev + + # 1) Use custom build of hipamd instead of system one + # 2) Build fails with libc++: https://github.com/llvm/llvm-project/issues/119076 + -DCMAKE_CXX_FLAGS="-I${BUILD_DIR}/hipamd/include -stdlib=libstdc++" + -DCMAKE_EXE_LINKER_FLAGS="-L${BUILD_DIR}/hipamd/lib" + ) + if use video_cards_amdgpu; then + mycmakeargs+=( + -DHIP_PLATFORM="amd" + ) + elif use video_cards_nvidia; then + mycmakeargs+=( + -DHIP_PLATFORM="nvidia" + ) + fi + hip_test_wrapper cmake_src_configure + fi +} + +src_compile() { + cmake_src_compile + + if use test; then + hip_test_wrapper cmake_src_compile build_tests + fi +} + +src_test() { + check_amdgpu + export LD_LIBRARY_PATH="${BUILD_DIR}/hipamd/lib" + + # TODO: research how to test Vulkan-related features. + local CMAKE_SKIP_TESTS=( + Unit_hipExternalMemoryGetMappedBuffer_Vulkan_Positive_Read_Write + Unit_hipExternalMemoryGetMappedBuffer_Vulkan_Negative_Parameters + Unit_hipImportExternalMemory_Vulkan_Negative_Parameters + Unit_hipWaitExternalSemaphoresAsync_Vulkan_Positive_Binary_Semaphore + Unit_hipWaitExternalSemaphoresAsync_Vulkan_Positive_Multiple_Semaphores + Unit_hipWaitExternalSemaphoresAsync_Vulkan_Negative_Parameters + Unit_hipSignalExternalSemaphoresAsync_Vulkan_Positive_Binary_Semaphore + Unit_hipSignalExternalSemaphoresAsync_Vulkan_Positive_Multiple_Semaphores + Unit_hipSignalExternalSemaphoresAsync_Vulkan_Negative_Parameters + Unit_hipImportExternalSemaphore_Vulkan_Negative_Parameters + Unit_hipDestroyExternalSemaphore_Vulkan_Negative_Parameters + ) + + hip_test_wrapper cmake_src_test +} diff --git a/dev-util/hip/metadata.xml b/dev-util/hip/metadata.xml index 8746df97725ca..fdffedd702e2d 100644 --- a/dev-util/hip/metadata.xml +++ b/dev-util/hip/metadata.xml @@ -22,10 +22,11 @@ Sv. Lockal - ROCm/HIP + ROCm/rocm-systems Build HIP runtime + Enable NUMA support using sys-process/numactl (NUMA kernel support is also required) Build OpenCL runtime Build for AMD platform Build for Nvidia platform