From bdbd4e99724a92bc48db89b60f4db4f3b7c6c10c Mon Sep 17 00:00:00 2001 From: Sakura286 Date: Thu, 28 May 2026 21:34:15 +0800 Subject: [PATCH] hipblaslt: init --- ...pblaslt-cmake-compile-and-link-pools.patch | 49 +++ .../0001-hipblaslt-find-origami-package.patch | 25 ++ ...-tensilelite-remove-yappi-dependency.patch | 57 +++ ...pblaslt-tensilelite-use-fedora-paths.patch | 41 ++ ...slt-tensilelite-use-nanobind-tarball.patch | 28 ++ SPECS/hipblaslt/hipblaslt.spec | 414 ++++++++++++++++++ 6 files changed, 614 insertions(+) create mode 100644 SPECS/hipblaslt/0001-hipblaslt-cmake-compile-and-link-pools.patch create mode 100644 SPECS/hipblaslt/0001-hipblaslt-find-origami-package.patch create mode 100644 SPECS/hipblaslt/0001-hipblaslt-tensilelite-remove-yappi-dependency.patch create mode 100644 SPECS/hipblaslt/0001-hipblaslt-tensilelite-use-fedora-paths.patch create mode 100644 SPECS/hipblaslt/0001-hipblaslt-tensilelite-use-nanobind-tarball.patch create mode 100644 SPECS/hipblaslt/hipblaslt.spec diff --git a/SPECS/hipblaslt/0001-hipblaslt-cmake-compile-and-link-pools.patch b/SPECS/hipblaslt/0001-hipblaslt-cmake-compile-and-link-pools.patch new file mode 100644 index 0000000..264e0b7 --- /dev/null +++ b/SPECS/hipblaslt/0001-hipblaslt-cmake-compile-and-link-pools.patch @@ -0,0 +1,49 @@ +From 8b2c3e3316334a2b251cdcd3f73130d2dfea2d0d Mon Sep 17 00:00:00 2001 +From: Tom Rix +Date: Sun, 7 Dec 2025 07:13:20 -0800 +Subject: [PATCH] hipblaslt cmake compile and link pools + +--- + CMakeLists.txt | 26 ++++++++++++++++++++++++++ + 1 file changed, 26 insertions(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d02df50540c2..8e8173fc4205 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -62,6 +62,32 @@ option(HIPBLASLT_BUNDLE_PYTHON_DEPS "Build python dependencies requied for devic + option(HIPBLASLT_ENABLE_COVERAGE "Build coverage support." OFF) + option(HIPBLASLT_ENABLE_THEROCK "Build hipBLASLt for TheRock." OFF) + ++# ++# Seperate linking jobs from compiling ++# Too many concurrent linking jobs can break the build ++# Copied from LLVM ++set(HIPBLASLT_PARALLEL_LINK_JOBS "" CACHE STRING ++ "Define the maximum number of concurrent link jobs (Ninja only).") ++if(CMAKE_GENERATOR MATCHES "Ninja") ++ if(HIPBLASLT_PARALLEL_LINK_JOBS) ++ set_property(GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${HIPBLASLT_PARALLEL_LINK_JOBS}) ++ set(CMAKE_JOB_POOL_LINK link_job_pool) ++ endif() ++elseif(HIPBLASLT_PARALLEL_LINK_JOBS) ++ message(WARNING "Job pooling is only available with Ninja generators.") ++endif() ++# Similar for compiling ++set(HIPBLASLT_PARALLEL_COMPILE_JOBS "" CACHE STRING ++ "Define the maximum number of concurrent compile jobs (Ninja only).") ++if(CMAKE_GENERATOR MATCHES "Ninja") ++ if(HIPBLASLT_PARALLEL_COMPILE_JOBS) ++ set_property(GLOBAL APPEND PROPERTY JOB_POOLS compile_job_pool=${HIPBLASLT_PARALLEL_COMPILE_JOBS}) ++ set(CMAKE_JOB_POOL_COMPILE compile_job_pool) ++ endif() ++elseif(HIPBLASLT_PARALLEL_COMPILE_JOBS) ++ message(WARNING "Job pooling is only available with Ninja generators.") ++endif() ++ + option(TENSILELITE_ENABLE_HOST "Build the tensilelite host library." ON) + option(TENSILELITE_BUILD_TESTING "Build client when building tests" OFF) + option(TENSILELITE_ENABLE_CLIENT "Build tensilelite client" ${TENSILELITE_BUILD_TESTING}) +-- +2.52.0 + diff --git a/SPECS/hipblaslt/0001-hipblaslt-find-origami-package.patch b/SPECS/hipblaslt/0001-hipblaslt-find-origami-package.patch new file mode 100644 index 0000000..380bc62 --- /dev/null +++ b/SPECS/hipblaslt/0001-hipblaslt-find-origami-package.patch @@ -0,0 +1,25 @@ +From 43c4a61c5d8836a16feb8e53c72f255790523ff3 Mon Sep 17 00:00:00 2001 +From: Tom Rix +Date: Mon, 3 Nov 2025 06:11:40 -0800 +Subject: [PATCH] hipblaslt find origami package + +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index dbccca92c84f..d02df50540c2 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -218,7 +218,7 @@ if(HIPBLASLT_ENABLE_MSGPACK) + endif() + endif() + +-add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../../shared/origami" origami) ++find_package(origami CONFIG REQUIRED) + add_subdirectory(tensilelite) + + if(HIPBLASLT_ENABLE_HOST) +-- +2.52.0 + diff --git a/SPECS/hipblaslt/0001-hipblaslt-tensilelite-remove-yappi-dependency.patch b/SPECS/hipblaslt/0001-hipblaslt-tensilelite-remove-yappi-dependency.patch new file mode 100644 index 0000000..db0e208 --- /dev/null +++ b/SPECS/hipblaslt/0001-hipblaslt-tensilelite-remove-yappi-dependency.patch @@ -0,0 +1,57 @@ +From 72521fcca77c010b9c8b9ce91cde925164502d6f Mon Sep 17 00:00:00 2001 +From: Tom Rix +Date: Thu, 25 Sep 2025 13:02:55 -0700 +Subject: [PATCH] hipblaslt tensilelite remove yappi dependency + +Signed-off-by: Tom Rix +--- + tensilelite/Tensile/TensileCreateLibrary/Run.py | 15 --------------- + tensilelite/requirements.txt | 2 +- + 2 files changed, 1 insertion(+), 16 deletions(-) + +diff --git a/tensilelite/Tensile/TensileCreateLibrary/Run.py b/tensilelite/Tensile/TensileCreateLibrary/Run.py +index 835ed9c01916..a02705f6554a 100644 +--- a/tensilelite/Tensile/TensileCreateLibrary/Run.py ++++ b/tensilelite/Tensile/TensileCreateLibrary/Run.py +@@ -231,12 +231,6 @@ def writeSolutionsAndKernels( + generateSourcesAndExit=False, + compress=True, + ): +- if globalParameters["PythonProfile"]: +- globalParameters["CpuThreads"] = 0 +- printWarning("Python profiling is enabled. CpuThreads set to 0.") +- import yappi +- yappi.start() +- + codeObjectFiles = [] + + outputPath = Path(outputPath) +@@ -299,15 +293,6 @@ def writeSolutionsAndKernels( + writeHelpers(outputPath, kernelHelperObjs, KERNEL_HELPER_FILENAME_CPP, KERNEL_HELPER_FILENAME_H) + srcKernelFile = Path(outputPath) / "Kernels.cpp" + +- if globalParameters["PythonProfile"]: +- yappi.stop() +- yappi.get_func_stats().save("yappi_results.profile", type="callgrind") +- with open("yappi_results.txt", "w") as f: +- yappi.get_func_stats().print_all(out=f) +- if globalParameters["CpuThreads"] != 0: +- with open("yappi_thread_stats.txt", "w") as f: +- yappi.get_thread_stats().print_all(out=f) +- + if not generateSourcesAndExit: + codeObjectFiles += buildAssemblyCodeObjectFiles( + asmToolchain.linker, +diff --git a/tensilelite/requirements.txt b/tensilelite/requirements.txt +index 60c4c1144537..e87db8445411 100644 +--- a/tensilelite/requirements.txt ++++ b/tensilelite/requirements.txt +@@ -7,4 +7,4 @@ joblib>=1.1.1; python_version < '3.8' + simplejson + ujson + orjson +-yappi ++ +-- +2.52.0 + diff --git a/SPECS/hipblaslt/0001-hipblaslt-tensilelite-use-fedora-paths.patch b/SPECS/hipblaslt/0001-hipblaslt-tensilelite-use-fedora-paths.patch new file mode 100644 index 0000000..0a92e7b --- /dev/null +++ b/SPECS/hipblaslt/0001-hipblaslt-tensilelite-use-fedora-paths.patch @@ -0,0 +1,41 @@ +From 1ac117ac0591a0f1bb67c34f537354c21412b2d8 Mon Sep 17 00:00:00 2001 +From: Tom Rix +Date: Sat, 1 Nov 2025 09:43:58 -0700 +Subject: [PATCH] hipblaslt tensilelite use fedora paths + +--- + tensilelite/Tensile/Common/GlobalParameters.py | 2 +- + tensilelite/Tensile/Toolchain/Validators.py | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/tensilelite/Tensile/Common/GlobalParameters.py b/tensilelite/Tensile/Common/GlobalParameters.py +index 567188da59bd..1f8037c183a6 100644 +--- a/tensilelite/Tensile/Common/GlobalParameters.py ++++ b/tensilelite/Tensile/Common/GlobalParameters.py +@@ -538,7 +538,7 @@ def assignGlobalParameters(config, isaInfoMap: Dict[IsaVersion, IsaInfo]): + else: + print2(" %24s: %8s (unspecified)" % (key, defaultValue)) + +- globalParameters["ROCmPath"] = "/opt/rocm" ++ globalParameters["ROCmPath"] = "/usr" + if "ROCM_PATH" in os.environ: + globalParameters["ROCmPath"] = os.environ.get("ROCM_PATH") + if "TENSILE_ROCM_PATH" in os.environ: +diff --git a/tensilelite/Tensile/Toolchain/Validators.py b/tensilelite/Tensile/Toolchain/Validators.py +index fd5dab5324c0..3ce024d31f52 100644 +--- a/tensilelite/Tensile/Toolchain/Validators.py ++++ b/tensilelite/Tensile/Toolchain/Validators.py +@@ -30,8 +30,8 @@ from typing import List, NamedTuple, Union + + from Tensile.Common.Utilities import isRhel8 + +-DEFAULT_ROCM_BIN_PATH_POSIX = Path("/opt/rocm/bin") +-DEFAULT_ROCM_LLVM_BIN_PATH_POSIX = Path("/opt/rocm/lib/llvm/bin") ++DEFAULT_ROCM_BIN_PATH_POSIX = Path("/usr/bin") ++DEFAULT_ROCM_LLVM_BIN_PATH_POSIX = Path("/usr/lib64/rocm/llvm/bin") + DEFAULT_ROCM_BIN_PATH_WINDOWS = Path("C:/Program Files/AMD/ROCm") + + +-- +2.52.0 + diff --git a/SPECS/hipblaslt/0001-hipblaslt-tensilelite-use-nanobind-tarball.patch b/SPECS/hipblaslt/0001-hipblaslt-tensilelite-use-nanobind-tarball.patch new file mode 100644 index 0000000..f4c8773 --- /dev/null +++ b/SPECS/hipblaslt/0001-hipblaslt-tensilelite-use-nanobind-tarball.patch @@ -0,0 +1,28 @@ +From db6ea0edb963cef7e4c62cabc8f991d8176d045b Mon Sep 17 00:00:00 2001 +From: Tom Rix +Date: Sun, 23 Nov 2025 08:19:04 -0800 +Subject: [PATCH] hipblaslt tensilelite use nanobind tarball + +--- + tensilelite/rocisa/CMakeLists.txt | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/tensilelite/rocisa/CMakeLists.txt b/tensilelite/rocisa/CMakeLists.txt +index 3918f1820d01..7705891bb7f0 100644 +--- a/tensilelite/rocisa/CMakeLists.txt ++++ b/tensilelite/rocisa/CMakeLists.txt +@@ -20,8 +20,9 @@ if(HIPBLASLT_BUNDLE_PYTHON_DEPS) + include(FetchContent) + FetchContent_Declare( + nanobind +- GIT_REPOSITORY https://github.com/wjakob/nanobind.git +- GIT_TAG 9b3afa9dbdc23641daf26fadef7743e7127ff92f # v2.6.1 ++ URL file://${CMAKE_CURRENT_SOURCE_DIR}/../../nanobind.tar.gz ++# GIT_REPOSITORY https://github.com/wjakob/nanobind.git ++# GIT_TAG 9b3afa9dbdc23641daf26fadef7743e7127ff92f # v2.6.1 + ) + FetchContent_MakeAvailable(nanobind) + +-- +2.52.0 + diff --git a/SPECS/hipblaslt/hipblaslt.spec b/SPECS/hipblaslt/hipblaslt.spec new file mode 100644 index 0000000..5d89901 --- /dev/null +++ b/SPECS/hipblaslt/hipblaslt.spec @@ -0,0 +1,414 @@ +%define python_exec python3 + +%bcond gitcommit 0 +%if %{with gitcommit} +%global commit0 2584e35062ad9c2edb68d93c464cf157bc57e3b0 +%global shortcommit0 %(c=%{commit0}; echo ${c:0:7}) +%global date0 20250926 +%endif + +%global upstreamname hipblaslt +%global rocm_release 7.1 +%global rocm_patch 1 +%global rocm_version %{rocm_release}.%{rocm_patch} + +%bcond compat 0 +%if %{with compat} +%global pkg_libdir lib +%global pkg_prefix %{_prefix}/lib64/rocm/rocm-%{rocm_release} +%global pkg_suffix -%{rocm_release} +%global pkg_module rocm%{pkg_suffix} +%else +%global pkg_libdir %{_lib} +%global pkg_prefix %{_prefix} +%global pkg_suffix %{nil} +%global pkg_module default +%endif +%global hipblaslt_name hipblaslt%{pkg_suffix} + +%global toolchain rocm +# hipcc does not support some clang flags +%global build_cxxflags %(echo %{optflags} | sed -e 's/-fstack-protector-strong/-Xarch_host -fstack-protector-strong/' -e 's/-fcf-protection/-Xarch_host -fcf-protection/' -e 's/-mtls-dialect=gnu2//') + +# Fortran is only used in testing +# clang and gfortran fedora toolchain args do not mix +%global build_fflags %{nil} + +# Reduce link memory pressure +%global _lto_cflags %{nil} + +# may run out of memory for both compile and link +# Calculate a good -j number below +%global _smp_mflags %{nil} + +# gfx90a: 10343 pass, 152 fail +%bcond test 0 +# Disable rpatch checks for a local build +%if %{with test} +%global __brp_check_rpaths %{nil} +%global build_test ON +%else +%global build_test OFF +%endif + +%global tensile_version 4.33.0 +# The upstream hipBLASTLt project has a hard fork of the python-tensile package +# The rocBLAS uses. The two versions are incompatible. It appears that the +# fork happened around version 4.33.0. Unfortunately hipBLASLt can no longer be +# build without using this fork. +# https://github.com/ROCm/hipBLASLt/issues/535 +# The problem with the fork has been raised here. +# https://github.com/ROCm/hipBLASLt/issues/908 + +# Compression type and level for source/binary package payloads. +# "w7T0.xzdio" xz level 7 using %%{getncpus} threads +%global _source_payload w7T0.xzdio +%global _binary_payload w7T0.xzdio + +# hipblaslt does not support our default set +#%global gpu_list %{rocm_gpu_list_hipblaslt} +%global gpu_list %{rocm_gpu_list_default} +# For testing +%global _gpu_list "gfx1100" + +# Use ninja if it is available +# Ninja is available on suse but obs times out with ninja build, make doesn't +%bcond ninja 1 + +%if %{with ninja} +%global cmake_generator -G Ninja +%else +%global cmake_generator %{nil} +%endif + +# Request for python-nanobind on EPEL +# https://bugzilla.redhat.com/show_bug.cgi?id=2402409 +%bcond nanobind 0 + +Name: %{hipblaslt_name} +%if %{with gitcommit} +Version: git%{date0}.%{shortcommit0} +Release: 2%{?dist} +%else +Version: %{rocm_version} +Release: 1%{?dist} +%endif +Summary: ROCm general matrix operations beyond BLAS +License: MIT AND BSD-3-Clause +URL: https://github.com/ROCm/rocm-libraries + +%if %{with gitcommit} +Source0: %{url}/archive/%{commit0}/rocm-libraries-%{shortcommit0}.tar.gz +%else +Source0: %{url}/releases/download/rocm-%{version}/%{upstreamname}.tar.gz#/%{upstreamname}-%{version}.tar.gz +%endif + +%global nanobind_version 2.9.2 +%global nanobind_giturl https://github.com/wjakob/nanobind +Source1: %{nanobind_giturl}/archive/v%{nanobind_version}/nanobind-%{nanobind_version}.tar.gz +%global robinmap_version 1.3.0 +%global robinmap_giturl https://github.com/Tessil/robin-map +Source2: %{robinmap_giturl}/archive/v%{robinmap_version}/robin-map-%{robinmap_version}.tar.gz + +# yappi is used in tensilelite to generate profiling data, we are not using that in the build +Patch1: 0001-hipblaslt-tensilelite-remove-yappi-dependency.patch +# change hard coded vendor paths to fedoras +Patch2: 0001-hipblaslt-tensilelite-use-fedora-paths.patch +# https://github.com/ROCm/rocm-libraries/issues/2422 +Patch3: 0001-hipblaslt-find-origami-package.patch +# do not try to fetch, point to the nanobind tarball +Patch4: 0001-hipblaslt-tensilelite-use-nanobind-tarball.patch +# compile and link jobpools +Patch5: 0001-hipblaslt-cmake-compile-and-link-pools.patch + +BuildRequires: llvm +BuildRequires: llvm-devel +BuildRequires: clang +BuildRequires: clang-devel +BuildRequires: clang-tools-extra +BuildRequires: clang-tools-extra-devel +BuildRequires: lld +BuildRequires: lld-devel +BuildRequires: compiler-rt +BuildRequires: rocm-device-libs + +BuildRequires: cmake +BuildRequires: gcc-c++ +BuildRequires: gcc-fortran +BuildRequires: hipblas%{pkg_suffix}-devel +BuildRequires: hipcc%{pkg_suffix} +BuildRequires: libzstd-devel +BuildRequires: rocblas%{pkg_suffix}-devel +BuildRequires: rocminfo%{pkg_suffix} +BuildRequires: rocm-cmake%{pkg_suffix} +BuildRequires: rocm-comgr%{pkg_suffix}-devel +BuildRequires: rocm-llvm%{pkg_suffix}-macros +BuildRequires: rocm-hip%{pkg_suffix}-devel +BuildRequires: rocm-origami%{pkg_suffix}-devel +BuildRequires: rocr-runtime%{pkg_suffix}-devel +BuildRequires: rocm-smi%{pkg_suffix}-devel +BuildRequires: zlib-devel + +# For tensilelite +BuildRequires: python3-devel +BuildRequires: python3dist(setuptools) +BuildRequires: python3dist(pyyaml) +%if %{with nanobind} +BuildRequires: python3dist(nanobind) +%endif +%global tensile_verbose 1 +BuildRequires: python3dist(joblib) +# https://github.com/ROCm/hipBLASLt/issues/1734 +BuildRequires: python3dist(msgpack) +BuildRequires: msgpack-devel + +%if %{with test} +BuildRequires: blis-devel +BuildRequires: lapack-devel +BuildRequires: gmock-devel +BuildRequires: gtest-devel +%endif + +%if %{with ninja} +BuildRequires: ninja +%define __builder ninja +%endif + +Provides: hipblaslt%{pkg_suffix} = %{version}-%{release} +Provides: bundled(python-tensile) = %{tensile_version} + +%if %{without nanobind} +# BSD-3-Clause +Provides: bundled(nanobind) = %{nanobind_version} +Provides: bundled(robin-map) = %{robinmap_version} +%endif + +ExclusiveArch: x86_64 riscv64 + +%description +hipBLASLt is a library that provides general matrix-matrix +operations. It has a flexible API that extends functionalities +beyond a traditional BLAS library, such as adding flexibility +to matrix data layouts, input types, compute types, and +algorithmic implementations and heuristics. + +%package devel +Summary: Libraries and headers for %{name} +Requires: %{name}%{?_isa} = %{version}-%{release} +Provides: hipblaslt%{pkg_suffix}-devel = %{version}-%{release} + +%description devel +%{summary} + +%if %{with test} +%package test +Summary: Tests for %{name} +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description test +%{summary} +%endif + +%prep +%if %{with gitcommit} +%setup -q -n rocm-libraries-%{commit0} +cd projects/hipblaslt +%patch -P1 -p1 +%patch -P2 -p1 +%else +%autosetup -p1 -n %{upstreamname} +%endif + +# Use PATH to find where TensileGetPath and other tensile bins are +sed -i -e 's@${Tensile_PREFIX}/bin/TensileGetPath@TensileGetPath@g' tensilelite/Tensile/cmake/TensileConfig.cmake + +# defer to cmdline +sed -i -e 's@set(CMAKE_INSTALL_LIBDIR@#set(CMAKE_INSTALL_LIBDIR@' CMakeLists.txt + +# Do not use virtualenv_install +sed -i -e 's@virtualenv_install@#virtualenv_install@' CMakeLists.txt + +# Disable trying to download rocm-cmake +sed -i -e 's@if(NOT ROCmCMakeBuildTools_FOUND)@if(FALSE)@' cmake/dependencies.cmake + +%if %{with nanobind} +# Disable download of nanobind +sed -i -e 's@FetchContent_MakeAvailable(nanobind)@find_package(nanobind)@' tensilelite/rocisa/CMakeLists.txt +%else +# Use bundled nanobind +tar xf %{SOURCE1} +mv nanobind-* nanobind +cd nanobind +tar xf %{SOURCE2} +cp -r robin-map-*/* ext/robin_map/ +cd .. +tar czf nanobind.tar.gz nanobind +%endif + +# As of 6.4, there is a long poll +# compile_code_object.sh gfx90a,gfx1100,gfx1101,gfx1151,gfx1200,gfx1201 RelWithDebInfo sha1 hipblasltTransform.hsaco +# This compiles a large file with multiple gpus. +GPUS=`echo %{gpu_list} | grep -o 'gfx' | wc -l` + +HIP_JOBS=`lscpu | grep 'Core(s)' | awk '{ print $4 }'` +if [ ${HIP_JOBS}x = x ]; then + HIP_JOBS=1 +fi +# Try again.. +if [ ${HIP_JOBS} = 1 ]; then + HIP_JOBS=`lscpu | grep '^CPU(s)' | awk '{ print $2 }'` + if [ ${HIP_JOBS}x = x ]; then + HIP_JOBS=4 + fi +fi +if [ "$GPUS" -lt "$HIP_JOBS" ]; then + HIP_JOBS=$GPUS +fi + +# HIPBLASLT_ENABLE_OPENMP is OFF yet it is still being used +# https://github.com/ROCm/rocm-libraries/issues/3201 +sed -i -e '/OpenMP::OpenMP_CXX/d' clients/CMakeLists.txt +sed -i -e '/omp/d' clients/common/src/blis_interface.cpp +sed -i -e '/#include /d' clients/common/include/testing_matmul.hpp +sed -i -e '/#include /d' clients/common/include/hipblaslt_init.hpp +sed -i -e '/#include /d' clients/common/src/cblas_interface.cpp + +# We are building from a tarball, not a git repo +sed -i -e 's@find_package(Git REQUIRED)@#find_package(Git REQUIRED)@' cmake/dependencies.cmake + +# Forcefully replace all mentions of 'amdclang' with 'clang' in the Tensile Python files +find tensilelite -type f -name "*.py" -exec sed -i 's/amdclang++/clang++/g; s/amdclang/clang/g' {} + + +%build +%if %{with gitcommit} +cd projects/hipblaslt +%endif + +# Do a manual install instead of cmake's virtualenv +cd tensilelite +TL=$PWD + +%python_exec setup.py install --root $TL +cd .. + +# Should not have to do this +export PATH=%{pkg_prefix}/bin:$PATH +CLANG_PATH=`hipconfig --hipclangpath` +ROCM_CLANG=${CLANG_PATH}/clang +RESOURCE_DIR=`${ROCM_CLANG} -print-resource-dir` +export DEVICE_LIB_PATH=${RESOURCE_DIR}/amdgcn/bitcode +export TENSILE_ROCM_ASSEMBLER_PATH=${CLANG_PATH}/clang++ +export TENSILE_ROCM_OFFLOAD_BUNDLER_PATH=${CLANG_PATH}/clang-offload-bundler + +# Look for the just built tensilelite +export PATH=${TL}/%{_bindir}:$PATH +export PYTHONPATH=${TL}%{python3_sitelib}:$PYTHONPATH +export Tensile_DIR=${TL}%{python3_sitelib}/Tensile +# Uncomment and see if the path is sane +# TensileGetPath + +cat /proc/cpuinfo +cat /proc/meminfo +lscpu + +# Real cores, No hyperthreading +COMPILE_JOBS=`lscpu | grep 'Core(s)' | awk '{ print $4 }'` +if [ ${COMPILE_JOBS}x = x ]; then + COMPILE_JOBS=1 +fi +# Try again.. +if [ ${COMPILE_JOBS} = 1 ]; then + COMPILE_JOBS=`lscpu | grep '^CPU(s)' | awk '{ print $2 }'` + if [ ${COMPILE_JOBS}x = x ]; then + COMPILE_JOBS=4 + fi +fi + +# Take into account memmory usage per core, do not thrash real memory +BUILD_MEM=8 +MEM_KB=0 +MEM_KB=`cat /proc/meminfo | grep MemTotal | awk '{ print $2 }'` +MEM_MB=`eval "expr ${MEM_KB} / 1024"` +MEM_GB=`eval "expr ${MEM_MB} / 1024"` +COMPILE_JOBS_MEM=`eval "expr 1 + ${MEM_GB} / ${BUILD_MEM}"` +if [ "$COMPILE_JOBS_MEM" -lt "$COMPILE_JOBS" ]; then + COMPILE_JOBS=$COMPILE_JOBS_MEM +fi +LINK_MEM=32 +LINK_JOBS=`eval "expr 1 + ${MEM_GB} / ${LINK_MEM}"` +JOBS=${COMPILE_JOBS} +if [ "$LINK_JOBS" -lt "$JOBS" ]; then + JOBS=$LINK_JOBS +fi + +%cmake %{cmake_generator} \ + -DGPU_TARGETS=%{gpu_list} \ + -DBLIS_INCLUDE_DIR=%{_includedir}/blis \ + -DBLIS_LIB=%{_libdir}/libblis.so \ + -DBUILD_CLIENTS_TESTS=%{build_test} \ + -DBUILD_FILE_REORG_BACKWARD_COMPATIBILITY=OFF \ + -DBUILD_VERBOSE=ON \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_C_COMPILER=%{rocmllvm_bindir}/clang \ + -DCMAKE_CXX_COMPILER=%{rocmllvm_bindir}/clang++ \ + -DCMAKE_INSTALL_LIBDIR=%{pkg_libdir} \ + -DCMAKE_INSTALL_PREFIX=%{pkg_prefix} \ + -DCMAKE_PREFIX_PATH=%{python3_sitelib}/nanobind \ + -DCMAKE_VERBOSE_MAKEFILE=ON \ + -DHIP_PLATFORM=amd \ + -DHIPBLASLT_ENABLE_CLIENT=%{build_test} \ + -DHIPBLASLT_ENABLE_MARKER=OFF \ + -DHIPBLASLT_ENABLE_OPENMP=OFF \ + -DHIPBLASLT_ENABLE_ROCROLLER=OFF \ + -DHIPBLASLT_ENABLE_SAMPLES=OFF \ + -DROCM_SYMLINK_LIBS=OFF \ + -DTensile_LIBRARY_FORMAT=msgpack \ + -DTensile_VERBOSE=%{tensile_verbose} \ + -DVIRTUALENV_BIN_DIR=%{_bindir} \ + -DHIPBLASLT_PARALLEL_COMPILE_JOBS=${COMPILE_JOBS} \ + -DHIPBLASLT_PARALLEL_LINK_JOBS=${LINK_JOBS} \ + %{nil} + +%cmake_build + +%install +%if %{with gitcommit} +cd projects/hipblaslt +%endif + +%cmake_install + +# Extra license +rm -f %{buildroot}%{pkg_prefix}/share/doc/hipblaslt/LICENSE.md + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig + +%files +%if %{with gitcommit} +%doc projects/hipblaslt/README.md +%license projects/hipblaslt/LICENSE.md +%else +%doc README.md +%license LICENSE.md +%endif + +%{pkg_prefix}/%{pkg_libdir}/libhipblaslt.so.* +%{pkg_prefix}/%{pkg_libdir}/hipblaslt/ + +%files devel +%{pkg_prefix}/include/hipblaslt/ +%{pkg_prefix}/include/hipblaslt-export.h +%{pkg_prefix}/include/hipblaslt-version.h +%{pkg_prefix}/%{pkg_libdir}/cmake/hipblaslt/ +%{pkg_prefix}/%{pkg_libdir}/libhipblaslt.so + +%if %{with test} +%files test +%{pkg_prefix}/bin/hipblaslt* +%{pkg_prefix}/bin/sequence.yaml +%endif + +%changelog +* Mon Feb 9 2026 Yifan Xu - 7.1.1-1 +- Import from upstream