ROCm 2.0.0 Release

This commit is contained in:
Tom Stellard
2018-10-11 00:54:07 +00:00
parent a95bf05b4e
commit e63a5f986e
4 changed files with 6 additions and 213 deletions
+6 -6
View File
@@ -1,14 +1,11 @@
Name: rocm-runtime
Version: 1.6.1
Release: 8%{?dist}
Version: 2.0.0
Release: 1%{?dist}
Summary: ROCm Runtime Library
License: NCSA
URL: https://github.com/RadeonOpenCompute/ROCm
Source0: https://github.com/RadeonOpenCompute/ROCR-Runtime/archive/roc-%{version}.tar.gz
Patch0: 0001-Fix-Werror-format-overflow-warning.patch
Patch1: 0001-Prefer-using-memfd_create-for-the-ring-buffer.patch
Patch2: 0001-Fix-build-with-gcc-8.patch
ExclusiveArch: x86_64 aarch64
@@ -24,7 +21,7 @@ ROCm Runtime Library
%package devel
Summary: ROCm Runtime development files
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: hsakmt-devel
Requires: hsakmt-devel >= 1.0.6-7.rocm%{version}
%description devel
ROCm Runtime development files
@@ -71,6 +68,9 @@ mv %{buildroot}{/usr/hsa/include/hsa,%{_includedir}}
%{_libdir}/libhsa-runtime64.so
%changelog
* Mon Jan 14 2019 Tom Stellard <tstellar@redhat.com> - 2.0.0-1
- ROCm 2.0.0 Release
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.1-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
@@ -1,25 +0,0 @@
From 04386ca5df5aa294fa40cc526dffd0ca3c658303 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar@redhat.com>
Date: Thu, 12 Oct 2017 21:31:50 -0700
Subject: [PATCH] Fix -Werror=format-overflow warning
---
src/core/runtime/hsa.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/core/runtime/hsa.cpp b/src/core/runtime/hsa.cpp
index 64129ac..3b45afd 100644
--- a/src/core/runtime/hsa.cpp
+++ b/src/core/runtime/hsa.cpp
@@ -336,7 +336,7 @@ static size_t get_extension_table_length(uint16_t extension, uint16_t major, uin
return 0;
}
- char buff[3];
+ char buff[6];
sprintf(buff, "%02u", minor);
name += std::to_string(major) + "_" + buff + "_pfn_t";
--
2.13.6
-27
View File
@@ -1,27 +0,0 @@
From 34076e8fd05abcbd6fa76d5aeb917b10f1a2420d Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar@redhat.com>
Date: Thu, 1 Feb 2018 16:09:42 -0800
Subject: [PATCH] Fix build with gcc 8
---
src/core/runtime/runtime.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/runtime/runtime.cpp b/src/core/runtime/runtime.cpp
index f65d00a..7e39b69 100644
--- a/src/core/runtime/runtime.cpp
+++ b/src/core/runtime/runtime.cpp
@@ -255,8 +255,8 @@ void Runtime::SetLinkCount(size_t num_link) {
const size_t last_index = GetIndexLinkInfo(0, num_link);
link_matrix_.resize(last_index);
- memset(&link_matrix_[0], 0,
- link_matrix_.size() * sizeof(hsa_amd_memory_pool_link_info_t));
+ memset((void*)link_matrix_.data(), 0,
+ link_matrix_.size() * sizeof(LinkInfo));
}
void Runtime::RegisterLinkInfo(uint32_t node_id_from, uint32_t node_id_to,
--
2.13.6
@@ -1,155 +0,0 @@
From 3c412229adcc073e9a378dad94701f2e8adc3f92 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar@redhat.com>
Date: Thu, 26 Oct 2017 20:36:28 +0000
Subject: [PATCH] Prefer using memfd_create() for the ring buffer
We were using /dev/shm, but this won't work on systems that
either don't have /dev/shm or have mounted it with noexec, because
for everything other than kaveri we map the ring buffer with PROT_EXEC.
memfd_create() is Linux specific and was added in Linux 3.17, so we
will fallback to using /dev/shm on systems where memfd_create() is
not available.
---
src/CMakeLists.txt | 7 ++++
src/core/inc/amd_aql_queue.h | 3 ++
src/core/runtime/amd_aql_queue.cpp | 68 ++++++++++++++++++++++++++------------
3 files changed, 57 insertions(+), 21 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d9a98c9..0db0493 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -58,12 +58,19 @@ include ( hsa_common )
## Find LibElf
find_package(LibElf REQUIRED)
+## Check for memfd_create syscall
+include(CheckSymbolExists)
+CHECK_SYMBOL_EXISTS ( "__NR_memfd_create" "sys/syscall.h" HAVE_MEMFD_CREATE )
+
## Compiler preproc definitions.
add_definitions ( -D__linux__ )
add_definitions ( -DHSA_EXPORT=1 )
add_definitions ( -DHSA_EXPORT_FINALIZER=1 )
add_definitions ( -DHSA_EXPORT_IMAGES=1 )
add_definitions ( -D HSA_DEPRECATED= )
+if ( HAVE_MEMFD_CREATE )
+ add_definitions ( -DHAVE_MEMFD_CREATE )
+endif()
## Get the package version. The defaults to 1.0.0.
get_version ( "1.0.0" )
diff --git a/src/core/inc/amd_aql_queue.h b/src/core/inc/amd_aql_queue.h
index 1932eaa..ba859a6 100644
--- a/src/core/inc/amd_aql_queue.h
+++ b/src/core/inc/amd_aql_queue.h
@@ -349,6 +349,9 @@ class AqlQueue : public core::Queue, public core::Signal {
uint32_t ComputeRingBufferMinPkts();
uint32_t ComputeRingBufferMaxPkts();
+ void CloseRingBufferFD(const char *ring_buf_shm_path, int fd) const;
+ int CreateRingBufferFD(const char *ring_buf_shm_path,
+ uint32_t ring_buf_phys_size_bytes) const;
// (De)allocates and (de)registers ring_buf_.
void AllocRegisteredRingBuffer(uint32_t queue_size_pkts);
void FreeRegisteredRingBuffer();
diff --git a/src/core/runtime/amd_aql_queue.cpp b/src/core/runtime/amd_aql_queue.cpp
index 9d680ac..a22bb59 100644
--- a/src/core/runtime/amd_aql_queue.cpp
+++ b/src/core/runtime/amd_aql_queue.cpp
@@ -479,6 +479,43 @@ uint32_t AqlQueue::ComputeRingBufferMaxPkts() {
return uint32_t(max_bytes / sizeof(core::AqlPacket));
}
+void AqlQueue::CloseRingBufferFD(const char *ring_buf_shm_path, int fd) const {
+#if !defined(HAVE_MEMFD_CREATE)
+ shm_unlink(ring_buf_shm_path);
+#endif
+ close(fd);
+}
+
+int AqlQueue::CreateRingBufferFD(const char *ring_buf_shm_path,
+ uint32_t ring_buf_phys_size_bytes) const {
+
+ int fd;
+#ifdef HAVE_MEMFD_CREATE
+ fd = syscall(__NR_memfd_create, ring_buf_shm_path, 0);
+
+ if (fd == -1)
+ return -1;
+
+ if (ftruncate(fd, ring_buf_phys_size_bytes) == -1) {
+ CloseRingBufferFD(ring_buf_shm_path, fd);
+ return -1;
+ }
+#else
+ fd = shm_open(ring_buf_shm_path, O_CREAT | O_RDWR | O_EXCL,
+ S_IRUSR | S_IWUSR);
+
+ if (fd == -1)
+ return -1;
+
+ if (posix_fallocate(fd, 0, ring_buf_phys_size_bytes) != 0)
+ CloseRingBufferFD(ring_buf_shm_path, fd);
+ return -1;
+ }
+#endif
+
+ return fd;
+}
+
void AqlQueue::AllocRegisteredRingBuffer(uint32_t queue_size_pkts) {
if (agent_->profile() == HSA_PROFILE_FULL) {
// Compute the physical and virtual size of the queue.
@@ -495,15 +532,13 @@ void AqlQueue::AllocRegisteredRingBuffer(uint32_t queue_size_pkts) {
int ring_buf_shm_fd = -1;
void* reserve_va = NULL;
- do {
- // Create a shared memory object to back the ring buffer.
- ring_buf_shm_fd = shm_open(ring_buf_shm_path, O_CREAT | O_RDWR | O_EXCL,
- S_IRUSR | S_IWUSR);
- if (ring_buf_shm_fd == -1) {
- break;
- }
- if (posix_fallocate(ring_buf_shm_fd, 0, ring_buf_phys_size_bytes) != 0)
- break;
+ ring_buf_shm_fd = CreateRingBufferFD(ring_buf_shm_path,
+ ring_buf_phys_size_bytes);
+
+ // TODO: Better error handling.
+ if (ring_buf_shm_fd == -1) {
+ return;
+ }
// Reserve a VA range twice the size of the physical backing store.
reserve_va = mmap(NULL, ring_buf_alloc_bytes_, PROT_NONE,
@@ -539,21 +574,12 @@ void AqlQueue::AllocRegisteredRingBuffer(uint32_t queue_size_pkts) {
assert(ring_buf_upper_half != MAP_FAILED && "mmap failed");
}
- // Release explicit reference to shared memory object.
- shm_unlink(ring_buf_shm_path);
- close(ring_buf_shm_fd);
-
// Successfully created mapping.
ring_buf_ = ring_buf_lower_half;
- return;
- } while (false);
- // Resource cleanup on failure.
- if (reserve_va) munmap(reserve_va, ring_buf_alloc_bytes_);
- if (ring_buf_shm_fd != -1) {
- shm_unlink(ring_buf_shm_path);
- close(ring_buf_shm_fd);
- }
+ // Release explicit reference to shared memory object.
+ CloseRingBufferFD(ring_buf_shm_path, ring_buf_shm_fd);
+ return;
#endif
#ifdef _WIN32
HANDLE ring_buf_mapping = INVALID_HANDLE_VALUE;
--
2.13.6