diff --git a/Makefile.am b/Makefile.am index 546e3ed758..1ef57af7a5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ # GNU Guix --- Functional package management for GNU -# Copyright © 2012-2025 Ludovic Courtès +# Copyright © 2012-2026 Ludovic Courtès # Copyright © 2013 Andreas Enge # Copyright © 2015, 2017 Alex Kost # Copyright © 2016, 2018 Mathieu Lirzin @@ -87,6 +87,7 @@ MODULES = \ guix/base64.scm \ guix/ci.scm \ guix/cpio.scm \ + guix/amd-gpu.scm \ guix/cpu.scm \ guix/deprecation.scm \ guix/docker.scm \ diff --git a/gnu/packages/rocm.scm b/gnu/packages/rocm.scm index 6b5bc632dd..1f2175ecc1 100644 --- a/gnu/packages/rocm.scm +++ b/gnu/packages/rocm.scm @@ -26,6 +26,7 @@ #:use-module (guix utils) #:use-module (guix git-download) #:use-module (guix build-system cmake) + #:use-module (guix amd-gpu) #:use-module (gnu packages) #:use-module (gnu packages base) #:use-module (gnu packages boost) @@ -53,9 +54,9 @@ #:use-module (gnu packages xorg) #:use-module (gnu packages libffi) #:use-module (ice-9 match) - #:export (%default-amd-gpu-targets - current-amd-gpu-targets - current-amd-gpu-targets-string)) + #:re-export (%default-amd-gpu-targets + current-amd-gpu-targets + current-amd-gpu-targets-string)) ;; The components are tightly integrated and can only be upgraded as a unit. If ;; you want to upgrade ROCm, bump this version number and the version number in @@ -328,18 +329,6 @@ CPUs to execute unmodified HIP code. It is generic and does not assume a particular CPU vendor or architecture.") (license license:expat)))) -(define %default-amd-gpu-targets - '("gfx908" "gfx90a" "gfx942" "gfx1030" "gfx1100" "gfx1101" "gfx1200" "gfx1201")) - -(define-syntax-rule (current-amd-gpu-targets) - "Return the list of AMD GPU targets for this package, as a list of strings." - (or (assoc-ref (package-properties this-package) 'amd-gpu-targets) - %default-amd-gpu-targets)) - -(define-syntax-rule (current-amd-gpu-targets-string) - "Return the list of AMD GPU targets for this package, as a string separated by \";\"." - (string-join (current-amd-gpu-targets) ";")) - (define-public rocm-bandwidth-test (package (name "rocm-bandwidth-test") diff --git a/guix/amd-gpu.scm b/guix/amd-gpu.scm new file mode 100644 index 0000000000..d16fea2a05 --- /dev/null +++ b/guix/amd-gpu.scm @@ -0,0 +1,44 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2026 Ludovic Courtès +;;; Copyright © 2026 David Elsing +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix amd-gpu) + #:autoload (guix packages) (this-package package-properties) + #:export (%default-amd-gpu-targets + current-amd-gpu-targets + current-amd-gpu-targets-string)) + +;;; Commentary: +;;; +;;; This module provides helpers for packages targeting AMD GPUs. +;;; +;;; Code: + +(define %default-amd-gpu-targets + '("gfx908" "gfx90a" "gfx942" "gfx1030" "gfx1100" "gfx1101" "gfx1200" "gfx1201")) + +(define-syntax-rule (current-amd-gpu-targets) + "Return the list of AMD GPU targets for this package, as a list of strings." + (or (assoc-ref (package-properties this-package) 'amd-gpu-targets) + %default-amd-gpu-targets)) + +(define-syntax-rule (current-amd-gpu-targets-string) + "Return the list of AMD GPU targets for this package, as a string separated +by \";\". This is useful for build options like 'AMDGPU_TARGETS' in many +CMake-based packages." + (string-join (current-amd-gpu-targets) ";"))