gnu: libretro-lowresnx: Update to 1.2.
[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 git-download)
27 #:use-module ((guix licenses) #:prefix license:)
28 #:use-module (guix packages)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages autotools)
31 #:use-module (gnu packages gl)
32 #:use-module (gnu packages gnupg)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages libedit)
35 #:use-module (gnu packages llvm)
36 #:use-module (gnu packages mpi)
37 #:use-module (gnu packages ncurses)
38 #:use-module (gnu packages pkg-config)
39 #:use-module (gnu packages python)
40 #:use-module (gnu packages python-xyz)
41 #:use-module (gnu packages ruby)
42 #:use-module (gnu packages video)
43 #:use-module (gnu packages xdisorg)
44 #:use-module (gnu packages xorg))
45
46 ;; This file adds OpenCL implementation related packages. Due to the fact that
47 ;; OpenCL devices like GPU are not available during build (store environment),
48 ;; tests that require such devices are all disabled.
49 ;; Check https://lists.gnu.org/archive/html/guix-devel/2018-04/msg00293.html
50
51 (define-public opencl-headers
52 (package
53 (name "opencl-headers")
54 (version "2020.12.18")
55 (source
56 (origin
57 (method git-fetch)
58 (uri (git-reference
59 (url "https://github.com/KhronosGroup/OpenCL-Headers")
60 (commit (string-append "v" version))))
61 (file-name (git-file-name name version))
62 (sha256
63 (base32 "1zslxfzvbb1mrzmsik4pjzj88ds8y3p94ry5nnrnkhv6qm4n4lw9"))))
64 (build-system copy-build-system)
65 (arguments
66 '(#:install-plan
67 '(("CL" "include/")))) ; TODO: add phase for tests
68 (synopsis "The Khronos OpenCL headers")
69 (description
70 "This package provides the C headers by Khronos for OpenCL programming.")
71 (home-page "https://www.khronos.org/registry/OpenCL/")
72 (license license:asl2.0)))
73
74 (define (make-opencl-headers major-version subversion)
75 ;; The upstream OpenCL-Headers repository is no longer separating headers by
76 ;; version; instead, you are supposed to #define CL_TARGET_OPENCL_VERSION.
77 (deprecated-package (string-append "opencl-headers-"
78 major-version "."
79 subversion) opencl-headers))
80
81 (define-public opencl-headers-2.2
82 (make-opencl-headers "2" "2"))
83 (define-public opencl-headers-2.1
84 (make-opencl-headers "2" "1"))
85 (define-public opencl-headers-2.0
86 (make-opencl-headers "2" "0"))
87 (define-public opencl-headers-1.2
88 (make-opencl-headers "1" "2"))
89 (define-public opencl-headers-1.1
90 (make-opencl-headers "1" "1"))
91 (define-public opencl-headers-1.0
92 (make-opencl-headers "1" "0"))
93
94 (define-public opencl-clhpp
95 (package
96 (name "opencl-clhpp")
97 (version "2.0.10")
98 (source
99 (origin
100 (method git-fetch)
101 (uri (git-reference
102 (url "https://github.com/KhronosGroup/OpenCL-CLHPP")
103 (commit (string-append "v" version))))
104 (sha256
105 (base32 "0h5kpg5cl8wzfnqmv6i26aig2apv06ffm9p3rh35938n9r8rladm"))
106 (file-name (git-file-name name version))))
107 (native-inputs
108 `(("python" ,python-wrapper)))
109 (propagated-inputs
110 `(("opencl-headers" ,opencl-headers)))
111 (arguments
112 `(#:configure-flags
113 (let ((out (assoc-ref %outputs "out")))
114 (list
115 "-DBUILD_EXAMPLES=OFF"
116 "-DBUILD_TESTS=OFF"
117 (string-append "-DCMAKE_INSTALL_PREFIX="
118 (assoc-ref %outputs "out")
119 "/include")))
120 ;; The regression tests require a lot more dependencies.
121 #:tests? #f))
122 (build-system cmake-build-system)
123 (home-page "https://github.khronos.org/OpenCL-CLHPP/")
124 (synopsis "Khronos OpenCL-CLHPP")
125 (description
126 "This package provides the @dfn{host API} C++ headers for OpenCL.")
127 (license license:expat)))
128
129 (define-public ocl-icd
130 (package
131 (name "ocl-icd")
132 (version "2.2.12")
133 (source (origin
134 (method url-fetch)
135 (uri (string-append
136 "https://forge.imag.fr/frs/download.php/836/ocl-icd-"
137 version ".tar.gz"))
138 (file-name (string-append name "-" version ".tar.gz"))
139 (sha256
140 (base32
141 "1x2dr8p4dkfds56r38av360i3nv1y3326jmshxvjngaf6mlg6rbn"))
142 (modules '((guix build utils)))
143 (snippet
144 '(delete-file-recursively "khronos-headers"))))
145 (native-inputs
146 `(("opencl-headers" ,opencl-headers)
147 ("ruby" ,ruby)))
148 (inputs
149 `(("libgcrypt" ,libgcrypt)))
150 (build-system gnu-build-system)
151 (arguments
152 '(#:configure-flags '("DEBUG_OCL_ICD=1")))
153 (native-search-paths
154 (list (search-path-specification
155 (variable "OPENCL_VENDOR_PATH")
156 (files '("etc/OpenCL/vendors")))))
157 (search-paths native-search-paths)
158 (home-page "https://forge.imag.fr/projects/ocl-icd/")
159 (synopsis "OpenCL loader for Installable Client Drivers (ICDs)")
160 (description
161 "OpenCL implementations are provided as ICDs (Installable Client
162 Drivers). An OpenCL program can use several ICDs thanks to the use of an ICD
163 Loader as provided by this package.")
164 (license license:bsd-2)))
165
166 (define-public clinfo
167 (package
168 (name "clinfo")
169 (version "2.2.18.04.06")
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 "0y2q0lz5yzxy970b7w7340vp4fl25vndahsyvvrywcrn51ipgplx"))))
179 (build-system gnu-build-system)
180 (native-inputs
181 `(("opencl-headers" ,opencl-headers)))
182 (inputs
183 `(("ocl-icd" ,ocl-icd)))
184 (arguments
185 `(#:phases
186 (modify-phases %standard-phases
187 (delete 'configure)
188 (replace 'build
189 (lambda _
190 (let ((cores (number->string (parallel-job-count))))
191 (setenv "CC" "gcc")
192 (invoke "make" "-j" cores))))
193 (replace 'install
194 (lambda* (#:key outputs #:allow-other-keys)
195 (invoke "make" "install" (string-append
196 "PREFIX="
197 (assoc-ref outputs "out"))))))
198 #:tests? #f))
199 (home-page "https://github.com/Oblomov/clinfo")
200 (synopsis "Print information about OpenCL platforms and devices")
201 ;; Only the implementation installed via Guix will be detected.
202 (description
203 "This package provides the @command{clinfo} command that enumerates all
204 possible (known) properties of the OpenCL platform and devices available on
205 the system.")
206 (license license:cc0)))
207
208 (define-public beignet
209 (package
210 (name "beignet")
211 (version "1.3.2")
212 (source
213 (origin
214 (method git-fetch)
215 (uri (git-reference
216 (url "https://github.com/intel/beignet")
217 (commit (string-append "Release_v" version))))
218 (file-name (git-file-name name version))
219 (sha256
220 (base32 "0lpv3lvi2vrmzb8blflrpbd3jgin76zqmz6jcv17vn9mylqdrfnd"))
221 (patches (search-patches "beignet-correct-file-names.patch"))
222 (modules '((guix build utils)))
223 (snippet
224 ;; There's a suspicious .isa binary file under kernels/.
225 ;; Remove it.
226 '(for-each delete-file (find-files "." "\\.isa$")))))
227 (native-inputs `(("pkg-config" ,pkg-config)
228 ("python" ,python)))
229 (inputs `(("clang@3.7" ,clang-3.7)
230 ("clang-runtime@3.7" ,clang-runtime-3.7)
231 ("glu" ,glu)
232 ("llvm@3.7" ,llvm-3.7)
233 ("libdrm" ,libdrm)
234 ("libedit" ,libedit)
235 ("libpthread-stubs" ,libpthread-stubs)
236 ("libsm" ,libsm)
237 ("libva" ,libva)
238 ("libxfixes" ,libxfixes)
239 ("libxext" ,libxext)
240 ("mesa-utils" ,mesa-utils)
241 ("ncurses" ,ncurses)
242 ("ocl-icd" ,ocl-icd)
243 ("opencl-headers" ,opencl-headers)
244 ("xextproto" ,xextproto)
245 ("zlib" ,zlib)))
246 (build-system cmake-build-system)
247 (arguments
248 `(#:configure-flags
249 (list (string-append "-DCLANG_LIBRARY_DIR="
250 (assoc-ref %build-inputs "clang@3.7") "/lib")
251 "-DENABLE_GL_SHARING=ON"
252 "-DEXPERIMENTAL_DOUBLE=ON")
253
254 #:phases
255 (modify-phases %standard-phases
256 (add-after 'install 'remove-headers
257 (lambda* (#:key outputs #:allow-other-keys)
258 (let ((out (assoc-ref outputs "out")))
259 (delete-file-recursively
260 (string-append out "/include"))
261 #t)))
262 (add-after 'remove-headers 'install-kernels
263 (lambda* (#:key outputs #:allow-other-keys)
264 (let* ((out (assoc-ref outputs "out"))
265 (builddir (getcwd))
266 (source-dir (string-append
267 builddir
268 "/../beignet-Release_v1.3.2/kernels")))
269 (copy-recursively source-dir
270 (string-append out "/lib/beignet/kernels"))
271 #t))))
272 ;; Beignet tries to find GPU when running tests, which is not available
273 ;; during build.
274 #:tests? #f))
275 (home-page "https://wiki.freedesktop.org/www/Software/Beignet/")
276 (synopsis "OpenCL framework for Intel GPUs")
277 (description
278 "Beignet is an implementation of the OpenCL specification. This code
279 base contains the code to run OpenCL programs on Intel GPUs---IvyBridge,
280 Haswell, Skylake, Apollolake, etc. It defines and implements the OpenCL host
281 functions required to initialize the device, create the command queues, the
282 kernels and the programs, and run them on the GPU. The code also contains a
283 back-end for the LLVM compiler framework.")
284 ;; Beignet only supports Intel processors.
285 (supported-systems '("x86_64-linux" "i686-linux"))
286 (license license:lgpl2.1+)))
287
288 (define-public pocl
289 (package
290 (name "pocl")
291 (version "1.4")
292 (source
293 (origin
294 (method git-fetch)
295 (uri (git-reference
296 (url "https://github.com/pocl/pocl")
297 (commit (string-append "v" version))))
298 (sha256
299 (base32 "1c4y69zks6hkq5fqh9waxgb8g4ka7y6h3vacmsm720kba0h57g8a"))
300 (file-name (git-file-name name version))))
301 (build-system cmake-build-system)
302 (native-inputs
303 `(("libltdl" ,libltdl)
304 ("pkg-config" ,pkg-config)))
305 (inputs
306 `(("clang" ,clang)
307 ("hwloc" ,hwloc-2 "lib")
308 ("llvm" ,llvm)
309 ("ocl-icd" ,ocl-icd)))
310 (arguments
311 `(#:configure-flags
312 (list "-DENABLE_ICD=ON"
313 "-DENABLE_TESTSUITES=ON"
314 ;; We are not developers, don't run conformance suite.
315 "-DENABLE_CONFORMANCE=OFF"
316 (string-append "-DEXTRA_HOST_LD_FLAGS=-L"
317 (assoc-ref %build-inputs "libc") "/lib"))
318 #:phases
319 (modify-phases %standard-phases
320 (add-before 'check 'set-HOME
321 (lambda _
322 (setenv "HOME" "/tmp")
323 #t)))))
324 (home-page "http://portablecl.org/")
325 (synopsis "Portable Computing Language (pocl), an OpenCL implementation")
326 (description
327 "Pocl is a portable implementation of the OpenCL standard (1.2 with some
328 2.0 features supported). This project seeks to improve performance
329 portability of OpenCL programs with the kernel compiler and the task run-time,
330 reducing the need for target-dependent manual optimizations.
331
332 pocl uses Clang as an OpenCL C frontend and LLVM for kernel compiler
333 implementation, and as a portability layer. Thus, if your desired target has
334 an LLVM backend, it should be able to get OpenCL support easily by using
335 pocl.")
336 (license license:expat)))
337
338 (define-public python-pytools
339 (package
340 (name "python-pytools")
341 (version "2020.4")
342 (source
343 (origin
344 (method url-fetch)
345 (uri (pypi-uri "pytools" version))
346 (sha256
347 (base32 "0q7439iy365a874ckpavx6h1mhnnngfy8nl7xj5grdd127zkknrp"))))
348 (build-system python-build-system)
349 (propagated-inputs
350 `(("python-appdirs" ,python-appdirs)
351 ("python-decorator" ,python-decorator)
352 ("python-numpy" ,python-numpy)
353 ("python-six" ,python-six)
354 ("python-mpi4py" ,python-mpi4py)))
355 (home-page "https://pypi.org/project/pytools/")
356 (synopsis "Assorted tools for Python")
357 (description
358 "Pytools is a bag of things that are ``missing'' from the Python standard
359 library:
360
361 @itemize
362 @item
363 small helper functions such as @code{len_iterable}, @code{argmin},
364 tuple generation, permutation generation, ASCII table pretty printing,
365 GvR's @code{monkeypatch_xxx} hack, the elusive @code{flatten}, and much more.
366 @item
367 Michele Simionato's decorator module
368 @item
369 A time-series logging module, @code{pytools.log}.
370 @item
371 Batch job submission, @code{pytools.batchjob}.
372 @item
373 A lexer, @code{pytools.lex}.
374 @end itemize\n")
375 (license license:expat)))
376
377 (define-public python-pyopencl
378 (package
379 (name "python-pyopencl")
380 (version "2019.1.1")
381 (source
382 (origin
383 ;; The tarball on PyPI lacks test programs such as
384 ;; 'pygpu_language_opencl.cpp' so fetch it from Git.
385 ;; XXX: The server at git.tiker.net is unreliable.
386 (method git-fetch)
387 (uri (git-reference
388 (url "http://git.tiker.net/trees/pyopencl.git")
389 (commit (string-append "v" version))
390 (recursive? #t)))
391 (file-name (git-file-name name version))
392 (sha256
393 (base32
394 "12q0rs8yla571vcfpsh0mfrjbdiayv0hi8r1rq0f178m3i3qjz80"))))
395 (build-system python-build-system)
396 (arguments
397 '(#:phases (modify-phases %standard-phases
398 (add-before 'build 'set-home
399 (lambda _
400 ;; Some of the Python build scripts expect 'HOME' to be
401 ;; set.
402 (setenv "HOME" (getcwd))
403 #t)))
404
405 ;; Tests in 'compyte/ndarray/setup_opencl.py' appear to rely on
406 ;; 'nvcc', which is not an option.
407 #:tests? #f))
408 (inputs
409 `(("opencl-headers" ,opencl-headers-1.2) ;POCL only supports OpenCL 1.2
410 ("pybind11" ,pybind11)
411 ("ocl-icd" ,ocl-icd))) ;libOpenCL
412 (propagated-inputs
413 `(("python-appdirs" ,python-appdirs)
414 ("python-decorator" ,python-decorator)
415 ("python-numpy" ,python-numpy)
416 ("python-pytools" ,python-pytools)
417 ("python-six" ,python-six)
418 ("python-mako" ,python-mako)))
419 (home-page "http://mathema.tician.de/software/pyopencl")
420 (synopsis "Python wrapper for OpenCL")
421 (description
422 "PyOpenCL lets you access parallel computing devices such as GPUs from
423 Python @i{via} OpenCL.")
424 (license license:expat)))