public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Benda XU" <heroxbd@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-util/hip/files/, dev-util/hip/
Date: Tue,  3 Aug 2021 06:32:28 +0000 (UTC)	[thread overview]
Message-ID: <1627972343.2ed748a3b6412f99bc249e089e9221e38417a8f8.heroxbd@gentoo> (raw)

commit:     2ed748a3b6412f99bc249e089e9221e38417a8f8
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Tue Aug  3 06:32:04 2021 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Tue Aug  3 06:32:23 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2ed748a3

dev-util/hip: remove environment variable dependencies.

ROCm upstream allows for overriding HIP_PATH, ROCM_PATH, CUDA_PATH,
HSA_PATH, HIP_CLANG_PATH, HIP_ROCCLR_HOME, HIP_PLATFORM, HIP_COMPILER,
HIP_RUNTIME for flexibility, at the cost of having to set a handful
environmental variables each time before invoking hipcc.

If any of the environmental variables is not set correctly, hipvars.pm
or hipcc may take wrong guesses and refuses to work.

For Gentoo, all the of variables are predictable and determined at
build time.  It is more straightforward and transparent to hardcode
them in the perl script.

Bug: https://github.com/ROCm-Developer-Tools/HIP/issues/2224
Bug: https://github.com/ROCm-Developer-Tools/HIP/issues/2256
Package-Manager: Portage-3.0.20, Repoman-3.0.3
Signed-off-by: Benda Xu <heroxbd <AT> gentoo.org>

 dev-util/hip/files/hipvars.pm    |  19 ++++++++
 dev-util/hip/hip-4.1.0-r1.ebuild | 103 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 122 insertions(+)

diff --git a/dev-util/hip/files/hipvars.pm b/dev-util/hip/files/hipvars.pm
new file mode 100644
index 00000000000..3f5c88409e0
--- /dev/null
+++ b/dev-util/hip/files/hipvars.pm
@@ -0,0 +1,19 @@
+#!/usr/bin/perl -w
+package hipvars;
+
+$HIP_BASE_VERSION_MAJOR = "4";
+$HIP_BASE_VERSION_MINOR = "1";
+
+$HIP_PATH='/usr/lib/hip';
+$ROCM_PATH='/usr';
+$CUDA_PATH='/opt/cuda';
+$HSA_PATH='/usr';
+$HIP_CLANG_PATH='/usr/lib/llvm/roc/bin';
+$HIP_ROCCLR_HOME=$HIP_PATH;
+$HIP_PLATFORM='amd';
+$HIP_COMPILER = "clang";
+$HIP_RUNTIME = "rocclr";
+$HIP_VERSION_MAJOR = $HIP_BASE_VERSION_MAJOR;
+$HIP_VERSION_MINOR = $HIP_BASE_VERSION_MINOR;
+$HIP_VERSION_PATCH = "0";
+$HIP_VERSION="$HIP_VERSION_MAJOR.$HIP_VERSION_MINOR.$HIP_VERSION_PATCH";

diff --git a/dev-util/hip/hip-4.1.0-r1.ebuild b/dev-util/hip/hip-4.1.0-r1.ebuild
new file mode 100644
index 00000000000..ff12517ad83
--- /dev/null
+++ b/dev-util/hip/hip-4.1.0-r1.ebuild
@@ -0,0 +1,103 @@
+# Copyright 1999-2021 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}-4.1.0-DisableTest.patch"
+	"${FILESDIR}/${PN}-3.9.0-add-include-directories.patch"
+	"${FILESDIR}/${PN}-3.5.1-config-cmake-in.patch"
+	"${FILESDIR}/${PN}-3.9.0-lpl_ca-add-include.patch"
+)
+
+S="${WORKDIR}/HIP-rocm-${PV}"
+
+src_prepare() {
+	cmake_src_prepare
+	eapply_user
+
+	# Use Gentoo version number, otherwise git hash is attempted in vain.
+	sed -e "/set (HIP_LIB_VERSION_STRING/cset (HIP_LIB_VERSION_STRING ${PVR})" -i CMakeLists.txt || die
+
+	# 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 CMakeLists.txt || die
+
+	# "hcc" is deprecated and not installed, new platform is "rocclr";
+	# Setting HSA_PATH to "/usr" results in setting "-isystem /usr/include"
+	# which makes "stdlib.h" not found when using "#include_next" in header files;
+	sed -e "/FLAGS .= \" -isystem \$HSA_PATH/d" \
+		-e "s:\$ENV{'DEVICE_LIB_PATH'}:'/usr/lib/amdgcn/bitcode':" \
+		-i bin/hipcc || die
+
+	# correctly find HIP_CLANG_INCLUDE_PATH using cmake
+	sed -e "/set(HIP_CLANG_ROOT/s:\"\${ROCM_PATH}/llvm\":/usr/lib/llvm/roc:" -i hip-config.cmake.in || 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}")
+
+	cp "${FILESDIR}"/hipvars.pm bin/ || die "failed to replace hipvars.pm"
+}
+
+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_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 "PATH=${EPREFIX}/usr/lib/hip/bin" >> 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
+}


             reply	other threads:[~2021-08-03  6:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-03  6:32 Benda XU [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-06-24  8:38 [gentoo-commits] repo/gentoo:master commit in: dev-util/hip/files/, dev-util/hip/ Alfredo Tupone
2024-06-26  9:21 Sam James
2024-03-08 19:22 Sam James
2023-11-19  2:18 Benda XU
2023-09-03  6:37 罗百科
2023-02-06  3:59 Sam James
2023-01-31 13:32 Benda XU
2022-09-12  8:41 Benda XU
2022-09-12  8:41 Benda XU
2022-06-22 13:03 Benda XU
2022-06-13 12:00 Benda XU
2021-08-26 12:39 Benda XU
2021-08-13  5:08 Benda XU
2021-04-11 15:17 Craig Andrews
2020-12-27  1:55 Benda XU

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1627972343.2ed748a3b6412f99bc249e089e9221e38417a8f8.heroxbd@gentoo \
    --to=heroxbd@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox