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>
5 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
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
51 (define-public opencl-headers
53 (name "opencl-headers")
54 (version "2020.12.18")
59 (url "https://github.com/KhronosGroup/OpenCL-Headers")
60 (commit (string-append "v" version))))
61 (file-name (git-file-name name version))
63 (base32 "1zslxfzvbb1mrzmsik4pjzj88ds8y3p94ry5nnrnkhv6qm4n4lw9"))))
64 (build-system copy-build-system)
67 '(("CL" "include/")))) ; TODO: add phase for tests
68 (synopsis "The Khronos OpenCL headers")
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)))
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-"
79 subversion) opencl-headers))
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"))
94 (define-public opencl-clhpp
102 (url "https://github.com/KhronosGroup/OpenCL-CLHPP")
103 (commit (string-append "v" version))))
105 (base32 "0h5kpg5cl8wzfnqmv6i26aig2apv06ffm9p3rh35938n9r8rladm"))
106 (file-name (git-file-name name version))))
108 `(("python" ,python-wrapper)))
110 `(("opencl-headers" ,opencl-headers)))
113 (let ((out (assoc-ref %outputs "out")))
115 "-DBUILD_EXAMPLES=OFF"
117 (string-append "-DCMAKE_INSTALL_PREFIX="
118 (assoc-ref %outputs "out")
120 ;; The regression tests require a lot more dependencies.
122 (build-system cmake-build-system)
123 (home-page "https://github.khronos.org/OpenCL-CLHPP/")
124 (synopsis "Khronos OpenCL-CLHPP")
126 "This package provides the @dfn{host API} C++ headers for OpenCL.")
127 (license license:expat)))
129 (define-public ocl-icd
136 "https://forge.imag.fr/frs/download.php/836/ocl-icd-"
138 (file-name (string-append name "-" version ".tar.gz"))
141 "1x2dr8p4dkfds56r38av360i3nv1y3326jmshxvjngaf6mlg6rbn"))
142 (modules '((guix build utils)))
144 '(delete-file-recursively "khronos-headers"))))
146 `(("opencl-headers" ,opencl-headers)
149 `(("libgcrypt" ,libgcrypt)))
150 (build-system gnu-build-system)
152 '(#:configure-flags '("DEBUG_OCL_ICD=1")))
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)")
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)))
166 (define-public clinfo
169 (version "2.2.18.04.06")
174 (url "https://github.com/Oblomov/clinfo")
176 (file-name (git-file-name name version))
178 (base32 "0y2q0lz5yzxy970b7w7340vp4fl25vndahsyvvrywcrn51ipgplx"))))
179 (build-system gnu-build-system)
181 `(("opencl-headers" ,opencl-headers)))
183 `(("ocl-icd" ,ocl-icd)))
186 (modify-phases %standard-phases
190 (let ((cores (number->string (parallel-job-count))))
192 (invoke "make" "-j" cores))))
194 (lambda* (#:key outputs #:allow-other-keys)
195 (invoke "make" "install" (string-append
197 (assoc-ref outputs "out"))))))
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.
203 "This package provides the @command{clinfo} command that enumerates all
204 possible (known) properties of the OpenCL platform and devices available on
206 (license license:cc0)))
208 (define-public beignet
216 (url "https://github.com/intel/beignet")
217 (commit (string-append "Release_v" version))))
218 (file-name (git-file-name name version))
220 (base32 "0lpv3lvi2vrmzb8blflrpbd3jgin76zqmz6jcv17vn9mylqdrfnd"))
221 (patches (search-patches "beignet-correct-file-names.patch"))
222 (modules '((guix build utils)))
224 ;; There's a suspicious .isa binary file under kernels/.
226 '(for-each delete-file (find-files "." "\\.isa$")))))
227 (native-inputs `(("pkg-config" ,pkg-config)
229 (inputs `(("clang@3.7" ,clang-3.7)
230 ("clang-runtime@3.7" ,clang-runtime-3.7)
232 ("llvm@3.7" ,llvm-3.7)
235 ("libpthread-stubs" ,libpthread-stubs)
238 ("libxfixes" ,libxfixes)
240 ("mesa-utils" ,mesa-utils)
243 ("opencl-headers" ,opencl-headers)
244 ("xextproto" ,xextproto)
246 (build-system cmake-build-system)
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")
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"))
262 (add-after 'remove-headers 'install-kernels
263 (lambda* (#:key outputs #:allow-other-keys)
264 (let* ((out (assoc-ref outputs "out"))
266 (source-dir (string-append
268 "/../beignet-Release_v1.3.2/kernels")))
269 (copy-recursively source-dir
270 (string-append out "/lib/beignet/kernels"))
272 ;; Beignet tries to find GPU when running tests, which is not available
275 (home-page "https://wiki.freedesktop.org/www/Software/Beignet/")
276 (synopsis "OpenCL framework for Intel GPUs")
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+)))
296 (url "https://github.com/pocl/pocl")
297 (commit (string-append "v" version))))
299 (base32 "1c4y69zks6hkq5fqh9waxgb8g4ka7y6h3vacmsm720kba0h57g8a"))
300 (file-name (git-file-name name version))))
301 (build-system cmake-build-system)
303 `(("libltdl" ,libltdl)
304 ("pkg-config" ,pkg-config)))
307 ("hwloc" ,hwloc-2 "lib")
309 ("ocl-icd" ,ocl-icd)))
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"))
319 (modify-phases %standard-phases
320 (add-before 'check 'set-HOME
322 (setenv "HOME" "/tmp")
324 (home-page "http://portablecl.org/")
325 (synopsis "Portable Computing Language (pocl), an OpenCL implementation")
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.
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
336 (license license:expat)))
338 (define-public python-pytools
340 (name "python-pytools")
345 (uri (pypi-uri "pytools" version))
347 (base32 "0q7439iy365a874ckpavx6h1mhnnngfy8nl7xj5grdd127zkknrp"))))
348 (build-system python-build-system)
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")
358 "Pytools is a bag of things that are ``missing'' from the Python standard
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.
367 Michele Simionato's decorator module
369 A time-series logging module, @code{pytools.log}.
371 Batch job submission, @code{pytools.batchjob}.
373 A lexer, @code{pytools.lex}.
375 (license license:expat)))
377 (define-public python-pyopencl
379 (name "python-pyopencl")
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.
388 (url "http://git.tiker.net/trees/pyopencl.git")
389 (commit (string-append "v" version))
391 (file-name (git-file-name name version))
394 "12q0rs8yla571vcfpsh0mfrjbdiayv0hi8r1rq0f178m3i3qjz80"))))
395 (build-system python-build-system)
397 '(#:phases (modify-phases %standard-phases
398 (add-before 'build 'set-home
400 ;; Some of the Python build scripts expect 'HOME' to be
402 (setenv "HOME" (getcwd))
405 ;; Tests in 'compyte/ndarray/setup_opencl.py' appear to rely on
406 ;; 'nvcc', which is not an option.
409 `(("opencl-headers" ,opencl-headers-1.2) ;POCL only supports OpenCL 1.2
410 ("pybind11" ,pybind11)
411 ("ocl-icd" ,ocl-icd))) ;libOpenCL
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")
422 "PyOpenCL lets you access parallel computing devices such as GPUs from
423 Python @i{via} OpenCL.")
424 (license license:expat)))