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 download)
24 #:use-module (guix git-download)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix packages)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages autotools)
29 #:use-module (gnu packages gl)
30 #:use-module (gnu packages gnupg)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages libedit)
33 #:use-module (gnu packages llvm)
34 #:use-module (gnu packages mpi)
35 #:use-module (gnu packages ncurses)
36 #:use-module (gnu packages pkg-config)
37 #:use-module (gnu packages python)
38 #:use-module (gnu packages ruby)
39 #:use-module (gnu packages video)
40 #:use-module (gnu packages xdisorg)
41 #:use-module (gnu packages xorg))
43 ;; This file adds OpenCL implementation related packages. Due to the fact that
44 ;; OpenCL devices like GPU are not available during build (store environment),
45 ;; tests that require such devices are all disabled.
46 ;; Check https://lists.gnu.org/archive/html/guix-devel/2018-04/msg00293.html
48 (define (make-opencl-headers major-version subversion)
49 (let ((commit "e986688daf750633898dfd3994e14a9e618f2aa5")
52 (name "opencl-headers")
54 (string-append major-version "." subversion ".0")
59 (url "https://github.com/KhronosGroup/OpenCL-Headers.git")
61 (file-name (git-file-name name version))
64 "176ydpbyws5nr4av6hf8p41pkhc0rc4m4vrah9w6gp2fw2i32838"))))
65 (build-system gnu-build-system)
68 (modify-phases %standard-phases
73 (lambda* (#:key outputs #:allow-other-keys)
74 (copy-recursively (string-append "./opencl" (string-append
78 (assoc-ref outputs "out")
80 (synopsis "The Khronos OpenCL headers")
82 "This package provides the C headers by Khronos for OpenCL
84 (home-page "https://www.khronos.org/registry/OpenCL/")
85 (license license:expat))))
87 (define-public opencl-headers-2.2
88 (make-opencl-headers "2" "2"))
89 (define-public opencl-headers-2.1
90 (make-opencl-headers "2" "1"))
91 (define-public opencl-headers-2.0
92 (make-opencl-headers "2" "0"))
93 (define-public opencl-headers-1.2
94 (make-opencl-headers "1" "2"))
95 (define-public opencl-headers-1.1
96 (make-opencl-headers "1" "1"))
97 (define-public opencl-headers-1.0
98 (make-opencl-headers "1" "0"))
100 (define-public opencl-headers opencl-headers-2.2)
102 (define-public opencl-clhpp
104 (name "opencl-clhpp")
110 (url "https://github.com/KhronosGroup/OpenCL-CLHPP.git")
111 (commit (string-append "v" version))))
113 (base32 "0h5kpg5cl8wzfnqmv6i26aig2apv06ffm9p3rh35938n9r8rladm"))
114 (file-name (git-file-name name version))))
116 `(("python" ,python-wrapper)))
118 `(("opencl-headers" ,opencl-headers)))
121 (let ((out (assoc-ref %outputs "out")))
123 "-DBUILD_EXAMPLES=OFF"
125 (string-append "-DCMAKE_INSTALL_PREFIX="
126 (assoc-ref %outputs "out")
128 ;; The regression tests require a lot more dependencies.
130 (build-system cmake-build-system)
131 (home-page "http://github.khronos.org/OpenCL-CLHPP/")
132 (synopsis "Khronos OpenCL-CLHPP")
134 "This package provides the @dfn{host API} C++ headers for OpenCL.")
135 (license license:expat)))
137 (define-public ocl-icd
144 "https://forge.imag.fr/frs/download.php/836/ocl-icd-"
146 (file-name (string-append name "-" version ".tar.gz"))
149 "1x2dr8p4dkfds56r38av360i3nv1y3326jmshxvjngaf6mlg6rbn"))
150 (modules '((guix build utils)))
152 '(delete-file-recursively "khronos-headers"))))
154 `(("opencl-headers" ,opencl-headers)
157 `(("libgcrypt" ,libgcrypt)))
158 (build-system gnu-build-system)
160 '(#:configure-flags '("DEBUG_OCL_ICD=1")))
162 (list (search-path-specification
163 (variable "OPENCL_VENDOR_PATH")
164 (files '("etc/OpenCL/vendors")))))
165 (search-paths native-search-paths)
166 (home-page "https://forge.imag.fr/projects/ocl-icd/")
167 (synopsis "OpenCL loader for Installable Client Drivers (ICDs)")
169 "OpenCL implementations are provided as ICDs (Installable Client
170 Drivers). An OpenCL program can use several ICDs thanks to the use of an ICD
171 Loader as provided by this package.")
172 (license license:bsd-2)))
174 (define-public clinfo
177 (version "2.2.18.04.06")
182 (url "https://github.com/Oblomov/clinfo.git")
184 (file-name (git-file-name name version))
186 (base32 "0y2q0lz5yzxy970b7w7340vp4fl25vndahsyvvrywcrn51ipgplx"))))
187 (build-system gnu-build-system)
189 `(("opencl-headers" ,opencl-headers)))
191 `(("ocl-icd" ,ocl-icd)))
194 (modify-phases %standard-phases
198 (let ((cores (number->string (parallel-job-count))))
200 (invoke "make" "-j" cores))))
202 (lambda* (#:key outputs #:allow-other-keys)
203 (invoke "make" "install" (string-append
205 (assoc-ref outputs "out"))))))
207 (home-page "https://github.com/Oblomov/clinfo")
208 (synopsis "Print information about OpenCL platforms and devices")
209 ;; Only the implementation installed via Guix will be detected.
211 "This package provides the @command{clinfo} command that enumerates all
212 possible (known) properties of the OpenCL platform and devices available on
214 (license license:cc0)))
216 (define-public beignet
224 (url "https://github.com/intel/beignet.git")
225 (commit (string-append "Release_v" version))))
226 (file-name (git-file-name name version))
228 (base32 "0lpv3lvi2vrmzb8blflrpbd3jgin76zqmz6jcv17vn9mylqdrfnd"))
229 (patches (search-patches "beignet-correct-file-names.patch"))
230 (modules '((guix build utils)))
232 ;; There's a suspicious .isa binary file under kernels/.
234 '(for-each delete-file (find-files "." "\\.isa$")))))
235 (native-inputs `(("pkg-config" ,pkg-config)
237 (inputs `(("clang@3.7" ,clang-3.7)
238 ("clang-runtime@3.7" ,clang-runtime-3.7)
240 ("llvm@3.7" ,llvm-3.7)
243 ("libpthread-stubs" ,libpthread-stubs)
246 ("libxfixes" ,libxfixes)
248 ("mesa-utils" ,mesa-utils)
251 ("opencl-headers" ,opencl-headers)
252 ("xextproto" ,xextproto)
254 (build-system cmake-build-system)
257 (list (string-append "-DCLANG_LIBRARY_DIR="
258 (assoc-ref %build-inputs "clang@3.7") "/lib")
259 "-DENABLE_GL_SHARING=ON"
260 "-DEXPERIMENTAL_DOUBLE=ON")
263 (modify-phases %standard-phases
264 (add-after 'install 'remove-headers
265 (lambda* (#:key outputs #:allow-other-keys)
266 (let ((out (assoc-ref outputs "out")))
267 (delete-file-recursively
268 (string-append out "/include"))
270 (add-after 'remove-headers 'install-kernels
271 (lambda* (#:key outputs #:allow-other-keys)
272 (let* ((out (assoc-ref outputs "out"))
274 (source-dir (string-append
276 "/../beignet-Release_v1.3.2/kernels")))
277 (copy-recursively source-dir
278 (string-append out "/lib/beignet/kernels"))
280 ;; Beignet tries to find GPU when running tests, which is not available
283 (home-page "https://wiki.freedesktop.org/www/Software/Beignet/")
284 (synopsis "OpenCL framework for Intel GPUs")
286 "Beignet is an implementation of the OpenCL specification. This code
287 base contains the code to run OpenCL programs on Intel GPUs---IvyBridge,
288 Haswell, Skylake, Apollolake, etc. It defines and implements the OpenCL host
289 functions required to initialize the device, create the command queues, the
290 kernels and the programs, and run them on the GPU. The code also contains a
291 back-end for the LLVM compiler framework.")
292 ;; Beignet only supports Intel processors.
293 (supported-systems '("x86_64-linux" "i686-linux"))
294 (license license:lgpl2.1+)))
304 (url "https://github.com/pocl/pocl.git")
305 (commit (string-append "v" version))))
307 (base32 "0fyiwd9nrqhl0jsac0bx17p9acpfzhyxp50mmp28mzn7psb9qidg"))
308 (file-name (git-file-name name version))))
309 (build-system cmake-build-system)
311 `(("libltdl" ,libltdl)
312 ("pkg-config" ,pkg-config)))
315 ("hwloc" ,hwloc-2.0 "lib")
317 ("ocl-icd" ,ocl-icd)))
320 (list "-DENABLE_ICD=ON"
321 "-DENABLE_TESTSUITES=ON"
322 ;; We are not developers, don't run conformance suite.
323 "-DENABLE_CONFORMANCE=OFF"
324 (string-append "-DEXTRA_HOST_LD_FLAGS=-L"
325 (assoc-ref %build-inputs "libc") "/lib"))
327 (modify-phases %standard-phases
328 (add-before 'check 'set-HOME
330 (setenv "HOME" "/tmp")
332 (home-page "http://portablecl.org/")
333 (synopsis "Portable Computing Language (pocl), an OpenCL implementation")
335 "Pocl is a portable implementation of the OpenCL standard (1.2 with some
336 2.0 features supported). This project seeks to improve performance
337 portability of OpenCL programs with the kernel compiler and the task run-time,
338 reducing the need for target-dependent manual optimizations.
340 pocl uses Clang as an OpenCL C frontend and LLVM for kernel compiler
341 implementation, and as a portability layer. Thus, if your desired target has
342 an LLVM backend, it should be able to get OpenCL support easily by using
344 (license license:expat)))