gnu: llvm-for-rocm: Move to llvm.scm.
[jackhill/guix/guix.git] / gnu / packages / rocm.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2021 Lars-Dominik Braun <lars@6xq.net>
3 ;;;
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.
8 ;;;
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.
13 ;;;
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/>.
16
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))
32
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")
36
37 (define-public rocm-cmake
38 (package
39 (name "rocm-cmake")
40 (version %rocm-version)
41 (source (origin
42 (method git-fetch)
43 (uri (git-reference
44 (url "https://github.com/RadeonOpenCompute/rocm-cmake.git")
45 (commit (string-append "rocm-" version))))
46 (file-name (git-file-name name version))
47 (sha256
48 (base32
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)))
58
59 (define-public rocm-device-libs
60 (package
61 (name "rocm-device-libs")
62 (version %rocm-version)
63 (source (origin
64 (method git-fetch)
65 (uri (git-reference
66 (url "https://github.com/RadeonOpenCompute/ROCm-Device-Libs.git")
67 (commit (string-append "rocm-" version))))
68 (file-name (git-file-name name version))
69 (sha256
70 (base32
71 "1f8xsylfajpxqjk6ayjnrry53y8b0a6lh9d72pd41nffxfyzvw3w"))))
72 (build-system cmake-build-system)
73 (arguments
74 `(#:configure-flags
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)))
83
84 (define-public rocm-comgr
85 (package
86 (name "rocm-comgr")
87 (version %rocm-version)
88 (source (origin
89 (method git-fetch)
90 (uri (git-reference
91 (url "https://github.com/RadeonOpenCompute/ROCm-CompilerSupport.git")
92 (commit (string-append "rocm-" version))))
93 (file-name (git-file-name name version))
94 (sha256
95 (base32
96 "0bakbm7shr0l67lph44b5cnc9psd6rivg1mp79qizaawkn380x60"))
97 (patches
98 (search-patches "rocm-comgr-3.1.0-dependencies.patch"))))
99 (build-system cmake-build-system)
100 (arguments
101 `(#:phases
102 (modify-phases %standard-phases
103 (add-after 'unpack 'chdir
104 (lambda _
105 (chdir "lib/comgr"))))))
106 (inputs
107 `(("rocm-device-libs" ,rocm-device-libs)
108 ("llvm" ,llvm-for-rocm)
109 ("lld" ,lld)))
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)))
115
116 (define-public roct-thunk-interface
117 (package
118 (name "roct-thunk-interface")
119 (version %rocm-version)
120 (source (origin
121 (method git-fetch)
122 (uri (git-reference
123 (url "https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface.git")
124 (commit (string-append "rocm-" version))))
125 (file-name (git-file-name name version))
126 (sha256
127 (base32
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
135 driver.")
136 (license license:ncsa)))
137
138 (define-public rocr-runtime
139 (package
140 (name "rocr-runtime")
141 (version %rocm-version)
142 (source (origin
143 (method git-fetch)
144 (uri (git-reference
145 (url "https://github.com/RadeonOpenCompute/ROCR-Runtime.git")
146 (commit (string-append "rocm-" version))))
147 (file-name (git-file-name name version))
148 (sha256
149 (base32
150 "0jqfqf5ymwlbpac065bhigmkgsk7mbyimdgvca7ymn38wpf80ka7"))))
151 (build-system cmake-build-system)
152 (arguments
153 `(#:configure-flags
154 `(,(string-append
155 "-DBITCODE_DIR="
156 (assoc-ref %build-inputs "rocm-device-libs")
157 "/amdgcn/bitcode/"))
158 #:tests? #f ; No tests.
159 #:phases
160 (modify-phases %standard-phases
161 (add-after 'unpack 'chdir
162 (lambda _
163 (chdir "src"))))))
164 (inputs
165 `(("libelf" ,libelf)
166 ("numactl" ,numactl)
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)))
176
177 (define-public rocclr
178 (package
179 (name "rocclr")
180 (version %rocm-version)
181 (source (origin
182 (method git-fetch)
183 (uri (git-reference
184 (url "https://github.com/ROCm-Developer-Tools/ROCclr.git")
185 (commit (string-append "rocm-" version))))
186 (file-name (git-file-name name version))
187 (sha256
188 (base32
189 "1pm1y020zriz7zmi95w0rcpka0jrsc7wwh81sssnysi8wxk3nnfy"))))
190 (build-system cmake-build-system)
191 (arguments
192 `(#:tests? #f ; No tests.
193 #:configure-flags
194 `(,(string-append
195 "-DOPENCL_DIR="
196 (assoc-ref %build-inputs "rocm-opencl-runtime-src")))))
197 (inputs
198 `(("mesa" ,mesa)
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"
206 ,(origin
207 (method git-fetch)
208 (uri (git-reference
209 (url "https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime.git")
210 (commit (string-append "rocm-" version))))
211 (file-name (git-file-name name version))
212 (sha256
213 (base32
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)))
221
222 (define-public rocm-opencl-runtime
223 (package
224 (name "rocm-opencl-runtime")
225 (version %rocm-version)
226 (home-page "https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime")
227 (source (origin
228 (method git-fetch)
229 (uri (git-reference
230 (url home-page)
231 (commit (string-append "rocm-" version))))
232 (file-name (git-file-name name version))
233 (sha256
234 (base32
235 "1cglpiaj3ny1z74ssmy6j63vj92sfy4q38ix6qsga0mg3b2wvqz3"))
236 (patches
237 (search-patches
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)
246 (arguments
247 `(#:tests? #f ; Not sure how to run them.
248 #:phases
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")))
257 (mkdir-p vendors)
258 (with-output-to-file (string-append vendors "/amdocl64.icd")
259 (lambda _ (display sopath)))))))))
260 (inputs
261 `(("mesa" ,mesa)
262 ("rocm-comgr" ,rocm-comgr)
263 ("rocr-runtime" ,rocr-runtime)
264 ("rocclr" ,rocclr)
265 ("opencl-icd-loader" ,opencl-icd-loader)
266 ("glew" ,glew)))
267 (native-inputs `())
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)))
272
273 (define-public rocminfo
274 (package
275 (name "rocminfo")
276 (version %rocm-version)
277 (source (origin
278 (method git-fetch)
279 (uri (git-reference
280 (url "https://github.com/RadeonOpenCompute/rocminfo.git")
281 (commit (string-append "rocm-" version))))
282 (file-name (git-file-name name version))
283 (sha256
284 (base32
285 "0pcm308vwkjrwnrk507iya20mkil8j0vx699w9jk2gas4n4jvkcz"))))
286 (build-system cmake-build-system)
287 (arguments
288 `(#:tests? #f ; No tests.
289 #:phases
290 (modify-phases %standard-phases
291 (add-after 'unpack 'patch-binary-paths
292 (lambda* (#:key inputs #:allow-other-keys)
293 (substitute* "rocminfo.cc"
294 (("lsmod")
295 (string-append (assoc-ref inputs "kmod") "/bin/lsmod"))
296 (("grep") (which "grep"))))))))
297 (inputs
298 `(("rocr-runtime" ,rocr-runtime)
299 ("kmod" ,kmod)))
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)))
305
306 (define-public rocm-bandwidth-test
307 (package
308 (name "rocm-bandwidth-test")
309 (version %rocm-version)
310 (source (origin
311 (method git-fetch)
312 (uri (git-reference
313 (url "https://github.com/RadeonOpenCompute/rocm_bandwidth_test.git")
314 (commit (string-append "rocm-" version))))
315 (file-name (git-file-name name version))
316 (sha256
317 (base32
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)))
330