1 |
commit: 53da9141ac01271e8abb862025df966e852d68a4 |
2 |
Author: Benda Xu <heroxbd <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Feb 6 16:15:07 2021 +0000 |
4 |
Commit: Benda XU <heroxbd <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Feb 6 16:19:49 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/sci.git/commit/?id=53da9141 |
7 |
|
8 |
dev-util/Tensile: move to standard directories. |
9 |
|
10 |
Let cmake to be able to locate Tensile. |
11 |
|
12 |
Move source code out of the python site-packages tree. |
13 |
|
14 |
Reported-by: Yiyang Wu <xgreenlandforwyy <AT> gmail.com>, Alexey Chernov |
15 |
Closes: https://bugs.gentoo.org/768474 |
16 |
Package-Manager: Portage-3.0.12, Repoman-3.0.1 |
17 |
Signed-off-by: Benda Xu <heroxbd <AT> gentoo.org> |
18 |
|
19 |
dev-util/Tensile/Tensile-4.0.0-r1.ebuild | 62 ++++++++++++++++++++++ |
20 |
dev-util/Tensile/Tensile-4.0.0.ebuild | 37 +++++++++++-- |
21 |
dev-util/Tensile/files/Tensile-4.0.0-cmake.patch | 38 +++++++++++++ |
22 |
.../files/Tensile-4.0.0-locate-commands.patch | 62 ++++++++++++++++++++++ |
23 |
.../files/Tensile-4.0.0-output-currentISA.patch | 22 ++++++++ |
24 |
.../files/Tensile-4.0.0-setup.py-cmake.patch | 13 +++++ |
25 |
6 files changed, 231 insertions(+), 3 deletions(-) |
26 |
|
27 |
diff --git a/dev-util/Tensile/Tensile-4.0.0-r1.ebuild b/dev-util/Tensile/Tensile-4.0.0-r1.ebuild |
28 |
new file mode 100644 |
29 |
index 000000000..eda97d225 |
30 |
--- /dev/null |
31 |
+++ b/dev-util/Tensile/Tensile-4.0.0-r1.ebuild |
32 |
@@ -0,0 +1,62 @@ |
33 |
+# Copyright 1999-2021 Gentoo Authors |
34 |
+# Distributed under the terms of the GNU General Public License v2 |
35 |
+ |
36 |
+EAPI=7 |
37 |
+ |
38 |
+PYTHON_COMPAT=( python3_{7,8,9} ) |
39 |
+DISTUTILS_USE_SETUPTOOLS=rdepend |
40 |
+ |
41 |
+inherit distutils-r1 |
42 |
+ |
43 |
+DESCRIPTION="Stretching GPU performance for GEMMs and tensor contractions" |
44 |
+HOMEPAGE="https://github.com/ROCmSoftwarePlatform/Tensile" |
45 |
+SRC_URI="https://github.com/ROCmSoftwarePlatform/Tensile/archive/rocm-${PV}.tar.gz -> rocm-Tensile-${PV}.tar.gz" |
46 |
+ |
47 |
+LICENSE="MIT" |
48 |
+KEYWORDS="~amd64" |
49 |
+SLOT="0" |
50 |
+IUSE="" |
51 |
+ |
52 |
+RDEPEND="${PYTHON_DEPS} |
53 |
+ dev-python/pyyaml[${PYTHON_USEDEP}] |
54 |
+ dev-python/msgpack[${PYTHON_USEDEP}]" |
55 |
+DEPEND="${RDEPEND} |
56 |
+ dev-util/hip" |
57 |
+ |
58 |
+PATCHES=( "${FILESDIR}"/${PN}-4.0.0-cmake.patch |
59 |
+ "${FILESDIR}"/${PN}-4.0.0-setup.py-cmake.patch |
60 |
+ "${FILESDIR}"/${PN}-4.0.0-locate-commands.patch |
61 |
+ "${FILESDIR}"/${PN}-4.0.0-output-currentISA.patch ) |
62 |
+ |
63 |
+S="${WORKDIR}/${PN}-rocm-${PVR}" |
64 |
+CMAKE_USE_DIR="${WORKDIR}/Source" |
65 |
+ |
66 |
+src_prepare() { |
67 |
+ distutils-r1_src_prepare |
68 |
+ |
69 |
+ mv ${PN}/Source "${WORKDIR}"/ || die |
70 |
+ sed -e "/ROCM_SMI_ROOT/s,lib,$(get_libdir)," \ |
71 |
+ -i "${WORKDIR}"/Source/cmake/FindROCmSMI.cmake || die |
72 |
+ sed -r -e "/TENSILE_USE_LLVM/s/ON/OFF/" \ |
73 |
+ -i "${WORKDIR}"/Source/CMakeLists.txt || die |
74 |
+ |
75 |
+ mv ${PN}/cmake "${T}"/ || die |
76 |
+ |
77 |
+ sed -e "/HipClangVersion/s/0,0,0/$(ver_rs 1-3 ,)/" \ |
78 |
+ -e "/SourcePath/s,os\.path\.join.*$,\"${EPREFIX}/usr/share/${PN}\"," \ |
79 |
+ -i ${PN}/Common.py || die |
80 |
+ |
81 |
+ sed -e "s|os\.path\.dirname.*$|\"${EPREFIX}/usr/share/Tensile\", end='')|" \ |
82 |
+ -i ${PN}/__init__.py || die |
83 |
+} |
84 |
+ |
85 |
+src_install() { |
86 |
+ distutils-r1_src_install |
87 |
+ |
88 |
+ insinto /usr/$(get_libdir)/cmake/${PN} |
89 |
+ doins "${T}"/cmake/*.cmake |
90 |
+ |
91 |
+ insinto /usr/share/${PN} |
92 |
+ doins -r "${WORKDIR}"/Source/* |
93 |
+ dosym . /usr/share/${PN}/Source |
94 |
+} |
95 |
|
96 |
diff --git a/dev-util/Tensile/Tensile-4.0.0.ebuild b/dev-util/Tensile/Tensile-4.0.0.ebuild |
97 |
index b930c3d69..eda97d225 100644 |
98 |
--- a/dev-util/Tensile/Tensile-4.0.0.ebuild |
99 |
+++ b/dev-util/Tensile/Tensile-4.0.0.ebuild |
100 |
@@ -4,6 +4,7 @@ |
101 |
EAPI=7 |
102 |
|
103 |
PYTHON_COMPAT=( python3_{7,8,9} ) |
104 |
+DISTUTILS_USE_SETUPTOOLS=rdepend |
105 |
|
106 |
inherit distutils-r1 |
107 |
|
108 |
@@ -19,13 +20,43 @@ IUSE="" |
109 |
RDEPEND="${PYTHON_DEPS} |
110 |
dev-python/pyyaml[${PYTHON_USEDEP}] |
111 |
dev-python/msgpack[${PYTHON_USEDEP}]" |
112 |
-DEPEND="${RDEPEND}" |
113 |
+DEPEND="${RDEPEND} |
114 |
+ dev-util/hip" |
115 |
+ |
116 |
+PATCHES=( "${FILESDIR}"/${PN}-4.0.0-cmake.patch |
117 |
+ "${FILESDIR}"/${PN}-4.0.0-setup.py-cmake.patch |
118 |
+ "${FILESDIR}"/${PN}-4.0.0-locate-commands.patch |
119 |
+ "${FILESDIR}"/${PN}-4.0.0-output-currentISA.patch ) |
120 |
|
121 |
S="${WORKDIR}/${PN}-rocm-${PVR}" |
122 |
+CMAKE_USE_DIR="${WORKDIR}/Source" |
123 |
+ |
124 |
+src_prepare() { |
125 |
+ distutils-r1_src_prepare |
126 |
+ |
127 |
+ mv ${PN}/Source "${WORKDIR}"/ || die |
128 |
+ sed -e "/ROCM_SMI_ROOT/s,lib,$(get_libdir)," \ |
129 |
+ -i "${WORKDIR}"/Source/cmake/FindROCmSMI.cmake || die |
130 |
+ sed -r -e "/TENSILE_USE_LLVM/s/ON/OFF/" \ |
131 |
+ -i "${WORKDIR}"/Source/CMakeLists.txt || die |
132 |
+ |
133 |
+ mv ${PN}/cmake "${T}"/ || die |
134 |
+ |
135 |
+ sed -e "/HipClangVersion/s/0,0,0/$(ver_rs 1-3 ,)/" \ |
136 |
+ -e "/SourcePath/s,os\.path\.join.*$,\"${EPREFIX}/usr/share/${PN}\"," \ |
137 |
+ -i ${PN}/Common.py || die |
138 |
+ |
139 |
+ sed -e "s|os\.path\.dirname.*$|\"${EPREFIX}/usr/share/Tensile\", end='')|" \ |
140 |
+ -i ${PN}/__init__.py || die |
141 |
+} |
142 |
|
143 |
src_install() { |
144 |
distutils-r1_src_install |
145 |
|
146 |
- dodir "/usr/$(get_libdir)/cmake" |
147 |
- mv "${ED}/usr/cmake" "${ED}/usr/$(get_libdir)/cmake/${PN}" || die |
148 |
+ insinto /usr/$(get_libdir)/cmake/${PN} |
149 |
+ doins "${T}"/cmake/*.cmake |
150 |
+ |
151 |
+ insinto /usr/share/${PN} |
152 |
+ doins -r "${WORKDIR}"/Source/* |
153 |
+ dosym . /usr/share/${PN}/Source |
154 |
} |
155 |
|
156 |
diff --git a/dev-util/Tensile/files/Tensile-4.0.0-cmake.patch b/dev-util/Tensile/files/Tensile-4.0.0-cmake.patch |
157 |
new file mode 100644 |
158 |
index 000000000..0c39f747c |
159 |
--- /dev/null |
160 |
+++ b/dev-util/Tensile/files/Tensile-4.0.0-cmake.patch |
161 |
@@ -0,0 +1,38 @@ |
162 |
+Index: Tensile-rocm-4.0.0/Tensile/cmake/TensileConfig.cmake |
163 |
+=================================================================== |
164 |
+--- Tensile-rocm-4.0.0.orig/Tensile/cmake/TensileConfig.cmake |
165 |
++++ Tensile-rocm-4.0.0/Tensile/cmake/TensileConfig.cmake |
166 |
+@@ -26,7 +26,7 @@ if(NOT DEFINED Tensile_ROOT) |
167 |
+ get_filename_component(Tensile_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) |
168 |
+ get_filename_component(Tensile_PREFIX "${Tensile_PREFIX}" PATH) |
169 |
+ |
170 |
+-execute_process(COMMAND "${Tensile_PREFIX}/bin/TensileGetPath" OUTPUT_VARIABLE Tensile_ROOT) |
171 |
++execute_process(COMMAND "TensileGetPath" OUTPUT_VARIABLE Tensile_ROOT) |
172 |
+ endif() |
173 |
+ list(APPEND CMAKE_MODULE_PATH "${Tensile_ROOT}/Source/cmake/") |
174 |
+ list(APPEND CMAKE_MODULE_PATH "${Tensile_ROOT}/Source/") |
175 |
+@@ -93,7 +93,7 @@ function(TensileCreateLibraryFiles |
176 |
+ set(Tensile_MERGE_FILES OFF) |
177 |
+ endif() |
178 |
+ |
179 |
+- set(Script "${Tensile_ROOT}/bin/TensileCreateLibrary") |
180 |
++ set(Script "TensileCreateLibrary") |
181 |
+ message(STATUS "Tensile script: ${Script}") |
182 |
+ |
183 |
+ set(Options "--new-client-only" "--no-legacy-components") |
184 |
+Index: Tensile-rocm-4.0.0/Tensile/Source/TensileCreateLibrary.cmake |
185 |
+=================================================================== |
186 |
+--- Tensile-rocm-4.0.0.orig/Tensile/Source/TensileCreateLibrary.cmake |
187 |
++++ Tensile-rocm-4.0.0/Tensile/Source/TensileCreateLibrary.cmake |
188 |
+@@ -52,10 +52,7 @@ function(TensileCreateLibraryCmake |
189 |
+ message(STATUS "Tensile_ARCHITECTURE from TensileCreateLibraryCmake : ${Tensile_ARCHITECTURE}") |
190 |
+ message(STATUS "Tensile_LIBRARY_FORMAT from TensileCreateLibraryCmake : ${Tensile_LIBRARY_FORMAT}") |
191 |
+ |
192 |
+- execute_process(COMMAND chmod 755 ${Tensile_ROOT}/bin/TensileCreateLibrary) |
193 |
+- execute_process(COMMAND chmod 755 ${Tensile_ROOT}/bin/Tensile) |
194 |
+- |
195 |
+- set(Tensile_CREATE_COMMAND "${Tensile_ROOT}/bin/TensileCreateLibrary") |
196 |
++ set(Tensile_CREATE_COMMAND "TensileCreateLibrary") |
197 |
+ |
198 |
+ set(Tensile_SOURCE_PATH "${PROJECT_BINARY_DIR}/Tensile") |
199 |
+ message(STATUS "Tensile_SOURCE_PATH=${Tensile_SOURCE_PATH}") |
200 |
|
201 |
diff --git a/dev-util/Tensile/files/Tensile-4.0.0-locate-commands.patch b/dev-util/Tensile/files/Tensile-4.0.0-locate-commands.patch |
202 |
new file mode 100644 |
203 |
index 000000000..78d467349 |
204 |
--- /dev/null |
205 |
+++ b/dev-util/Tensile/files/Tensile-4.0.0-locate-commands.patch |
206 |
@@ -0,0 +1,62 @@ |
207 |
+Index: Tensile-rocm-4.0.0/Tensile/Common.py |
208 |
+=================================================================== |
209 |
+--- Tensile-rocm-4.0.0.orig/Tensile/Common.py |
210 |
++++ Tensile-rocm-4.0.0/Tensile/Common.py |
211 |
+@@ -155,7 +155,7 @@ globalParameters["PrintTensorRef"] = 0 |
212 |
+ globalParameters["PrintIndexAssignments"] = 0 # Print the tensor index assignment info |
213 |
+ globalParameters["PrintTensorRef"] = 0 # Print reference tensor. 0x1=after init; 0x2=after copy-back; 0x3=both |
214 |
+ globalParameters["PrintWinnersOnly"] = False # Only print the solutions which become the fastest |
215 |
+-globalParameters["PrintCodeCommands"] = False # print the commands used to generate the code objects (asm,link,hip-clang, etc) |
216 |
++globalParameters["PrintCodeCommands"] = True # print the commands used to generate the code objects (asm,link,hip-clang, etc) |
217 |
+ |
218 |
+ # TODO - remove this when NewClient is mainstream |
219 |
+ globalParameters["OldClientSourceTmp"] = True # Use an intermediate sourceTmp dir to detect file changes and minimize rebuilds on old client |
220 |
+@@ -1521,14 +1521,14 @@ def assignGlobalParameters( config ): |
221 |
+ print2(" %24s: %8s (unspecified)" % (key, defaultValue)) |
222 |
+ |
223 |
+ # ROCm Agent Enumerator Path |
224 |
+- globalParameters["ROCmAgentEnumeratorPath"] = locateExe("/opt/rocm/bin", "rocm_agent_enumerator") |
225 |
++ globalParameters["ROCmAgentEnumeratorPath"] = locateExe("", "rocm_agent_enumerator") |
226 |
+ if "CxxCompiler" in config: |
227 |
+ globalParameters["CxxCompiler"] = config["CxxCompiler"] |
228 |
+ |
229 |
+ if "TENSILE_ROCM_ASSEMBLER_PATH" in os.environ: |
230 |
+ globalParameters["AssemblerPath"] = os.environ.get("TENSILE_ROCM_ASSEMBLER_PATH") |
231 |
+ elif globalParameters["AssemblerPath"] is None and globalParameters["CxxCompiler"] == "hipcc": |
232 |
+- globalParameters["AssemblerPath"] = locateExe("/opt/rocm/llvm/bin", "clang++") |
233 |
++ globalParameters["AssemblerPath"] = locateExe("", "clang++") |
234 |
+ elif globalParameters["AssemblerPath"] is None and globalParameters["CxxCompiler"] == "hcc": |
235 |
+ globalParameters["AssemblerPath"] = locateExe("/opt/rocm/bin", "hcc") |
236 |
+ |
237 |
+@@ -1536,8 +1536,8 @@ def assignGlobalParameters( config ): |
238 |
+ if globalParameters["CxxCompiler"] == "hcc": |
239 |
+ globalParameters["ExtractKernelPath"] = locateExe("/opt/rocm/bin", "extractkernel") |
240 |
+ else: |
241 |
+- globalParameters["ExtractKernelPath"] = locateExe("/opt/rocm/hip/bin", "extractkernel") |
242 |
+- globalParameters["ClangOffloadBundlerPath"] = locateExe("/opt/rocm/llvm/bin", "clang-offload-bundler") |
243 |
++ globalParameters["ExtractKernelPath"] = locateExe("", "extractkernel") |
244 |
++ globalParameters["ClangOffloadBundlerPath"] = locateExe("", "clang-offload-bundler") |
245 |
+ |
246 |
+ if "ROCmAgentEnumeratorPath" in config: |
247 |
+ globalParameters["ROCmAgentEnumeratorPath"] = config["ROCmAgentEnumeratorPath"] |
248 |
+@@ -1579,20 +1579,6 @@ def assignGlobalParameters( config ): |
249 |
+ # Due to platform.linux_distribution() being deprecated, just try to run dpkg regardless. |
250 |
+ # The alternative would be to install the `distro` package. |
251 |
+ # See https://docs.python.org/3.7/library/platform.html#platform.linux_distribution |
252 |
+- try: |
253 |
+- if globalParameters["CxxCompiler"] == "hipcc": |
254 |
+- output = subprocess.run(["dpkg", "-l", "hip-rocclr"], check=True, stdout=subprocess.PIPE).stdout.decode() |
255 |
+- elif globalParameters["CxxCompiler"] == "hcc": |
256 |
+- output = subprocess.run(["dpkg", "-l", "hcc"], check=True, stdout=subprocess.PIPE).stdout.decode() |
257 |
+- |
258 |
+- for line in output.split('\n'): |
259 |
+- if 'hipcc' in line: |
260 |
+- globalParameters['HipClangVersion'] = line.split()[2] |
261 |
+- elif 'hcc' in line: |
262 |
+- globalParameters['HccVersion'] = line.split()[2] |
263 |
+- |
264 |
+- except (subprocess.CalledProcessError, OSError) as e: |
265 |
+- printWarning("Error: {} looking for package {}: {}".format('dpkg', 'hip-rocclr', e)) |
266 |
+ |
267 |
+ for key in config: |
268 |
+ value = config[key] |
269 |
|
270 |
diff --git a/dev-util/Tensile/files/Tensile-4.0.0-output-currentISA.patch b/dev-util/Tensile/files/Tensile-4.0.0-output-currentISA.patch |
271 |
new file mode 100644 |
272 |
index 000000000..a00f9fdca |
273 |
--- /dev/null |
274 |
+++ b/dev-util/Tensile/files/Tensile-4.0.0-output-currentISA.patch |
275 |
@@ -0,0 +1,22 @@ |
276 |
+Index: Tensile-rocm-4.0.0/Tensile/TensileCreateLibrary.py |
277 |
+=================================================================== |
278 |
+--- Tensile-rocm-4.0.0.orig/Tensile/TensileCreateLibrary.py |
279 |
++++ Tensile-rocm-4.0.0/Tensile/TensileCreateLibrary.py |
280 |
+@@ -132,7 +132,7 @@ def buildSourceCodeObjectFile(CxxCompile |
281 |
+ return globalParameters["AsmCaps"][arch]["SupportedISA"] and \ |
282 |
+ globalParameters["AsmCaps"][arch]["SupportedSource"] |
283 |
+ |
284 |
+- archs = ['gfx'+''.join(map(str,arch)) for arch in globalParameters['SupportedISA'] \ |
285 |
++ archs = ['gfx'+''.join(map(str,arch)) for arch in [globalParameters['CurrentISA']] \ |
286 |
+ if isSupported(arch)] |
287 |
+ |
288 |
+ archFlags = ['--amdgpu-target=' + arch for arch in archs] |
289 |
+@@ -1004,7 +1004,7 @@ def buildObjectFileNames(solutionWriter, |
290 |
+ kernelHelperOjbNmaes = [ko.getKernelName() for ko in kernelHelperOjbs] |
291 |
+ |
292 |
+ # Source based kernels are built for all supported architectures |
293 |
+- sourceArchs = ['gfx'+''.join(map(str,arch)) for arch in globalParameters['SupportedISA'] \ |
294 |
++ sourceArchs = ['gfx'+''.join(map(str,arch)) for arch in [globalParameters['CurrentISA']] \ |
295 |
+ if isSupported(arch)] |
296 |
+ |
297 |
+ # Asm based kernels target the configured ISA |
298 |
|
299 |
diff --git a/dev-util/Tensile/files/Tensile-4.0.0-setup.py-cmake.patch b/dev-util/Tensile/files/Tensile-4.0.0-setup.py-cmake.patch |
300 |
new file mode 100644 |
301 |
index 000000000..e020842b2 |
302 |
--- /dev/null |
303 |
+++ b/dev-util/Tensile/files/Tensile-4.0.0-setup.py-cmake.patch |
304 |
@@ -0,0 +1,13 @@ |
305 |
+Index: Tensile-rocm-4.0.0/setup.py |
306 |
+=================================================================== |
307 |
+--- Tensile-rocm-4.0.0.orig/setup.py |
308 |
++++ Tensile-rocm-4.0.0/setup.py |
309 |
+@@ -30,8 +30,6 @@ setup( |
310 |
+ install_requires=readRequirementsFromTxt(), |
311 |
+ python_requires='>=3.5', |
312 |
+ packages=["Tensile"], |
313 |
+- package_data={ "Tensile": ["Tensile/cmake/*"] }, |
314 |
+- data_files=[ ("cmake", ["Tensile/cmake/TensileConfig.cmake", "Tensile/cmake/TensileConfigVersion.cmake"]) ], |
315 |
+ include_package_data=True, |
316 |
+ entry_points={"console_scripts": [ |
317 |
+ # user runs a benchmark |