projects/guix·blob python-team · refs

878 lines · 34.1 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2021 Lars-Dominik Braun <[email protected]>
3;;; Copyright © 2022, 2023, 2025 John Kehayias <[email protected]>
4;;; Copyright © 2026 Jean-Baptiste Note <[email protected]>
5;;; Copyright © 2023 Advanced Micro Devices, Inc.
6;;; Copyright © 2026 David Elsing <[email protected]>
7;;;
8;;; This program is free software; you can redistribute it and/or modify it
9;;; under the terms of the GNU General Public License as published by
10;;; the Free Software Foundation; either version 3 of the License, or (at
11;;; your option) any later version.
12;;;
13;;; This program is distributed in the hope that it will be useful, but
14;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;;; GNU General Public License for more details.
17;;;
18;;; You should have received a copy of the GNU General Public License
19;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21(define-module (gnu packages rocm)
22 #:use-module ((guix licenses) #:prefix license:)
23 #:use-module (guix packages)
24 #:use-module (guix download)
25 #:use-module (guix gexp)
26 #:use-module (guix utils)
27 #:use-module (guix git-download)
28 #:use-module (guix build-system cmake)
29 #:use-module (guix amd-gpu)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages base)
32 #:use-module (gnu packages boost)
33 #:use-module (gnu packages check)
34 #:use-module (gnu packages cpp)
35 #:use-module (gnu packages curl)
36 #:use-module (gnu packages elf)
37 #:use-module (gnu packages gcc)
38 #:use-module (gnu packages gl)
39 #:use-module (gnu packages instrumentation)
40 #:use-module (gnu packages linux)
41 #:use-module (gnu packages llvm)
42 #:use-module (gnu packages logging)
43 #:use-module (gnu packages opencl)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages pretty-print)
46 #:use-module (gnu packages python)
47 #:use-module (gnu packages python-build)
48 #:use-module (gnu packages python-xyz)
49 #:use-module (gnu packages version-control)
50 #:use-module (gnu packages vim)
51 #:use-module (gnu packages perl)
52 #:use-module (gnu packages profiling)
53 #:use-module (gnu packages xdisorg)
54 #:use-module (gnu packages xml)
55 #:use-module (gnu packages xorg)
56 #:use-module (gnu packages libffi)
57 #:use-module (ice-9 match)
58 #:re-export (%default-amd-gpu-targets
59 current-amd-gpu-targets
60 current-amd-gpu-targets-string))
61
62;; The components are tightly integrated and can only be upgraded as a unit. If
63;; you want to upgrade ROCm, bump this version number and the version number in
64;; - rocm-libs.scm
65;; - rocm-tools.scm
66;; - gdb.scm
67;; and update the hashes of the affected packages.
68
69(define %rocm-version "7.1.1")
70
71;; ROCm-systems derived packages belong here.
72
73(define %rocm-systems-url "https://github.com/ROCm/rocm-systems")
74(define %rocm-systems-origin
75 (origin
76 (method git-fetch)
77 (uri (git-reference
78 (url (string-append %rocm-systems-url))
79 (commit (string-append "rocm-" %rocm-version))))
80 (file-name (git-file-name "rocm-systems" %rocm-version))
81 (sha256
82 (base32
83 "056dwpkddjj5gq4xys1vbca0znq4qlhqnfdsgp1y9c5y9avqfkxx"))
84 (patches
85 (search-patches
86 "rocclr-5.6.0-enable-gfx800.patch"
87 "rocm-opencl-runtime-4.3-noclinfo.patch"))))
88
89(define-public rocr-runtime
90 (package
91 (name "rocr-runtime")
92 (version %rocm-version)
93 (source %rocm-systems-origin)
94 (build-system cmake-build-system)
95 (arguments
96 (list
97 #:tests? #f ; No tests.
98 #:build-type "Release"
99 #:phases
100 #~(modify-phases %standard-phases
101 (add-after 'unpack 'chdir
102 (lambda _
103 (chdir "projects/rocr-runtime")))
104 (add-after 'unpack 'add-rocm-device-lib-path
105 (lambda _
106 (setenv "ROCM_PATH"
107 #$(this-package-input "rocm-device-libs")))))))
108 (inputs
109 (list libdrm
110 libelf-shared
111 clang-rocm
112 lld-rocm
113 numactl
114 rocm-device-libs
115 rocprofiler-register))
116 (native-inputs (list pkg-config xxd))
117 (home-page %rocm-systems-url)
118 (synopsis "ROCm Platform Runtime")
119 (description "User-mode API interfaces and libraries necessary for host
120applications to launch compute kernels to available HSA ROCm kernel agents.")
121 (license license:ncsa)))
122
123(define-public rocm-opencl-runtime
124 (package
125 (name "rocm-opencl-runtime")
126 (version %rocm-version)
127 (home-page %rocm-systems-url)
128 (source %rocm-systems-origin)
129 (build-system cmake-build-system)
130 (arguments
131 (list
132 #:tests? #f ; Not sure how to run them.
133 #:build-type "Release"
134 #:configure-flags
135 #~(list
136 (string-append "-DAMD_OPENCL_PATH=" #$(package-source this-package))
137 "-DCLR_BUILD_OCL=ON"
138 (string-append "-DROCM_PATH=" #$output)
139 ;; Don't build the ICD loader as we have the opencl-icd-loader
140 ;; package already.
141 "-DBUILD_ICD=OFF"
142 ;; Don't duplicate the install in an "opencl" directory as well.
143 "-DFILE_REORG_BACKWARD_COMPATIBILITY=OFF")
144 #:phases
145 #~(modify-phases %standard-phases
146 (add-after 'unpack 'chdir
147 (lambda _
148 (chdir "projects/clr")))
149 (add-after 'chdir 'no-os-release
150 (lambda _
151 (substitute* "opencl/packaging/CMakeLists.txt"
152 (("/etc/os-release") "/dev/null"))))
153 (add-after 'install 'create-icd
154 ;; Manually install ICD, which simply consists of dumping
155 ;; the path of the .so into the correct file.
156 (lambda* (#:key outputs #:allow-other-keys)
157 (let* ((vendors (string-append #$output "/etc/OpenCL/vendors"))
158 (sopath (string-append #$output "/lib/libamdocl64.so")))
159 (mkdir-p vendors)
160 (with-output-to-file (string-append vendors "/amdocl64.icd")
161 (lambda _ (display sopath)))))))))
162 (inputs
163 (list glew
164 mesa
165 numactl
166 opencl-headers
167 opencl-icd-loader
168 libffi
169 rocm-comgr
170 rocr-runtime))
171 (synopsis "ROCm OpenCL Runtime")
172 (description "OpenCL 2.0 compatible language runtime, supporting offline
173and in-process/in-memory compilation.")
174 (license license:expat)))
175
176;; this runtime includes the hipcc and hip-config present in rocm-hipcc
177;; wrapping them in rocm-hipcc allows the copies that are made here to be
178;; wrapped also.
179(define-public rocm-hip-runtime
180 (package
181 (name "rocm-hip-runtime")
182 (version %rocm-version)
183 (home-page %rocm-systems-url)
184 (source %rocm-systems-origin)
185 (build-system cmake-build-system)
186 (arguments
187 (list
188 #:tests? #f ; Not sure how to run them.
189 #:build-type "Release"
190 #:configure-flags
191 #~(list
192 (string-append "-DAMD_OPENCL_PATH=" #$(package-source this-package))
193 "-DCLR_BUILD_HIP=ON"
194 "-DCLR_BUILD_OCL=OFF"
195 (string-append "-DROCM_PATH=" #$output)
196 "-DHIP_PLATFORM=amd"
197 (string-append
198 "-DHIPCC_BIN_DIR=" #$(this-package-native-input "rocm-hipcc") "/bin")
199 (string-append
200 "-DHIP_COMMON_DIR=" #$(package-source this-package) "/projects/hip")
201 ;; for now
202 "-DUSE_PROF_API=OFF")
203 #:phases
204 #~(modify-phases %standard-phases
205 (add-after 'unpack 'chdir
206 (lambda _
207 (chdir "projects/clr")))
208 (add-after 'chdir 'no-os-release
209 (lambda _
210 (substitute* '("hipamd/packaging/CMakeLists.txt"
211 "hipamd/CMakeLists.txt")
212 (("/etc/os-release") "/dev/null"))))
213 (add-after 'chdir 'less-cmake-warnings
214 (lambda _
215 (substitute* "rocclr/cmake/ROCclrLC.cmake"
216 (("2\\.9") "3.0"))))
217 (add-after 'chdir 'fix-clang-location-for-embed-pch
218 (lambda _
219 (substitute* "hipamd/src/CMakeLists.txt"
220 ;; differentiate between CLANG and LLVM packages
221 (("\\$\\{HIP_LLVM_ROOT\\}")
222 (string-append "${HIP_LLVM_ROOT} "
223 #$(this-package-native-input "clang-rocm"))))
224 (substitute* "hipamd/src/hip_embed_pch.sh"
225 (("\\$5") "$6")
226 (("LLVM_DIR=\"\\$4\"")
227 "LLVM_DIR=\"$4\"; CLANG_DIR=\"$5\";")
228 (("\\$LLVM_DIR/bin/clang")
229 (string-append "$CLANG_DIR/bin/clang")))))
230 ;; Packages that require `hipcc' should use the `rocm-hipcc'
231 ;; package. This disables the installation of `hipcc' and
232 ;; `hipconfig' binaries, and makes sure that the references to them
233 ;; are expected to be found in $PATH.
234 (add-after 'chdir 'disable-hipcc-installation
235 (lambda _
236 (substitute* "hipamd/CMakeLists.txt"
237 (("if \\(NOT \\$\\{HIPCC_BIN_DIR\\} STREQUAL \"\"\\)")
238 "if (FALSE)"))
239 (substitute* "hipamd/hip-config.cmake.in"
240 (("\\$\\{hip_HIPCC_EXECUTABLE\\}")
241 "hipcc")
242 (("\\$\\{hip_HIPCONFIG_EXECUTABLE\\}")
243 "hipconfig"))))
244 ;; Adjust CMAKE helper so hipconfig is retrieved from path.
245 (add-after 'install 'adjust-cmake-helpers
246 (lambda _
247 (substitute* (string-append #$output "/bin/hipcc_cmake_linker_helper")
248 (("\\$HIP_PATH/bin/hipconfig")
249 "hipconfig")
250 (("\\$HIP_PATH/bin/hipcc")
251 "hipcc")))))))
252 (inputs
253 (list glew
254 mesa
255 numactl
256 perl
257 opencl-headers
258 rocr-runtime
259 rocm-device-libs
260 rocprofiler-register
261 libffi))
262 (native-inputs (list rocm-hipcc clang-rocm))
263 (propagated-inputs
264 (list rocm-comgr rocminfo))
265 (synopsis "ROCm HIP Runtime")
266 (description "HIP language runtime, allowing execution of HIP kernels
267on AMD hardware, with library support for in-process/in-memory
268compilation (hipclr) of HIP kernel code, and its execution on AMD hardware.")
269 (license license:expat)))
270
271(define-public rocminfo
272 (package
273 (name "rocminfo")
274 (version %rocm-version)
275 (source %rocm-systems-origin)
276 (build-system cmake-build-system)
277 (arguments
278 (list
279 #:tests? #f ; No tests.
280 #:phases
281 #~(modify-phases %standard-phases
282 (add-after 'unpack 'chdir
283 (lambda _
284 (chdir "projects/rocminfo")))
285 (add-after 'chdir 'patch-binary-paths
286 (lambda* (#:key inputs #:allow-other-keys)
287 (substitute* "rocminfo.cc"
288 (("lsmod")
289 (search-input-file inputs "bin/lsmod"))
290 (("grep")
291 (search-input-file inputs "bin/grep"))))))))
292 (inputs
293 (list rocr-runtime kmod python))
294 (home-page %rocm-systems-url)
295 (synopsis "ROCm Application for Reporting System Info")
296 (description "List @acronym{HSA,Heterogeneous System Architecture} Agents
297available to ROCm and show their properties.")
298 (license license:ncsa)))
299
300
301
302;; ROCm base helpers.
303
304(define-public rocm-cmake
305 (package
306 (name "rocm-cmake")
307 (version %rocm-version)
308 (source (origin
309 (method git-fetch)
310 (uri (git-reference
311 (url "https://github.com/ROCm/rocm-cmake/")
312 (commit (string-append "rocm-" version))))
313 (file-name (git-file-name name version))
314 (sha256
315 (base32
316 "19jyymisxiikphzmq6h8vy5cg0r5dz3lxr5wvdf44frb8wxr8vla"))))
317 (build-system cmake-build-system)
318 (arguments `(#:tests? #f)) ; Tests try to use git commit
319 (native-inputs (list git-minimal/pinned))
320 (home-page "https://rocm.docs.amd.com/projects/ROCmCMakeBuildTools/")
321 (synopsis "ROCm cmake modules")
322 (description "ROCm cmake modules provides cmake modules for common build
323tasks needed for the ROCM software stack.")
324 (license license:ncsa)))
325
326(define-public rocm-hip-cpu
327 ;; There are no releases or tags.
328 (let ((commit "e112c935057434897bb12d9ab3910380a8bd5f58")
329 (release "0"))
330 (package
331 (name "rocm-hip-cpu")
332 (version "0.1.4142") ;from CMakeLists.txt
333 (source
334 (origin
335 (method git-fetch)
336 (uri (git-reference
337 (url "https://github.com/ROCm/HIP-CPU/")
338 (commit commit)))
339 (file-name (git-file-name name version))
340 (sha256
341 (base32
342 "1rbih56kfry7scvww54dwx8ph11ddzc5bf4ww1vs1vmhi3r05gpa"))))
343 (build-system cmake-build-system)
344 (arguments
345 (list
346 #:configure-flags #~(list "-DBUILD_EXAMPLES=ON")))
347 (home-page "https://github.com/ROCm/HIP-CPU/")
348 (synopsis "Implementation of HIP that works on CPUs")
349 (description "The HIP CPU Runtime is a header-only library that allows
350CPUs to execute unmodified HIP code. It is generic and does not assume a
351particular CPU vendor or architecture.")
352 (license license:expat))))
353
354(define-public rocm-bandwidth-test
355 (package
356 (name "rocm-bandwidth-test")
357 (version %rocm-version)
358 (source (origin
359 (method git-fetch)
360 (uri (git-reference
361 (url "https://github.com/ROCm/rocm_bandwidth_test")
362 (commit (string-append "rocm-" version))))
363 (file-name (git-file-name name version))
364 (sha256
365 (base32
366 "03icj943x9qhilw112qbp8lc974f949qz0hc7gn1iv8q9zn2pcp8"))
367 (patches
368 (search-patches
369 "rocm-bandwidth-test-take-default-gpus-from-environment.patch"
370 "rocm-bandwidth-test-fix-hsa-include-file-lookup.patch"
371 "rocm-bandwidth-test-fix-external-packages-search.patch"))))
372 (build-system cmake-build-system)
373 (arguments
374 (list
375 #:tests? #f
376 #:build-type "Release"
377 #:configure-flags
378 #~(list
379 "-DAMD_APP_TREAT_WARNINGS_AS_ERRORS=FALSE"
380 "-DAMD_APP_ROCM_BUILD_PACKAGE=ON"
381 ;; The rocm build system is very opiniated about the rpath and
382 ;; mangles it beyond recognition, stripping all inputs from it.
383 ;; Avoid the breakage.
384 "-DAMD_APP_ROCM_BUILD_TRY_RPATH=OFF"
385 ;; Allows the plugin files to be correctly rpathed to $#output/lib
386 ;; where shared libraries reside.
387 "-DAMD_WORK_BENCH_PLUGIN_ADD_INSTALL_PREFIX_TO_RPATH=TRUE"
388 ;; Unfortunately this also needs to be patched everywhere, as the
389 ;; value is individually set to OFF for a lot of targets, and not
390 ;; propagated from the top. So set it here, and use substitutions
391 ;; below.
392 "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE"
393 (string-append "-DROCM_PATH=" #$output)
394 "-DUSE_LOCAL_FMT_LIB=ON"
395 "-DUSE_LOCAL_NLOHMANN_JSON=ON"
396 "-DUSE_LOCAL_SPDLOG=ON"
397 "-DUSE_LOCAL_BOOST=ON"
398 "-DUSE_LOCAL_CLI11=ON"
399 "-DUSE_LOCAL_CATCH2=ON")
400 #:phases
401 #~(modify-phases %standard-phases
402 (add-after 'unpack 'patch-out-bogus-git-requirement
403 (lambda _
404 (substitute* "CMakeLists.txt"
405 (("find_package\\(Git QUIET\\)")
406 "set(GIT_FOUND ON)"))))
407 ;; This converts the 'amd-gpu-targets' property to its proper entry
408 ;; point in this package; this relies on the patch
409 ;; rocm-bandwidth-test-take-default-gpus-from-environment.patch
410 ;; above, as I can't seem to find a way to do multiline matches.
411 ;; Note that compiling for all GPUs architectures is sequential, and
412 ;; will run for a very long time.
413 (add-after 'unpack 'inject-amdgpu-targets
414 (lambda _
415 (substitute* "plugins/tb/transferbench/CMakeLists.txt"
416 (("set\\(DEFAULT_GPUS[^)]*\\)")
417 (string-append "set(DEFAULT_GPUS "
418 #$(string-join (current-amd-gpu-targets))
419 ")" )))))
420 ;; See configure-flags above.
421 (add-after 'unpack 'fix-use-link-path
422 (lambda _
423 (substitute* (find-files "." "CMakeLists\\.txt$|\\.cmake$")
424 ;; NB: this will also catch instances of
425 ;; CMAKE_INSTALL_RPATH_USE_LINK_PATH
426 (("INSTALL_RPATH_USE_LINK_PATH FALSE")
427 "INSTALL_RPATH_USE_LINK_PATH TRUE"))))
428 ;; For the same reason, just in case patchelf ends up in the inputs
429 ;; (the build system may require it), we remove a hardcoded rpath in
430 ;; a bash build script which triggers if patchelf is detected.
431 (add-after 'unpack 'remove-hardcoded-patchelf
432 (lambda _
433 (substitute* "plugins/tb/transferbench/build_libamd_tb.sh"
434 (("command -v patchelf") "false"))))
435 ;; XXX The build system uses -fuse-ld=lld flag for c++ linking if it
436 ;; finds ld.lld in any way. Unfortunately, for some reason, ld.lld
437 ;; does not correctly setup the rpath when compiling the
438 ;; rocm_bandwidth_test binary (the only executable which shows the
439 ;; problem). We do need ld.lld from lld-rocm in the path for
440 ;; ROCm-specific linking however. Therefore, just disable ld.lld
441 ;; lookup for standard binaries.
442 ;; I guess there's a standard Guix way to have lld behave for rpath
443 ;; -- which should be applied to lld-rocm, probably.
444 (add-after 'unpack 'dont-use-lld-for-executables
445 (lambda _
446 (substitute* "cmake/build_utils.cmake"
447 (("find_program\\(LD_LLD_PATH ld\\.lld\\)")
448 "#find_program(LD_LLD_PATH ld.lld)"))))
449 ;; This is just cosmetic and removes superfluous rpath entries
450 ;; involving a nonexistent relative llvm/lib path.
451 ;; XXX: RUNPATH checks are okay with $ORIGIN, but it looks like
452 ;; other packages are removing it altogether -- what to do?
453 (add-after 'unpack 'remove-dubious-rpath
454 (lambda _
455 (substitute* (find-files "." "CMakeLists\\.txt$|\\.cmake$")
456 ((":\\\\\\$ORIGIN(/\\.\\./lib)?/llvm/lib") "")))))))
457 (inputs (list rocm-hip-runtime
458 numactl
459 curl
460 fmt-12
461 spdlog
462 boost
463 catch2))
464 (native-inputs
465 (list cli11
466 nlohmann-json
467 rocm-cmake
468 rocm-toolchain))
469 (properties `((amd-gpu-targets . ,%default-amd-gpu-targets)))
470 (home-page "https://github.com/ROCm/rocm_bandwidth_test")
471 (synopsis "Bandwidth test for ROCm")
472 (description "RocBandwidthTest is designed to capture the performance
473characteristics of buffer copying and kernel read/write operations. The help
474screen of the benchmark shows various options one can use in initiating
475cop/read/writer operations. In addition one can also query the topology of
476the system in terms of memory pools and their agents.")
477 (license license:expat)))
478
479;; e-smi looks hard to unbundle correctly from amd-smi
480;; the required esmi version is hardcoded in CMakeLists.txt
481(define (make-esmi-source version hash)
482 (origin
483 (method git-fetch)
484 (uri (git-reference
485 (url "https://github.com/amd/esmi_ib_library.git")
486 (commit version)))
487 (file-name (git-file-name "esmi_ib_library" version))
488 (sha256 hash)))
489
490(define %e-smi-version-for-rocm "esmi_pkg_ver-4.2")
491(define e-smi-for-amd-smi
492 (make-esmi-source
493 %e-smi-version-for-rocm
494 (base32 "0z7yarzf1yzmbjicamcagxj0w1zlnwpg7qa51vp46fq075xpscbk")))
495
496(define-public amd-smi
497 (package
498 (name "amd-smi")
499 (version "26.2.0")
500 (source (origin
501 (method git-fetch)
502 (uri (git-reference
503 (url "https://github.com/ROCm/amdsmi")
504 (commit (string-append "rocm-" %rocm-version))))
505 (file-name (git-file-name name version))
506 (sha256
507 (base32
508 "10qjisjz4shsznh61in6zjjzsag49mdzj1ahclsyxhh5qvxvfrq4"))
509 (patches
510 (search-patches "amd-smi-python.patch"
511 "amd-smi-newer-libdrm.patch"))))
512 (build-system cmake-build-system)
513 (arguments (list
514 #:tests? #f ;; The test suite is empty and failing as of 25.5.1
515 #:configure-flags
516 #~(list
517 "-DBUILD_SHARED_LIBS=ON"
518 ;; this requires ctypeslib2 packaging
519 ;; "-DBUILD_WRAPPER=ON"
520 "-DENABLE_ESMI_LIB=ON"
521 "-DBUILD_CLI=ON")
522 #:phases
523 #~(modify-phases %standard-phases
524 (add-after 'unpack 'add-e-smi
525 (lambda* _
526 (copy-recursively
527 #$(this-package-input
528 (origin-file-name e-smi-for-amd-smi))
529 "esmi_ib_library")
530 ;; Fool cmake, which uses failing git calls above this.
531 (substitute* "CMakeLists.txt"
532 (("# Update to latest tags if not matched")
533 (format #f "set(latest_esmi_tag ~s)"
534 #$%e-smi-version-for-rocm)))))
535 (add-after 'add-e-smi 'patch-dlopen
536 (lambda* (#:key inputs #:allow-other-keys)
537 (substitute* "CMakeLists.txt"
538 (("get_imported_soname\\(PkgConfig::DRM_AMDGPU \
539LIBDRM_AMDGPU_SONAME\\)")
540 (string-append
541 "set(LIBDRM_AMDGPU_SONAME \""
542 (search-input-file inputs
543 "/lib/libdrm_amdgpu.so.1")
544 "\")")))))
545 (add-after 'add-e-smi 'patch-python
546 (lambda* _
547 (substitute* (find-files "py-interface" "\\.py$")
548 (("/opt/rocm") #$output)))))))
549 (inputs (list libdrm
550 python
551 e-smi-for-amd-smi))
552 (native-inputs (list pkg-config))
553 (home-page "https://github.com/ROCm/amdsmi")
554 (synopsis "ROCm library and application for managing AMD devices")
555 (description "The AMD @acronym{SMI,System Management Interface} allows
556managing and monitoring AMD devices, particularly in high-performance
557computing environments. It provides a user-space interface that allows
558applications to control GPU operations, monitor performance, and retrieve
559information about the system's drivers and GPUs. It also provides a
560command-line tool, @command{amd-smi}, which can be used to do the same.")
561 (license (list license:expat license:ncsa))))
562
563(define-public rocprofiler
564 (package
565 (name "rocprofiler")
566 (version %rocm-version)
567 (home-page %rocm-systems-url)
568 (source %rocm-systems-origin)
569 (build-system cmake-build-system)
570 (arguments
571 (list
572 #:tests? #f ; requires GPU
573 #:build-type "Release"
574 #:configure-flags
575 #~(list
576 "-DROCPROFILER_BUILD_PLUGIN_PERFETTO=OFF"
577 (string-append "-DCMAKE_CXX_COMPILER=clang++")
578 (string-append "-DCMAKE_C_COMPILER=clang")
579 "-DROCPROFILER_LD_AQLPROFILE=ON")
580 #:phases
581 #~(modify-phases %standard-phases
582 (add-after 'unpack 'chdir
583 (lambda _
584 (chdir "projects/rocprofiler")))
585 (add-after 'chdir 'disable-tests
586 (lambda _
587 (substitute* "CMakeLists.txt"
588 (("set.*ROCPROFILER_BUILD_(TESTS|CI).*") ""))))
589 (add-after 'chdir 'disable-git
590 (lambda _
591 (substitute* "plugin/perfetto/CMakeLists.txt"
592 (("rocprofiler_checkout_git_submodule") "message"))))
593 (add-after 'chdir 'fix-experimental
594 (lambda _
595 (substitute* (find-files "." "\\.(h|cpp)$")
596 (("experimental(/|::)") ""))))
597 (add-after 'chdir 'fix-script-path
598 (lambda _
599 (substitute* "bin/rocprofv2"
600 (("ROCM_DIR=.*")
601 (string-append "ROCM_DIR=" #$output "\n"))
602 (("LD_LIBRARY_PATH=.*")
603 (string-append
604 "LD_LIBRARY_PATH=" #$(this-package-input "aqlprofile") "/lib"
605 ":$LD_LIBRARY_PATH\n")))))
606 (add-after 'install 'remove-rocprof
607 (lambda _
608 (delete-file (string-append #$output "/bin/rocprof")))))))
609 (propagated-inputs (list roctracer))
610 (inputs
611 (list aqlprofile
612 barectf
613 elfutils
614 libffi
615 libpciaccess
616 numactl
617 rocm-hip-runtime))
618 (native-inputs
619 (list perfetto
620 python
621 python-cppheaderparser
622 python-lxml
623 python-pyyaml
624 python-setuptools
625 rocm-cmake
626 rocm-toolchain))
627 (synopsis "ROC profiler library")
628 (description "ROC profiler library. Profiling with perf-counters
629and derived metrics.")
630 (license license:expat)))
631
632(define-public rocprofiler-register
633 (package
634 (name "rocprofiler-register")
635 (version %rocm-version)
636 (source %rocm-systems-origin)
637 (build-system cmake-build-system)
638 (arguments
639 (list
640 #:configure-flags
641 #~(list
642 "-DROCPROFILER_REGISTER_BUILD_GLOG=OFF"
643 "-DROCPROFILER_REGISTER_BUILD_FMT=OFF"
644 "-DROCPROFILER_REGISTER_BUILD_TESTS=ON")
645 #:phases
646 '(modify-phases %standard-phases
647 (add-after 'unpack 'chdir
648 (lambda _
649 (chdir "projects/rocprofiler-register")))
650 (add-after 'chdir 'patch-cmake
651 (lambda _
652 (substitute* "CMakeLists.txt"
653 (("find_package\\(Git.*") ""))
654 (substitute* "cmake/rocprofiler_register_config_packaging.cmake"
655 (("set\\(_DESC.*" orig)
656 (string-append orig "\ninclude(CPack)\n")))
657 (substitute* "source/lib/rocprofiler-register/CMakeLists.txt"
658 (("target_link_libraries" orig)
659 (string-append
660 "find_package(fmt REQUIRED)\n"
661 "find_package(glog REQUIRED)\n"
662 orig))))))))
663 (inputs (list glog-next))
664 (native-inputs (list fmt-11))
665 (home-page %rocm-systems-url)
666 (synopsis "Support library to be used with rocprofiler")
667 (description "The rocprofiler-register library coordinates the
668modification of the intercept API table(s) of the HSA/HIP/ROCTx
669runtime libraries by the ROCprofiler (v2) library.")
670 (license license:expat)))
671
672(define-public rocm-core
673 (package
674 (name "rocm-core")
675 (version %rocm-version)
676 (source (origin
677 (method git-fetch)
678 (uri (git-reference
679 (url "https://github.com/ROCm/rocm-core")
680 (commit (string-append "rocm-" version))))
681 (file-name (git-file-name name version))
682 (sha256
683 (base32
684 "1a0sp50vql4nl6h19frpf1swka8j2hwmy0iaw8l1lbgvpd3hyr6x"))))
685 (build-system cmake-build-system)
686 (arguments
687 (list
688 #:tests? #f ; no tests
689 #:configure-flags
690 `(list ,(string-append "-DROCM_VERSION=" %rocm-version))))
691 (home-page "https://github.com/Rocm/rocm-core")
692 (synopsis "Utility to get the ROCm release version")
693 (description "Utility to get the ROCm release version")
694 (license license:expat)))
695
696(define-public aqlprofile
697 (package
698 (name "aqlprofile")
699 (version %rocm-version)
700 (source %rocm-systems-origin)
701 (build-system cmake-build-system)
702 (arguments
703 (list
704 #:phases
705 '(modify-phases %standard-phases
706 (add-after 'unpack 'chdir
707 (lambda _
708 (chdir "projects/aqlprofile"))))
709 ;; XXX: Tests require CMake HIP language support, which expects a common
710 ;; ROCm root directory.
711 #:tests? #f))
712 (inputs (list rocr-runtime))
713 (home-page %rocm-systems-url)
714 (synopsis "Architected Queuing Language Profiling Library")
715 (description "AQLprofile is an open source library that enables advanced
716 GPU profiling and tracing on AMD platforms.")
717 (license license:expat)))
718
719(define-public roctracer
720 (package
721 (name "roctracer")
722 (version %rocm-version)
723 (source %rocm-systems-origin)
724 (build-system cmake-build-system)
725 (arguments
726 (list
727 #:tests? #f ; requires GPU
728 #:build-type "Release"
729 #:configure-flags
730 #~(list
731 (string-append "-DCMAKE_CXX_COMPILER=clang++")
732 (string-append "-DCMAKE_C_COMPILER=clang")
733 (string-append "-DCMAKE_MODULE_PATH="
734 #$(this-package-input "rocm-hip-runtime")
735 "/lib/cmake/hip"))
736 #:modules '((srfi srfi-1)
737 (guix build cmake-build-system)
738 (guix build utils))
739 #:phases
740 #~(modify-phases %standard-phases
741 (add-after 'unpack 'chdir
742 (lambda _
743 (chdir "projects/roctracer")))
744 (add-after 'chdir 'fix-experimental
745 (lambda _
746 (substitute* (list
747 "plugin/file/file.cpp"
748 "src/hip_stats/hip_stats.cpp"
749 "src/roctracer/loader.h"
750 "src/tracer_tool/tracer_tool.cpp")
751 (("experimental(/|::)") "")))))))
752 (inputs (list rocm-hip-runtime))
753 (native-inputs
754 (list
755 rocm-toolchain
756 python
757 python-cppheaderparser
758 rocm-cmake))
759 (home-page %rocm-systems-url)
760 (synopsis "ROCm performance tracing library")
761 (description "The ROCTracer library provides APIs for tracing (also
762asynchronous) runtime calls in an application. It is intended for tracing
763ROCm API calls in GPU applications, such as kernel dispatches and memory
764moves.")
765 (license license:expat)))
766
767(define-public rccl
768 (package
769 (name "rccl")
770 (version %rocm-version)
771 ;; TODO: Switch to
772 ;; (source %rocm-systems-origin)
773 ;; with %rocm-version 7.1.3
774 (source
775 (origin
776 (method git-fetch)
777 (uri (git-reference
778 (url "https://github.com/ROCm/rccl")
779 (commit (string-append "rocm-" version))))
780 (file-name (git-file-name name version))
781 (sha256
782 (base32
783 "0k1k181az3hifripd99srvshq9bw9kj2p77z5nw7zmnydbfc7vny"))))
784 (build-system cmake-build-system)
785 (arguments
786 (list
787 #:tests? #f ; requires GPU
788 #:build-type "Release"
789 #:configure-flags
790 #~(list
791 (string-append "-DCMAKE_CXX_COMPILER="
792 #$(this-package-native-input "rocm-toolchain")
793 "/bin/hipcc")
794 (string-append "-DEXPLICIT_ROCM_VERSION=" #$%rocm-version)
795 #$(string-append "-DGPU_TARGETS=" (current-amd-gpu-targets-string)))
796 #:phases
797 #~(modify-phases %standard-phases
798 (add-after 'unpack 'patch-rocm-version
799 (lambda _
800 (substitute* "CMakeLists.txt"
801 (("cat \\$\\{ROCM_PATH\\}/\\.info/version")
802 (string-append "echo " #$%rocm-version)))))
803 (add-after 'unpack 'fix-cmake
804 (lambda _
805 (substitute* "CMakeLists.txt"
806 (("bash.*/etc/os-release.*")
807 "echo guix\n")))))))
808 (inputs
809 (list libdrm
810 rocm-hip-runtime
811 rocprofiler-register
812 (@ (gnu packages rocm-tools) hipify)
813 rocm-smi-lib))
814 (native-inputs
815 (list fmt
816 perl
817 python
818 rocm-cmake
819 rocm-core
820 rocm-toolchain))
821 (properties `((amd-gpu-targets . ,%default-amd-gpu-targets)))
822 (home-page %rocm-systems-url)
823 (synopsis "ROCm Communication Collectives Library")
824 (description "@code{RCCL} (ROCm Communication Collectives Library) is a
825library for collective communication on GPUs, such as reduce, gather or
826scatter operations.")
827 (license license:bsd-3)))
828
829(define-public rocm-smi-lib
830 (package
831 (name "rocm-smi-lib")
832 (version %rocm-version)
833 (source %rocm-systems-origin)
834 (build-system cmake-build-system)
835 (arguments
836 (list
837 #:tests? #f ; requires GPU
838 #:build-type "Release"
839 #:configure-flags
840 #~(list (string-append "-DCMAKE_INSTALL_LIBEXECDIR="
841 #$output:bin "/lib")
842 (string-append "-DCMAKE_INSTALL_BINDIR="
843 #$output:bin "/bin"))
844 #:phases
845 #~(modify-phases %standard-phases
846 (add-after 'unpack 'setup
847 (lambda _
848 (chdir "projects/rocm-smi-lib")
849 ;; Remove relative prefix so 'CMAKE_INSTALL_LIBEXECDIR' can be
850 ;; an absolute path, that allows pointing it to a different
851 ;; output in the store, such as `#$output:bin'.
852 (substitute* "rocm_smi/CMakeLists.txt"
853 (("../(\\$\\{CMAKE_INSTALL_LIBEXECDIR\\}/\\$\\{ROCM_SMI\\}/rocm_smi.py)" _ suffix)
854 suffix))
855
856 ;; The 'rocm-smi' binary dlopens 'librocm_smi64.so' from Python
857 ;; but gets the file name wrong. Fix that.
858 (substitute* '("python_smi_tools/rsmiBindings.py.in"
859 "python_smi_tools/rsmiBindingsInit.py.in")
860 (("rocm_smi_lib_path = .*")
861 (string-append "rocm_smi_lib_path = '" #$output
862 "/lib/librocm_smi64.so.@VERSION_MAJOR@'\n"))))))))
863 (native-inputs (list pkg-config))
864 (inputs (list libdrm python))
865 (propagated-inputs (list grep coreutils))
866 ;; The 'bin' output will store Python utilities in order to reduce the
867 ;; closure size size of the package. That way the 'out' output will not
868 ;; depend on Python.
869 (outputs '("out" "bin"))
870 (home-page %rocm-systems-url)
871 (synopsis "The ROCm System Management Interface (ROCm SMI) Library")
872 (description "The ROCm System Management Interface Library, or
873ROCm SMI library, is part of the Radeon Open Compute ROCm software
874stack. It is a C library for Linux that provides a user space
875interface for applications to monitor and control GPU applications.")
876 (license license:expat)))
877
878(define-deprecated-package rocm-smi rocm-smi-lib)