gnu: dnsmasq: Update to 2.87.
[jackhill/guix/guix.git] / gnu / packages / opencl.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com>
3 ;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
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)
22 #:use-module (guix build-system cmake)
23 #:use-module (guix build-system copy)
24 #:use-module (guix build-system python)
25 #:use-module (guix download)
26 #:use-module (guix utils)
27 #:use-module (guix git-download)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix packages)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages autotools)
32 #:use-module (gnu packages gl)
33 #:use-module (gnu packages gnupg)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages libedit)
36 #:use-module (gnu packages llvm)
37 #:use-module (gnu packages mpi)
38 #:use-module (gnu packages ncurses)
39 #:use-module (gnu packages pkg-config)
40 #:use-module (gnu packages python)
41 #:use-module (gnu packages python-xyz)
42 #:use-module (gnu packages ruby)
43 #:use-module (gnu packages video)
44 #:use-module (gnu packages xdisorg)
45 #:use-module (gnu packages xorg))
46
47 ;; This file adds OpenCL implementation related packages. Due to the fact that
48 ;; OpenCL devices like GPU are not available during build (store environment),
49 ;; tests that require such devices are all disabled.
50 ;; Check https://lists.gnu.org/archive/html/guix-devel/2018-04/msg00293.html
51
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.
55 (define-public opencl-headers
56 (package
57 (name "opencl-headers")
58 (version "2021.06.30")
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
67 (base32 "1nrvx0x9r1nz1qpmzbgffnn9h9pn2fwcxsksf101bkpmqziq5lii"))))
68 (build-system cmake-build-system)
69 (arguments `(#:tests? #f)) ; Not enabled during build.
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
76 (define (make-opencl-headers major-version subversion)
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))
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
96 (define-public opencl-clhpp
97 (package
98 (name "opencl-clhpp")
99 (version "2.0.15")
100 (source
101 (origin
102 (method git-fetch)
103 (uri (git-reference
104 (url "https://github.com/KhronosGroup/OpenCL-CLHPP")
105 (commit (string-append "v" version))))
106 (sha256
107 (base32 "1wycdbvwbdn7lqdd3sby8471qg2zdisr70218ava6cfvxdsqcp83"))
108 (file-name (git-file-name name version))))
109 (native-inputs
110 `(("python" ,python-wrapper)))
111 (propagated-inputs
112 (list opencl-headers))
113 (arguments
114 `(#:configure-flags (list "-DBUILD_EXAMPLES=OFF" "-DBUILD_TESTS=OFF")
115 ;; The regression tests require a lot more dependencies.
116 #:tests? #f))
117 (build-system cmake-build-system)
118 (home-page "https://github.khronos.org/OpenCL-CLHPP/")
119 (synopsis "Khronos OpenCL-CLHPP")
120 (description
121 "This package provides the @dfn{host API} C++ headers for OpenCL.")
122 (license license:expat)))
123
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 ;; Only supports a single directory.
144 (separator #f))))
145 (home-page "https://github.com/KhronosGroup/OpenCL-ICD-Loader")
146 (inputs (list opencl-headers))
147 (synopsis "OpenCL Installable Client Driver")
148 (description
149 "OpenCL defines an Installable Client Driver (ICD) mechanism to allow
150 developers to build applications against an Installable Client Driver loader
151 (ICD loader) rather than linking their applications against a specific OpenCL
152 implementation. The ICD Loader is responsible for:
153
154 @itemize
155 @item Exporting OpenCL API entry points
156 @item Enumerating OpenCL implementations
157 @item Forwarding OpenCL API calls to the correct implementation
158 @end itemize
159
160 This package contains the Khronos official OpenCL ICD Loader.")
161 (license license:asl2.0)))
162
163 (define-public ocl-icd
164 (deprecated-package "ocl-icd" opencl-icd-loader))
165
166 (define-public clinfo
167 (package
168 (name "clinfo")
169 (version "3.0.21.02.21")
170 (source
171 (origin
172 (method git-fetch)
173 (uri (git-reference
174 (url "https://github.com/Oblomov/clinfo")
175 (commit version)))
176 (file-name (git-file-name name version))
177 (sha256
178 (base32 "1sfxp6ai83i0vwdg7b05h0k07q6873q1z1avnyksj5zmzdnxya6j"))))
179 (build-system gnu-build-system)
180 (native-inputs
181 (list opencl-headers))
182 (inputs
183 (list opencl-icd-loader))
184 (arguments
185 `(#:make-flags
186 (list ,(string-append "CC=" (cc-for-target))
187 (string-append "PREFIX=" (assoc-ref %outputs "out")))
188 #:phases (modify-phases %standard-phases (delete 'configure))
189 #:tests? #f))
190 (home-page "https://github.com/Oblomov/clinfo")
191 (synopsis "Print information about OpenCL platforms and devices")
192 ;; Only the implementation installed via Guix will be detected.
193 (description
194 "This package provides the @command{clinfo} command that enumerates all
195 possible (known) properties of the OpenCL platform and devices available on
196 the system.")
197 (license license:cc0)))
198
199 (define-public beignet
200 (package
201 (name "beignet")
202 (version "1.3.2")
203 (source
204 (origin
205 (method git-fetch)
206 (uri (git-reference
207 (url "https://github.com/intel/beignet")
208 (commit (string-append "Release_v" version))))
209 (file-name (git-file-name name version))
210 (sha256
211 (base32 "0lpv3lvi2vrmzb8blflrpbd3jgin76zqmz6jcv17vn9mylqdrfnd"))
212 (patches (search-patches "beignet-correct-file-names.patch"))
213 (modules '((guix build utils)))
214 (snippet
215 ;; There's a suspicious .isa binary file under kernels/.
216 ;; Remove it.
217 '(for-each delete-file (find-files "." "\\.isa$")))))
218 (native-inputs (list pkg-config python))
219 (inputs `(("clang@3.7" ,clang-3.7)
220 ("clang-runtime@3.7" ,clang-runtime-3.7)
221 ("glu" ,glu)
222 ("llvm@3.7" ,llvm-3.7)
223 ("libdrm" ,libdrm)
224 ("libedit" ,libedit)
225 ("libpthread-stubs" ,libpthread-stubs)
226 ("libsm" ,libsm)
227 ("libva" ,libva)
228 ("libxfixes" ,libxfixes)
229 ("libxext" ,libxext)
230 ("mesa-utils" ,mesa-utils)
231 ("ncurses" ,ncurses)
232 ("opencl-icd-loader" ,opencl-icd-loader)
233 ("opencl-headers" ,opencl-headers)
234 ("xextproto" ,xextproto)
235 ("zlib" ,zlib)))
236 (build-system cmake-build-system)
237 (arguments
238 `(#:configure-flags
239 (list (string-append "-DCLANG_LIBRARY_DIR="
240 (assoc-ref %build-inputs "clang@3.7") "/lib")
241 "-DENABLE_GL_SHARING=ON"
242 "-DEXPERIMENTAL_DOUBLE=ON")
243
244 #:phases
245 (modify-phases %standard-phases
246 (add-after 'install 'remove-headers
247 (lambda* (#:key outputs #:allow-other-keys)
248 (let ((out (assoc-ref outputs "out")))
249 (delete-file-recursively
250 (string-append out "/include"))
251 #t)))
252 (add-after 'remove-headers 'install-kernels
253 (lambda* (#:key outputs #:allow-other-keys)
254 (let* ((out (assoc-ref outputs "out"))
255 (builddir (getcwd))
256 (source-dir (string-append
257 builddir
258 "/../beignet-Release_v1.3.2/kernels")))
259 (copy-recursively source-dir
260 (string-append out "/lib/beignet/kernels"))
261 #t))))
262 ;; Beignet tries to find GPU when running tests, which is not available
263 ;; during build.
264 #:tests? #f))
265 (home-page "https://wiki.freedesktop.org/www/Software/Beignet/")
266 (synopsis "OpenCL framework for Intel GPUs")
267 (description
268 "Beignet is an implementation of the OpenCL specification. This code
269 base contains the code to run OpenCL programs on Intel GPUs---IvyBridge,
270 Haswell, Skylake, Apollolake, etc. It defines and implements the OpenCL host
271 functions required to initialize the device, create the command queues, the
272 kernels and the programs, and run them on the GPU. The code also contains a
273 back-end for the LLVM compiler framework.")
274 ;; Beignet only supports Intel processors.
275 (supported-systems '("x86_64-linux" "i686-linux"))
276 (license license:lgpl2.1+)))
277
278 (define-public pocl
279 (package
280 (name "pocl")
281 (version "1.4")
282 (source
283 (origin
284 (method git-fetch)
285 (uri (git-reference
286 (url "https://github.com/pocl/pocl")
287 (commit (string-append "v" version))))
288 (sha256
289 (base32 "1c4y69zks6hkq5fqh9waxgb8g4ka7y6h3vacmsm720kba0h57g8a"))
290 (file-name (git-file-name name version))))
291 (build-system cmake-build-system)
292 (native-inputs
293 (list libltdl pkg-config))
294 (inputs
295 (list clang-9 llvm-9 `(,hwloc-2 "lib") opencl-icd-loader))
296 (arguments
297 `(#:configure-flags
298 (list "-DENABLE_ICD=ON"
299 "-DENABLE_TESTSUITES=ON"
300 ;; We are not developers, don't run conformance suite.
301 "-DENABLE_CONFORMANCE=OFF"
302 (string-append "-DEXTRA_HOST_LD_FLAGS=-L"
303 (assoc-ref %build-inputs "libc") "/lib"))
304 #:phases
305 (modify-phases %standard-phases
306 (add-before 'check 'set-HOME
307 (lambda _
308 (setenv "HOME" "/tmp")
309 #t)))))
310 (home-page "http://portablecl.org/")
311 (synopsis "Portable Computing Language (pocl), an OpenCL implementation")
312 (description
313 "Pocl is a portable implementation of the OpenCL standard (1.2 with some
314 2.0 features supported). This project seeks to improve performance
315 portability of OpenCL programs with the kernel compiler and the task run-time,
316 reducing the need for target-dependent manual optimizations.
317
318 pocl uses Clang as an OpenCL C frontend and LLVM for kernel compiler
319 implementation, and as a portability layer. Thus, if your desired target has
320 an LLVM backend, it should be able to get OpenCL support easily by using
321 pocl.")
322 (license license:expat)))
323
324 (define-public python-pytools
325 (package
326 (name "python-pytools")
327 (version "2021.2.7")
328 (source
329 (origin
330 (method url-fetch)
331 (uri (pypi-uri "pytools" version))
332 (sha256
333 (base32 "1yyr4k6sqx859gjhc02633l2vxwdnj6m2f5blmf7dgq0gzzgcf05"))))
334 (build-system python-build-system)
335 (arguments `(#:tests? #f)) ; Tests depend on packages not present in Guix.
336 (propagated-inputs
337 (list python-appdirs python-numpy))
338 (home-page "https://pypi.org/project/pytools/")
339 (synopsis "Assorted tools for Python")
340 (description
341 "Pytools is a bag of things that are ``missing'' from the Python standard
342 library:
343
344 @itemize
345 @item
346 small helper functions such as @code{len_iterable}, @code{argmin},
347 tuple generation, permutation generation, ASCII table pretty printing,
348 GvR's @code{monkeypatch_xxx} hack, the elusive @code{flatten}, and much more.
349 @item
350 Michele Simionato's decorator module
351 @item
352 A time-series logging module, @code{pytools.log}.
353 @item
354 Batch job submission, @code{pytools.batchjob}.
355 @item
356 A lexer, @code{pytools.lex}.
357 @end itemize\n")
358 (license license:expat)))
359
360 (define-public python-pyopencl
361 (package
362 (name "python-pyopencl")
363 (version "2021.2.6")
364 (source
365 (origin
366 (method git-fetch)
367 (uri (git-reference
368 (url "https://github.com/inducer/pyopencl.git")
369 (commit (string-append "v" version))
370 (recursive? #t)))
371 (file-name (git-file-name name version))
372 (sha256
373 (base32
374 "1s2cls7avxvf753zzpx422ikslaxdnm8rz58zg7mal15yak0wv2x"))))
375 (build-system python-build-system)
376 (arguments
377 `(#:tests? #f)) ; Tests cannot find pygpu_language_opencl.cpp
378 (inputs
379 (list opencl-headers pybind11 opencl-icd-loader)) ;libOpenCL
380 (propagated-inputs
381 (list python-appdirs python-numpy python-pytools python-mako))
382 (home-page "http://mathema.tician.de/software/pyopencl")
383 (synopsis "Python wrapper for OpenCL")
384 (description
385 "PyOpenCL lets you access parallel computing devices such as GPUs from
386 Python @i{via} OpenCL.")
387 (license license:expat)))