1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com>
3 ;;; Copyright © 2018 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 python)
24 #:use-module (guix download)
25 #:use-module (guix git-download)
26 #:use-module ((guix licenses) #:prefix license:)
27 #:use-module (guix packages)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages autotools)
30 #:use-module (gnu packages gl)
31 #:use-module (gnu packages gnupg)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages libedit)
34 #:use-module (gnu packages llvm)
35 #:use-module (gnu packages mpi)
36 #:use-module (gnu packages ncurses)
37 #:use-module (gnu packages pkg-config)
38 #:use-module (gnu packages python)
39 #:use-module (gnu packages python-xyz)
40 #:use-module (gnu packages ruby)
41 #:use-module (gnu packages video)
42 #:use-module (gnu packages xdisorg)
43 #:use-module (gnu packages xorg))
45 ;; This file adds OpenCL implementation related packages. Due to the fact that
46 ;; OpenCL devices like GPU are not available during build (store environment),
47 ;; tests that require such devices are all disabled.
48 ;; Check https://lists.gnu.org/archive/html/guix-devel/2018-04/msg00293.html
50 (define (make-opencl-headers major-version subversion)
51 (let ((commit "e986688daf750633898dfd3994e14a9e618f2aa5")
54 (name "opencl-headers")
56 (string-append major-version "." subversion ".0")
61 (url "https://github.com/KhronosGroup/OpenCL-Headers.git")
63 (file-name (git-file-name name version))
66 "176ydpbyws5nr4av6hf8p41pkhc0rc4m4vrah9w6gp2fw2i32838"))))
67 (build-system gnu-build-system)
70 (modify-phases %standard-phases
75 (lambda* (#:key outputs #:allow-other-keys)
76 (copy-recursively (string-append "./opencl" (string-append
80 (assoc-ref outputs "out")
82 (synopsis "The Khronos OpenCL headers")
84 "This package provides the C headers by Khronos for OpenCL
86 (home-page "https://www.khronos.org/registry/OpenCL/")
87 (license license:expat))))
89 (define-public opencl-headers-2.2
90 (make-opencl-headers "2" "2"))
91 (define-public opencl-headers-2.1
92 (make-opencl-headers "2" "1"))
93 (define-public opencl-headers-2.0
94 (make-opencl-headers "2" "0"))
95 (define-public opencl-headers-1.2
96 (make-opencl-headers "1" "2"))
97 (define-public opencl-headers-1.1
98 (make-opencl-headers "1" "1"))
99 (define-public opencl-headers-1.0
100 (make-opencl-headers "1" "0"))
102 (define-public opencl-headers opencl-headers-2.2)
104 (define-public opencl-clhpp
106 (name "opencl-clhpp")
112 (url "https://github.com/KhronosGroup/OpenCL-CLHPP.git")
113 (commit (string-append "v" version))))
115 (base32 "0h5kpg5cl8wzfnqmv6i26aig2apv06ffm9p3rh35938n9r8rladm"))
116 (file-name (git-file-name name version))))
118 `(("python" ,python-wrapper)))
120 `(("opencl-headers" ,opencl-headers)))
123 (let ((out (assoc-ref %outputs "out")))
125 "-DBUILD_EXAMPLES=OFF"
127 (string-append "-DCMAKE_INSTALL_PREFIX="
128 (assoc-ref %outputs "out")
130 ;; The regression tests require a lot more dependencies.
132 (build-system cmake-build-system)
133 (home-page "https://github.khronos.org/OpenCL-CLHPP/")
134 (synopsis "Khronos OpenCL-CLHPP")
136 "This package provides the @dfn{host API} C++ headers for OpenCL.")
137 (license license:expat)))
139 (define-public ocl-icd
146 "https://forge.imag.fr/frs/download.php/836/ocl-icd-"
148 (file-name (string-append name "-" version ".tar.gz"))
151 "1x2dr8p4dkfds56r38av360i3nv1y3326jmshxvjngaf6mlg6rbn"))
152 (modules '((guix build utils)))
154 '(delete-file-recursively "khronos-headers"))))
156 `(("opencl-headers" ,opencl-headers)
159 `(("libgcrypt" ,libgcrypt)))
160 (build-system gnu-build-system)
162 '(#:configure-flags '("DEBUG_OCL_ICD=1")))
164 (list (search-path-specification
165 (variable "OPENCL_VENDOR_PATH")
166 (files '("etc/OpenCL/vendors")))))
167 (search-paths native-search-paths)
168 (home-page "https://forge.imag.fr/projects/ocl-icd/")
169 (synopsis "OpenCL loader for Installable Client Drivers (ICDs)")
171 "OpenCL implementations are provided as ICDs (Installable Client
172 Drivers). An OpenCL program can use several ICDs thanks to the use of an ICD
173 Loader as provided by this package.")
174 (license license:bsd-2)))
176 (define-public clinfo
179 (version "2.2.18.04.06")
184 (url "https://github.com/Oblomov/clinfo.git")
186 (file-name (git-file-name name version))
188 (base32 "0y2q0lz5yzxy970b7w7340vp4fl25vndahsyvvrywcrn51ipgplx"))))
189 (build-system gnu-build-system)
191 `(("opencl-headers" ,opencl-headers)))
193 `(("ocl-icd" ,ocl-icd)))
196 (modify-phases %standard-phases
200 (let ((cores (number->string (parallel-job-count))))
202 (invoke "make" "-j" cores))))
204 (lambda* (#:key outputs #:allow-other-keys)
205 (invoke "make" "install" (string-append
207 (assoc-ref outputs "out"))))))
209 (home-page "https://github.com/Oblomov/clinfo")
210 (synopsis "Print information about OpenCL platforms and devices")
211 ;; Only the implementation installed via Guix will be detected.
213 "This package provides the @command{clinfo} command that enumerates all
214 possible (known) properties of the OpenCL platform and devices available on
216 (license license:cc0)))
218 (define-public beignet
226 (url "https://github.com/intel/beignet.git")
227 (commit (string-append "Release_v" version))))
228 (file-name (git-file-name name version))
230 (base32 "0lpv3lvi2vrmzb8blflrpbd3jgin76zqmz6jcv17vn9mylqdrfnd"))
231 (patches (search-patches "beignet-correct-file-names.patch"))
232 (modules '((guix build utils)))
234 ;; There's a suspicious .isa binary file under kernels/.
236 '(for-each delete-file (find-files "." "\\.isa$")))))
237 (native-inputs `(("pkg-config" ,pkg-config)
239 (inputs `(("clang@3.7" ,clang-3.7)
240 ("clang-runtime@3.7" ,clang-runtime-3.7)
242 ("llvm@3.7" ,llvm-3.7)
245 ("libpthread-stubs" ,libpthread-stubs)
248 ("libxfixes" ,libxfixes)
250 ("mesa-utils" ,mesa-utils)
253 ("opencl-headers" ,opencl-headers)
254 ("xextproto" ,xextproto)
256 (build-system cmake-build-system)
259 (list (string-append "-DCLANG_LIBRARY_DIR="
260 (assoc-ref %build-inputs "clang@3.7") "/lib")
261 "-DENABLE_GL_SHARING=ON"
262 "-DEXPERIMENTAL_DOUBLE=ON")
265 (modify-phases %standard-phases
266 (add-after 'install 'remove-headers
267 (lambda* (#:key outputs #:allow-other-keys)
268 (let ((out (assoc-ref outputs "out")))
269 (delete-file-recursively
270 (string-append out "/include"))
272 (add-after 'remove-headers 'install-kernels
273 (lambda* (#:key outputs #:allow-other-keys)
274 (let* ((out (assoc-ref outputs "out"))
276 (source-dir (string-append
278 "/../beignet-Release_v1.3.2/kernels")))
279 (copy-recursively source-dir
280 (string-append out "/lib/beignet/kernels"))
282 ;; Beignet tries to find GPU when running tests, which is not available
285 (home-page "https://wiki.freedesktop.org/www/Software/Beignet/")
286 (synopsis "OpenCL framework for Intel GPUs")
288 "Beignet is an implementation of the OpenCL specification. This code
289 base contains the code to run OpenCL programs on Intel GPUs---IvyBridge,
290 Haswell, Skylake, Apollolake, etc. It defines and implements the OpenCL host
291 functions required to initialize the device, create the command queues, the
292 kernels and the programs, and run them on the GPU. The code also contains a
293 back-end for the LLVM compiler framework.")
294 ;; Beignet only supports Intel processors.
295 (supported-systems '("x86_64-linux" "i686-linux"))
296 (license license:lgpl2.1+)))
306 (url "https://github.com/pocl/pocl.git")
307 (commit (string-append "v" version))))
309 (base32 "1c4y69zks6hkq5fqh9waxgb8g4ka7y6h3vacmsm720kba0h57g8a"))
310 (file-name (git-file-name name version))))
311 (build-system cmake-build-system)
313 `(("libltdl" ,libltdl)
314 ("pkg-config" ,pkg-config)))
317 ("hwloc" ,hwloc-2 "lib")
319 ("ocl-icd" ,ocl-icd)))
322 (list "-DENABLE_ICD=ON"
323 "-DENABLE_TESTSUITES=ON"
324 ;; We are not developers, don't run conformance suite.
325 "-DENABLE_CONFORMANCE=OFF"
326 (string-append "-DEXTRA_HOST_LD_FLAGS=-L"
327 (assoc-ref %build-inputs "libc") "/lib"))
329 (modify-phases %standard-phases
330 (add-before 'check 'set-HOME
332 (setenv "HOME" "/tmp")
334 (home-page "http://portablecl.org/")
335 (synopsis "Portable Computing Language (pocl), an OpenCL implementation")
337 "Pocl is a portable implementation of the OpenCL standard (1.2 with some
338 2.0 features supported). This project seeks to improve performance
339 portability of OpenCL programs with the kernel compiler and the task run-time,
340 reducing the need for target-dependent manual optimizations.
342 pocl uses Clang as an OpenCL C frontend and LLVM for kernel compiler
343 implementation, and as a portability layer. Thus, if your desired target has
344 an LLVM backend, it should be able to get OpenCL support easily by using
346 (license license:expat)))
348 (define-public python-pytools
350 (name "python-pytools")
355 (uri (pypi-uri "pytools" version))
358 "19h47pqfrq7ax7601i5g8icpb6b42h8zzwq0dqfdcjjqamwd2cn1"))))
359 (build-system python-build-system)
361 `(("python-appdirs" ,python-appdirs)
362 ("python-decorator" ,python-decorator)
363 ("python-numpy" ,python-numpy)
364 ("python-six" ,python-six)
365 ("python-mpi4py" ,python-mpi4py)))
366 (home-page "https://pypi.org/project/pytools/")
367 (synopsis "Assorted tools for Python")
369 "Pytools is a bag of things that are ``missing'' from the Python standard
374 small helper functions such as @code{len_iterable}, @code{argmin},
375 tuple generation, permutation generation, ASCII table pretty printing,
376 GvR's @code{monkeypatch_xxx} hack, the elusive @code{flatten}, and much more.
378 Michele Simionato's decorator module
380 A time-series logging module, @code{pytools.log}.
382 Batch job submission, @code{pytools.batchjob}.
384 A lexer, @code{pytools.lex}.
386 (license license:expat)))
388 (define-public python-pyopencl
390 (name "python-pyopencl")
394 ;; The tarball on PyPI lacks test programs such as
395 ;; 'pygpu_language_opencl.cpp' so fetch it from Git.
396 ;; XXX: The server at git.tiker.net is unreliable.
399 (url "http://git.tiker.net/trees/pyopencl.git")
400 (commit (string-append "v" version))
402 (file-name (git-file-name name version))
405 "12q0rs8yla571vcfpsh0mfrjbdiayv0hi8r1rq0f178m3i3qjz80"))))
406 (build-system python-build-system)
408 '(#:phases (modify-phases %standard-phases
409 (add-before 'build 'set-home
411 ;; Some of the Python build scripts expect 'HOME' to be
413 (setenv "HOME" (getcwd))
416 ;; Tests in 'compyte/ndarray/setup_opencl.py' appear to rely on
417 ;; 'nvcc', which is not an option.
420 `(("opencl-headers" ,opencl-headers-1.2) ;POCL only supports OpenCL 1.2
421 ("pybind11" ,pybind11)
422 ("ocl-icd" ,ocl-icd))) ;libOpenCL
424 `(("python-appdirs" ,python-appdirs)
425 ("python-decorator" ,python-decorator)
426 ("python-numpy" ,python-numpy)
427 ("python-pytools" ,python-pytools)
428 ("python-six" ,python-six)
429 ("python-mako" ,python-mako)))
430 (home-page "http://mathema.tician.de/software/pyopencl")
431 (synopsis "Python wrapper for OpenCL")
433 "PyOpenCL lets you access parallel computing devices such as GPUs from
434 Python @i{via} OpenCL.")
435 (license license:expat)))