packages: 'modify-inputs' preserves and introduces input labels if needed.
[jackhill/guix/guix.git] / gnu / packages / opencl.scm
CommitLineData
7f996b4c
FT
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com>
d45cec39 3;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
7f996b4c
FT
4;;;
5;;; This file is part of GNU Guix.
6;;;
7;;; GNU Guix is free software; you can redistribute it and/or modify it
8;;; under the terms of the GNU General Public License as published by
9;;; the Free Software Foundation; either version 3 of the License, or (at
10;;; your option) any later version.
11;;;
12;;; GNU Guix is distributed in the hope that it will be useful, but
13;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;;; GNU General Public License for more details.
16;;;
17;;; You should have received a copy of the GNU General Public License
18;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20(define-module (gnu packages opencl)
21 #:use-module (guix build-system gnu)
f69c1a18 22 #:use-module (guix build-system cmake)
de84dfbe 23 #:use-module (guix build-system copy)
3f1a0f16 24 #:use-module (guix build-system python)
f69c1a18 25 #:use-module (guix download)
d8c63f87 26 #:use-module (guix utils)
7f996b4c 27 #:use-module (guix git-download)
f69c1a18 28 #:use-module ((guix licenses) #:prefix license:)
f19b2630
FT
29 #:use-module (guix packages)
30 #:use-module (gnu packages)
53fc7a09 31 #:use-module (gnu packages autotools)
f19b2630 32 #:use-module (gnu packages gl)
2a0539e2 33 #:use-module (gnu packages gnupg)
f19b2630
FT
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages libedit)
36 #:use-module (gnu packages llvm)
53fc7a09 37 #:use-module (gnu packages mpi)
f19b2630
FT
38 #:use-module (gnu packages ncurses)
39 #:use-module (gnu packages pkg-config)
2a0539e2 40 #:use-module (gnu packages python)
3f1a0f16 41 #:use-module (gnu packages python-xyz)
f19b2630
FT
42 #:use-module (gnu packages ruby)
43 #:use-module (gnu packages video)
44 #:use-module (gnu packages xdisorg)
45 #:use-module (gnu packages xorg))
7f996b4c
FT
46
47;; This file adds OpenCL implementation related packages. Due to the fact that
53fc7a09
FT
48;; OpenCL devices like GPU are not available during build (store environment),
49;; tests that require such devices are all disabled.
7f996b4c
FT
50;; Check https://lists.gnu.org/archive/html/guix-devel/2018-04/msg00293.html
51
ac52d4b9
LDB
52;; If you update either of opencl-headers, opencl-clhpp or opencl-icd-loader
53;; note that they are released together (lockstep) and must be updated
54;; together.
de84dfbe
MM
55(define-public opencl-headers
56 (package
57 (name "opencl-headers")
ac52d4b9 58 (version "2021.06.30")
de84dfbe
MM
59 (source
60 (origin
61 (method git-fetch)
62 (uri (git-reference
63 (url "https://github.com/KhronosGroup/OpenCL-Headers")
64 (commit (string-append "v" version))))
65 (file-name (git-file-name name version))
66 (sha256
ac52d4b9
LDB
67 (base32 "1nrvx0x9r1nz1qpmzbgffnn9h9pn2fwcxsksf101bkpmqziq5lii"))))
68 (build-system cmake-build-system)
69 (arguments `(#:tests? #f)) ; Not enabled during build.
de84dfbe
MM
70 (synopsis "The Khronos OpenCL headers")
71 (description
72 "This package provides the C headers by Khronos for OpenCL programming.")
73 (home-page "https://www.khronos.org/registry/OpenCL/")
74 (license license:asl2.0)))
75
7f996b4c 76(define (make-opencl-headers major-version subversion)
de84dfbe
MM
77 ;; The upstream OpenCL-Headers repository is no longer separating headers by
78 ;; version; instead, you are supposed to #define CL_TARGET_OPENCL_VERSION.
79 (deprecated-package (string-append "opencl-headers-"
80 major-version "."
81 subversion) opencl-headers))
7f996b4c
FT
82
83(define-public opencl-headers-2.2
84 (make-opencl-headers "2" "2"))
85(define-public opencl-headers-2.1
86 (make-opencl-headers "2" "1"))
87(define-public opencl-headers-2.0
88 (make-opencl-headers "2" "0"))
89(define-public opencl-headers-1.2
90 (make-opencl-headers "1" "2"))
91(define-public opencl-headers-1.1
92 (make-opencl-headers "1" "1"))
93(define-public opencl-headers-1.0
94 (make-opencl-headers "1" "0"))
95
f69c1a18
FT
96(define-public opencl-clhpp
97 (package
98 (name "opencl-clhpp")
95a86b9b 99 (version "2.0.15")
d6d9ca10
TGR
100 (source
101 (origin
102 (method git-fetch)
103 (uri (git-reference
b0e7b699 104 (url "https://github.com/KhronosGroup/OpenCL-CLHPP")
d6d9ca10
TGR
105 (commit (string-append "v" version))))
106 (sha256
95a86b9b 107 (base32 "1wycdbvwbdn7lqdd3sby8471qg2zdisr70218ava6cfvxdsqcp83"))
d6d9ca10 108 (file-name (git-file-name name version))))
f69c1a18
FT
109 (native-inputs
110 `(("python" ,python-wrapper)))
111 (propagated-inputs
112 `(("opencl-headers" ,opencl-headers)))
113 (arguments
95a86b9b 114 `(#:configure-flags (list "-DBUILD_EXAMPLES=OFF" "-DBUILD_TESTS=OFF")
d6d9ca10 115 ;; The regression tests require a lot more dependencies.
f69c1a18
FT
116 #:tests? #f))
117 (build-system cmake-build-system)
c6be7eed 118 (home-page "https://github.khronos.org/OpenCL-CLHPP/")
f69c1a18
FT
119 (synopsis "Khronos OpenCL-CLHPP")
120 (description
121 "This package provides the @dfn{host API} C++ headers for OpenCL.")
122 (license license:expat)))
2a0539e2 123
2c6c1f8d
LDB
124(define-public opencl-icd-loader
125 (package
126 (name "opencl-icd-loader")
127 (version "2021.06.30")
128 (source (origin
129 (method git-fetch)
130 (uri (git-reference
131 (url "https://github.com/KhronosGroup/OpenCL-ICD-Loader.git")
132 (commit (string-append "v" version))))
133 (file-name (git-file-name name version))
134 (sha256
135 (base32
136 "007ws357n1ijrxal1bf9lwy68p0dz1sm9cfcfnnz5f88iwc9xd6m"))))
137 (build-system cmake-build-system)
138 (arguments `(#:tests? #f)) ; Tests need stub loader setup.
139 (native-search-paths
140 (list (search-path-specification
141 (variable "OCL_ICD_VENDORS")
142 (files '("etc/OpenCL/vendors")))))
143 (home-page "https://github.com/KhronosGroup/OpenCL-ICD-Loader")
144 (inputs `(("opencl-headers" ,opencl-headers)))
145 (synopsis "OpenCL Installable Client Driver")
146 (description
147 "OpenCL defines an Installable Client Driver (ICD) mechanism to allow
148developers to build applications against an Installable Client Driver loader
149(ICD loader) rather than linking their applications against a specific OpenCL
150implementation. The ICD Loader is responsible for:
151
152@itemize
153@item Exporting OpenCL API entry points
154@item Enumerating OpenCL implementations
155@item Forwarding OpenCL API calls to the correct implementation
156@end itemize
157
158This package contains the Khronos official OpenCL ICD Loader.")
159 (license license:asl2.0)))
160
2a0539e2 161(define-public ocl-icd
4d1157fc 162 (deprecated-package "ocl-icd" opencl-icd-loader))
184a214b
FT
163
164(define-public clinfo
165 (package
166 (name "clinfo")
d8c63f87 167 (version "3.0.21.02.21")
d6d9ca10
TGR
168 (source
169 (origin
170 (method git-fetch)
171 (uri (git-reference
b0e7b699 172 (url "https://github.com/Oblomov/clinfo")
d6d9ca10
TGR
173 (commit version)))
174 (file-name (git-file-name name version))
175 (sha256
d8c63f87 176 (base32 "1sfxp6ai83i0vwdg7b05h0k07q6873q1z1avnyksj5zmzdnxya6j"))))
184a214b
FT
177 (build-system gnu-build-system)
178 (native-inputs
179 `(("opencl-headers" ,opencl-headers)))
180 (inputs
4d1157fc 181 `(("opencl-icd-loader" ,opencl-icd-loader)))
184a214b 182 (arguments
d8c63f87
LDB
183 `(#:make-flags
184 (list ,(string-append "CC=" (cc-for-target))
185 (string-append "PREFIX=" (assoc-ref %outputs "out")))
186 #:phases (modify-phases %standard-phases (delete 'configure))
184a214b
FT
187 #:tests? #f))
188 (home-page "https://github.com/Oblomov/clinfo")
189 (synopsis "Print information about OpenCL platforms and devices")
190 ;; Only the implementation installed via Guix will be detected.
191 (description
192 "This package provides the @command{clinfo} command that enumerates all
193possible (known) properties of the OpenCL platform and devices available on
194the system.")
195 (license license:cc0)))
f19b2630
FT
196
197(define-public beignet
198 (package
199 (name "beignet")
200 (version "1.3.2")
d6d9ca10
TGR
201 (source
202 (origin
203 (method git-fetch)
204 (uri (git-reference
b0e7b699 205 (url "https://github.com/intel/beignet")
d6d9ca10
TGR
206 (commit (string-append "Release_v" version))))
207 (file-name (git-file-name name version))
208 (sha256
209 (base32 "0lpv3lvi2vrmzb8blflrpbd3jgin76zqmz6jcv17vn9mylqdrfnd"))
210 (patches (search-patches "beignet-correct-file-names.patch"))
211 (modules '((guix build utils)))
212 (snippet
213 ;; There's a suspicious .isa binary file under kernels/.
214 ;; Remove it.
215 '(for-each delete-file (find-files "." "\\.isa$")))))
f19b2630
FT
216 (native-inputs `(("pkg-config" ,pkg-config)
217 ("python" ,python)))
218 (inputs `(("clang@3.7" ,clang-3.7)
219 ("clang-runtime@3.7" ,clang-runtime-3.7)
220 ("glu" ,glu)
221 ("llvm@3.7" ,llvm-3.7)
222 ("libdrm" ,libdrm)
223 ("libedit" ,libedit)
b42b5afd 224 ("libpthread-stubs" ,libpthread-stubs)
f19b2630
FT
225 ("libsm" ,libsm)
226 ("libva" ,libva)
227 ("libxfixes" ,libxfixes)
228 ("libxext" ,libxext)
229 ("mesa-utils" ,mesa-utils)
230 ("ncurses" ,ncurses)
4d1157fc 231 ("opencl-icd-loader" ,opencl-icd-loader)
f19b2630
FT
232 ("opencl-headers" ,opencl-headers)
233 ("xextproto" ,xextproto)
234 ("zlib" ,zlib)))
235 (build-system cmake-build-system)
236 (arguments
237 `(#:configure-flags
238 (list (string-append "-DCLANG_LIBRARY_DIR="
239 (assoc-ref %build-inputs "clang@3.7") "/lib")
240 "-DENABLE_GL_SHARING=ON"
241 "-DEXPERIMENTAL_DOUBLE=ON")
242
243 #:phases
244 (modify-phases %standard-phases
245 (add-after 'install 'remove-headers
246 (lambda* (#:key outputs #:allow-other-keys)
247 (let ((out (assoc-ref outputs "out")))
248 (delete-file-recursively
249 (string-append out "/include"))
250 #t)))
251 (add-after 'remove-headers 'install-kernels
252 (lambda* (#:key outputs #:allow-other-keys)
253 (let* ((out (assoc-ref outputs "out"))
254 (builddir (getcwd))
255 (source-dir (string-append
256 builddir
257 "/../beignet-Release_v1.3.2/kernels")))
258 (copy-recursively source-dir
259 (string-append out "/lib/beignet/kernels"))
260 #t))))
261 ;; Beignet tries to find GPU when running tests, which is not available
262 ;; during build.
263 #:tests? #f))
264 (home-page "https://wiki.freedesktop.org/www/Software/Beignet/")
265 (synopsis "OpenCL framework for Intel GPUs")
266 (description
267 "Beignet is an implementation of the OpenCL specification. This code
268base contains the code to run OpenCL programs on Intel GPUs---IvyBridge,
269Haswell, Skylake, Apollolake, etc. It defines and implements the OpenCL host
270functions required to initialize the device, create the command queues, the
271kernels and the programs, and run them on the GPU. The code also contains a
272back-end for the LLVM compiler framework.")
35aa016a
EF
273 ;; Beignet only supports Intel processors.
274 (supported-systems '("x86_64-linux" "i686-linux"))
f19b2630 275 (license license:lgpl2.1+)))
53fc7a09
FT
276
277(define-public pocl
278 (package
279 (name "pocl")
bbad38f4 280 (version "1.4")
d6d9ca10
TGR
281 (source
282 (origin
283 (method git-fetch)
284 (uri (git-reference
b0e7b699 285 (url "https://github.com/pocl/pocl")
d6d9ca10 286 (commit (string-append "v" version))))
d6d9ca10 287 (sha256
bbad38f4 288 (base32 "1c4y69zks6hkq5fqh9waxgb8g4ka7y6h3vacmsm720kba0h57g8a"))
bfb22078 289 (file-name (git-file-name name version))))
53fc7a09
FT
290 (build-system cmake-build-system)
291 (native-inputs
292 `(("libltdl" ,libltdl)
293 ("pkg-config" ,pkg-config)))
294 (inputs
295 `(("clang" ,clang)
8c8e1089 296 ("hwloc" ,hwloc-2 "lib")
6fda3a6c 297 ("llvm" ,llvm)
4d1157fc 298 ("opencl-icd-loader" ,opencl-icd-loader)))
53fc7a09
FT
299 (arguments
300 `(#:configure-flags
301 (list "-DENABLE_ICD=ON"
302 "-DENABLE_TESTSUITES=ON"
303 ;; We are not developers, don't run conformance suite.
304 "-DENABLE_CONFORMANCE=OFF"
305 (string-append "-DEXTRA_HOST_LD_FLAGS=-L"
306 (assoc-ref %build-inputs "libc") "/lib"))
307 #:phases
308 (modify-phases %standard-phases
53fc7a09
FT
309 (add-before 'check 'set-HOME
310 (lambda _
311 (setenv "HOME" "/tmp")
312 #t)))))
313 (home-page "http://portablecl.org/")
314 (synopsis "Portable Computing Language (pocl), an OpenCL implementation")
315 (description
316 "Pocl is a portable implementation of the OpenCL standard (1.2 with some
3172.0 features supported). This project seeks to improve performance
318portability of OpenCL programs with the kernel compiler and the task run-time,
319reducing the need for target-dependent manual optimizations.
320
321pocl uses Clang as an OpenCL C frontend and LLVM for kernel compiler
322implementation, and as a portability layer. Thus, if your desired target has
323an LLVM backend, it should be able to get OpenCL support easily by using
324pocl.")
325 (license license:expat)))
3f1a0f16
LC
326
327(define-public python-pytools
328 (package
329 (name "python-pytools")
65a5eec0 330 (version "2021.2.7")
3f1a0f16
LC
331 (source
332 (origin
333 (method url-fetch)
334 (uri (pypi-uri "pytools" version))
335 (sha256
65a5eec0 336 (base32 "1yyr4k6sqx859gjhc02633l2vxwdnj6m2f5blmf7dgq0gzzgcf05"))))
3f1a0f16 337 (build-system python-build-system)
65a5eec0 338 (arguments `(#:tests? #f)) ; Tests depend on packages not present in Guix.
3f1a0f16
LC
339 (propagated-inputs
340 `(("python-appdirs" ,python-appdirs)
65a5eec0 341 ("python-numpy" ,python-numpy)))
3f1a0f16
LC
342 (home-page "https://pypi.org/project/pytools/")
343 (synopsis "Assorted tools for Python")
344 (description
345 "Pytools is a bag of things that are ``missing'' from the Python standard
346library:
347
348@itemize
349@item
350small helper functions such as @code{len_iterable}, @code{argmin},
351tuple generation, permutation generation, ASCII table pretty printing,
352GvR's @code{monkeypatch_xxx} hack, the elusive @code{flatten}, and much more.
353@item
354Michele Simionato's decorator module
355@item
356A time-series logging module, @code{pytools.log}.
357@item
358Batch job submission, @code{pytools.batchjob}.
359@item
360A lexer, @code{pytools.lex}.
361@end itemize\n")
362 (license license:expat)))
01dce79f
LC
363
364(define-public python-pyopencl
365 (package
366 (name "python-pyopencl")
9c7c3f77 367 (version "2021.2.6")
01dce79f
LC
368 (source
369 (origin
01dce79f
LC
370 (method git-fetch)
371 (uri (git-reference
9c7c3f77 372 (url "https://github.com/inducer/pyopencl.git")
01dce79f
LC
373 (commit (string-append "v" version))
374 (recursive? #t)))
375 (file-name (git-file-name name version))
376 (sha256
377 (base32
9c7c3f77 378 "1s2cls7avxvf753zzpx422ikslaxdnm8rz58zg7mal15yak0wv2x"))))
01dce79f
LC
379 (build-system python-build-system)
380 (arguments
9c7c3f77 381 `(#:tests? #f)) ; Tests cannot find pygpu_language_opencl.cpp
01dce79f 382 (inputs
9c7c3f77 383 `(("opencl-headers" ,opencl-headers)
01dce79f 384 ("pybind11" ,pybind11)
4d1157fc 385 ("opencl-icd-loader" ,opencl-icd-loader))) ;libOpenCL
01dce79f
LC
386 (propagated-inputs
387 `(("python-appdirs" ,python-appdirs)
01dce79f
LC
388 ("python-numpy" ,python-numpy)
389 ("python-pytools" ,python-pytools)
01dce79f
LC
390 ("python-mako" ,python-mako)))
391 (home-page "http://mathema.tician.de/software/pyopencl")
392 (synopsis "Python wrapper for OpenCL")
393 (description
394 "PyOpenCL lets you access parallel computing devices such as GPUs from
395Python @i{via} OpenCL.")
396 (license license:expat)))