guix_mirror_bot pushed a commit to branch master
in repository guix.

commit ee1614f4aebb3a87eadffa11d1642493b597583f
Author: David Elsing <[email protected]>
AuthorDate: Tue Feb 3 21:33:21 2026 +0100

    gnu: Add rocrand.
    
    Adapted from the Guix-HPC channel 
(https://gitlab.inria.fr/guix-hpc/guix-hpc).
    
    * gnu/packages/rocm-libs.scm: New file.
    (%rocm-version): New variable.
    (%rocm-libraries-url): New variable.
    (rocm-libraries-monorepo): New variable.
    (rocm-library-source): New procedure.
    (rocrand): New variable.
    * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
    
    Signed-off-by: Ludovic Courtès <[email protected]>
---
 gnu/local.mk                |  1 +
 gnu/packages/gdb.scm        |  1 +
 gnu/packages/rocm-libs.scm  | 96 +++++++++++++++++++++++++++++++++++++++++++++
 gnu/packages/rocm-tools.scm |  1 +
 gnu/packages/rocm.scm       |  4 +-
 5 files changed, 102 insertions(+), 1 deletion(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index 13d4302ddc..aba20a9af1 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -602,6 +602,7 @@ GNU_SYSTEM_MODULES =                                \
   %D%/packages/regex.scm                               \
   %D%/packages/robotics.scm                    \
   %D%/packages/rocm.scm                                \
+  %D%/packages/rocm-libs.scm                   \
   %D%/packages/rocm-tools.scm                  \
   %D%/packages/rpc.scm                         \
   %D%/packages/rpm.scm                         \
diff --git a/gnu/packages/gdb.scm b/gnu/packages/gdb.scm
index 4338be3667..8a377474ad 100644
--- a/gnu/packages/gdb.scm
+++ b/gnu/packages/gdb.scm
@@ -319,6 +319,7 @@ microcontroller architecture.")))
 
 ;; This must match '%rocm-version' in the following files:
 ;; - rocm.scm
+;; - rocm-libs.scm
 ;; - rocm-tools.scm
 (define %rocm-gdb-version "7.1.1")
 
diff --git a/gnu/packages/rocm-libs.scm b/gnu/packages/rocm-libs.scm
new file mode 100644
index 0000000000..d224e53ad4
--- /dev/null
+++ b/gnu/packages/rocm-libs.scm
@@ -0,0 +1,96 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2026 David Elsing <[email protected]>
+;;; Copyright © 2023 Advanced Micro Devices, Inc.
+;;;
+;;; This program 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.
+;;;
+;;; This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages rocm-libs)
+  #:use-module (guix build-system cmake)
+  #:use-module (guix gexp)
+  #:use-module (guix git-download)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix packages)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages llvm)
+  #:use-module (gnu packages python)
+  #:use-module (gnu packages python-xyz)
+  #:use-module (gnu packages rocm))
+
+;; 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
+;; - rocm.scm
+;; - rocm-tools.scm
+;; - gdb.scm
+;; and update the hashes of the affected packages.
+
+(define %rocm-version "7.1.1")
+(define %rocm-libraries-url "https://github.com/ROCm/rocm-libraries";)
+
+(define rocm-libraries-monorepo
+  (origin
+    (method git-fetch)
+    (uri (git-reference
+           (url %rocm-libraries-url)
+           (commit (string-append "rocm-" %rocm-version))))
+    (file-name (git-file-name "rocm-libraries" %rocm-version))
+    (sha256 (base32 "0jyjhkg1xlvziip29wqsvh386qy72018y114cx0x3cgfd8qy1dh0"))))
+
+(define* (rocm-library-source name
+                              #:key (patches '())
+                              (location #f))
+  (computed-file
+   (string-append name "-" %rocm-version)
+   (with-imported-modules '((guix build utils))
+     #~(begin
+         (use-modules (guix build utils))
+         (copy-recursively
+          (string-append #$rocm-libraries-monorepo
+                         #$(if location
+                               (string-append "/" location)
+                               (string-append "/projects/" name)))
+          #$output)
+         (with-directory-excursion #$output
+           (for-each
+            (lambda (file)
+              (invoke (string-append #+(delayed-object patch) "/bin/patch")
+                      "--force" "--no-backup-if-mismatch"
+                      "-p1" "-i" file))
+            '#$(map (lambda (file)
+                      (local-file (assume-valid-file-name file)))
+                    patches)))))))
+
+
+(define-public rocrand
+  (package
+    (name "rocrand")
+    (version %rocm-version)
+    (source (rocm-library-source "rocrand"))
+    (build-system cmake-build-system)
+    (arguments
+     (list
+      #:tests? #f ; requires GPU
+      #:build-type "Release"
+      #:configure-flags
+      #~(list
+         "-DCMAKE_CXX_COMPILER=hipcc"
+         (string-append "-DAMDGPU_TARGETS="
+                        #$(current-amd-gpu-targets-string)))))
+    (inputs (list rocm-hip-runtime))
+    (native-inputs (list rocm-cmake rocm-toolchain))
+    (properties `((amd-gpu-targets . ,%default-amd-gpu-targets)))
+    (home-page %rocm-libraries-url)
+    (synopsis "RAND library for the HIP programming language")
+    (description "This package contains implementations for
+pseudorandom and quasirandom number generation in HIP.")
+    (license license:expat)))
diff --git a/gnu/packages/rocm-tools.scm b/gnu/packages/rocm-tools.scm
index 9b441df3e1..6ac4d5b851 100644
--- a/gnu/packages/rocm-tools.scm
+++ b/gnu/packages/rocm-tools.scm
@@ -39,6 +39,7 @@
 ;; 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
 ;; - rocm.scm
+;; - rocm-libs.scm
 ;; - gdb.scm
 ;; and update the hashes of the affected packages.
 
diff --git a/gnu/packages/rocm.scm b/gnu/packages/rocm.scm
index 8379f79655..73e6396de6 100644
--- a/gnu/packages/rocm.scm
+++ b/gnu/packages/rocm.scm
@@ -49,10 +49,12 @@
   #:use-module (gnu packages libffi)
   #:use-module (ice-9 match)
   #:export (%default-amd-gpu-targets
-            current-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
+;; - rocm-libs.scm
 ;; - rocm-tools.scm
 ;; - gdb.scm
 ;; and update the hashes of the affected packages.

Reply via email to