dev-libs/rocr-runtime: Fix SIGSEGV
authorCraig Andrews <candrews@gentoo.org>
Thu, 3 Oct 2019 15:54:04 +0000 (11:54 -0400)
committerCraig Andrews <candrews@gentoo.org>
Thu, 3 Oct 2019 15:54:18 +0000 (11:54 -0400)
Bug: https://github.com/RadeonOpenCompute/ROCR-Runtime/issues/68
Closes: https://bugs.gentoo.org/696108
Package-Manager: Portage-2.3.76, Repoman-2.3.17
Signed-off-by: Craig Andrews <candrews@gentoo.org>
dev-libs/rocr-runtime/files/rocr-runtime-2.8.0-fix_doorbell_map.patch [new file with mode: 0644]
dev-libs/rocr-runtime/rocr-runtime-2.8.0-r1.ebuild [new file with mode: 0644]

diff --git a/dev-libs/rocr-runtime/files/rocr-runtime-2.8.0-fix_doorbell_map.patch b/dev-libs/rocr-runtime/files/rocr-runtime-2.8.0-fix_doorbell_map.patch
new file mode 100644 (file)
index 0000000..aef3d29
--- /dev/null
@@ -0,0 +1,57 @@
+https://github.com/RadeonOpenCompute/ROCR-Runtime/pull/71
+
+From d2a6ad97eb96a28d8f8b658b26ab94e911886cf2 Mon Sep 17 00:00:00 2001
+From: Sean Keely <Sean.Keely@amd.com>
+Date: Thu, 5 Sep 2019 20:58:57 -0500
+Subject: [PATCH] Correct doorbell_queue_map allocation.
+
+doorbell_queue_map should be allocated unconditionally.
+---
+ core/runtime/amd_gpu_agent.cpp | 22 +++++++++++-----------
+ 1 file changed, 11 insertions(+), 11 deletions(-)
+
+diff --git a/core/runtime/amd_gpu_agent.cpp b/core/runtime/amd_gpu_agent.cpp
+index 9b79a6b..76df913 100644
+--- a/core/runtime/amd_gpu_agent.cpp
++++ b/core/runtime/amd_gpu_agent.cpp
+@@ -1182,12 +1182,22 @@ void GpuAgent::SyncClocks() {
+ }
+ void GpuAgent::BindTrapHandler() {
++  // Make an empty map from doorbell index to queue.
++  // The trap handler uses this to retrieve a wave's amd_queue_t*.
++  auto doorbell_queue_map_size = MAX_NUM_DOORBELLS * sizeof(amd_queue_t*);
++
++  doorbell_queue_map_ = (amd_queue_t**)core::Runtime::runtime_singleton_->system_allocator()(
++      doorbell_queue_map_size, 0x1000, 0);
++  assert(doorbell_queue_map_ != NULL && "Doorbell queue map allocation failed");
++
++  memset(doorbell_queue_map_, 0, doorbell_queue_map_size);
++
+   if (isa_->GetMajorVersion() == 7) {
+     // No trap handler support on Gfx7, soft error.
+     return;
+   }
+-  // Disable trap handler on Carrizo until KFD is fixed.
++  // Disable trap handler on APUs until KFD is fixed.
+   if (profile_ == HSA_PROFILE_FULL) {
+     return;
+   }
+@@ -1195,16 +1205,6 @@ void GpuAgent::BindTrapHandler() {
+   // Assemble the trap handler source code.
+   AssembleShader("TrapHandler", AssembleTarget::ISA, trap_code_buf_, trap_code_buf_size_);
+-  // Make an empty map from doorbell index to queue.
+-  // The trap handler uses this to retrieve a wave's amd_queue_t*.
+-  auto doorbell_queue_map_size = MAX_NUM_DOORBELLS * sizeof(amd_queue_t*);
+-
+-  doorbell_queue_map_ = (amd_queue_t**)core::Runtime::runtime_singleton_->system_allocator()(
+-      doorbell_queue_map_size, 0x1000, 0);
+-  assert(doorbell_queue_map_ != NULL && "Doorbell queue map allocation failed");
+-
+-  memset(doorbell_queue_map_, 0, doorbell_queue_map_size);
+-
+   // Bind the trap handler to this node.
+   HSAKMT_STATUS err = hsaKmtSetTrapHandler(node_id(), trap_code_buf_, trap_code_buf_size_,
+                                            doorbell_queue_map_, doorbell_queue_map_size);
diff --git a/dev-libs/rocr-runtime/rocr-runtime-2.8.0-r1.ebuild b/dev-libs/rocr-runtime/rocr-runtime-2.8.0-r1.ebuild
new file mode 100644 (file)
index 0000000..9a38ed3
--- /dev/null
@@ -0,0 +1,38 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit cmake-utils
+
+if [[ ${PV} == *9999 ]] ; then
+       EGIT_REPO_URI="https://github.com/RadeonOpenCompute/ROCR-Runtime/"
+       inherit git-r3
+       S="${WORKDIR}/${P}/src"
+else
+       SRC_URI="https://github.com/RadeonOpenCompute/ROCR-Runtime/archive/roc-${PV}.tar.gz -> ${P}.tar.gz"
+       S="${WORKDIR}/ROCR-Runtime-roc-${PV}/src"
+       KEYWORDS="~amd64"
+fi
+
+DESCRIPTION="Radeon Open Compute Runtime"
+HOMEPAGE="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+PATCHES=(
+       "${FILESDIR}/${PN}-2.0.0-cmake-install-paths.patch"
+       "${FILESDIR}/${P}-fix_doorbell_map.patch"
+)
+
+LICENSE="MIT"
+SLOT="0/$(ver_cut 1-2)"
+IUSE="nonfree"
+
+COMMON_DEPEND="sys-process/numactl"
+RDEPEND="${COMMON_DEPEND}
+       nonfree? ( dev-libs/hsa-ext-rocr )"
+DEPEND="${COMMON_DEPEND}
+       >=dev-libs/roct-thunk-interface-${PV}"
+
+src_prepare() {
+       sed -e "s:get_version ( \"1.0.0\" ):get_version ( \"${PV}\" ):" -i CMakeLists.txt || die
+       cmake-utils_src_prepare
+}