rocm.scm 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2021 Lars-Dominik Braun <lars@6xq.net>
  3. ;;;
  4. ;;; This program is free software; you can redistribute it and/or modify it
  5. ;;; under the terms of the GNU General Public License as published by
  6. ;;; the Free Software Foundation; either version 3 of the License, or (at
  7. ;;; your option) any later version.
  8. ;;;
  9. ;;; This program is distributed in the hope that it will be useful, but
  10. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;;; GNU General Public License for more details.
  13. ;;;
  14. ;;; You should have received a copy of the GNU General Public License
  15. ;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. (define-module (gnu packages rocm)
  17. #:use-module ((guix licenses) #:prefix license:)
  18. #:use-module (guix packages)
  19. #:use-module (guix download)
  20. #:use-module (guix utils)
  21. #:use-module (guix git-download)
  22. #:use-module (guix build-system cmake)
  23. #:use-module (gnu packages)
  24. #:use-module (gnu packages elf)
  25. #:use-module (gnu packages gl)
  26. #:use-module (gnu packages linux)
  27. #:use-module (gnu packages llvm)
  28. #:use-module (gnu packages opencl)
  29. #:use-module (gnu packages version-control)
  30. #:use-module (gnu packages vim))
  31. ;; The components are tightly integrated and can only be upgraded as a unit. If
  32. ;; you want to upgrade ROCm, bump this version number and update hashes below.
  33. (define %rocm-version "4.3.0")
  34. (define-public rocm-cmake
  35. (package
  36. (name "rocm-cmake")
  37. (version %rocm-version)
  38. (source (origin
  39. (method git-fetch)
  40. (uri (git-reference
  41. (url "https://github.com/RadeonOpenCompute/rocm-cmake.git")
  42. (commit (string-append "rocm-" version))))
  43. (file-name (git-file-name name version))
  44. (sha256
  45. (base32
  46. "0sic2zxmzl2pb2865vvq55mbpcr8pby8v19pjdlm08pypqw5h6h6"))))
  47. (build-system cmake-build-system)
  48. (arguments `(#:tests? #f)) ; Tests try to use git commit
  49. (native-inputs `(("git" ,git)))
  50. (home-page "https://github.com/RadeonOpenCompute/rocm-cmake")
  51. (synopsis "ROCm cmake modules")
  52. (description "ROCm cmake modules provides cmake modules for common build
  53. tasks needed for the ROCM software stack.")
  54. (license license:ncsa)))
  55. (define-public rocm-device-libs
  56. (package
  57. (name "rocm-device-libs")
  58. (version %rocm-version)
  59. (source (origin
  60. (method git-fetch)
  61. (uri (git-reference
  62. (url "https://github.com/RadeonOpenCompute/ROCm-Device-Libs.git")
  63. (commit (string-append "rocm-" version))))
  64. (file-name (git-file-name name version))
  65. (sha256
  66. (base32
  67. "1f8xsylfajpxqjk6ayjnrry53y8b0a6lh9d72pd41nffxfyzvw3w"))))
  68. (build-system cmake-build-system)
  69. (arguments
  70. `(#:configure-flags
  71. (list "-DCMAKE_SKIP_BUILD_RPATH=FALSE"
  72. "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE")))
  73. (inputs `(("llvm" ,llvm-for-rocm)))
  74. (home-page "https://github.com/RadeonOpenCompute/ROCm-Device-Libs")
  75. (synopsis "ROCm Device libraries")
  76. (description "AMD-specific device-side language runtime libraries, namely
  77. oclc, ocml, ockl, opencl, hip and hc.")
  78. (license license:ncsa)))
  79. (define-public rocm-comgr
  80. (package
  81. (name "rocm-comgr")
  82. (version %rocm-version)
  83. (source (origin
  84. (method git-fetch)
  85. (uri (git-reference
  86. (url "https://github.com/RadeonOpenCompute/ROCm-CompilerSupport.git")
  87. (commit (string-append "rocm-" version))))
  88. (file-name (git-file-name name version))
  89. (sha256
  90. (base32
  91. "0bakbm7shr0l67lph44b5cnc9psd6rivg1mp79qizaawkn380x60"))
  92. (patches
  93. (search-patches "rocm-comgr-3.1.0-dependencies.patch"))))
  94. (build-system cmake-build-system)
  95. (arguments
  96. `(#:phases
  97. (modify-phases %standard-phases
  98. (add-after 'unpack 'chdir
  99. (lambda _
  100. (chdir "lib/comgr"))))))
  101. (inputs
  102. `(("rocm-device-libs" ,rocm-device-libs)
  103. ("llvm" ,llvm-for-rocm)
  104. ("lld" ,lld)))
  105. (home-page "https://github.com/RadeonOpenCompute/ROCm-CompilerSupport")
  106. (synopsis "ROCm Code Object Manager")
  107. (description "The Comgr library provides APIs for compiling and inspecting
  108. AMDGPU code objects.")
  109. (license license:ncsa)))
  110. (define-public roct-thunk-interface
  111. (package
  112. (name "roct-thunk-interface")
  113. (version %rocm-version)
  114. (source (origin
  115. (method git-fetch)
  116. (uri (git-reference
  117. (url "https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface.git")
  118. (commit (string-append "rocm-" version))))
  119. (file-name (git-file-name name version))
  120. (sha256
  121. (base32
  122. "0ffqhrrscmcydfqf61dk58d7nnxk6n2k68jhqfj7a4hvhlphb74f"))))
  123. (build-system cmake-build-system)
  124. (arguments `(#:tests? #f)) ; Not sure how to run tests.
  125. (inputs `(("numactl" ,numactl)))
  126. (home-page "https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface")
  127. (synopsis "Radeon Open Compute Thunk Interface")
  128. (description "User-mode API interfaces used to interact with the ROCk
  129. driver.")
  130. (license license:ncsa)))
  131. (define-public rocr-runtime
  132. (package
  133. (name "rocr-runtime")
  134. (version %rocm-version)
  135. (source (origin
  136. (method git-fetch)
  137. (uri (git-reference
  138. (url "https://github.com/RadeonOpenCompute/ROCR-Runtime.git")
  139. (commit (string-append "rocm-" version))))
  140. (file-name (git-file-name name version))
  141. (sha256
  142. (base32
  143. "0jqfqf5ymwlbpac065bhigmkgsk7mbyimdgvca7ymn38wpf80ka7"))))
  144. (build-system cmake-build-system)
  145. (arguments
  146. `(#:configure-flags
  147. `(,(string-append
  148. "-DBITCODE_DIR="
  149. (assoc-ref %build-inputs "rocm-device-libs")
  150. "/amdgcn/bitcode/"))
  151. #:tests? #f ; No tests.
  152. #:phases
  153. (modify-phases %standard-phases
  154. (add-after 'unpack 'chdir
  155. (lambda _
  156. (chdir "src"))))))
  157. (inputs
  158. `(("libelf" ,libelf)
  159. ("numactl" ,numactl)
  160. ("llvm" ,llvm-for-rocm)
  161. ("roct-thunk-interface" ,roct-thunk-interface)
  162. ("rocm-device-libs" ,rocm-device-libs))) ; For bitcode.
  163. (native-inputs `(("xxd" ,xxd)))
  164. (home-page "https://github.com/RadeonOpenCompute/ROCR-Runtime")
  165. (synopsis "ROCm Platform Runtime")
  166. (description "User-mode API interfaces and libraries necessary for host
  167. applications to launch compute kernels to available HSA ROCm kernel agents.")
  168. (license license:ncsa)))
  169. (define-public rocclr
  170. (package
  171. (name "rocclr")
  172. (version %rocm-version)
  173. (source (origin
  174. (method git-fetch)
  175. (uri (git-reference
  176. (url "https://github.com/ROCm-Developer-Tools/ROCclr.git")
  177. (commit (string-append "rocm-" version))))
  178. (file-name (git-file-name name version))
  179. (sha256
  180. (base32
  181. "1pm1y020zriz7zmi95w0rcpka0jrsc7wwh81sssnysi8wxk3nnfy"))))
  182. (build-system cmake-build-system)
  183. (arguments
  184. `(#:tests? #f ; No tests.
  185. #:configure-flags
  186. `(,(string-append
  187. "-DOPENCL_DIR="
  188. (assoc-ref %build-inputs "rocm-opencl-runtime-src")))))
  189. (inputs
  190. `(("mesa" ,mesa)
  191. ("rocm-comgr" ,rocm-comgr)
  192. ("llvm" ,llvm-for-rocm)
  193. ("rocm-device-libs" ,rocm-device-libs)
  194. ("rocr-runtime" ,rocr-runtime)
  195. ("rocm-cmake" ,rocm-cmake)
  196. ;; rocclr depends on a few headers provided by rocm-opencl-runtime.
  197. ("rocm-opencl-runtime-src"
  198. ,(origin
  199. (method git-fetch)
  200. (uri (git-reference
  201. (url "https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime.git")
  202. (commit (string-append "rocm-" version))))
  203. (file-name (git-file-name name version))
  204. (sha256
  205. (base32
  206. "1cglpiaj3ny1z74ssmy6j63vj92sfy4q38ix6qsga0mg3b2wvqz3"))))))
  207. (home-page "https://github.com/ROCm-Developer-Tools/ROCclr")
  208. (synopsis "Radeon Open Compute Common Language Runtime")
  209. (description "ROCclr is a virtual device interface that compute runtimes
  210. interact with to different backends such as ROCr or PAL. This abstraction
  211. allows runtimes to work on Windows as well as on Linux without much effort.")
  212. (license license:ncsa)))
  213. (define-public rocm-opencl-runtime
  214. (package
  215. (name "rocm-opencl-runtime")
  216. (version %rocm-version)
  217. (home-page "https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime")
  218. (source (origin
  219. (method git-fetch)
  220. (uri (git-reference
  221. (url home-page)
  222. (commit (string-append "rocm-" version))))
  223. (file-name (git-file-name name version))
  224. (sha256
  225. (base32
  226. "1cglpiaj3ny1z74ssmy6j63vj92sfy4q38ix6qsga0mg3b2wvqz3"))
  227. (patches
  228. (search-patches
  229. "rocm-opencl-runtime-3.10.0-includes.patch"
  230. ;; Do not install libOpenCL, which ocl-icd provides.
  231. "rocm-opencl-runtime-4.3-noopencl.patch"
  232. ;; Guix includes a program clinfo already.
  233. "rocm-opencl-runtime-4.3-noclinfo.patch"
  234. ;; cltrace linking fails, remove it.
  235. "rocm-opencl-runtime-4.3-nocltrace.patch"))))
  236. (build-system cmake-build-system)
  237. (arguments
  238. `(#:tests? #f ; Not sure how to run them.
  239. #:phases
  240. (modify-phases %standard-phases
  241. (add-after 'install 'create-icd
  242. ;; Manually install ICD, which simply consists of dumping
  243. ;; the path of the .so into the correct file.
  244. (lambda* (#:key outputs #:allow-other-keys)
  245. (let* ((out (assoc-ref outputs "out"))
  246. (vendors (string-append out "/etc/OpenCL/vendors"))
  247. (sopath (string-append out "/lib/libamdocl64.so")))
  248. (mkdir-p vendors)
  249. (with-output-to-file (string-append vendors "/amdocl64.icd")
  250. (lambda _ (display sopath)))))))))
  251. (inputs
  252. `(("mesa" ,mesa)
  253. ("rocm-comgr" ,rocm-comgr)
  254. ("rocr-runtime" ,rocr-runtime)
  255. ("rocclr" ,rocclr)
  256. ("opencl-icd-loader" ,opencl-icd-loader)
  257. ("glew" ,glew)))
  258. (native-inputs `())
  259. (synopsis "ROCm OpenCL Runtime")
  260. (description "OpenCL 2.0 compatible language runtime, supporting offline
  261. and in-process/in-memory compilation.")
  262. (license license:ncsa)))
  263. (define-public rocminfo
  264. (package
  265. (name "rocminfo")
  266. (version %rocm-version)
  267. (source (origin
  268. (method git-fetch)
  269. (uri (git-reference
  270. (url "https://github.com/RadeonOpenCompute/rocminfo.git")
  271. (commit (string-append "rocm-" version))))
  272. (file-name (git-file-name name version))
  273. (sha256
  274. (base32
  275. "0pcm308vwkjrwnrk507iya20mkil8j0vx699w9jk2gas4n4jvkcz"))))
  276. (build-system cmake-build-system)
  277. (arguments
  278. `(#:tests? #f ; No tests.
  279. #:phases
  280. (modify-phases %standard-phases
  281. (add-after 'unpack 'patch-binary-paths
  282. (lambda* (#:key inputs #:allow-other-keys)
  283. (substitute* "rocminfo.cc"
  284. (("lsmod")
  285. (string-append (assoc-ref inputs "kmod") "/bin/lsmod"))
  286. (("grep") (which "grep"))))))))
  287. (inputs
  288. `(("rocr-runtime" ,rocr-runtime)
  289. ("kmod" ,kmod)))
  290. (home-page "https://github.com/RadeonOpenCompute/rocminfo")
  291. (synopsis "ROCm Application for Reporting System Info")
  292. (description "List @acronym{HSA,Heterogeneous System Architecture} Agents
  293. available to ROCm and show their properties.")
  294. (license license:ncsa)))
  295. (define-public rocm-bandwidth-test
  296. (package
  297. (name "rocm-bandwidth-test")
  298. (version %rocm-version)
  299. (source (origin
  300. (method git-fetch)
  301. (uri (git-reference
  302. (url "https://github.com/RadeonOpenCompute/rocm_bandwidth_test.git")
  303. (commit (string-append "rocm-" version))))
  304. (file-name (git-file-name name version))
  305. (sha256
  306. (base32
  307. "0a14kwkjpiyljgzxblh031qibn6xgbxp6m12zdy1pmwb2c44jjmm"))))
  308. (build-system cmake-build-system)
  309. (arguments `(#:tests? #f)) ; No tests.
  310. (inputs `(("rocr-runtime" ,rocr-runtime)))
  311. (home-page "https://github.com/RadeonOpenCompute/rocm_bandwidth_test")
  312. (synopsis "Bandwidth test for ROCm")
  313. (description "RocBandwidthTest is designed to capture the performance
  314. characteristics of buffer copying and kernel read/write operations. The help
  315. screen of the benchmark shows various options one can use in initiating
  316. cop/read/writer operations. In addition one can also query the topology of the
  317. system in terms of memory pools and their agents.")
  318. (license license:ncsa)))