Gentoo Archives: gentoo-commits

From: Benda XU <heroxbd@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sci-libs/rocBLAS/files/, sci-libs/rocBLAS/
Date: Sun, 27 Mar 2022 03:13:03
Message-Id: 1648350771.f1dcb1e8ba4936959138ccf747400d0d54d87b26.heroxbd@gentoo
1 commit: f1dcb1e8ba4936959138ccf747400d0d54d87b26
2 Author: YiyangWu <xgreenlandforwyy <AT> gmail <DOT> com>
3 AuthorDate: Mon Feb 21 15:03:56 2022 +0000
4 Commit: Benda XU <heroxbd <AT> gentoo <DOT> org>
5 CommitDate: Sun Mar 27 03:12:51 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f1dcb1e8
7
8 sci-libs/rocBLAS: bump version to 5.0.2
9
10 Enable nai22 chips (Radeon RX 6700/6700 XT / 6800M, gfx1031)
11 fix test issue when PORTAGE_USERNAME is not portage:
12 "[: too many arguments"
13
14 Closes: https://bugs.gentoo.org/834672
15 Package-Manager: Portage-3.0.30, Repoman-3.0.3
16 Signed-off-by: Yiyang Wu <xgreenlandforwyy <AT> gmail.com>
17 Signed-off-by: Benda Xu <heroxbd <AT> gentoo.org>
18
19 sci-libs/rocBLAS/Manifest | 2 +
20 ...-5.0.2-change-default-Tensile-library-dir.patch | 47 +++++++
21 .../files/rocBLAS-5.0.2-cpp_lib_filesystem.patch | 50 ++++++++
22 .../files/rocBLAS-5.0.2-unbundle-Tensile.patch | 25 ++++
23 sci-libs/rocBLAS/rocBLAS-5.0.2.ebuild | 135 +++++++++++++++++++++
24 5 files changed, 259 insertions(+)
25
26 diff --git a/sci-libs/rocBLAS/Manifest b/sci-libs/rocBLAS/Manifest
27 index 00865310a02d..e8bb583d38a1 100644
28 --- a/sci-libs/rocBLAS/Manifest
29 +++ b/sci-libs/rocBLAS/Manifest
30 @@ -1,2 +1,4 @@
31 +DIST rocBLAS-5.0.2-Tensile-asm_full-navi22.tar.gz 1110323 BLAKE2B 80fab97c6f89fccf1f8829ad41baf15ad31bbbb313b48825841834c7ec1b9f8ece794aebdf9fda42b54a38f642beb1bc1e374f2f3b4e43d8ba9dfd1eb6e3ece5 SHA512 8f6946cf9d68afd195640ae7e0da8dc33341c67f28813813b5361a56531fa2af4453d075703ea52c66d93a1936cf74688b86aa2fa62b52a7ed5f03272290c232
32 DIST rocm-Tensile-4.3.0.tar.gz 14250149 BLAKE2B 030138eaca2a0aadd96801e6dbd72e510716dd90553ef3795c5e04e00a34a05ecae82b24f755e4033a4acfcdb1cf26291da1e7902bb090f89a010d403e832beb SHA512 126db0b413c716fba8d5be9bff7a44fd1badacbf32f3db8d0db649819177db37ebd56fd22dd3c809655f5d29675be115e698cd10bc3d0b4b23878ae3726fce47
33 DIST rocm-rocBLAS-4.3.0.tar.gz 11569970 BLAKE2B f11b0acf2bbd5737b036142d3b2cc1e18c38e088a8b7db58156d478dd6718befbb82bb7fd43a38fe64a5427124c5ad5241fa37977f094e6efd195d168d3e5f65 SHA512 490ab1c1e98a8b311ad5630515c448d9bb0a2bf588a08bcbebee345e2954d616b4ffe7c2e03dadca82c590438c42afccb98fe8ba00856aece101b5ffe62ef1e0
34 +DIST rocm-rocBLAS-5.0.2.tar.gz 13295178 BLAKE2B e1abfa06b9ac1545732465857839dae3f3708af49439a306a2b5b1b1b392101c38c95815f2c05a0d9ed29d41b154bc2e16a4f9203a37f5e2f68ee12cc4b44a06 SHA512 2f4a74f49350ede0debcf32229a6b6b95505615723c3f2bee16e4c169a3bb966dfb1971819028f47c525f571bea5662b892e63f655b0d1d2b8f20746bc5fe770
35
36 diff --git a/sci-libs/rocBLAS/files/rocBLAS-5.0.2-change-default-Tensile-library-dir.patch b/sci-libs/rocBLAS/files/rocBLAS-5.0.2-change-default-Tensile-library-dir.patch
37 new file mode 100644
38 index 000000000000..618847b8fb8d
39 --- /dev/null
40 +++ b/sci-libs/rocBLAS/files/rocBLAS-5.0.2-change-default-Tensile-library-dir.patch
41 @@ -0,0 +1,47 @@
42 +change the default rocm tensile library search path
43 +Index: rocBLAS-rocm-5.0.1/library/src/tensile_host.cpp
44 +===================================================================
45 +--- rocBLAS-rocm-5.0.1.orig/library/src/tensile_host.cpp
46 ++++ rocBLAS-rocm-5.0.1/library/src/tensile_host.cpp
47 +@@ -558,40 +558,8 @@ namespace
48 + // Find the location of librocblas.dll/.so
49 + // Fall back on hard-coded path if static library or not found
50 +
51 +-#ifndef ROCBLAS_STATIC_LIB
52 +-#ifdef WIN32
53 +- // wchar_t wpath[MAX_PATH + 1] = {0};
54 +- // if(GetModuleFileNameW(GetModuleHandle("rocblas.dll"), wpath, MAX_PATH + 1))
55 +- // {
56 +- // std::wstring wspath(wpath);
57 +- // std::string tmp(wspath.begin(), wspath.end());
58 +
59 +- std::vector<TCHAR> dll_path(MAX_PATH + 1);
60 +- if(GetModuleFileNameA(
61 +- GetModuleHandleA("rocblas.dll"), dll_path.data(), MAX_PATH + 1))
62 +- {
63 +- std::string tmp(dll_path.begin(), dll_path.end());
64 +- std::filesystem::path exepath = tmp;
65 +- if(exepath.has_filename())
66 +- {
67 +- path = exepath.remove_filename().string();
68 +- }
69 +- }
70 +-#else
71 +- dl_iterate_phdr(rocblas_dl_iterate_phdr_callback, NULL);
72 +- if(rocblas_so_path.size())
73 +- path = std::string{dirname(&rocblas_so_path[0])};
74 +-#endif
75 +-#endif // ifndef ROCBLAS_STATIC_LIB
76 +-
77 +- // Find the location of the libraries
78 +- if(TestPath(path + "/../../Tensile/library"))
79 +- path += "/../../Tensile/library";
80 +- else
81 +- path += "/library";
82 +-
83 +- if(TestPath(path + "/" + processor))
84 +- path += "/" + processor;
85 ++ path="@GENTOO_PORTAGE_EPREFIX@/usr/lib64/rocblas/library";
86 + }
87 +
88 + // only load modules for the current architecture
89
90 diff --git a/sci-libs/rocBLAS/files/rocBLAS-5.0.2-cpp_lib_filesystem.patch b/sci-libs/rocBLAS/files/rocBLAS-5.0.2-cpp_lib_filesystem.patch
91 new file mode 100644
92 index 000000000000..500abbacfdc2
93 --- /dev/null
94 +++ b/sci-libs/rocBLAS/files/rocBLAS-5.0.2-cpp_lib_filesystem.patch
95 @@ -0,0 +1,50 @@
96 +--- b/clients/common/utility.cpp 2022-01-26 03:31:42.000000000 +0800
97 ++++ a/clients/common/utility.cpp 2022-02-22 18:45:35.319732953 +0800
98 +@@ -23,6 +23,7 @@
99 + #include <fcntl.h>
100 + #endif
101 +
102 ++#include <version>
103 + #ifdef __cpp_lib_filesystem
104 + #include <filesystem>
105 + #else
106 +--- b/clients/include/rocblas_data.hpp 2022-01-26 03:31:42.000000000 +0800
107 ++++ a/clients/include/rocblas_data.hpp 2022-02-22 18:44:51.275733070 +0800
108 +@@ -17,6 +17,7 @@
109 + #include <string>
110 + #include <utility>
111 +
112 ++#include<version>
113 + #ifdef __cpp_lib_filesystem
114 + #include <filesystem>
115 + #else
116 +--- b/clients/include/singletons.hpp 2022-01-26 03:31:42.000000000 +0800
117 ++++ a/clients/include/singletons.hpp 2022-02-22 18:47:55.139732583 +0800
118 +@@ -3,6 +3,6 @@
119 + * ************************************************************************ */
120 +
121 + // global for device memory padding see d_vector.hpp
122 ++#include<cstddef>
123 +-
124 + extern size_t g_DVEC_PAD;
125 + void d_vector_set_pad_length(size_t pad);
126 +--- b/clients/include/testing_logging.hpp 2022-01-26 03:31:42.000000000 +0800
127 ++++ a/clients/include/testing_logging.hpp 2022-02-22 18:44:13.115733171 +0800
128 +@@ -22,6 +22,7 @@
129 + #include <unistd.h>
130 + #endif
131 +
132 ++#include<version>
133 + #ifdef __cpp_lib_filesystem
134 + #include <filesystem>
135 + #else
136 +--- b/clients/include/testing_ostream_threadsafety.hpp 2022-01-26 03:31:42.000000000 +0800
137 ++++ a/clients/include/testing_ostream_threadsafety.hpp 2022-02-22 18:45:19.055732996 +0800
138 +@@ -30,6 +30,7 @@
139 + #include <sys/types.h>
140 + #endif
141 +
142 ++#include <version>
143 + #ifdef __cpp_lib_filesystem
144 + #include <filesystem>
145 + #else
146
147 diff --git a/sci-libs/rocBLAS/files/rocBLAS-5.0.2-unbundle-Tensile.patch b/sci-libs/rocBLAS/files/rocBLAS-5.0.2-unbundle-Tensile.patch
148 new file mode 100644
149 index 000000000000..75f673f63d47
150 --- /dev/null
151 +++ b/sci-libs/rocBLAS/files/rocBLAS-5.0.2-unbundle-Tensile.patch
152 @@ -0,0 +1,25 @@
153 +Index: rocBLAS-rocm-5.0.2/CMakeLists.txt
154 +===================================================================
155 +--- rocBLAS-rocm-5.0.2.orig/CMakeLists.txt
156 ++++ rocBLAS-rocm-5.0.2/CMakeLists.txt
157 +@@ -271,20 +271,6 @@ if(NOT SKIP_LIBRARY)
158 + set( Tensile_ROOT "${CMAKE_BINARY_DIR}/virtualenv/Lib/site-packages/Tensile" )
159 + endif()
160 +
161 +- include(virtualenv)
162 +- if (Tensile_TEST_LOCAL_PATH)
163 +- virtualenv_install(${Tensile_TEST_LOCAL_PATH})
164 +- message (STATUS "using local Tensile from ${Tensile_TEST_LOCAL_PATH}, copied to ${Tensile_ROOT}")
165 +- else()
166 +- # Use the virtual-env setup and download package from specified repot:
167 +- set( tensile_fork "ROCmSoftwarePlatform" CACHE STRING "Tensile fork to use" )
168 +- file (STRINGS "tensile_tag.txt" read_tensile_tag)
169 +- set( tensile_tag ${read_tensile_tag} CACHE STRING "Tensile tag to download" )
170 +- virtualenv_install("git+https://github.com/${tensile_fork}/Tensile.git@${tensile_tag}")
171 +- message (STATUS "using GIT Tensile fork=${tensile_fork} from branch=${tensile_tag}")
172 +- endif()
173 +- message(STATUS "Adding ${VIRTUALENV_HOME_DIR} to CMAKE_PREFIX_PATH")
174 +- list(APPEND CMAKE_PREFIX_PATH ${VIRTUALENV_HOME_DIR})
175 + if (TENSILE_VERSION)
176 + find_package(Tensile ${TENSILE_VERSION} EXACT REQUIRED HIP LLVM OpenMP PATHS "${INSTALLED_TENSILE_PATH}")
177 + else()
178
179 diff --git a/sci-libs/rocBLAS/rocBLAS-5.0.2.ebuild b/sci-libs/rocBLAS/rocBLAS-5.0.2.ebuild
180 new file mode 100644
181 index 000000000000..0600f90bac37
182 --- /dev/null
183 +++ b/sci-libs/rocBLAS/rocBLAS-5.0.2.ebuild
184 @@ -0,0 +1,135 @@
185 +# Copyright 1999-2022 Gentoo Authors
186 +# Distributed under the terms of the GNU General Public License v2
187 +
188 +EAPI=8
189 +
190 +DOCS_BUILDER="doxygen"
191 +DOCS_DIR="docs"
192 +DOCS_DEPEND="media-gfx/graphviz"
193 +inherit cmake docs prefix
194 +
195 +DESCRIPTION="AMD's library for BLAS on ROCm"
196 +HOMEPAGE="https://github.com/ROCmSoftwarePlatform/rocBLAS"
197 +SRC_URI="https://github.com/ROCmSoftwarePlatform/rocBLAS/archive/rocm-${PV}.tar.gz -> rocm-${P}.tar.gz
198 + https://media.githubusercontent.com/media/littlewu2508/littlewu2508.github.io/main/gentoo-distfiles/${P}-Tensile-asm_full-navi22.tar.gz"
199 +S="${WORKDIR}/${PN}-rocm-${PV}"
200 +
201 +LICENSE="BSD"
202 +KEYWORDS="~amd64"
203 +SLOT="0/$(ver_cut 1-2)"
204 +IUSE="benchmark test"
205 +RESTRICT="!test? ( test )"
206 +
207 +BDEPEND="
208 + dev-util/rocm-cmake:${SLOT}
209 + dev-util/Tensile:${SLOT}
210 +"
211 +
212 +DEPEND="
213 + dev-util/hip:${SLOT}
214 + dev-libs/msgpack
215 + test? (
216 + virtual/blas
217 + dev-cpp/gtest
218 + sys-libs/libomp
219 + )
220 + benchmark? (
221 + virtual/blas
222 + sys-libs/libomp
223 + )
224 +"
225 +
226 +PATCHES=(
227 + "${FILESDIR}"/${PN}-4.3.0-fix-glibc-2.32-and-above.patch
228 + "${FILESDIR}"/${PN}-5.0.2-change-default-Tensile-library-dir.patch
229 + "${FILESDIR}"/${PN}-5.0.2-cpp_lib_filesystem.patch
230 + "${FILESDIR}"/${PN}-5.0.2-unbundle-Tensile.patch
231 + )
232 +
233 +src_prepare() {
234 + cmake_src_prepare
235 + cp -a "${WORKDIR}/asm_full/" library/src/blas3/Tensile/Logic/ || die
236 + # Fit for Gentoo FHS rule
237 + sed -e "/PREFIX rocblas/d" \
238 + -e "/<INSTALL_INTERFACE/s:include:include/rocblas:" \
239 + -e "s:rocblas/include:include/rocblas:" \
240 + -e "s:\\\\\${CPACK_PACKAGING_INSTALL_PREFIX}rocblas/lib:${EPREFIX}/usr/$(get_libdir)/rocblas:" \
241 + -e "s:share/doc/rocBLAS:share/doc/${P}:" \
242 + -e "/rocm_install_symlink_subdir( rocblas )/d" -i library/src/CMakeLists.txt || die
243 +
244 + sed -e "s:,-rpath=.*\":\":" -i clients/CMakeLists.txt || die
245 +
246 + eprefixify library/src/tensile_host.cpp
247 +}
248 +
249 +src_configure() {
250 + # allow acces to hardware
251 + addpredict /dev/kfd
252 + addpredict /dev/dri/
253 + addpredict /dev/random
254 +
255 + export PATH="${EPREFIX}/usr/lib/llvm/roc/bin:${PATH}"
256 +
257 + local mycmakeargs=(
258 + -DTensile_LOGIC="asm_full"
259 + -DTensile_COMPILER="hipcc"
260 + -DTensile_LIBRARY_FORMAT="msgpack"
261 + -DTensile_CODE_OBJECT_VERSION="V3"
262 + -DTensile_TEST_LOCAL_PATH="${EPREFIX}/usr/share/Tensile"
263 + -DTensile_ROOT="${EPREFIX}/usr/share/Tensile"
264 + -DBUILD_WITH_TENSILE=ON
265 + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr"
266 + -DCMAKE_INSTALL_INCLUDEDIR="include/rocblas"
267 + -DCMAKE_SKIP_RPATH=TRUE
268 + -DBUILD_TESTING=OFF
269 + -DBUILD_CLIENTS_SAMPLES=OFF
270 + -DBUILD_CLIENTS_TESTS=$(usex test ON OFF)
271 + -DBUILD_CLIENTS_BENCHMARKS=$(usex benchmark ON OFF)
272 + ${AMDGPU_TARGETS+-DAMDGPU_TARGETS="${AMDGPU_TARGETS}"}
273 + )
274 +
275 + CXX="hipcc" cmake_src_configure
276 +
277 + # do not rerun cmake and the build process in src_install
278 + sed -e '/RERUN/,+1d' -i "${BUILD_DIR}"/build.ninja || die
279 +}
280 +
281 +src_compile() {
282 + docs_compile
283 + cmake_src_compile
284 +}
285 +
286 +check_rw_permission() {
287 + local cmd="[ -r $1 ] && [ -w $1 ]"
288 + local error=0 user
289 + if has sandbox ${FEATURES}; then
290 + user="portage"
291 + su portage -c "${cmd}" || error=1
292 + else
293 + user="$(whoami)"
294 + bash -c "${cmd}" || error=1
295 + fi
296 + if [[ "${error}" == 1 ]]; then
297 + die "${user} do not have read and write permissions on $1! \n Make sure ${user} is in render group and check the permissions."
298 + fi
299 +}
300 +
301 +src_test() {
302 + # check permissions on /dev/kfd and /dev/dri/render*
303 + check_rw_permission /dev/kfd
304 + check_rw_permission /dev/dri/render*
305 + addwrite /dev/kfd
306 + addwrite /dev/dri/
307 + cd "${BUILD_DIR}/clients/staging" || die
308 + ROCBLAS_TEST_TIMEOUT=3600 LD_LIBRARY_PATH="${BUILD_DIR}/clients:${BUILD_DIR}/library/src" ROCBLAS_TENSILE_LIBPATH="${BUILD_DIR}/Tensile/library" ./rocblas-test || die "Tests failed"
309 +}
310 +
311 +src_install() {
312 + cmake_src_install
313 +
314 + if use benchmark; then
315 + cd "${BUILD_DIR}" || die
316 + dolib.so clients/librocblas_fortran_client.so
317 + dobin clients/staging/rocblas-bench
318 + fi
319 +}