opencl.scm 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com>
  3. ;;; Copyright © 2018, 2020 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. (define-module (gnu packages opencl)
  20. #:use-module (guix build-system gnu)
  21. #:use-module (guix build-system cmake)
  22. #:use-module (guix build-system copy)
  23. #:use-module (guix build-system python)
  24. #:use-module (guix download)
  25. #:use-module (guix utils)
  26. #:use-module (guix git-download)
  27. #:use-module ((guix licenses) #:prefix license:)
  28. #:use-module (guix packages)
  29. #:use-module (gnu packages)
  30. #:use-module (gnu packages autotools)
  31. #:use-module (gnu packages gl)
  32. #:use-module (gnu packages gnupg)
  33. #:use-module (gnu packages compression)
  34. #:use-module (gnu packages libedit)
  35. #:use-module (gnu packages llvm)
  36. #:use-module (gnu packages mpi)
  37. #:use-module (gnu packages ncurses)
  38. #:use-module (gnu packages pkg-config)
  39. #:use-module (gnu packages python)
  40. #:use-module (gnu packages python-xyz)
  41. #:use-module (gnu packages ruby)
  42. #:use-module (gnu packages video)
  43. #:use-module (gnu packages xdisorg)
  44. #: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
  49. ;; If you update either of opencl-headers, opencl-clhpp or opencl-icd-loader
  50. ;; note that they are released together (lockstep) and must be updated
  51. ;; together.
  52. (define-public opencl-headers
  53. (package
  54. (name "opencl-headers")
  55. (version "2021.06.30")
  56. (source
  57. (origin
  58. (method git-fetch)
  59. (uri (git-reference
  60. (url "https://github.com/KhronosGroup/OpenCL-Headers")
  61. (commit (string-append "v" version))))
  62. (file-name (git-file-name name version))
  63. (sha256
  64. (base32 "1nrvx0x9r1nz1qpmzbgffnn9h9pn2fwcxsksf101bkpmqziq5lii"))))
  65. (build-system cmake-build-system)
  66. (arguments `(#:tests? #f)) ; Not enabled during build.
  67. (synopsis "The Khronos OpenCL headers")
  68. (description
  69. "This package provides the C headers by Khronos for OpenCL programming.")
  70. (home-page "https://www.khronos.org/registry/OpenCL/")
  71. (license license:asl2.0)))
  72. (define (make-opencl-headers major-version subversion)
  73. ;; The upstream OpenCL-Headers repository is no longer separating headers by
  74. ;; version; instead, you are supposed to #define CL_TARGET_OPENCL_VERSION.
  75. (deprecated-package (string-append "opencl-headers-"
  76. major-version "."
  77. subversion) opencl-headers))
  78. (define-public opencl-headers-2.2
  79. (make-opencl-headers "2" "2"))
  80. (define-public opencl-headers-2.1
  81. (make-opencl-headers "2" "1"))
  82. (define-public opencl-headers-2.0
  83. (make-opencl-headers "2" "0"))
  84. (define-public opencl-headers-1.2
  85. (make-opencl-headers "1" "2"))
  86. (define-public opencl-headers-1.1
  87. (make-opencl-headers "1" "1"))
  88. (define-public opencl-headers-1.0
  89. (make-opencl-headers "1" "0"))
  90. (define-public opencl-clhpp
  91. (package
  92. (name "opencl-clhpp")
  93. (version "2.0.15")
  94. (source
  95. (origin
  96. (method git-fetch)
  97. (uri (git-reference
  98. (url "https://github.com/KhronosGroup/OpenCL-CLHPP")
  99. (commit (string-append "v" version))))
  100. (sha256
  101. (base32 "1wycdbvwbdn7lqdd3sby8471qg2zdisr70218ava6cfvxdsqcp83"))
  102. (file-name (git-file-name name version))))
  103. (native-inputs
  104. `(("python" ,python-wrapper)))
  105. (propagated-inputs
  106. `(("opencl-headers" ,opencl-headers)))
  107. (arguments
  108. `(#:configure-flags (list "-DBUILD_EXAMPLES=OFF" "-DBUILD_TESTS=OFF")
  109. ;; The regression tests require a lot more dependencies.
  110. #:tests? #f))
  111. (build-system cmake-build-system)
  112. (home-page "https://github.khronos.org/OpenCL-CLHPP/")
  113. (synopsis "Khronos OpenCL-CLHPP")
  114. (description
  115. "This package provides the @dfn{host API} C++ headers for OpenCL.")
  116. (license license:expat)))
  117. (define-public opencl-icd-loader
  118. (package
  119. (name "opencl-icd-loader")
  120. (version "2021.06.30")
  121. (source (origin
  122. (method git-fetch)
  123. (uri (git-reference
  124. (url "https://github.com/KhronosGroup/OpenCL-ICD-Loader.git")
  125. (commit (string-append "v" version))))
  126. (file-name (git-file-name name version))
  127. (sha256
  128. (base32
  129. "007ws357n1ijrxal1bf9lwy68p0dz1sm9cfcfnnz5f88iwc9xd6m"))))
  130. (build-system cmake-build-system)
  131. (arguments `(#:tests? #f)) ; Tests need stub loader setup.
  132. (native-search-paths
  133. (list (search-path-specification
  134. (variable "OCL_ICD_VENDORS")
  135. (files '("etc/OpenCL/vendors")))))
  136. (home-page "https://github.com/KhronosGroup/OpenCL-ICD-Loader")
  137. (inputs `(("opencl-headers" ,opencl-headers)))
  138. (synopsis "OpenCL Installable Client Driver")
  139. (description
  140. "OpenCL defines an Installable Client Driver (ICD) mechanism to allow
  141. developers to build applications against an Installable Client Driver loader
  142. (ICD loader) rather than linking their applications against a specific OpenCL
  143. implementation. The ICD Loader is responsible for:
  144. @itemize
  145. @item Exporting OpenCL API entry points
  146. @item Enumerating OpenCL implementations
  147. @item Forwarding OpenCL API calls to the correct implementation
  148. @end itemize
  149. This package contains the Khronos official OpenCL ICD Loader.")
  150. (license license:asl2.0)))
  151. (define-public ocl-icd
  152. (deprecated-package "ocl-icd" opencl-icd-loader))
  153. (define-public clinfo
  154. (package
  155. (name "clinfo")
  156. (version "3.0.21.02.21")
  157. (source
  158. (origin
  159. (method git-fetch)
  160. (uri (git-reference
  161. (url "https://github.com/Oblomov/clinfo")
  162. (commit version)))
  163. (file-name (git-file-name name version))
  164. (sha256
  165. (base32 "1sfxp6ai83i0vwdg7b05h0k07q6873q1z1avnyksj5zmzdnxya6j"))))
  166. (build-system gnu-build-system)
  167. (native-inputs
  168. `(("opencl-headers" ,opencl-headers)))
  169. (inputs
  170. `(("opencl-icd-loader" ,opencl-icd-loader)))
  171. (arguments
  172. `(#:make-flags
  173. (list ,(string-append "CC=" (cc-for-target))
  174. (string-append "PREFIX=" (assoc-ref %outputs "out")))
  175. #:phases (modify-phases %standard-phases (delete 'configure))
  176. #:tests? #f))
  177. (home-page "https://github.com/Oblomov/clinfo")
  178. (synopsis "Print information about OpenCL platforms and devices")
  179. ;; Only the implementation installed via Guix will be detected.
  180. (description
  181. "This package provides the @command{clinfo} command that enumerates all
  182. possible (known) properties of the OpenCL platform and devices available on
  183. the system.")
  184. (license license:cc0)))
  185. (define-public beignet
  186. (package
  187. (name "beignet")
  188. (version "1.3.2")
  189. (source
  190. (origin
  191. (method git-fetch)
  192. (uri (git-reference
  193. (url "https://github.com/intel/beignet")
  194. (commit (string-append "Release_v" version))))
  195. (file-name (git-file-name name version))
  196. (sha256
  197. (base32 "0lpv3lvi2vrmzb8blflrpbd3jgin76zqmz6jcv17vn9mylqdrfnd"))
  198. (patches (search-patches "beignet-correct-file-names.patch"))
  199. (modules '((guix build utils)))
  200. (snippet
  201. ;; There's a suspicious .isa binary file under kernels/.
  202. ;; Remove it.
  203. '(for-each delete-file (find-files "." "\\.isa$")))))
  204. (native-inputs `(("pkg-config" ,pkg-config)
  205. ("python" ,python)))
  206. (inputs `(("clang@3.7" ,clang-3.7)
  207. ("clang-runtime@3.7" ,clang-runtime-3.7)
  208. ("glu" ,glu)
  209. ("llvm@3.7" ,llvm-3.7)
  210. ("libdrm" ,libdrm)
  211. ("libedit" ,libedit)
  212. ("libpthread-stubs" ,libpthread-stubs)
  213. ("libsm" ,libsm)
  214. ("libva" ,libva)
  215. ("libxfixes" ,libxfixes)
  216. ("libxext" ,libxext)
  217. ("mesa-utils" ,mesa-utils)
  218. ("ncurses" ,ncurses)
  219. ("opencl-icd-loader" ,opencl-icd-loader)
  220. ("opencl-headers" ,opencl-headers)
  221. ("xextproto" ,xextproto)
  222. ("zlib" ,zlib)))
  223. (build-system cmake-build-system)
  224. (arguments
  225. `(#:configure-flags
  226. (list (string-append "-DCLANG_LIBRARY_DIR="
  227. (assoc-ref %build-inputs "clang@3.7") "/lib")
  228. "-DENABLE_GL_SHARING=ON"
  229. "-DEXPERIMENTAL_DOUBLE=ON")
  230. #:phases
  231. (modify-phases %standard-phases
  232. (add-after 'install 'remove-headers
  233. (lambda* (#:key outputs #:allow-other-keys)
  234. (let ((out (assoc-ref outputs "out")))
  235. (delete-file-recursively
  236. (string-append out "/include"))
  237. #t)))
  238. (add-after 'remove-headers 'install-kernels
  239. (lambda* (#:key outputs #:allow-other-keys)
  240. (let* ((out (assoc-ref outputs "out"))
  241. (builddir (getcwd))
  242. (source-dir (string-append
  243. builddir
  244. "/../beignet-Release_v1.3.2/kernels")))
  245. (copy-recursively source-dir
  246. (string-append out "/lib/beignet/kernels"))
  247. #t))))
  248. ;; Beignet tries to find GPU when running tests, which is not available
  249. ;; during build.
  250. #:tests? #f))
  251. (home-page "https://wiki.freedesktop.org/www/Software/Beignet/")
  252. (synopsis "OpenCL framework for Intel GPUs")
  253. (description
  254. "Beignet is an implementation of the OpenCL specification. This code
  255. base contains the code to run OpenCL programs on Intel GPUs---IvyBridge,
  256. Haswell, Skylake, Apollolake, etc. It defines and implements the OpenCL host
  257. functions required to initialize the device, create the command queues, the
  258. kernels and the programs, and run them on the GPU. The code also contains a
  259. back-end for the LLVM compiler framework.")
  260. ;; Beignet only supports Intel processors.
  261. (supported-systems '("x86_64-linux" "i686-linux"))
  262. (license license:lgpl2.1+)))
  263. (define-public pocl
  264. (package
  265. (name "pocl")
  266. (version "1.4")
  267. (source
  268. (origin
  269. (method git-fetch)
  270. (uri (git-reference
  271. (url "https://github.com/pocl/pocl")
  272. (commit (string-append "v" version))))
  273. (sha256
  274. (base32 "1c4y69zks6hkq5fqh9waxgb8g4ka7y6h3vacmsm720kba0h57g8a"))
  275. (file-name (git-file-name name version))))
  276. (build-system cmake-build-system)
  277. (native-inputs
  278. `(("libltdl" ,libltdl)
  279. ("pkg-config" ,pkg-config)))
  280. (inputs
  281. `(("clang" ,clang)
  282. ("hwloc" ,hwloc-2 "lib")
  283. ("llvm" ,llvm)
  284. ("opencl-icd-loader" ,opencl-icd-loader)))
  285. (arguments
  286. `(#:configure-flags
  287. (list "-DENABLE_ICD=ON"
  288. "-DENABLE_TESTSUITES=ON"
  289. ;; We are not developers, don't run conformance suite.
  290. "-DENABLE_CONFORMANCE=OFF"
  291. (string-append "-DEXTRA_HOST_LD_FLAGS=-L"
  292. (assoc-ref %build-inputs "libc") "/lib"))
  293. #:phases
  294. (modify-phases %standard-phases
  295. (add-before 'check 'set-HOME
  296. (lambda _
  297. (setenv "HOME" "/tmp")
  298. #t)))))
  299. (home-page "http://portablecl.org/")
  300. (synopsis "Portable Computing Language (pocl), an OpenCL implementation")
  301. (description
  302. "Pocl is a portable implementation of the OpenCL standard (1.2 with some
  303. 2.0 features supported). This project seeks to improve performance
  304. portability of OpenCL programs with the kernel compiler and the task run-time,
  305. reducing the need for target-dependent manual optimizations.
  306. pocl uses Clang as an OpenCL C frontend and LLVM for kernel compiler
  307. implementation, and as a portability layer. Thus, if your desired target has
  308. an LLVM backend, it should be able to get OpenCL support easily by using
  309. pocl.")
  310. (license license:expat)))
  311. (define-public python-pytools
  312. (package
  313. (name "python-pytools")
  314. (version "2021.2.7")
  315. (source
  316. (origin
  317. (method url-fetch)
  318. (uri (pypi-uri "pytools" version))
  319. (sha256
  320. (base32 "1yyr4k6sqx859gjhc02633l2vxwdnj6m2f5blmf7dgq0gzzgcf05"))))
  321. (build-system python-build-system)
  322. (arguments `(#:tests? #f)) ; Tests depend on packages not present in Guix.
  323. (propagated-inputs
  324. `(("python-appdirs" ,python-appdirs)
  325. ("python-numpy" ,python-numpy)))
  326. (home-page "https://pypi.org/project/pytools/")
  327. (synopsis "Assorted tools for Python")
  328. (description
  329. "Pytools is a bag of things that are ``missing'' from the Python standard
  330. library:
  331. @itemize
  332. @item
  333. small helper functions such as @code{len_iterable}, @code{argmin},
  334. tuple generation, permutation generation, ASCII table pretty printing,
  335. GvR's @code{monkeypatch_xxx} hack, the elusive @code{flatten}, and much more.
  336. @item
  337. Michele Simionato's decorator module
  338. @item
  339. A time-series logging module, @code{pytools.log}.
  340. @item
  341. Batch job submission, @code{pytools.batchjob}.
  342. @item
  343. A lexer, @code{pytools.lex}.
  344. @end itemize\n")
  345. (license license:expat)))
  346. (define-public python-pyopencl
  347. (package
  348. (name "python-pyopencl")
  349. (version "2021.2.6")
  350. (source
  351. (origin
  352. (method git-fetch)
  353. (uri (git-reference
  354. (url "https://github.com/inducer/pyopencl.git")
  355. (commit (string-append "v" version))
  356. (recursive? #t)))
  357. (file-name (git-file-name name version))
  358. (sha256
  359. (base32
  360. "1s2cls7avxvf753zzpx422ikslaxdnm8rz58zg7mal15yak0wv2x"))))
  361. (build-system python-build-system)
  362. (arguments
  363. `(#:tests? #f)) ; Tests cannot find pygpu_language_opencl.cpp
  364. (inputs
  365. `(("opencl-headers" ,opencl-headers)
  366. ("pybind11" ,pybind11)
  367. ("opencl-icd-loader" ,opencl-icd-loader))) ;libOpenCL
  368. (propagated-inputs
  369. `(("python-appdirs" ,python-appdirs)
  370. ("python-numpy" ,python-numpy)
  371. ("python-pytools" ,python-pytools)
  372. ("python-mako" ,python-mako)))
  373. (home-page "http://mathema.tician.de/software/pyopencl")
  374. (synopsis "Python wrapper for OpenCL")
  375. (description
  376. "PyOpenCL lets you access parallel computing devices such as GPUs from
  377. Python @i{via} OpenCL.")
  378. (license license:expat)))