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