1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2021 Lars-Dominik Braun <lars@6xq.net>
4 ;;; This program is free software; you can redistribute it and/or modify it
5 ;;; under the terms of the GNU General Public License as published by
6 ;;; the Free Software Foundation; either version 3 of the License, or (at
7 ;;; your option) any later version.
9 ;;; This program is distributed in the hope that it will be useful, but
10 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ;;; GNU General Public License for more details.
14 ;;; You should have received a copy of the GNU General Public License
15 ;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
17 (define-module (gnu packages rocm)
18 #:use-module ((guix licenses) #:prefix license:)
19 #:use-module (guix packages)
20 #:use-module (guix download)
21 #:use-module (guix utils)
22 #:use-module (guix git-download)
23 #:use-module (guix build-system cmake)
24 #:use-module (gnu packages)
25 #:use-module (gnu packages elf)
26 #:use-module (gnu packages gl)
27 #:use-module (gnu packages linux)
28 #:use-module (gnu packages llvm)
29 #:use-module (gnu packages opencl)
30 #:use-module (gnu packages version-control)
31 #:use-module (gnu packages vim))
33 ;; The components are tightly integrated and can only be upgraded as a unit. If
34 ;; you want to upgrade ROCm, bump this version number and update hashes below.
35 (define %rocm-version "4.3.0")
37 (define-public rocm-cmake
40 (version %rocm-version)
44 (url "https://github.com/RadeonOpenCompute/rocm-cmake.git")
45 (commit (string-append "rocm-" version))))
46 (file-name (git-file-name name version))
49 "0sic2zxmzl2pb2865vvq55mbpcr8pby8v19pjdlm08pypqw5h6h6"))))
50 (build-system cmake-build-system)
51 (arguments `(#:tests? #f)) ; Tests try to use git commit
52 (native-inputs `(("git" ,git)))
53 (home-page "https://github.com/RadeonOpenCompute/rocm-cmake")
54 (synopsis "ROCm cmake modules")
55 (description "ROCm cmake modules provides cmake modules for common build
56 tasks needed for the ROCM software stack.")
57 (license license:ncsa)))
59 (define-public rocm-device-libs
61 (name "rocm-device-libs")
62 (version %rocm-version)
66 (url "https://github.com/RadeonOpenCompute/ROCm-Device-Libs.git")
67 (commit (string-append "rocm-" version))))
68 (file-name (git-file-name name version))
71 "1f8xsylfajpxqjk6ayjnrry53y8b0a6lh9d72pd41nffxfyzvw3w"))))
72 (build-system cmake-build-system)
75 (list "-DCMAKE_SKIP_BUILD_RPATH=FALSE"
76 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE")))
77 (inputs `(("llvm" ,llvm-for-rocm)))
78 (home-page "https://github.com/RadeonOpenCompute/ROCm-Device-Libs")
79 (synopsis "ROCm Device libraries")
80 (description "AMD-specific device-side language runtime libraries, namely
81 oclc, ocml, ockl, opencl, hip and hc.")
82 (license license:ncsa)))
84 (define-public rocm-comgr
87 (version %rocm-version)
91 (url "https://github.com/RadeonOpenCompute/ROCm-CompilerSupport.git")
92 (commit (string-append "rocm-" version))))
93 (file-name (git-file-name name version))
96 "0bakbm7shr0l67lph44b5cnc9psd6rivg1mp79qizaawkn380x60"))
98 (search-patches "rocm-comgr-3.1.0-dependencies.patch"))))
99 (build-system cmake-build-system)
102 (modify-phases %standard-phases
103 (add-after 'unpack 'chdir
105 (chdir "lib/comgr"))))))
107 `(("rocm-device-libs" ,rocm-device-libs)
108 ("llvm" ,llvm-for-rocm)
110 (home-page "https://github.com/RadeonOpenCompute/ROCm-CompilerSupport")
111 (synopsis "ROCm Code Object Manager")
112 (description "The Comgr library provides APIs for compiling and inspecting
113 AMDGPU code objects.")
114 (license license:ncsa)))
116 (define-public roct-thunk-interface
118 (name "roct-thunk-interface")
119 (version %rocm-version)
123 (url "https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface.git")
124 (commit (string-append "rocm-" version))))
125 (file-name (git-file-name name version))
128 "0ffqhrrscmcydfqf61dk58d7nnxk6n2k68jhqfj7a4hvhlphb74f"))))
129 (build-system cmake-build-system)
130 (arguments `(#:tests? #f)) ; Not sure how to run tests.
131 (inputs `(("numactl" ,numactl)))
132 (home-page "https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface")
133 (synopsis "Radeon Open Compute Thunk Interface")
134 (description "User-mode API interfaces used to interact with the ROCk
136 (license license:ncsa)))
138 (define-public rocr-runtime
140 (name "rocr-runtime")
141 (version %rocm-version)
145 (url "https://github.com/RadeonOpenCompute/ROCR-Runtime.git")
146 (commit (string-append "rocm-" version))))
147 (file-name (git-file-name name version))
150 "0jqfqf5ymwlbpac065bhigmkgsk7mbyimdgvca7ymn38wpf80ka7"))))
151 (build-system cmake-build-system)
156 (assoc-ref %build-inputs "rocm-device-libs")
158 #:tests? #f ; No tests.
160 (modify-phases %standard-phases
161 (add-after 'unpack 'chdir
167 ("llvm" ,llvm-for-rocm)
168 ("roct-thunk-interface" ,roct-thunk-interface)
169 ("rocm-device-libs" ,rocm-device-libs))) ; For bitcode.
170 (native-inputs `(("xxd" ,xxd)))
171 (home-page "https://github.com/RadeonOpenCompute/ROCR-Runtime")
172 (synopsis "ROCm Platform Runtime")
173 (description "User-mode API interfaces and libraries necessary for host
174 applications to launch compute kernels to available HSA ROCm kernel agents.")
175 (license license:ncsa)))
177 (define-public rocclr
180 (version %rocm-version)
184 (url "https://github.com/ROCm-Developer-Tools/ROCclr.git")
185 (commit (string-append "rocm-" version))))
186 (file-name (git-file-name name version))
189 "1pm1y020zriz7zmi95w0rcpka0jrsc7wwh81sssnysi8wxk3nnfy"))))
190 (build-system cmake-build-system)
192 `(#:tests? #f ; No tests.
196 (assoc-ref %build-inputs "rocm-opencl-runtime-src")))))
199 ("rocm-comgr" ,rocm-comgr)
200 ("llvm" ,llvm-for-rocm)
201 ("rocm-device-libs" ,rocm-device-libs)
202 ("rocr-runtime" ,rocr-runtime)
203 ("rocm-cmake" ,rocm-cmake)
204 ;; rocclr depends on a few headers provided by rocm-opencl-runtime.
205 ("rocm-opencl-runtime-src"
209 (url "https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime.git")
210 (commit (string-append "rocm-" version))))
211 (file-name (git-file-name name version))
214 "1cglpiaj3ny1z74ssmy6j63vj92sfy4q38ix6qsga0mg3b2wvqz3"))))))
215 (home-page "https://github.com/ROCm-Developer-Tools/ROCclr")
216 (synopsis "Radeon Open Compute Common Language Runtime")
217 (description "ROCclr is a virtual device interface that compute runtimes
218 interact with to different backends such as ROCr or PAL. This abstraction
219 allows runtimes to work on Windows as well as on Linux without much effort.")
220 (license license:ncsa)))
222 (define-public rocm-opencl-runtime
224 (name "rocm-opencl-runtime")
225 (version %rocm-version)
226 (home-page "https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime")
231 (commit (string-append "rocm-" version))))
232 (file-name (git-file-name name version))
235 "1cglpiaj3ny1z74ssmy6j63vj92sfy4q38ix6qsga0mg3b2wvqz3"))
238 "rocm-opencl-runtime-3.10.0-includes.patch"
239 ;; Do not install libOpenCL, which ocl-icd provides.
240 "rocm-opencl-runtime-4.3-noopencl.patch"
241 ;; Guix includes a program clinfo already.
242 "rocm-opencl-runtime-4.3-noclinfo.patch"
243 ;; cltrace linking fails, remove it.
244 "rocm-opencl-runtime-4.3-nocltrace.patch"))))
245 (build-system cmake-build-system)
247 `(#:tests? #f ; Not sure how to run them.
249 (modify-phases %standard-phases
250 (add-after 'install 'create-icd
251 ;; Manually install ICD, which simply consists of dumping
252 ;; the path of the .so into the correct file.
253 (lambda* (#:key outputs #:allow-other-keys)
254 (let* ((out (assoc-ref outputs "out"))
255 (vendors (string-append out "/etc/OpenCL/vendors"))
256 (sopath (string-append out "/lib/libamdocl64.so")))
258 (with-output-to-file (string-append vendors "/amdocl64.icd")
259 (lambda _ (display sopath)))))))))
262 ("rocm-comgr" ,rocm-comgr)
263 ("rocr-runtime" ,rocr-runtime)
265 ("opencl-icd-loader" ,opencl-icd-loader)
268 (synopsis "ROCm OpenCL Runtime")
269 (description "OpenCL 2.0 compatible language runtime, supporting offline
270 and in-process/in-memory compilation.")
271 (license license:ncsa)))
273 (define-public rocminfo
276 (version %rocm-version)
280 (url "https://github.com/RadeonOpenCompute/rocminfo.git")
281 (commit (string-append "rocm-" version))))
282 (file-name (git-file-name name version))
285 "0pcm308vwkjrwnrk507iya20mkil8j0vx699w9jk2gas4n4jvkcz"))))
286 (build-system cmake-build-system)
288 `(#:tests? #f ; No tests.
290 (modify-phases %standard-phases
291 (add-after 'unpack 'patch-binary-paths
292 (lambda* (#:key inputs #:allow-other-keys)
293 (substitute* "rocminfo.cc"
295 (string-append (assoc-ref inputs "kmod") "/bin/lsmod"))
296 (("grep") (which "grep"))))))))
298 `(("rocr-runtime" ,rocr-runtime)
300 (home-page "https://github.com/RadeonOpenCompute/rocminfo")
301 (synopsis "ROCm Application for Reporting System Info")
302 (description "List @acronym{HSA,Heterogeneous System Architecture} Agents
303 available to ROCm and show their properties.")
304 (license license:ncsa)))
306 (define-public rocm-bandwidth-test
308 (name "rocm-bandwidth-test")
309 (version %rocm-version)
313 (url "https://github.com/RadeonOpenCompute/rocm_bandwidth_test.git")
314 (commit (string-append "rocm-" version))))
315 (file-name (git-file-name name version))
318 "0a14kwkjpiyljgzxblh031qibn6xgbxp6m12zdy1pmwb2c44jjmm"))))
319 (build-system cmake-build-system)
320 (arguments `(#:tests? #f)) ; No tests.
321 (inputs `(("rocr-runtime" ,rocr-runtime)))
322 (home-page "https://github.com/RadeonOpenCompute/rocm_bandwidth_test")
323 (synopsis "Bandwidth test for ROCm")
324 (description "RocBandwidthTest is designed to capture the performance
325 characteristics of buffer copying and kernel read/write operations. The help
326 screen of the benchmark shows various options one can use in initiating
327 cop/read/writer operations. In addition one can also query the topology of the
328 system in terms of memory pools and their agents.")
329 (license license:ncsa)))