| 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 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)) |
| 44 | |
| 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 |
| 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 |
| 61 | (url "https://github.com/KhronosGroup/OpenCL-Headers.git") |
| 62 | (commit commit))) |
| 63 | (file-name (git-file-name name version)) |
| 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 |
| 85 | programming.") |
| 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) |
| 103 | |
| 104 | (define-public opencl-clhpp |
| 105 | (package |
| 106 | (name "opencl-clhpp") |
| 107 | (version "2.0.10") |
| 108 | (source |
| 109 | (origin |
| 110 | (method git-fetch) |
| 111 | (uri (git-reference |
| 112 | (url "https://github.com/KhronosGroup/OpenCL-CLHPP.git") |
| 113 | (commit (string-append "v" version)))) |
| 114 | (sha256 |
| 115 | (base32 "0h5kpg5cl8wzfnqmv6i26aig2apv06ffm9p3rh35938n9r8rladm")) |
| 116 | (file-name (git-file-name name version)))) |
| 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"))) |
| 130 | ;; The regression tests require a lot more dependencies. |
| 131 | #:tests? #f)) |
| 132 | (build-system cmake-build-system) |
| 133 | (home-page "http://github.khronos.org/OpenCL-CLHPP/") |
| 134 | (synopsis "Khronos OpenCL-CLHPP") |
| 135 | (description |
| 136 | "This package provides the @dfn{host API} C++ headers for OpenCL.") |
| 137 | (license license:expat))) |
| 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 |
| 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))) |
| 175 | |
| 176 | (define-public clinfo |
| 177 | (package |
| 178 | (name "clinfo") |
| 179 | (version "2.2.18.04.06") |
| 180 | (source |
| 181 | (origin |
| 182 | (method git-fetch) |
| 183 | (uri (git-reference |
| 184 | (url "https://github.com/Oblomov/clinfo.git") |
| 185 | (commit version))) |
| 186 | (file-name (git-file-name name version)) |
| 187 | (sha256 |
| 188 | (base32 "0y2q0lz5yzxy970b7w7340vp4fl25vndahsyvvrywcrn51ipgplx")))) |
| 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 |
| 214 | possible (known) properties of the OpenCL platform and devices available on |
| 215 | the system.") |
| 216 | (license license:cc0))) |
| 217 | |
| 218 | (define-public beignet |
| 219 | (package |
| 220 | (name "beignet") |
| 221 | (version "1.3.2") |
| 222 | (source |
| 223 | (origin |
| 224 | (method git-fetch) |
| 225 | (uri (git-reference |
| 226 | (url "https://github.com/intel/beignet.git") |
| 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$"))))) |
| 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) |
| 245 | ("libpthread-stubs" ,libpthread-stubs) |
| 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 |
| 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+))) |
| 297 | |
| 298 | (define-public pocl |
| 299 | (package |
| 300 | (name "pocl") |
| 301 | (version "1.4") |
| 302 | (source |
| 303 | (origin |
| 304 | (method git-fetch) |
| 305 | (uri (git-reference |
| 306 | (url "https://github.com/pocl/pocl.git") |
| 307 | (commit (string-append "v" version)))) |
| 308 | (sha256 |
| 309 | (base32 "1c4y69zks6hkq5fqh9waxgb8g4ka7y6h3vacmsm720kba0h57g8a")) |
| 310 | (file-name (git-file-name name version)))) |
| 311 | (build-system cmake-build-system) |
| 312 | (native-inputs |
| 313 | `(("libltdl" ,libltdl) |
| 314 | ("pkg-config" ,pkg-config))) |
| 315 | (inputs |
| 316 | `(("clang" ,clang) |
| 317 | ("hwloc" ,hwloc-2 "lib") |
| 318 | ("llvm" ,llvm-8) |
| 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 |
| 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 |
| 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. |
| 341 | |
| 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 |
| 345 | pocl.") |
| 346 | (license license:expat))) |
| 347 | |
| 348 | (define-public python-pytools |
| 349 | (package |
| 350 | (name "python-pytools") |
| 351 | (version "2020.1") |
| 352 | (source |
| 353 | (origin |
| 354 | (method url-fetch) |
| 355 | (uri (pypi-uri "pytools" version)) |
| 356 | (sha256 |
| 357 | (base32 |
| 358 | "19h47pqfrq7ax7601i5g8icpb6b42h8zzwq0dqfdcjjqamwd2cn1")))) |
| 359 | (build-system python-build-system) |
| 360 | (propagated-inputs |
| 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") |
| 368 | (description |
| 369 | "Pytools is a bag of things that are ``missing'' from the Python standard |
| 370 | library: |
| 371 | |
| 372 | @itemize |
| 373 | @item |
| 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. |
| 377 | @item |
| 378 | Michele Simionato's decorator module |
| 379 | @item |
| 380 | A time-series logging module, @code{pytools.log}. |
| 381 | @item |
| 382 | Batch job submission, @code{pytools.batchjob}. |
| 383 | @item |
| 384 | A lexer, @code{pytools.lex}. |
| 385 | @end itemize\n") |
| 386 | (license license:expat))) |
| 387 | |
| 388 | (define-public python-pyopencl |
| 389 | (package |
| 390 | (name "python-pyopencl") |
| 391 | (version "2019.1.1") |
| 392 | (source |
| 393 | (origin |
| 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. |
| 397 | (method git-fetch) |
| 398 | (uri (git-reference |
| 399 | (url "http://git.tiker.net/trees/pyopencl.git") |
| 400 | (commit (string-append "v" version)) |
| 401 | (recursive? #t))) |
| 402 | (file-name (git-file-name name version)) |
| 403 | (sha256 |
| 404 | (base32 |
| 405 | "12q0rs8yla571vcfpsh0mfrjbdiayv0hi8r1rq0f178m3i3qjz80")))) |
| 406 | (build-system python-build-system) |
| 407 | (arguments |
| 408 | '(#:phases (modify-phases %standard-phases |
| 409 | (add-before 'build 'set-home |
| 410 | (lambda _ |
| 411 | ;; Some of the Python build scripts expect 'HOME' to be |
| 412 | ;; set. |
| 413 | (setenv "HOME" (getcwd)) |
| 414 | #t))) |
| 415 | |
| 416 | ;; Tests in 'compyte/ndarray/setup_opencl.py' appear to rely on |
| 417 | ;; 'nvcc', which is not an option. |
| 418 | #:tests? #f)) |
| 419 | (inputs |
| 420 | `(("opencl-headers" ,opencl-headers-1.2) ;POCL only supports OpenCL 1.2 |
| 421 | ("pybind11" ,pybind11) |
| 422 | ("ocl-icd" ,ocl-icd))) ;libOpenCL |
| 423 | (propagated-inputs |
| 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") |
| 432 | (description |
| 433 | "PyOpenCL lets you access parallel computing devices such as GPUs from |
| 434 | Python @i{via} OpenCL.") |
| 435 | (license license:expat))) |