gnu: pocl: Update to 1.2.
[jackhill/guix/guix.git] / gnu / packages / opencl.scm
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>
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)
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))
42
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
47
48 (define (make-opencl-headers major-version subversion)
49 (let ((commit "e986688daf750633898dfd3994e14a9e618f2aa5")
50 (revision "0"))
51 (package
52 (name "opencl-headers")
53 (version (git-version
54 (string-append major-version "." subversion ".0")
55 revision commit))
56 (source (origin
57 (method git-fetch)
58 (uri (git-reference
59 (url "https://github.com/KhronosGroup/OpenCL-Headers.git")
60 (commit commit)))
61 (file-name (git-file-name name version))
62 (sha256
63 (base32
64 "176ydpbyws5nr4av6hf8p41pkhc0rc4m4vrah9w6gp2fw2i32838"))))
65 (build-system gnu-build-system)
66 (arguments
67 `(#:phases
68 (modify-phases %standard-phases
69 (delete 'configure)
70 (delete 'build)
71 (delete 'check)
72 (replace 'install
73 (lambda* (#:key outputs #:allow-other-keys)
74 (copy-recursively (string-append "./opencl" (string-append
75 ,major-version
76 ,subversion) "/CL")
77 (string-append
78 (assoc-ref outputs "out")
79 "/include/CL")))))))
80 (synopsis "The Khronos OpenCL headers")
81 (description
82 "This package provides the C headers by Khronos for OpenCL
83 programming.")
84 (home-page "https://www.khronos.org/registry/OpenCL/")
85 (license license:expat))))
86
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"))
99
100 (define-public opencl-headers opencl-headers-2.2)
101
102 (define-public opencl-clhpp
103 (package
104 (name "opencl-clhpp")
105 (version "2.0.10")
106 (source
107 (origin
108 (method git-fetch)
109 (uri (git-reference
110 (url "https://github.com/KhronosGroup/OpenCL-CLHPP.git")
111 (commit (string-append "v" version))))
112 (sha256
113 (base32 "0h5kpg5cl8wzfnqmv6i26aig2apv06ffm9p3rh35938n9r8rladm"))
114 (file-name (git-file-name name version))))
115 (native-inputs
116 `(("python" ,python-wrapper)))
117 (propagated-inputs
118 `(("opencl-headers" ,opencl-headers)))
119 (arguments
120 `(#:configure-flags
121 (let ((out (assoc-ref %outputs "out")))
122 (list
123 "-DBUILD_EXAMPLES=OFF"
124 "-DBUILD_TESTS=OFF"
125 (string-append "-DCMAKE_INSTALL_PREFIX="
126 (assoc-ref %outputs "out")
127 "/include")))
128 ;; The regression tests require a lot more dependencies.
129 #:tests? #f))
130 (build-system cmake-build-system)
131 (home-page "http://github.khronos.org/OpenCL-CLHPP/")
132 (synopsis "Khronos OpenCL-CLHPP")
133 (description
134 "This package provides the @dfn{host API} C++ headers for OpenCL.")
135 (license license:expat)))
136
137 (define-public ocl-icd
138 (package
139 (name "ocl-icd")
140 (version "2.2.12")
141 (source (origin
142 (method url-fetch)
143 (uri (string-append
144 "https://forge.imag.fr/frs/download.php/836/ocl-icd-"
145 version ".tar.gz"))
146 (file-name (string-append name "-" version ".tar.gz"))
147 (sha256
148 (base32
149 "1x2dr8p4dkfds56r38av360i3nv1y3326jmshxvjngaf6mlg6rbn"))
150 (modules '((guix build utils)))
151 (snippet
152 '(delete-file-recursively "khronos-headers"))))
153 (native-inputs
154 `(("opencl-headers" ,opencl-headers)
155 ("ruby" ,ruby)))
156 (inputs
157 `(("libgcrypt" ,libgcrypt)))
158 (build-system gnu-build-system)
159 (arguments
160 '(#:configure-flags '("DEBUG_OCL_ICD=1")))
161 (native-search-paths
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)")
168 (description
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)))
173
174 (define-public clinfo
175 (package
176 (name "clinfo")
177 (version "2.2.18.04.06")
178 (source
179 (origin
180 (method git-fetch)
181 (uri (git-reference
182 (url "https://github.com/Oblomov/clinfo.git")
183 (commit version)))
184 (file-name (git-file-name name version))
185 (sha256
186 (base32 "0y2q0lz5yzxy970b7w7340vp4fl25vndahsyvvrywcrn51ipgplx"))))
187 (build-system gnu-build-system)
188 (native-inputs
189 `(("opencl-headers" ,opencl-headers)))
190 (inputs
191 `(("ocl-icd" ,ocl-icd)))
192 (arguments
193 `(#:phases
194 (modify-phases %standard-phases
195 (delete 'configure)
196 (replace 'build
197 (lambda _
198 (let ((cores (number->string (parallel-job-count))))
199 (setenv "CC" "gcc")
200 (invoke "make" "-j" cores))))
201 (replace 'install
202 (lambda* (#:key outputs #:allow-other-keys)
203 (invoke "make" "install" (string-append
204 "PREFIX="
205 (assoc-ref outputs "out"))))))
206 #:tests? #f))
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.
210 (description
211 "This package provides the @command{clinfo} command that enumerates all
212 possible (known) properties of the OpenCL platform and devices available on
213 the system.")
214 (license license:cc0)))
215
216 (define-public beignet
217 (package
218 (name "beignet")
219 (version "1.3.2")
220 (source
221 (origin
222 (method git-fetch)
223 (uri (git-reference
224 (url "https://github.com/intel/beignet.git")
225 (commit (string-append "Release_v" version))))
226 (file-name (git-file-name name version))
227 (sha256
228 (base32 "0lpv3lvi2vrmzb8blflrpbd3jgin76zqmz6jcv17vn9mylqdrfnd"))
229 (patches (search-patches "beignet-correct-file-names.patch"))
230 (modules '((guix build utils)))
231 (snippet
232 ;; There's a suspicious .isa binary file under kernels/.
233 ;; Remove it.
234 '(for-each delete-file (find-files "." "\\.isa$")))))
235 (native-inputs `(("pkg-config" ,pkg-config)
236 ("python" ,python)))
237 (inputs `(("clang@3.7" ,clang-3.7)
238 ("clang-runtime@3.7" ,clang-runtime-3.7)
239 ("glu" ,glu)
240 ("llvm@3.7" ,llvm-3.7)
241 ("libdrm" ,libdrm)
242 ("libedit" ,libedit)
243 ("libpthread-stubs", libpthread-stubs)
244 ("libsm" ,libsm)
245 ("libva" ,libva)
246 ("libxfixes" ,libxfixes)
247 ("libxext" ,libxext)
248 ("mesa-utils" ,mesa-utils)
249 ("ncurses" ,ncurses)
250 ("ocl-icd" ,ocl-icd)
251 ("opencl-headers" ,opencl-headers)
252 ("xextproto" ,xextproto)
253 ("zlib" ,zlib)))
254 (build-system cmake-build-system)
255 (arguments
256 `(#:configure-flags
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")
261
262 #:phases
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"))
269 #t)))
270 (add-after 'remove-headers 'install-kernels
271 (lambda* (#:key outputs #:allow-other-keys)
272 (let* ((out (assoc-ref outputs "out"))
273 (builddir (getcwd))
274 (source-dir (string-append
275 builddir
276 "/../beignet-Release_v1.3.2/kernels")))
277 (copy-recursively source-dir
278 (string-append out "/lib/beignet/kernels"))
279 #t))))
280 ;; Beignet tries to find GPU when running tests, which is not available
281 ;; during build.
282 #:tests? #f))
283 (home-page "https://wiki.freedesktop.org/www/Software/Beignet/")
284 (synopsis "OpenCL framework for Intel GPUs")
285 (description
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 (license license:lgpl2.1+)))
293
294 (define-public pocl
295 (package
296 (name "pocl")
297 (version "1.2")
298 (source
299 (origin
300 (method git-fetch)
301 (uri (git-reference
302 (url "https://github.com/pocl/pocl.git")
303 (commit (string-append "v" version))))
304 (sha256
305 (base32 "0fyiwd9nrqhl0jsac0bx17p9acpfzhyxp50mmp28mzn7psb9qidg"))
306 (file-name (git-file-name name version))))
307 (build-system cmake-build-system)
308 (native-inputs
309 `(("libltdl" ,libltdl)
310 ("pkg-config" ,pkg-config)))
311 (inputs
312 `(("clang" ,clang)
313 ("hwloc" ,hwloc-2.0 "lib")
314 ("llvm" ,llvm)
315 ("ocl-icd" ,ocl-icd)))
316 (arguments
317 `(#:configure-flags
318 (list "-DENABLE_ICD=ON"
319 "-DENABLE_TESTSUITES=ON"
320 ;; We are not developers, don't run conformance suite.
321 "-DENABLE_CONFORMANCE=OFF"
322 (string-append "-DEXTRA_HOST_LD_FLAGS=-L"
323 (assoc-ref %build-inputs "libc") "/lib"))
324 #:phases
325 (modify-phases %standard-phases
326 (add-before 'check 'set-HOME
327 (lambda _
328 (setenv "HOME" "/tmp")
329 #t)))))
330 (home-page "http://portablecl.org/")
331 (synopsis "Portable Computing Language (pocl), an OpenCL implementation")
332 (description
333 "Pocl is a portable implementation of the OpenCL standard (1.2 with some
334 2.0 features supported). This project seeks to improve performance
335 portability of OpenCL programs with the kernel compiler and the task run-time,
336 reducing the need for target-dependent manual optimizations.
337
338 pocl uses Clang as an OpenCL C frontend and LLVM for kernel compiler
339 implementation, and as a portability layer. Thus, if your desired target has
340 an LLVM backend, it should be able to get OpenCL support easily by using
341 pocl.")
342 (license license:expat)))