projects/guix·blob java-team · refs

867 lines · 33.5 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* (find-files "src" "\\.cc$")
538 (("libdrm.so.2")
539 (search-input-file inputs "/lib/libdrm.so.2"))
540 (("libdrm_amdgpu.so")
541 (search-input-file inputs "/lib/libdrm_amdgpu.so")))))
542 (add-after 'add-e-smi 'patch-python
543 (lambda* _
544 (substitute* (find-files "py-interface" "\\.py$")
545 (("/opt/rocm") #$output)))))))
546 (inputs (list libdrm
547 python
548 e-smi-for-amd-smi))
549 (native-inputs (list pkg-config))
550 (home-page "https://github.com/ROCm/amdsmi")
551 (synopsis "ROCm library and application for managing AMD devices")
552 (description "The AMD @acronym{SMI,System Management Interface} allows
553managing and monitoring AMD devices, particularly in high-performance
554computing environments. It provides a user-space interface that allows
555applications to control GPU operations, monitor performance, and retrieve
556information about the system's drivers and GPUs. It also provides a
557command-line tool, @command{amd-smi}, which can be used to do the same.")
558 (license (list license:expat license:ncsa))))
559
560(define-public rocprofiler
561 (package
562 (name "rocprofiler")
563 (version %rocm-version)
564 (home-page %rocm-systems-url)
565 (source %rocm-systems-origin)
566 (build-system cmake-build-system)
567 (arguments
568 (list
569 #:tests? #f ; requires GPU
570 #:build-type "Release"
571 #:configure-flags
572 #~(list
573 "-DROCPROFILER_BUILD_PLUGIN_PERFETTO=OFF"
574 (string-append "-DCMAKE_CXX_COMPILER=clang++")
575 (string-append "-DCMAKE_C_COMPILER=clang")
576 "-DROCPROFILER_LD_AQLPROFILE=ON")
577 #:phases
578 #~(modify-phases %standard-phases
579 (add-after 'unpack 'chdir
580 (lambda _
581 (chdir "projects/rocprofiler")))
582 (add-after 'chdir 'disable-tests
583 (lambda _
584 (substitute* "CMakeLists.txt"
585 (("set.*ROCPROFILER_BUILD_(TESTS|CI).*") ""))))
586 (add-after 'chdir 'disable-git
587 (lambda _
588 (substitute* "plugin/perfetto/CMakeLists.txt"
589 (("rocprofiler_checkout_git_submodule") "message"))))
590 (add-after 'chdir 'fix-experimental
591 (lambda _
592 (substitute* (find-files "." "\\.(h|cpp)$")
593 (("experimental(/|::)") ""))))
594 (add-after 'chdir 'fix-script-path
595 (lambda _
596 (substitute* "bin/rocprofv2"
597 (("ROCM_DIR=.*")
598 (string-append "ROCM_DIR=" #$output "\n"))
599 (("LD_LIBRARY_PATH=.*")
600 (string-append
601 "LD_LIBRARY_PATH=" #$(this-package-input "aqlprofile") "/lib"
602 ":$LD_LIBRARY_PATH\n")))))
603 (add-after 'install 'remove-rocprof
604 (lambda _
605 (delete-file (string-append #$output "/bin/rocprof")))))))
606 (propagated-inputs (list roctracer))
607 (inputs
608 (list aqlprofile
609 barectf
610 elfutils
611 libffi
612 libpciaccess
613 numactl
614 rocm-hip-runtime))
615 (native-inputs
616 (list perfetto
617 python
618 python-cppheaderparser
619 python-lxml
620 python-pyyaml
621 python-setuptools
622 rocm-cmake
623 rocm-toolchain))
624 (synopsis "ROC profiler library")
625 (description "ROC profiler library. Profiling with perf-counters
626and derived metrics.")
627 (license license:expat)))
628
629(define-public rocprofiler-register
630 (package
631 (name "rocprofiler-register")
632 (version %rocm-version)
633 (source %rocm-systems-origin)
634 (build-system cmake-build-system)
635 (arguments
636 (list
637 #:configure-flags
638 #~(list
639 "-DROCPROFILER_REGISTER_BUILD_GLOG=OFF"
640 "-DROCPROFILER_REGISTER_BUILD_FMT=OFF"
641 "-DROCPROFILER_REGISTER_BUILD_TESTS=ON")
642 #:phases
643 '(modify-phases %standard-phases
644 (add-after 'unpack 'chdir
645 (lambda _
646 (chdir "projects/rocprofiler-register")))
647 (add-after 'chdir 'patch-cmake
648 (lambda _
649 (substitute* "CMakeLists.txt"
650 (("find_package\\(Git.*") ""))
651 (substitute* "cmake/rocprofiler_register_config_packaging.cmake"
652 (("set\\(_DESC.*" orig)
653 (string-append orig "\ninclude(CPack)\n")))
654 (substitute* "source/lib/rocprofiler-register/CMakeLists.txt"
655 (("target_link_libraries" orig)
656 (string-append
657 "find_package(fmt REQUIRED)\n"
658 "find_package(glog REQUIRED)\n"
659 orig))))))))
660 (inputs (list glog-next))
661 (native-inputs (list fmt-11))
662 (home-page %rocm-systems-url)
663 (synopsis "Support library to be used with rocprofiler")
664 (description "The rocprofiler-register library coordinates the
665modification of the intercept API table(s) of the HSA/HIP/ROCTx
666runtime libraries by the ROCprofiler (v2) library.")
667 (license license:expat)))
668
669(define-public rocm-core
670 (package
671 (name "rocm-core")
672 (version %rocm-version)
673 (source (origin
674 (method git-fetch)
675 (uri (git-reference
676 (url "https://github.com/ROCm/rocm-core")
677 (commit (string-append "rocm-" version))))
678 (file-name (git-file-name name version))
679 (sha256
680 (base32
681 "1a0sp50vql4nl6h19frpf1swka8j2hwmy0iaw8l1lbgvpd3hyr6x"))))
682 (build-system cmake-build-system)
683 (arguments
684 (list
685 #:tests? #f ; no tests
686 #:configure-flags
687 `(list ,(string-append "-DROCM_VERSION=" %rocm-version))))
688 (home-page "https://github.com/Rocm/rocm-core")
689 (synopsis "Utility to get the ROCm release version")
690 (description "Utility to get the ROCm release version")
691 (license license:expat)))
692
693(define-public aqlprofile
694 (package
695 (name "aqlprofile")
696 (version %rocm-version)
697 (source %rocm-systems-origin)
698 (build-system cmake-build-system)
699 (arguments
700 (list
701 #:phases
702 '(modify-phases %standard-phases
703 (add-after 'unpack 'chdir
704 (lambda _
705 (chdir "projects/aqlprofile"))))
706 ;; XXX: Tests require CMake HIP language support, which expects a common
707 ;; ROCm root directory.
708 #:tests? #f))
709 (inputs (list rocr-runtime))
710 (home-page %rocm-systems-url)
711 (synopsis "Architected Queuing Language Profiling Library")
712 (description "AQLprofile is an open source library that enables advanced
713 GPU profiling and tracing on AMD platforms.")
714 (license license:expat)))
715
716(define-public roctracer
717 (package
718 (name "roctracer")
719 (version %rocm-version)
720 (source %rocm-systems-origin)
721 (build-system cmake-build-system)
722 (arguments
723 (list
724 #:tests? #f ; requires GPU
725 #:build-type "Release"
726 #:configure-flags
727 #~(list
728 (string-append "-DCMAKE_CXX_COMPILER=clang++")
729 (string-append "-DCMAKE_C_COMPILER=clang")
730 (string-append "-DCMAKE_MODULE_PATH="
731 #$(this-package-input "rocm-hip-runtime")
732 "/lib/cmake/hip"))
733 #:modules '((srfi srfi-1)
734 (guix build cmake-build-system)
735 (guix build utils))
736 #:phases
737 #~(modify-phases %standard-phases
738 (add-after 'unpack 'chdir
739 (lambda _
740 (chdir "projects/roctracer")))
741 (add-after 'chdir 'fix-experimental
742 (lambda _
743 (substitute* (list
744 "plugin/file/file.cpp"
745 "src/hip_stats/hip_stats.cpp"
746 "src/roctracer/loader.h"
747 "src/tracer_tool/tracer_tool.cpp")
748 (("experimental(/|::)") "")))))))
749 (inputs (list rocm-hip-runtime))
750 (native-inputs
751 (list
752 rocm-toolchain
753 python
754 python-cppheaderparser
755 rocm-cmake))
756 (home-page %rocm-systems-url)
757 (synopsis "ROCm performance tracing library")
758 (description "The ROCTracer library provides APIs for tracing (also
759asynchronous) runtime calls in an application. It is intended for tracing
760ROCm API calls in GPU applications, such as kernel dispatches and memory
761moves.")
762 (license license:expat)))
763
764(define-public rccl
765 (package
766 (name "rccl")
767 (version %rocm-version)
768 ;; TODO: Switch to
769 ;; (source %rocm-systems-origin)
770 ;; with %rocm-version 7.1.3
771 (source
772 (origin
773 (method git-fetch)
774 (uri (git-reference
775 (url "https://github.com/ROCm/rccl")
776 (commit (string-append "rocm-" version))))
777 (file-name (git-file-name name version))
778 (sha256
779 (base32
780 "0k1k181az3hifripd99srvshq9bw9kj2p77z5nw7zmnydbfc7vny"))))
781 (build-system cmake-build-system)
782 (arguments
783 (list
784 #:tests? #f ; requires GPU
785 #:build-type "Release"
786 #:configure-flags
787 #~(list
788 (string-append "-DCMAKE_CXX_COMPILER="
789 #$(this-package-native-input "rocm-toolchain")
790 "/bin/hipcc")
791 (string-append "-DEXPLICIT_ROCM_VERSION=" #$%rocm-version)
792 #$(string-append "-DGPU_TARGETS=" (current-amd-gpu-targets-string)))
793 #:phases
794 #~(modify-phases %standard-phases
795 (add-after 'unpack 'patch-rocm-version
796 (lambda _
797 (substitute* "CMakeLists.txt"
798 (("cat \\$\\{ROCM_PATH\\}/\\.info/version")
799 (string-append "echo " #$%rocm-version)))))
800 (add-after 'unpack 'fix-cmake
801 (lambda _
802 (substitute* "CMakeLists.txt"
803 (("bash.*/etc/os-release.*")
804 "echo guix\n")))))))
805 (inputs
806 (list libdrm
807 rocm-hip-runtime
808 rocprofiler-register
809 (@ (gnu packages rocm-tools) hipify)
810 rocm-smi-lib))
811 (native-inputs
812 (list fmt
813 perl
814 python
815 rocm-cmake
816 rocm-core
817 rocm-toolchain))
818 (properties `((amd-gpu-targets . ,%default-amd-gpu-targets)))
819 (home-page %rocm-systems-url)
820 (synopsis "ROCm Communication Collectives Library")
821 (description "@code{RCCL} (ROCm Communication Collectives Library) is a
822library for collective communication on GPUs, such as reduce, gather or
823scatter operations.")
824 (license license:bsd-3)))
825
826(define-public rocm-smi-lib
827 (package
828 (name "rocm-smi-lib")
829 (version %rocm-version)
830 (source %rocm-systems-origin)
831 (build-system cmake-build-system)
832 (arguments
833 (list
834 #:tests? #f ; requires GPU
835 #:build-type "Release"
836 #:configure-flags
837 #~(list (string-append "-DCMAKE_INSTALL_LIBEXECDIR="
838 #$output:bin "/lib")
839 (string-append "-DCMAKE_INSTALL_BINDIR="
840 #$output:bin "/bin"))
841 #:phases
842 #~(modify-phases %standard-phases
843 (add-after 'unpack 'setup
844 (lambda _
845 (chdir "projects/rocm-smi-lib")
846 ;; Remove relative prefix so 'CMAKE_INSTALL_LIBEXECDIR' can be
847 ;; an absolute path, that allows pointing it to a different
848 ;; output in the store, such as `#$output:bin'.
849 (substitute* "rocm_smi/CMakeLists.txt"
850 (("../(\\$\\{CMAKE_INSTALL_LIBEXECDIR\\}/\\$\\{ROCM_SMI\\}/rocm_smi.py)" _ suffix)
851 suffix)))))))
852 (native-inputs (list pkg-config))
853 (inputs (list libdrm python))
854 (propagated-inputs (list grep coreutils))
855 ;; The 'bin' output will store Python utilities in order to reduce the
856 ;; closure size size of the package. That way the 'out' output will not
857 ;; depend on Python.
858 (outputs '("out" "bin"))
859 (home-page %rocm-systems-url)
860 (synopsis "The ROCm System Management Interface (ROCm SMI) Library")
861 (description "The ROCm System Management Interface Library, or
862ROCm SMI library, is part of the Radeon Open Compute ROCm software
863stack. It is a C library for Linux that provides a user space
864interface for applications to monitor and control GPU applications.")
865 (license license:expat)))
866
867(define-deprecated-package rocm-smi rocm-smi-lib)