blob: 9f9ee86cb68dcb0e3923dc25d0873098b4abb350 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
ROCM_SKIP_GLOBALS=1
PYTHON_COMPAT=( python3_{13..14} )
LLVM_COMPAT=( 23 )
inherit cmake edob flag-o-matic multiprocessing llvm-r2 python-any-r1 rocm
DESCRIPTION="General matrix-matrix operations library for AMD Instinct accelerators"
HOMEPAGE="https://github.com/ROCm/rocm-libraries/tree/develop/projects/hipblaslt"
MY_URI="https://github.com/ROCm/rocm-libraries/releases/download/therock-${PV%.0}"
SRC_URI="
${MY_URI}/hipblaslt.tar.gz -> hipblaslt-${PV}.tar.gz
${MY_URI}/origami.tar.gz -> origami-${PV}.tar.gz
${MY_URI}/stinkytofu.tar.gz -> stinkytofu-${PV}.tar.gz
benchmark? ( ${MY_URI}/mxdatagenerator.tar.gz -> mxdatagenerator-${PV}.tar.gz )
https://github.com/ROCm/rocm-libraries/commit/bf56af2e53b7ba22b4ac86e8d8cd25df8040b0f2.patch
-> ${P}-true16.patch
"
# monorepo layout: hipBLASLt refers to ../../shared/{origami,stinkytofu,mxdatagenerator}
S="${WORKDIR}/projects/hipblaslt"
LICENSE="MIT"
SLOT="0/$(ver_cut 1-2)"
KEYWORDS="~amd64"
SUPPORTED_GPUS=(
gfx908 gfx90a gfx942 gfx950 gfx1100 gfx1101 gfx1102 gfx1103
gfx1150 gfx1151 gfx1152 gfx1153 gfx1200 gfx1201
)
IUSE_TARGETS=( "${SUPPORTED_GPUS[@]/#/amdgpu_targets_}" )
IUSE="${IUSE_TARGETS[*]/#/+} benchmark roctracer test"
RESTRICT="!test? ( test )"
RDEPEND="
dev-util/hip:${SLOT}
roctracer? ( dev-util/roctracer:${SLOT} )
benchmark? (
sci-libs/flexiblas
)
"
DEPEND="
${RDEPEND}
dev-cpp/msgpack-cxx
sci-libs/hipBLAS-common:${SLOT}
llvm-runtimes/openmp
test? ( dev-util/amdsmi:${SLOT} )
"
BDEPEND="
${PYTHON_DEPS}
dev-build/rocm-cmake:${SLOT}
dev-util/hipcc:${SLOT}
$(python_gen_any_dep "
dev-python/msgpack[\${PYTHON_USEDEP}]
dev-python/pyyaml[\${PYTHON_USEDEP}]
dev-python/joblib[\${PYTHON_USEDEP}]
dev-python/nanobind[\${PYTHON_USEDEP}]
dev-python/setuptools[\${PYTHON_USEDEP}]
")
$(llvm_gen_dep "llvm-core/clang:\${LLVM_SLOT}")
test? (
dev-cpp/gtest
sci-libs/flexiblas
)
"
# Since 7.1.0 to build tests one needs to build benchmarks (which will be installed)
# TODO: make build of tests independent benchmarks
REQUIRED_USE="test? ( benchmark )"
PATCHES=(
"${FILESDIR}"/${PN}-10.1.0-rocisa-nanobind.patch
)
python_check_deps() {
python_has_version "dev-python/msgpack[${PYTHON_USEDEP}]" &&
python_has_version "dev-python/pyyaml[${PYTHON_USEDEP}]" &&
python_has_version "dev-python/joblib[${PYTHON_USEDEP}]" &&
python_has_version "dev-python/nanobind[${PYTHON_USEDEP}]" &&
python_has_version "dev-python/setuptools[${PYTHON_USEDEP}]"
}
pkg_setup() {
QA_FLAGS_IGNORED="usr/$(get_libdir)/hipblaslt/library/.*"
python-any-r1_pkg_setup
}
pkg_pretend() {
if [[ "${AMDGPU_TARGETS[*]}" = "" ]]; then
ewarn "hipBLASLt supports only some GPUs: ${SUPPORTED_GPUS[*]},"
ewarn "but none of them were defined in AMDGPU_TARGETS USE_EXPAND variable."
ewarn
ewarn "Library will continue to be built in \"dummy\" mode,"
ewarn "serving as a non-functional placeholder for end-user applications."
fi
}
src_unpack() {
mkdir -p projects shared || die
pushd projects >/dev/null || die
unpack hipblaslt-${PV}.tar.gz
popd >/dev/null || die
pushd shared >/dev/null || die
unpack origami-${PV}.tar.gz stinkytofu-${PV}.tar.gz
use benchmark && unpack mxdatagenerator-${PV}.tar.gz
popd >/dev/null || die
}
src_prepare() {
# LLVM 23 rejects fake16 syntax on gfx11/gfx12; the patch spans projects/ and shared/
pushd "${WORKDIR}" >/dev/null || die
eapply "${DISTDIR}"/${P}-true16.patch
popd >/dev/null || die
local shebangs=($(grep -rl "#!/usr/bin/env python3" tensilelite/Tensile || die))
python_fix_shebang -q "${shebangs[@]}"
rocm_use_clang
sed -e "s:\$(ROCM_PATH)/bin/amdclang++:$(get_llvm_prefix)/bin/clang++:g" \
-i tensilelite/Makefile || die
# Fix compiler validation (just a validation)
sed -e "s/amdclang/$(basename "$CC")/g" \
-i tensilelite/Tensile/Toolchain/Validators.py \
-i tensilelite/Tensile/Tests/unit/test_MatrixInstructionConversion.py || die
# Do not install tests
sed -e "s/COMPONENT tests/COMPONENT tests EXCLUDE_FROM_ALL/" -i CMakeLists.txt || die
# No -Werror
sed -e "/set(STINKYTOFU_ENABLE_WERROR ON)/d" -i tensilelite/rocisa/CMakeLists.txt || die
# libc++ does not include <iterator> and <cstdlib> transitively
sed -e "/#include <map>/i #include <iterator>" \
-i tensilelite/include/Tensile/{MasterSolutionLibrary,PlaceholderLibrary}.hpp || die
sed -e "/#include <cxxabi.h>/a #include <cstdlib>" \
-i tensilelite/rocisa/rocisa/src/helper.cpp || die
cmake_src_prepare
}
src_configure() {
rocm_use_clang
# too many warnings
append-cxxflags -Wno-explicit-specialization-storage-class
# rocisa asserts on comments inside macro bodies, upstream builds without asserts
append-cppflags -DNDEBUG
local targets="$(get_amdgpu_flags)"
local Tensile_SKIP_BUILD=$([ "${AMDGPU_TARGETS[*]}" = "" ] && echo ON || echo OFF )
local HIPBLASLT_ENABLE_DEVICE=$([ "${AMDGPU_TARGETS[*]}" != "" ] && echo ON || echo OFF )
# targets has a trailing semicolon, this trips up Tensile's input parser, so carefully prune
local mycmakeargs=(
-DGPU_TARGETS="${targets%;}"
-DHIPBLASLT_ENABLE_CLIENT="$(usex benchmark ON $(usex test ON OFF))"
-DHIPBLASLT_ENABLE_SAMPLES=OFF
-DHIPBLASLT_ENABLE_DEVICE=${HIPBLASLT_ENABLE_DEVICE}
-DHIPBLASLT_ENABLE_MARKER="$(usex roctracer ON OFF)"
-DHIPBLASLT_ENABLE_ROCROLLER=OFF
-DHIPBLASLT_ENABLE_FETCH=OFF
-DHIPBLASLT_BUNDLE_PYTHON_DEPS=ON
-Dnanobind_DIR="$(python_get_sitedir)/nanobind/cmake"
# use system nanobind and rocm-cmake instead of git clones
-DFETCHCONTENT_TRY_FIND_PACKAGE_MODE=ALWAYS
-DPython_EXECUTABLE="${PYTHON}"
-DROCM_SYMLINK_LIBS=OFF
-DTENSILELITE_BUILD_PARALLEL_LEVEL=$(makeopts_jobs)
-DHIPBLASLT_BUILD_TESTING="$(usex test ON OFF)"
-DHIPBLASLT_ENABLE_AMD_SMI="$(usex test ON OFF)"
-Wno-dev
)
if use test || use benchmark; then
# HIPBLASLT_ENABLE_CLIENT=ON branch
mycmakeargs+=(
-DBLA_PKGCONFIG_BLAS=ON
-DBLA_VENDOR=FlexiBLAS
-DHIPBLASLT_ENABLE_BLIS=OFF
)
fi
cmake_src_configure
}
src_compile() {
local -x ROCM_PATH="${EPREFIX}/usr"
# set PYTHONPATH to load Tensile from virtualenv, not the system-wide one
local -x PYTHONPATH="${S}_build/virtualenv/lib/${EPYTHON}/site-packages"
local -x TENSILE_ROCM_ASSEMBLER_PATH="$(get_llvm_prefix)/bin/clang++"
# TensileCreateLibrary reads CMAKE_CXX_COMPILER again
local -x CMAKE_CXX_COMPILER="$(get_llvm_prefix)/bin/clang++"
cmake_src_compile
}
src_install() {
cmake_src_install
# Stop llvm-strip from removing .strtab section from *.hsaco files,
# otherwise rocclr/elf/elf.cpp complains with "failed: null sections(STRTAB)" and crashes
dostrip -x /usr/$(get_libdir)/hipblaslt/library/
}
src_test() {
check_amdgpu
# hipblaslt-test is added to CTest only within the rocm-libraries tree (shared/ctest);
# run it like TheRock CI does (no filter). Expected time for 7900 XTX: 580s
cd "${BUILD_DIR}"/clients || die
# Fails in `MatrixTransformTest.MultipleDevices` in dGPU+iGPU combination
local -x HIP_VISIBLE_DEVICES=0
edob ./hipblaslt-test
}
|