guix_mirror_bot pushed a commit to branch master
in repository guix.
commit 1eb057021d009aafa9c8542f33d3568f97e6184e
Author: David Elsing <[email protected]>
AuthorDate: Tue Feb 3 21:33:21 2026 +0100
gnu: Add tensile.
* gnu/packages/rocm-tools.scm (tensile): New variable.
* gnu/packages/patches/tensile-copy-if-not-exist.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Register it.
Signed-off-by: Ludovic Courtès <[email protected]>
---
gnu/local.mk | 1 +
.../patches/tensile-copy-if-not-exist.patch | 26 ++++++++
gnu/packages/rocm-libs.scm | 75 +++++++++++++++++++++-
3 files changed, 101 insertions(+), 1 deletion(-)
diff --git a/gnu/local.mk b/gnu/local.mk
index aba20a9af1..928d608357 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2404,6 +2404,7 @@ dist_patch_DATA =
\
%D%/packages/patches/telegram-desktop-unbundle-cppgir.patch \
%D%/packages/patches/telegram-purple-adjust-test.patch \
%D%/packages/patches/telepathy-glib-fix-test.patch \
+ %D%/packages/patches/tensile-copy-if-not-exist.patch \
%D%/packages/patches/teuchos-remove-duplicate-using.patch \
%D%/packages/patches/texi2html-document-encoding.patch \
%D%/packages/patches/texi2html-i18n.patch \
diff --git a/gnu/packages/patches/tensile-copy-if-not-exist.patch
b/gnu/packages/patches/tensile-copy-if-not-exist.patch
new file mode 100644
index 0000000000..d0f6a37707
--- /dev/null
+++ b/gnu/packages/patches/tensile-copy-if-not-exist.patch
@@ -0,0 +1,26 @@
+Remove target files if they exist
+
+diff --git a/Tensile/TensileCreateLibrary.py b/Tensile/TensileCreateLibrary.py
+index a164460..0ec998d 100644
+--- a/Tensile/TensileCreateLibrary.py
++++ b/Tensile/TensileCreateLibrary.py
+@@ -854,6 +854,9 @@ def copyStaticFiles(outputPath=None):
+
+ for fileName in libraryStaticFiles:
+ # copy file
++ path = Path(outputPath) / fileName
++ if path.is_file():
++ path.unlink()
+ shutil.copy(os.path.join(globalParameters["SourcePath"], fileName),
outputPath)
+
+ return libraryStaticFiles
+@@ -1762,6 +1765,9 @@ def TensileCreateLibrary():
+
+ # Make sure to copy the library static files.
+ for fileName in staticFiles:
++ path = Path(outputPath) / fileName
++ if path.is_file():
++ path.unlink()
+ shutil.copy(os.path.join(globalParameters["SourcePath"], fileName),
outputPath)
+
+ codeObjectFiles, kernels, solutions = writeKernels(
diff --git a/gnu/packages/rocm-libs.scm b/gnu/packages/rocm-libs.scm
index 8b7268c815..9c7f98e58b 100644
--- a/gnu/packages/rocm-libs.scm
+++ b/gnu/packages/rocm-libs.scm
@@ -17,15 +17,20 @@
(define-module (gnu packages rocm-libs)
#:use-module (guix build-system cmake)
+ #:use-module (guix build-system python)
#:use-module (guix gexp)
#:use-module (guix git-download)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
+ #:use-module (gnu packages)
#:use-module (gnu packages base)
+ #:use-module (gnu packages check)
#:use-module (gnu packages llvm)
#:use-module (gnu packages python)
+ #:use-module (gnu packages python-science)
#:use-module (gnu packages python-xyz)
- #:use-module (gnu packages rocm))
+ #:use-module (gnu packages rocm)
+ #:use-module (gnu packages serialization))
;; 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
@@ -132,3 +137,71 @@ random numbers on GPUs, in particular via rocRAND for AMD
GPUs.")
(description "hipBLAS-common is a header-only library with common
definitions for hipBLAS and hipBLASLt.")
(license license:expat)))
+
+(define-public tensile
+ (package
+ (name "tensile")
+ (version %rocm-version)
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url (string-append "https://github.com/ROCm/tensile"))
+ (commit (string-append "rocm-" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1wff80vd1x1vcg3n56qlc9hdabk9svz6qk0sznycjwzbsmpfb0mr"))
+ (patches
+ (search-patches "tensile-copy-if-not-exist.patch"))))
+ (build-system python-build-system)
+ (arguments
+ (list
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'fix-rocm-directory
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* '("Tensile/Utilities/Toolchain.py")
+ (("/opt/rocm/bin")
+ (dirname
+ (search-input-file inputs "/bin/clang++")))
+ (("/opt/rocm/llvm/bin")
+ (dirname
+ (search-input-file inputs "/bin/clang++"))))))
+ (add-after 'unpack 'fix-tests
+ (lambda _
+ (substitute* "Tensile/Tests/yaml_only/test_config.py"
+ (("availableArchs = findAvailableArchs\\(\\)")
+ #$(string-append
+ "availableArchs = ['"
+ (string-join (current-amd-gpu-targets) "', '") "']")))
+ (setenv "TENSILE_ROCM_ASSEMBLER_PATH"
+ (string-append (which "clang")))))
+ (replace 'check
+ (lambda* (#:key tests? #:allow-other-keys)
+ (when tests?
+ (invoke "pytest" "-vv" "Tensile/Tests" "-m" "unit"
+ "-k" "not test_prepAsm")))))))
+ (native-inputs
+ (list python-filelock
+ python-pandas
+ python-pytest
+ rocminfo
+ rocm-hip-runtime
+ rocm-toolchain))
+ (propagated-inputs
+ (list msgpack-3
+ python-msgpack
+ python-pyyaml
+ python-joblib
+ python-rich))
+ (properties `((amd-gpu-targets . ,%default-amd-gpu-targets)))
+ (home-page %rocm-libraries-url)
+ (synopsis "GEMM kernel generator for AMD GPUs")
+ (description "Tensile is a tool for creating benchmark-driven
+backend libraries for GEMMs, GEMM-like problems (such as batched
+GEMM), and general N-dimensional tensor contractions on a GPU. The
+Tensile library is mainly used as backend library to rocBLAS. Tensile
+acts as the performance backbone for a wide variety of compute
+applications running on AMD GPUs.")
+ (license license:expat)))