[PATCH 00/11] AMD ROCm OpenCL runtime

  • Done
  • quality assurance status badge
Details
One participant
  • Lars-Dominik Braun
Owner
unassigned
Submitted by
Lars-Dominik Braun
Severity
normal
L
L
Lars-Dominik Braun wrote on 6 Aug 2021 09:06
(address . guix-patches@gnu.org)
YQzfkzqmdBHHrs+u@noor.fritz.box
Hi,

this patchset adds AMD’s ROCm OpenCL runtime for their GPU’s. It works
fine with Linux’ standard kernel module (no need to package ROCk), but
only if firmware has been loaded. The userspace software itself is
completely free though.

The final patch adjusts one consumer of ROCm OpenCL, darktable, so both
actually work together. Try it yourself with (obviously needs an AMD
GPU):

guix environment --ad-hoc darktable ocl-icd rocm-opencl-runtime -- darktable-cltest

Lars-Dominik Braun (11):
gnu: Add rocm-cmake.
gnu: Add llvm-for-rocm.
gnu: Add rocm-device-libs.
gnu: Add rocm-comgr.
gnu: Add roct-thunk-interface.
gnu: Add rocr-runtime.
gnu: Add rocclr.
gnu: Add rocm-opencl-runtime.
gnu: Add rocminfo.
gnu: Add rocm-bandwidth-test.
gnu: darktable: Add compatibility for ROCm.

gnu/local.mk | 8 +
.../llvm-roc-3.0.0-add_libraries.patch | 22 ++
...roc-4.0.0-remove-isystem-usr-include.patch | 29 ++
.../patches/llvm-roc-4.2.0-add_Object.patch | 13 +
.../rocm-comgr-3.1.0-dependencies.patch | 52 +++
....10.0-add-rocclr-include-directories.patch | 14 +
.../rocm-opencl-runtime-4.3-noclinfo.patch | 28 ++
.../rocm-opencl-runtime-4.3-nocltrace.patch | 25 ++
.../rocm-opencl-runtime-4.3-noopencl.patch | 63 ++++
gnu/packages/photo.scm | 24 +-
gnu/packages/rocm.scm | 355 ++++++++++++++++++
11 files changed, 628 insertions(+), 5 deletions(-)
create mode 100644 gnu/packages/patches/llvm-roc-3.0.0-add_libraries.patch
create mode 100644 gnu/packages/patches/llvm-roc-4.0.0-remove-isystem-usr-include.patch
create mode 100644 gnu/packages/patches/llvm-roc-4.2.0-add_Object.patch
create mode 100644 gnu/packages/patches/rocm-comgr-3.1.0-dependencies.patch
create mode 100644 gnu/packages/patches/rocm-opencl-runtime-3.10.0-add-rocclr-include-directories.patch
create mode 100644 gnu/packages/patches/rocm-opencl-runtime-4.3-noclinfo.patch
create mode 100644 gnu/packages/patches/rocm-opencl-runtime-4.3-nocltrace.patch
create mode 100644 gnu/packages/patches/rocm-opencl-runtime-4.3-noopencl.patch
create mode 100644 gnu/packages/rocm.scm

--
2.31.1
L
L
Lars-Dominik Braun wrote on 6 Aug 2021 09:11
Re: bug#49907: Acknowledgement ([PATCH 00/11] AMD ROCm OpenCL runtime)
(address . 49907@debbugs.gnu.org)
YQzgijKaVsWcCvQv@noor.fritz.box
Forgot to attach the actual patches, sorry.
From 4e4ca903ff7b94fceba9ba85c85f6d267baf71fc Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Thu, 5 Aug 2021 15:33:47 +0200
Subject: [PATCH 01/11] gnu: Add rocm-cmake.

* gnu/packages/rocm.scm (%rocm-version, rocm-cmake): New variables.
---
gnu/packages/rocm.scm | 57 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
create mode 100644 gnu/packages/rocm.scm

Toggle diff (65 lines)
diff --git a/gnu/packages/rocm.scm b/gnu/packages/rocm.scm
new file mode 100644
index 0000000000..b04eb8050e
--- /dev/null
+++ b/gnu/packages/rocm.scm
@@ -0,0 +1,57 @@
+;;;
+;;; Copyright � 2021 Lars-Dominik Braun <lars@6xq.net>
+;;;
+;;; This program is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages rocm)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix packages)
+ #:use-module (guix download)
+ #:use-module (guix utils)
+ #:use-module (guix git-download)
+ #:use-module (guix build-system cmake)
+ #:use-module (gnu packages)
+ #:use-module (gnu packages elf)
+ #:use-module (gnu packages gl)
+ #:use-module (gnu packages linux)
+ #:use-module (gnu packages llvm)
+ #:use-module (gnu packages opencl)
+ #:use-module (gnu packages version-control)
+ #:use-module (gnu packages vim))
+
+;; The components are tightly integrated and can only be upgraded as a unit. If
+;; you want to upgrade ROCm, bump this version number and update hashes below.
+(define %rocm-version "4.3.0")
+
+(define-public rocm-cmake
+ (package
+ (name "rocm-cmake")
+ (version %rocm-version)
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/RadeonOpenCompute/rocm-cmake.git")
+ (commit (string-append "rocm-" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0sic2zxmzl2pb2865vvq55mbpcr8pby8v19pjdlm08pypqw5h6h6"))))
+ (build-system cmake-build-system)
+ (arguments `(#:tests? #f)) ; Tests try to use git commit
+ (native-inputs `(("git" ,git)))
+ (home-page "https://github.com/RadeonOpenCompute/rocm-cmake")
+ (synopsis "ROCm cmake modules")
+ (description "ROCm cmake modules provides cmake modules for common build
+tasks needed for the ROCM software stack.")
+ (license license:ncsa)))
--
2.31.1
From 2dc8ac256a1994e3072b884c616d4aeb5bbdfa28 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Fri, 6 Aug 2021 08:19:34 +0200
Subject: [PATCH 03/11] gnu: Add rocm-device-libs.

* gnu/packages/rocm.scm (rocm-device-libs): New variable.
---
gnu/packages/rocm.scm | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

Toggle diff (35 lines)
diff --git a/gnu/packages/rocm.scm b/gnu/packages/rocm.scm
index 473fbe21d0..14eaed9007 100644
--- a/gnu/packages/rocm.scm
+++ b/gnu/packages/rocm.scm
@@ -90,3 +90,28 @@ tasks needed for the ROCM software stack.")
"-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
"-DBUILD_SHARED_LIBS:BOOL=TRUE"
"-DLLVM_VERSION_SUFFIX=")))))))
+
+(define-public rocm-device-libs
+ (package
+ (name "rocm-device-libs")
+ (version %rocm-version)
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/RadeonOpenCompute/ROCm-Device-Libs.git")
+ (commit (string-append "rocm-" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1f8xsylfajpxqjk6ayjnrry53y8b0a6lh9d72pd41nffxfyzvw3w"))))
+ (build-system cmake-build-system)
+ (arguments
+ `(#:configure-flags
+ (list "-DCMAKE_SKIP_BUILD_RPATH=FALSE"
+ "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE")))
+ (inputs `(("llvm" ,llvm-for-rocm)))
+ (home-page "https://github.com/RadeonOpenCompute/ROCm-Device-Libs")
+ (synopsis "ROCm Device libraries")
+ (description "AMD-specific device-side language runtime libraries, namely
+oclc, ocml, ockl, opencl, hip and hc.")
+ (license license:ncsa)))
--
2.31.1
From 588e8c6636fe6e9dad2845ff7ffa6a88cfe3bd07 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Fri, 6 Aug 2021 08:21:20 +0200
Subject: [PATCH 04/11] gnu: Add rocm-comgr.

* gnu/packages/rocm.scm (rocm-comgr): New variable.
* gnu/packages/patches/rocm-comgr-3.1.0-dependencies.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
---
gnu/local.mk | 1 +
.../rocm-comgr-3.1.0-dependencies.patch | 52 +++++++++++++++++++
gnu/packages/rocm.scm | 33 ++++++++++++
3 files changed, 86 insertions(+)
create mode 100644 gnu/packages/patches/rocm-comgr-3.1.0-dependencies.patch

Toggle diff (113 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index ac9f1d6154..db1f8e499d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1698,6 +1698,7 @@ dist_patch_DATA = \
%D%/packages/patches/rnp-add-version.cmake.patch \
%D%/packages/patches/rnp-disable-ruby-rnp-tests.patch \
%D%/packages/patches/rnp-unbundle-googletest.patch \
+ %D%/packages/patches/rocm-comgr-3.1.0-dependencies.patch \
%D%/packages/patches/ruby-sanitize-system-libxml.patch \
%D%/packages/patches/rust-1.19-mrustc.patch \
%D%/packages/patches/rust-1.25-accept-more-detailed-gdb-lines.patch \
diff --git a/gnu/packages/patches/rocm-comgr-3.1.0-dependencies.patch b/gnu/packages/patches/rocm-comgr-3.1.0-dependencies.patch
new file mode 100644
index 0000000000..c91d273f92
--- /dev/null
+++ b/gnu/packages/patches/rocm-comgr-3.1.0-dependencies.patch
@@ -0,0 +1,52 @@
+https://github.com/RadeonOpenCompute/ROCm-CompilerSupport/pull/25
+
+From c65cba2e73f9118e128b9ab7e655ee0f8a7798e7 Mon Sep 17 00:00:00 2001
+From: Craig Andrews <candrews@integralblue.com>
+Date: Sun, 1 Mar 2020 19:24:22 -0500
+Subject: [PATCH] Link additional required LLVM libraries
+
+Without these additional required dependencies, linking fails with errors such as:
+`undefined reference to llvm::errs()'`
+---
+ CMakeLists.txt | 20 ++++++++++++++++++--
+ 1 file changed, 18 insertions(+), 2 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 1794a07..c7b852a 100644
+--- a/lib/comgr/CMakeLists.txt
++++ b/lib/comgr/CMakeLists.txt
+@@ -207,7 +207,11 @@ install(FILES
+ DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}")
+
+ set(CLANG_LIBS
+- clangFrontendTool)
++ clangFrontendTool
++ clangFrontend
++ clangBasic
++ clangDriver
++ clangSerialization)
+
+ set(LLD_LIBS
+ lldELF
+@@ -218,8 +222,20 @@ if (LLVM_LINK_LLVM_DYLIB)
+ else()
+ llvm_map_components_to_libnames(LLVM_LIBS
+ ${LLVM_TARGETS_TO_BUILD}
++ Option
+ DebugInfoDWARF
+- Symbolize)
++ Symbolize
++ Support
++ Object
++ BitWriter
++ MC
++ MCParser
++ MCDisassembler
++ Core
++ IRReader
++ CodeGen
++ Linker
++ BinaryFormat)
+ endif()
+
+ target_link_libraries(amd_comgr
diff --git a/gnu/packages/rocm.scm b/gnu/packages/rocm.scm
index 14eaed9007..92530b5d83 100644
--- a/gnu/packages/rocm.scm
+++ b/gnu/packages/rocm.scm
@@ -115,3 +115,36 @@ tasks needed for the ROCM software stack.")
(description "AMD-specific device-side language runtime libraries, namely
oclc, ocml, ockl, opencl, hip and hc.")
(license license:ncsa)))
+
+(define-public rocm-comgr
+ (package
+ (name "rocm-comgr")
+ (version %rocm-version)
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/RadeonOpenCompute/ROCm-CompilerSupport.git")
+ (commit (string-append "rocm-" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0bakbm7shr0l67lph44b5cnc9psd6rivg1mp79qizaawkn380x60"))
+ (patches
+ (search-patches "rocm-comgr-3.1.0-dependencies.patch"))))
+ (build-system cmake-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda* (#:key inputs native-inputs #:allow-other-keys)
+ (chdir "lib/comgr")
+ #t)))))
+ (inputs
+ `(("rocm-device-libs" ,rocm-device-libs)
+ ("llvm" ,llvm-for-rocm)
+ ("lld" ,lld)))
+ (home-page "https://github.com/RadeonOpenCompute/ROCm-CompilerSupport")
+ (synopsis "ROCm Code Object Manager")
+ (description "The Comgr library provides APIs for compiling and inspecting
+AMDGPU code objects.")
+ (license license:ncsa)))
--
2.31.1
From a2f768e7d53a58d3d94a072fc87f5516b8c84c86 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Fri, 6 Aug 2021 08:23:53 +0200
Subject: [PATCH 05/11] gnu: Add roct-thunk-interface.

* gnu/packages/rocm.scm (roct-thunk-interface): New variable.
---
gnu/packages/rocm.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

Toggle diff (32 lines)
diff --git a/gnu/packages/rocm.scm b/gnu/packages/rocm.scm
index 92530b5d83..21b7e43d2b 100644
--- a/gnu/packages/rocm.scm
+++ b/gnu/packages/rocm.scm
@@ -148,3 +148,25 @@ oclc, ocml, ockl, opencl, hip and hc.")
(description "The Comgr library provides APIs for compiling and inspecting
AMDGPU code objects.")
(license license:ncsa)))
+
+(define-public roct-thunk-interface
+ (package
+ (name "roct-thunk-interface")
+ (version %rocm-version)
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface.git")
+ (commit (string-append "rocm-" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0ffqhrrscmcydfqf61dk58d7nnxk6n2k68jhqfj7a4hvhlphb74f"))))
+ (build-system cmake-build-system)
+ (arguments `(#:tests? #f)) ; Not sure how to run tests.
+ (inputs `(("numactl" ,numactl)))
+ (home-page "https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface")
+ (synopsis "Radeon Open Compute Thunk Interface")
+ (description "User-mode API interfaces used to interact with the ROCk
+driver.")
+ (license license:ncsa)))
--
2.31.1
From d0537f8c11f59a0b0793f8763f913a9b88fe46df Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Fri, 6 Aug 2021 08:24:44 +0200
Subject: [PATCH 06/11] gnu: Add rocr-runtime.

* gnu/packages/rocm.scm (rocr-runtime): New variable.
---
gnu/packages/rocm.scm | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)

Toggle diff (50 lines)
diff --git a/gnu/packages/rocm.scm b/gnu/packages/rocm.scm
index 21b7e43d2b..86b113ce42 100644
--- a/gnu/packages/rocm.scm
+++ b/gnu/packages/rocm.scm
@@ -170,3 +170,43 @@ AMDGPU code objects.")
(description "User-mode API interfaces used to interact with the ROCk
driver.")
(license license:ncsa)))
+
+(define-public rocr-runtime
+ (package
+ (name "rocr-runtime")
+ (version %rocm-version)
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/RadeonOpenCompute/ROCR-Runtime.git")
+ (commit (string-append "rocm-" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0jqfqf5ymwlbpac065bhigmkgsk7mbyimdgvca7ymn38wpf80ka7"))))
+ (build-system cmake-build-system)
+ (arguments
+ `(#:configure-flags
+ `(,(string-append
+ "-DBITCODE_DIR="
+ (assoc-ref %build-inputs "rocm-device-libs")
+ "/amdgcn/bitcode/"))
+ #:tests? #f ; No tests.
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda* (#:key inputs native-inputs #:allow-other-keys)
+ (chdir "src")
+ #t)))))
+ (inputs
+ `(("libelf" ,libelf)
+ ("numactl" ,numactl)
+ ("llvm" ,llvm-for-rocm)
+ ("roct-thunk-interface" ,roct-thunk-interface)
+ ("rocm-device-libs" ,rocm-device-libs))) ; For bitcode.
+ (native-inputs `(("xxd" ,xxd)))
+ (home-page "https://github.com/RadeonOpenCompute/ROCR-Runtime")
+ (synopsis "ROCm Platform Runtime")
+ (description "User-mode API interfaces and libraries necessary for host
+applications to launch compute kernels to available HSA ROCm kernel agents.")
+ (license license:ncsa)))
--
2.31.1
From 0b0b8ef438d2adf5900e0e4e7be4da032a502821 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Fri, 6 Aug 2021 08:25:38 +0200
Subject: [PATCH 07/11] gnu: Add rocclr.

* gnu/packages/rocm.scm (rocclr): New variable.
---
gnu/packages/rocm.scm | 45 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)

Toggle diff (55 lines)
diff --git a/gnu/packages/rocm.scm b/gnu/packages/rocm.scm
index 86b113ce42..3538208577 100644
--- a/gnu/packages/rocm.scm
+++ b/gnu/packages/rocm.scm
@@ -210,3 +210,48 @@ driver.")
(description "User-mode API interfaces and libraries necessary for host
applications to launch compute kernels to available HSA ROCm kernel agents.")
(license license:ncsa)))
+
+(define-public rocclr
+ (package
+ (name "rocclr")
+ (version %rocm-version)
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/ROCm-Developer-Tools/ROCclr.git")
+ (commit (string-append "rocm-" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1pm1y020zriz7zmi95w0rcpka0jrsc7wwh81sssnysi8wxk3nnfy"))))
+ (build-system cmake-build-system)
+ (arguments
+ `(#:tests? #f ; No tests.
+ #:configure-flags
+ `(,(string-append
+ "-DOPENCL_DIR="
+ (assoc-ref %build-inputs "rocm-opencl-runtime-src")))))
+ (inputs
+ `(("mesa" ,mesa)
+ ("rocm-comgr" ,rocm-comgr)
+ ("llvm" ,llvm-for-rocm)
+ ("rocm-device-libs" ,rocm-device-libs)
+ ("rocr-runtime" ,rocr-runtime)
+ ("rocm-cmake" ,rocm-cmake)
+ ;; rocclr depends on a few headers provided by rocm-opencl-runtime.
+ ("rocm-opencl-runtime-src"
+ ,(origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime.git")
+ (commit (string-append "rocm-" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1cglpiaj3ny1z74ssmy6j63vj92sfy4q38ix6qsga0mg3b2wvqz3"))))))
+ (home-page "https://github.com/ROCm-Developer-Tools/ROCclr")
+ (synopsis "Radeon Open Compute Common Language Runtime")
+ (description "ROCclr is a virtual device interface that compute runtimes
+interact with to different backends such as ROCr or PAL. This abstraction
+allows runtimes to work on Windows as well as on Linux without much effort.")
+ (license license:ncsa)))
--
2.31.1
From cdfbc09ae5ceb21357aeaaece3676afbcf3442b4 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Fri, 6 Aug 2021 08:29:12 +0200
Subject: [PATCH 09/11] gnu: Add rocminfo.

* gnu/packages/rocm.scm (rocminfo): New variable.
---
gnu/packages/rocm.scm | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

Toggle diff (31 lines)
diff --git a/gnu/packages/rocm.scm b/gnu/packages/rocm.scm
index 8cc0eff9e3..95b586c640 100644
--- a/gnu/packages/rocm.scm
+++ b/gnu/packages/rocm.scm
@@ -306,3 +306,24 @@ allows runtimes to work on Windows as well as on Linux without much effort.")
(description "OpenCL 2.0 compatible language runtime, supporting offline
and in-process/in-memory compilation.")
(license license:ncsa)))
+
+(define-public rocminfo
+ (package
+ (name "rocminfo")
+ (version %rocm-version)
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/RadeonOpenCompute/rocminfo.git")
+ (commit (string-append "rocm-" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0pcm308vwkjrwnrk507iya20mkil8j0vx699w9jk2gas4n4jvkcz"))))
+ (build-system cmake-build-system)
+ (arguments `(#:tests? #f)) ; No tests.
+ (inputs `(("rocr-runtime" ,rocr-runtime)))
+ (home-page "https://github.com/RadeonOpenCompute/rocminfo")
+ (synopsis "ROCm Application for Reporting System Info")
+ (description #f)
+ (license license:ncsa)))
--
2.31.1
From 79680d7d55c98212e6f397c133e74d52996e31a6 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Fri, 6 Aug 2021 08:29:39 +0200
Subject: [PATCH 10/11] gnu: Add rocm-bandwidth-test.

* gnu/packages/rocm.scm (rocm-bandwidth-test): New variable.
---
gnu/packages/rocm.scm | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)

Toggle diff (36 lines)
diff --git a/gnu/packages/rocm.scm b/gnu/packages/rocm.scm
index 95b586c640..eeea66526d 100644
--- a/gnu/packages/rocm.scm
+++ b/gnu/packages/rocm.scm
@@ -327,3 +327,29 @@ and in-process/in-memory compilation.")
(synopsis "ROCm Application for Reporting System Info")
(description #f)
(license license:ncsa)))
+
+(define-public rocm-bandwidth-test
+ (package
+ (name "rocm-bandwidth-test")
+ (version %rocm-version)
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/RadeonOpenCompute/rocm_bandwidth_test.git")
+ (commit (string-append "rocm-" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0a14kwkjpiyljgzxblh031qibn6xgbxp6m12zdy1pmwb2c44jjmm"))))
+ (build-system cmake-build-system)
+ (arguments `(#:tests? #f)) ; No tests.
+ (inputs `(("rocr-runtime" ,rocr-runtime)))
+ (home-page "https://github.com/RadeonOpenCompute/rocm_bandwidth_test")
+ (synopsis "Bandwidth test for ROCm")
+ (description "RocBandwidthTest is designed to capture the performance
+characteristics of buffer copying and kernel read/write operations. The help
+screen of the benchmark shows various options one can use in initiating
+cop/read/writer operations. In addition one can also query the topology of the
+system in terms of memory pools and their agents.")
+ (license license:ncsa)))
+
--
2.31.1
From 164a786fe3bc322bdba549c6f3b8b49e7435d0f1 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Fri, 6 Aug 2021 08:30:13 +0200
Subject: [PATCH 11/11] gnu: darktable: Add compatibility for ROCm.

darktable has a few tools, which can use OpenCL, not just the main
binary. Instead of wrapping it, patch the search path. ROCm also
fails to build OpenCL kernels with just the inline keyword. Apply
upstream fix.

* gnu/packages/photo.scm (darktable) [#:phases]: Add new phases, remove
LD_LIBRARY_PATH from wrap-binary.
---
gnu/packages/photo.scm | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)

Toggle diff (44 lines)
diff --git a/gnu/packages/photo.scm b/gnu/packages/photo.scm
index 3ef0fbf7f5..bf51e6885f 100644
--- a/gnu/packages/photo.scm
+++ b/gnu/packages/photo.scm
@@ -486,6 +486,24 @@ photographic equipment.")
"-DBUILD_TESTING=On")
#:phases
(modify-phases %standard-phases
+ (add-after 'unpack 'libOpenCL-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; Statically link to libOpenCL.
+ (substitute* "./src/common/dlopencl.c"
+ (("\"libOpenCL\"")
+ (string-append "\"" (assoc-ref inputs "ocl-icd") "/lib/libOpenCL.so\"")))
+ #t))
+ ;; The use of inline is wrong and darktable cannot compile its kernels
+ ;; with ROCm. See upstream commit
+ ;; https://github.com/darktable-org/darktable/commit/f0d8710f5ef34eb7e33b4064e022ebf3057b9e53
+ (add-after 'unpack 'opencl-inline
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; This is a feature of OpenCL 1.2 and later.
+ (substitute* "data/kernels/CMakeLists.txt"
+ (("CL1\\.1") "CL1.2"))
+ (substitute* (find-files "data/kernels" "\\.(cl|h)$")
+ (("inline") "static inline"))
+ #t))
(add-before 'configure 'prepare-build-environment
(lambda* (#:key inputs #:allow-other-keys)
;; Rawspeed fails to build with GCC due to OpenMP error:
@@ -516,11 +534,7 @@ photographic equipment.")
;; For GtkFileChooserDialog.
`("GSETTINGS_SCHEMA_DIR" =
(,(string-append (assoc-ref inputs "gtk+")
- "/share/glib-2.0/schemas")))
- ;; For libOpenCL.so.
- `("LD_LIBRARY_PATH" =
- (,(string-append (assoc-ref inputs "ocl-icd")
- "/lib"))))
+ "/share/glib-2.0/schemas"))))
#t)))))
(native-inputs
`(("clang" ,clang-11)
--
2.31.1
L
L
Lars-Dominik Braun wrote on 8 Aug 2021 16:59
Re: [PATCH 00/11] AMD ROCm OpenCL runtime
(address . 49907-done@debbugs.gnu.org)
YQ/xOfH0zI0qVX6L@noor.fritz.box
Hi,

pushed after review from Rekado and with minor changes as
e81cf4e79a6e297db0ae2a9c39eab495e7e204f0 and before.

Cheers,
Lars
Closed
?