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 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))
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
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
55 (define-public opencl-headers
57 (name "opencl-headers")
58 (version "2021.06.30")
63 (url "https://github.com/KhronosGroup/OpenCL-Headers")
64 (commit (string-append "v" version))))
65 (file-name (git-file-name name version))
67 (base32 "1nrvx0x9r1nz1qpmzbgffnn9h9pn2fwcxsksf101bkpmqziq5lii"))))
68 (build-system cmake-build-system)
69 (arguments `(#:tests? #f)) ; Not enabled during build.
70 (synopsis "The Khronos OpenCL headers")
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)))
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-"
81 subversion) opencl-headers))
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"))
96 (define-public opencl-clhpp
104 (url "https://github.com/KhronosGroup/OpenCL-CLHPP")
105 (commit (string-append "v" version))))
107 (base32 "1wycdbvwbdn7lqdd3sby8471qg2zdisr70218ava6cfvxdsqcp83"))
108 (file-name (git-file-name name version))))
110 `(("python" ,python-wrapper)))
112 (list opencl-headers))
114 `(#:configure-flags (list "-DBUILD_EXAMPLES=OFF" "-DBUILD_TESTS=OFF")
115 ;; The regression tests require a lot more dependencies.
117 (build-system cmake-build-system)
118 (home-page "https://github.khronos.org/OpenCL-CLHPP/")
119 (synopsis "Khronos OpenCL-CLHPP")
121 "This package provides the @dfn{host API} C++ headers for OpenCL.")
122 (license license:expat)))
124 (define-public opencl-icd-loader
126 (name "opencl-icd-loader")
127 (version "2021.06.30")
131 (url "https://github.com/KhronosGroup/OpenCL-ICD-Loader.git")
132 (commit (string-append "v" version))))
133 (file-name (git-file-name name version))
136 "007ws357n1ijrxal1bf9lwy68p0dz1sm9cfcfnnz5f88iwc9xd6m"))))
137 (build-system cmake-build-system)
138 (arguments `(#:tests? #f)) ; Tests need stub loader setup.
140 (list (search-path-specification
141 (variable "OCL_ICD_VENDORS")
142 (files '("etc/OpenCL/vendors"))
143 ;; Only supports a single directory.
145 (home-page "https://github.com/KhronosGroup/OpenCL-ICD-Loader")
146 (inputs (list opencl-headers))
147 (synopsis "OpenCL Installable Client Driver")
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:
155 @item Exporting OpenCL API entry points
156 @item Enumerating OpenCL implementations
157 @item Forwarding OpenCL API calls to the correct implementation
160 This package contains the Khronos official OpenCL ICD Loader.")
161 (license license:asl2.0)))
163 (define-public ocl-icd
164 (deprecated-package "ocl-icd" opencl-icd-loader))
166 (define-public clinfo
169 (version "3.0.21.02.21")
174 (url "https://github.com/Oblomov/clinfo")
176 (file-name (git-file-name name version))
178 (base32 "1sfxp6ai83i0vwdg7b05h0k07q6873q1z1avnyksj5zmzdnxya6j"))))
179 (build-system gnu-build-system)
181 (list opencl-headers))
183 (list opencl-icd-loader))
186 (list ,(string-append "CC=" (cc-for-target))
187 (string-append "PREFIX=" (assoc-ref %outputs "out")))
188 #:phases (modify-phases %standard-phases (delete 'configure))
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.
194 "This package provides the @command{clinfo} command that enumerates all
195 possible (known) properties of the OpenCL platform and devices available on
197 (license license:cc0)))
199 (define-public beignet
207 (url "https://github.com/intel/beignet")
208 (commit (string-append "Release_v" version))))
209 (file-name (git-file-name name version))
211 (base32 "0lpv3lvi2vrmzb8blflrpbd3jgin76zqmz6jcv17vn9mylqdrfnd"))
212 (patches (search-patches "beignet-correct-file-names.patch"))
213 (modules '((guix build utils)))
215 ;; There's a suspicious .isa binary file under kernels/.
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)
222 ("llvm@3.7" ,llvm-3.7)
225 ("libpthread-stubs" ,libpthread-stubs)
228 ("libxfixes" ,libxfixes)
230 ("mesa-utils" ,mesa-utils)
232 ("opencl-icd-loader" ,opencl-icd-loader)
233 ("opencl-headers" ,opencl-headers)
234 ("xextproto" ,xextproto)
236 (build-system cmake-build-system)
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")
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"))
252 (add-after 'remove-headers 'install-kernels
253 (lambda* (#:key outputs #:allow-other-keys)
254 (let* ((out (assoc-ref outputs "out"))
256 (source-dir (string-append
258 "/../beignet-Release_v1.3.2/kernels")))
259 (copy-recursively source-dir
260 (string-append out "/lib/beignet/kernels"))
262 ;; Beignet tries to find GPU when running tests, which is not available
265 (home-page "https://wiki.freedesktop.org/www/Software/Beignet/")
266 (synopsis "OpenCL framework for Intel GPUs")
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+)))
286 (url "https://github.com/pocl/pocl")
287 (commit (string-append "v" version))))
289 (base32 "1c4y69zks6hkq5fqh9waxgb8g4ka7y6h3vacmsm720kba0h57g8a"))
290 (file-name (git-file-name name version))))
291 (build-system cmake-build-system)
293 (list libltdl pkg-config))
295 (list clang-9 llvm-9 `(,hwloc-2 "lib") opencl-icd-loader))
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"))
305 (modify-phases %standard-phases
306 (add-before 'check 'set-HOME
308 (setenv "HOME" "/tmp")
310 (home-page "http://portablecl.org/")
311 (synopsis "Portable Computing Language (pocl), an OpenCL implementation")
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.
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
322 (license license:expat)))
324 (define-public python-pytools
326 (name "python-pytools")
331 (uri (pypi-uri "pytools" version))
333 (base32 "1yyr4k6sqx859gjhc02633l2vxwdnj6m2f5blmf7dgq0gzzgcf05"))))
334 (build-system python-build-system)
335 (arguments `(#:tests? #f)) ; Tests depend on packages not present in Guix.
337 (list python-appdirs python-numpy))
338 (home-page "https://pypi.org/project/pytools/")
339 (synopsis "Assorted tools for Python")
341 "Pytools is a bag of things that are ``missing'' from the Python standard
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.
350 Michele Simionato's decorator module
352 A time-series logging module, @code{pytools.log}.
354 Batch job submission, @code{pytools.batchjob}.
356 A lexer, @code{pytools.lex}.
358 (license license:expat)))
360 (define-public python-pyopencl
362 (name "python-pyopencl")
368 (url "https://github.com/inducer/pyopencl.git")
369 (commit (string-append "v" version))
371 (file-name (git-file-name name version))
374 "1s2cls7avxvf753zzpx422ikslaxdnm8rz58zg7mal15yak0wv2x"))))
375 (build-system python-build-system)
377 `(#:tests? #f)) ; Tests cannot find pygpu_language_opencl.cpp
379 (list opencl-headers pybind11 opencl-icd-loader)) ;libOpenCL
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")
385 "PyOpenCL lets you access parallel computing devices such as GPUs from
386 Python @i{via} OpenCL.")
387 (license license:expat)))