summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenda Xu <heroxbd@gentoo.org>2020-12-24 01:06:47 +0800
committerBenda Xu <heroxbd@gentoo.org>2020-12-27 09:55:26 +0800
commit36781efd38eb25f8e0d4643af2c44029f61f702c (patch)
tree0403a7697f05e761a9e279c04db15e8fbcd97fb8 /dev-util/hip
parentsys-devel/llvm-roc: add support for Prefix. (diff)
downloadgentoo-36781efd38eb25f8e0d4643af2c44029f61f702c.tar.gz
gentoo-36781efd38eb25f8e0d4643af2c44029f61f702c.tar.bz2
gentoo-36781efd38eb25f8e0d4643af2c44029f61f702c.zip
dev-util/hip: C++ Heterogeneous-Compute Interface for Portability.
This ebuild is adopted from that of https://github.com/justxi/rocm. 1. change hip location from /usr/lib/hip/<ver> to /usr/lib/hip. We do not have plans to support multiple hip versions at once. 2. turn the hipify function off as it does not work. We will re-enable it as a USE flag when possible. 3. properly prefixify the source code making use of hprefixify(). 4. migrate from cmake-utils to cmake eclass. Closes: https://github.com/gentoo/gentoo/pull/18787 Suggested-by: Wilfried Holzke <gentoo@holzke.net> Suggested-by: Yiyang Wu <xgreenlandforwyy@gmail.com> Package-Manager: Portage-3.0.12, Repoman-3.0.1 Signed-off-by: Benda Xu <heroxbd@gentoo.org>
Diffstat (limited to 'dev-util/hip')
-rw-r--r--dev-util/hip/Manifest1
-rw-r--r--dev-util/hip/files/hip-3.5.1-config-cmake-in.patch28
-rw-r--r--dev-util/hip/files/hip-3.5.1-detect_offload-arch_for_clang-roc.patch21
-rw-r--r--dev-util/hip/files/hip-3.5.1-hip_vector_types.patch10
-rw-r--r--dev-util/hip/files/hip-3.9.0-DisableTest.patch87
-rw-r--r--dev-util/hip/files/hip-3.9.0-add-include-directories.patch13
-rw-r--r--dev-util/hip/files/hip-3.9.0-lpl_ca-add-include.patch10
-rw-r--r--dev-util/hip/hip-4.0.0.ebuild107
-rw-r--r--dev-util/hip/metadata.xml19
9 files changed, 296 insertions, 0 deletions
diff --git a/dev-util/hip/Manifest b/dev-util/hip/Manifest
new file mode 100644
index 000000000000..5081a96f35a6
--- /dev/null
+++ b/dev-util/hip/Manifest
@@ -0,0 +1 @@
+DIST rocm-hip-4.0.0.tar.gz 1012154 BLAKE2B 02343239a5b27c42dafd241f2c9b6f5195c50f78bfd717ae72bcb16d384bd6cf97ff6f2b86bfcf323aaaf022d6897f46d0987826c80d6f6279be4cb4792e15be SHA512 cf840dbe28a9a15e3be14351bfa22d3c81e1654813a7aee55f53e71b2ee183f8dd0de14a79791617fabb5b357cadbf2ce2f476f78884b2843d30f206d65088f6
diff --git a/dev-util/hip/files/hip-3.5.1-config-cmake-in.patch b/dev-util/hip/files/hip-3.5.1-config-cmake-in.patch
new file mode 100644
index 000000000000..f3b5ac9c19ef
--- /dev/null
+++ b/dev-util/hip/files/hip-3.5.1-config-cmake-in.patch
@@ -0,0 +1,28 @@
+--- a/hip-config.cmake.in 2020-06-21 21:17:35.576297760 +0200
++++ b/hip-config.cmake.in 2020-06-21 21:17:59.861296628 +0200
+@@ -123,8 +123,10 @@
+ )
+ set_target_properties(hip::device PROPERTIES
+ INTERFACE_COMPILE_DEFINITIONS "__HIP_ROCclr__=1"
+- INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/../include"
+- INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/../include"
++ INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
++ INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
++# INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/../include"
++# INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/../include"
+ )
+ else()
+ set_target_properties(hip::hip_hcc_static PROPERTIES
+@@ -156,9 +158,9 @@
+ INTERFACE_LINK_LIBRARIES --hip-device-lib-path=${AMD_DEVICE_LIBS_PREFIX}/lib --hip-link
+ )
+
+- set_property(TARGET hip::device APPEND PROPERTY
+- INTERFACE_INCLUDE_DIRECTORIES "${HIP_CLANG_INCLUDE_PATH}/.."
+- )
++# set_property(TARGET hip::device APPEND PROPERTY
++# INTERFACE_INCLUDE_DIRECTORIES "${HIP_CLANG_INCLUDE_PATH}/.."
++# )
+
+ set_property(TARGET hip::device APPEND PROPERTY
+ INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${HIP_CLANG_INCLUDE_PATH}/.."
diff --git a/dev-util/hip/files/hip-3.5.1-detect_offload-arch_for_clang-roc.patch b/dev-util/hip/files/hip-3.5.1-detect_offload-arch_for_clang-roc.patch
new file mode 100644
index 000000000000..7997e2929666
--- /dev/null
+++ b/dev-util/hip/files/hip-3.5.1-detect_offload-arch_for_clang-roc.patch
@@ -0,0 +1,21 @@
+diff -uprN HIP-rocm-3.5.1/bin/hipcc patched/bin/hipcc
+--- HIP-rocm-3.5.1/bin/hipcc 2020-07-21 14:29:11.625878447 +0800
++++ patched/bin/hipcc 2020-07-21 14:34:11.454395203 +0800
+@@ -675,7 +675,7 @@ foreach $arg (@ARGV)
+ $prevArg = $arg;
+ }
+
+-if($HIP_PLATFORM eq "hcc"){
++if($HIP_PLATFORM eq "hcc" || $HIP_PLATFORM eq "rocclr"){
+ # No AMDGPU target specified at commandline. So look for HCC_AMDGPU_TARGET
+ if($default_amdgpu_target eq 1) {
+ if (defined $ENV{HCC_AMDGPU_TARGET}) {
+@@ -694,6 +694,8 @@ if($HIP_PLATFORM eq "hcc"){
+
+ if($HIP_COMPILER eq "hcc") {
+ $GPU_ARCH_OPT = " --amdgpu-target=";
++ } elsif($HIP_COMPILER eq "clang") {
++ $GPU_ARCH_OPT = " --offload-arch=";
+ } else {
+ $GPU_ARCH_OPT = " --cuda-gpu-arch=";
+ }
diff --git a/dev-util/hip/files/hip-3.5.1-hip_vector_types.patch b/dev-util/hip/files/hip-3.5.1-hip_vector_types.patch
new file mode 100644
index 000000000000..382ed52f6923
--- /dev/null
+++ b/dev-util/hip/files/hip-3.5.1-hip_vector_types.patch
@@ -0,0 +1,10 @@
+--- a/include/hip/hcc_detail/hip_vector_types.h
++++ b/include/hip/hcc_detail/hip_vector_types.h
+@@ -42,6 +42,7 @@
+ #endif
+
+ #if defined(__cplusplus)
++ #include <new>
+ #include <array>
+ #include <iosfwd>
+ #include <type_traits>
diff --git a/dev-util/hip/files/hip-3.9.0-DisableTest.patch b/dev-util/hip/files/hip-3.9.0-DisableTest.patch
new file mode 100644
index 000000000000..3fc787a7354e
--- /dev/null
+++ b/dev-util/hip/files/hip-3.9.0-DisableTest.patch
@@ -0,0 +1,87 @@
+--- a/CMakeLists.txt 2020-11-15 11:26:09.747793881 +0100
++++ b/CMakeLists.txt 2020-11-15 11:28:45.289793287 +0100
+@@ -676,45 +676,45 @@
+ # Target: test
+ set(HIP_ROOT_DIR ${CMAKE_CURRENT_BINARY_DIR})
+ set(HIP_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+-if(HIP_PLATFORM STREQUAL "nvcc")
+- execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/include" "${CMAKE_CURRENT_BINARY_DIR}/include" RESULT_VARIABLE RUN_HIT ERROR_QUIET)
+-endif()
+-execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/cmake" "${HIP_ROOT_DIR}/cmake" RESULT_VARIABLE RUN_HIT ERROR_QUIET)
+-if(${RUN_HIT} EQUAL 0)
+- execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/bin" "${HIP_ROOT_DIR}/bin" RESULT_VARIABLE RUN_HIT ERROR_QUIET)
+-endif()
+-if(${RUN_HIT} EQUAL 0)
+- set(CMAKE_MODULE_PATH "${HIP_ROOT_DIR}/cmake" ${CMAKE_MODULE_PATH})
+- include(${HIP_SRC_PATH}/tests/hit/HIT.cmake)
+-
+- # Add tests
+- include_directories(${HIP_SRC_PATH}/tests/src)
+- hit_add_directory_recursive(${HIP_CTEST_CONFIG_DEFAULT} ${HIP_SRC_PATH}/tests/src "directed_tests")
+-
+- # Add unit tests
+- include_directories(${HIP_SRC_PATH}/tests/unit)
+- hit_add_directory_recursive(${HIP_CTEST_CONFIG_DEFAULT} ${HIP_SRC_PATH}/tests/unit "unit_tests")
+-
+- # Add performance tests
+- include_directories(${HIP_SRC_PATH}/tests/performance)
+- hit_add_directory_recursive(${HIP_CTEST_CONFIG_PERFORMANCE} ${HIP_SRC_PATH}/tests/performance "performance_tests")
+-
+- # Add top-level tests to build_tests
+- add_custom_target(build_tests DEPENDS directed_tests unit_tests)
+-
+- # Add top-level tests to build performance_tests.
+- # To build performance tests, just run "make build_perf"
+- add_custom_target(build_perf DEPENDS performance_tests)
+-
+- # Add custom target: perf.
+- # To run performance tests, just run "make perf"
+- add_custom_target(perf COMMAND "${CMAKE_CTEST_COMMAND}" -C "${HIP_CTEST_CONFIG_PERFORMANCE}" -R "performance_tests/" --verbose)
+-
+- # Add custom target: check
+- add_custom_target(check COMMAND "${CMAKE_COMMAND}" --build . --target test DEPENDS build_tests)
+-else()
+- message(STATUS "Testing targets will not be available. To enable them please ensure that the HIP installation directory is writeable. Use -DCMAKE_INSTALL_PREFIX to specify a suitable location")
+-endif()
++#if(HIP_PLATFORM STREQUAL "nvcc")
++# execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/include" "${CMAKE_CURRENT_BINARY_DIR}/include" RESULT_VARIABLE RUN_HIT ERROR_QUIET)
++#endif()
++#execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/cmake" "${HIP_ROOT_DIR}/cmake" RESULT_VARIABLE RUN_HIT ERROR_QUIET)
++#if(${RUN_HIT} EQUAL 0)
++# execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/bin" "${HIP_ROOT_DIR}/bin" RESULT_VARIABLE RUN_HIT ERROR_QUIET)
++#endif()
++#if(${RUN_HIT} EQUAL 0)
++# set(CMAKE_MODULE_PATH "${HIP_ROOT_DIR}/cmake" ${CMAKE_MODULE_PATH})
++# include(${HIP_SRC_PATH}/tests/hit/HIT.cmake)
++#
++# # Add tests
++# include_directories(${HIP_SRC_PATH}/tests/src)
++# hit_add_directory_recursive(${HIP_CTEST_CONFIG_DEFAULT} ${HIP_SRC_PATH}/tests/src "directed_tests")
++#
++# # Add unit tests
++# include_directories(${HIP_SRC_PATH}/tests/unit)
++# hit_add_directory_recursive(${HIP_CTEST_CONFIG_DEFAULT} ${HIP_SRC_PATH}/tests/unit "unit_tests")
++#
++# # Add performance tests
++# include_directories(${HIP_SRC_PATH}/tests/performance)
++# hit_add_directory_recursive(${HIP_CTEST_CONFIG_PERFORMANCE} ${HIP_SRC_PATH}/tests/performance "performance_tests")
++#
++# # Add top-level tests to build_tests
++# add_custom_target(build_tests DEPENDS directed_tests unit_tests)
++#
++# # Add top-level tests to build performance_tests.
++# # To build performance tests, just run "make build_perf"
++# add_custom_target(build_perf DEPENDS performance_tests)
++#
++# # Add custom target: perf.
++# # To run performance tests, just run "make perf"
++# add_custom_target(perf COMMAND "${CMAKE_CTEST_COMMAND}" -C "${HIP_CTEST_CONFIG_PERFORMANCE}" -R "performance_tests/" --verbose)
++#
++# # Add custom target: check
++# add_custom_target(check COMMAND "${CMAKE_COMMAND}" --build . --target test DEPENDS build_tests)
++#else()
++# message(STATUS "Testing targets will not be available. To enable them please ensure that the HIP installation directory is writeable. Use -DCMAKE_INSTALL_PREFIX to specify a suitable location")
++#endif()
+
+ #############################
+ # Code analysis
diff --git a/dev-util/hip/files/hip-3.9.0-add-include-directories.patch b/dev-util/hip/files/hip-3.9.0-add-include-directories.patch
new file mode 100644
index 000000000000..42bd9736ee2c
--- /dev/null
+++ b/dev-util/hip/files/hip-3.9.0-add-include-directories.patch
@@ -0,0 +1,13 @@
+--- a/rocclr/CMakeLists.txt 2020-08-23 11:45:13.148817894 +0200
++++ b/rocclr/CMakeLists.txt 2020-08-23 11:50:12.409816752 +0200
+@@ -139,6 +139,10 @@
+ target_compile_definitions(hip64
+ PRIVATE
+ $<TARGET_PROPERTY:amdrocclr_static,INTERFACE_COMPILE_DEFINITIONS>)
++
++ include_directories(/usr/include/rocclr)
++ include_directories(/usr/include/rocclr/elf)
++ include_directories(/usr/include/rocclr/compiler/lib/include/)
+ endif()
+
+ # Enable profiling API
diff --git a/dev-util/hip/files/hip-3.9.0-lpl_ca-add-include.patch b/dev-util/hip/files/hip-3.9.0-lpl_ca-add-include.patch
new file mode 100644
index 000000000000..bebe6f0f4ecc
--- /dev/null
+++ b/dev-util/hip/files/hip-3.9.0-lpl_ca-add-include.patch
@@ -0,0 +1,10 @@
+--- a/lpl_ca/CMakeLists.txt 2020-11-15 11:47:55.091788901 +0100
++++ b/lpl_ca/CMakeLists.txt 2020-11-15 11:49:14.881788597 +0100
+@@ -17,6 +17,7 @@
+ ${PROJECT_SOURCE_DIR}/src
+ PRIVATE
+ $<TARGET_PROPERTY:amdrocclr_static,INTERFACE_INCLUDE_DIRECTORIES>)
++target_include_directories(lpl SYSTEM PUBLIC /usr/include/rocclr/elf)
+
+ target_compile_options(lpl PUBLIC -Wall)
+ target_link_libraries(lpl PUBLIC pthread)
diff --git a/dev-util/hip/hip-4.0.0.ebuild b/dev-util/hip/hip-4.0.0.ebuild
new file mode 100644
index 000000000000..ae96dbdc84e7
--- /dev/null
+++ b/dev-util/hip/hip-4.0.0.ebuild
@@ -0,0 +1,107 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+inherit cmake flag-o-matic prefix
+
+DESCRIPTION="C++ Heterogeneous-Compute Interface for Portability"
+HOMEPAGE="https://github.com/ROCm-Developer-Tools/HIP"
+SRC_URI="https://github.com/ROCm-Developer-Tools/HIP/archive/rocm-${PV}.tar.gz -> rocm-hip-${PV}.tar.gz"
+
+KEYWORDS="~amd64"
+LICENSE="MIT"
+SLOT="0/$(ver_cut 1-2)"
+
+IUSE="debug profile"
+
+# Don't strip to prevent some tests from failing.
+RESTRICT="strip"
+
+DEPEND=">=dev-libs/rocclr-$(ver_cut 1-2)
+ >=dev-util/rocminfo-$(ver_cut 1-2)
+ =sys-devel/llvm-roc-${PV}*[runtime]"
+RDEPEND="${DEPEND}"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-3.9.0-DisableTest.patch"
+ "${FILESDIR}/${PN}-3.9.0-add-include-directories.patch"
+ "${FILESDIR}/${PN}-3.5.1-config-cmake-in.patch"
+ "${FILESDIR}/${PN}-3.5.1-hip_vector_types.patch"
+ "${FILESDIR}/${PN}-3.5.1-detect_offload-arch_for_clang-roc.patch"
+ "${FILESDIR}/${PN}-3.9.0-lpl_ca-add-include.patch"
+)
+
+S="${WORKDIR}/HIP-rocm-${PV}"
+
+src_prepare() {
+ cmake_src_prepare
+ eapply_user
+
+ # disable PCH, because it results in a build error in ROCm 4.0.0
+ sed -e "s:option(__HIP_ENABLE_PCH:#option(__HIP_ENABLE_PCH:" -i "${S}/CMakeLists.txt" || die
+
+ # "hcc" is deprecated and not installed, new platform is "rocclr";
+ # Due to setting HAS_PATH to "/usr", this results in setting "-isystem /usr/include"
+ # which results in a e.g. "stdlib.h" not found when using "#include_next" in header files;
+ sed -e "s:\$HIP_PLATFORM eq \"hcc\" and \$HIP_COMPILER eq \"clang\":\$HIP_PLATFORM eq \"rocclr\" and \$HIP_COMPILER eq \"clang\":" \
+ -e "/FLAGS .= \" -isystem \$HSA_PATH/d" \
+ -e "s:\$ENV{'DEVICE_LIB_PATH'}:'/usr/lib/amdgcn/bitcode':" \
+ -i bin/hipcc || die
+
+ # change --hip-device-lib-path to "/usr/lib/amdgcn/bitcode", must align with "dev-libs/rocm-device-libs"
+ sed -e "s:\${AMD_DEVICE_LIBS_PREFIX}/lib:/usr/lib/amdgcn/bitcode:" \
+ -i "${S}/hip-config.cmake.in" || die
+
+ einfo "prefixing hipcc and its utils..."
+ hprefixify $(grep -rl --exclude-dir=build/ "/usr" "${S}")
+}
+
+src_configure() {
+ strip-flags
+ if ! use debug; then
+ append-cflags "-DNDEBUG"
+ append-cxxflags "-DNDEBUG"
+ buildtype="Release"
+ else
+ buildtype="Debug"
+ fi
+
+ # TODO: Currently a GENTOO configuration is build,
+ # this is also used in the cmake configuration files
+ # which will be installed to find HIP;
+ # Other ROCm packages expect a "RELEASE" configuration,
+ # see "hipBLAS"
+ local mycmakeargs=(
+ -DCMAKE_PREFIX_PATH="${EPREFIX}/usr/lib/llvm/roc"
+ -DCMAKE_BUILD_TYPE=${buildtype}
+ -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/hip"
+ -DBUILD_HIPIFY_CLANG=OFF
+ -DHIP_PLATFORM=rocclr
+ -DHIP_RUNTIME=ROCclr
+ -DHIP_COMPILER=clang
+ -DROCM_PATH="${EPREFIX}/usr"
+ -DHSA_PATH="${EPREFIX}/usr"
+ -DUSE_PROF_API=$(usex profile 1 0)
+ -DROCclr_DIR="${EPREFIX}"/usr/include/rocclr
+ )
+
+ cmake_src_configure
+}
+
+src_install() {
+ echo "HSA_PATH=${EPREFIX}/usr" > 99hip || die
+ echo "ROCM_PATH=${EPREFIX}/usr" >> 99hip || die
+ echo "HIP_PLATFORM=rocclr" >> 99hip || die
+ echo "HIP_RUNTIME=ROCclr" >> 99hip || die
+ echo "HIP_COMPILER=clang" >> 99hip || die
+ echo "HIP_CLANG_PATH=${EPREFIX}/usr/lib/llvm/roc/bin" >> 99hip || die
+
+ echo "PATH=${EPREFIX}/usr/lib/hip/bin" >> 99hip || die
+ echo "HIP_PATH=${EPREFIX}/usr/lib/hip" >> 99hip || die
+ echo "LDPATH=${EPREFIX}/usr/lib/hip/lib" >> 99hip || die
+ echo "ROOTPATH=${EPREFIX}/usr/lib/hip/bin" >> 99hip || die
+
+ doenvd 99hip
+
+ cmake_src_install
+}
diff --git a/dev-util/hip/metadata.xml b/dev-util/hip/metadata.xml
new file mode 100644
index 000000000000..db491e13a348
--- /dev/null
+++ b/dev-util/hip/metadata.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>sci@gentoo.org</email>
+ <name>Gentoo Science Project</name>
+ </maintainer>
+ <maintainer type="person">
+ <email>candrews@gentoo.org</email>
+ <name>Craig Andrews</name>
+ </maintainer>
+ <maintainer type="person">
+ <email>gentoo@holzke.net</email>
+ <name>Wilfried Holzke</name>
+ </maintainer>
+ <upstream>
+ <remote-id type="github">ROCm-Developer-Tools/HIP</remote-id>
+ </upstream>
+</pkgmetadata>