-
Notifications
You must be signed in to change notification settings - Fork 406
Expand file tree
/
Copy paththerock_matrix.py
More file actions
319 lines (300 loc) · 12.7 KB
/
Copy paththerock_matrix.py
File metadata and controls
319 lines (300 loc) · 12.7 KB
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
"""
This dictionary is used to map specific file directory changes to the corresponding build flag and tests
"""
import copy
import os
subtree_to_project_map = {
"dnn-providers/hipblaslt-provider": "hipblaslt-provider",
"dnn-providers/hip-kernel-provider": "hip-kernel-provider",
"dnn-providers/miopen-provider": "miopen-provider",
"dnn-providers/integration-tests": "dnn-provider-integration-tests",
"projects/composablekernel": "miopen",
"projects/hipblas": "blas",
"projects/hipblas-common": "blas",
"projects/hipblaslt": "blas",
# Registered as its own repos-config.json subtree (nested inside hipblaslt)
# so change detection can distinguish it from hipblaslt-proper; it maps to
# the same "blas" bucket, which already tests tensilelite (see below), so
# legacy matrix selection is unaffected either way.
"projects/hipblaslt/tensilelite": "blas",
"projects/hipcub": "prim",
"projects/hipdnn": "hipdnn",
"projects/hipfft": "fft",
"projects/hiprand": "rand",
"projects/hiptensor": "hiptensor",
"projects/hipsolver": "solver",
"projects/hipsparse": "sparse",
"projects/hipsparselt": "sparselt",
"projects/miopen": "miopen",
"projects/rocblas": "blas",
"projects/rocfft": "fft",
"projects/rocprim": "prim",
"projects/rocrand": "rand",
"projects/rocsolver": "solver",
"projects/rocsparse": "sparse",
"projects/rocthrust": "prim",
"projects/rocalution": "rocalution",
"projects/rocwmma": "rocwmma",
"projects/hipthreads": "hipthreads",
"projects/rpp": "rpp",
"shared/mxdatagenerator": "blas",
"shared/origami": "blas",
"shared/rocroller": "rocroller",
"shared/stinkytofu": "blas",
"shared/tensile": "blas",
}
project_map = {
"prim": {
"cmake_options": ["-DTHEROCK_ENABLE_PRIM=ON"],
"projects_to_test": ["rocprim", "rocthrust", "hipcub"],
},
"rand": {
"cmake_options": ["-DTHEROCK_ENABLE_RAND=ON"],
"projects_to_test": ["rocrand", "hiprand"],
},
"blas": {
"cmake_options": ["-DTHEROCK_ENABLE_BLAS=ON"],
"projects_to_test": ["hipblaslt", "rocblas", "hipblas", "tensilelite"],
},
"miopen": {
"cmake_options": [
"-DTHEROCK_ENABLE_MIOPEN=ON",
"-DTHEROCK_ENABLE_MIOPENPROVIDER=ON",
"-DTHEROCK_ENABLE_COMPOSABLE_KERNEL=ON",
"-DTHEROCK_COMPOSABLE_KERNEL_FOR_MIOPEN_ONLY=ON",
],
"projects_to_test": ["miopen", "miopenprovider"],
},
"fft": {
"cmake_options": ["-DTHEROCK_ENABLE_FFT=ON", "-DTHEROCK_ENABLE_RAND=ON"],
"projects_to_test": ["hipfft", "rocfft"],
},
"hiptensor": {
"cmake_options": [
"-DTHEROCK_ENABLE_HIPTENSOR=ON",
"-DTHEROCK_ENABLE_COMPOSABLE_KERNEL=ON",
"-DTHEROCK_ENABLE_RAND=ON",
],
"additional_flags": {
"linux": ["-DTHEROCK_ENABLE_ROCPROFV3=ON"],
},
"projects_to_test": ["hiptensor"],
},
"hip-kernel-provider": {
"cmake_options": [
"-DTHEROCK_ENABLE_HIPKERNELPROVIDER=ON",
"-DHIP_KERNEL_PROVIDER_ENABLE=ON",
"-DTHEROCK_FLAG_HIPKERNELPROVIDER_ENABLE_ROCKE=ON",
],
"projects_to_test": ["hipkernelprovider"],
},
"hipthreads": {
"cmake_options": ["-DTHEROCK_ENABLE_HIPTHREADS=ON"],
"projects_to_test": ["hipthreads"],
},
# RPP is the computer vision umbrella. Its artifact only depends on core
# (core-runtime, core-hip, base, sysdeps), so no math umbrella is needed.
# Windows support is experimental and off by default in TheRock, and
# TheRock's rpp test job is Linux-only, so this row is restricted to Linux.
"rpp": {
"cmake_options": [
"-DTHEROCK_ENABLE_RPP=ON",
"-DTHEROCK_DIST_AMDGPU_FAMILIES=gfx94X-dcgpu;gfx950-dcgpu;gfx125X-dcgpu",
],
"projects_to_test": ["rpp"],
"platforms": ["linux"],
},
}
# For certain math components, they are optional during building and testing.
# As they are optional, we do not want to include them as default as this takes more time in the CI.
# However, if we run a separate build for optional components, those files will be overriden as these components share the same umbrella as other projects
# Example: SPARSE is included in BLAS, but a separate build would cause overwriting of the blas_lib.tar.xz and blas_test.tar.xz and be missing libraries and tests
additional_options = {
"sparse": {
"cmake_options": ["-DTHEROCK_ENABLE_SPARSE=ON"],
"projects_to_test": ["rocsparse", "hipsparse"],
"project_to_add": "blas",
},
"sparselt": {
"cmake_options": ["-DTHEROCK_ENABLE_SPARSE=ON"],
"projects_to_test": ["hipsparselt"],
"project_to_add": "blas",
},
"solver": {
"cmake_options": ["-DTHEROCK_ENABLE_SOLVER=ON"],
"projects_to_test": ["rocsolver", "hipsolver"],
"project_to_add": "blas",
},
"hipdnn": {
"cmake_options": [
"-DTHEROCK_ENABLE_HIPBLASLTPROVIDER=ON",
"-DTHEROCK_ENABLE_HIPKERNELPROVIDER=ON",
"-DHIP_KERNEL_PROVIDER_ENABLE=ON",
"-DTHEROCK_ENABLE_MIOPENPROVIDER=ON",
"-DTHEROCK_ENABLE_HIPDNN_SAMPLES=ON",
"-DTHEROCK_ENABLE_COMPOSABLE_KERNEL=ON",
"-DTHEROCK_ENABLE_HIPDNN_INTEGRATION_TESTS=ON",
"-DTHEROCK_COMPOSABLE_KERNEL_FOR_MIOPEN_ONLY=ON",
],
"projects_to_test": [
"hipdnn",
"hipdnn_install",
"hipdnn-samples",
"miopenprovider",
"hipblasltprovider",
"hipkernelprovider",
"hipdnn-integration-tests",
],
"project_to_add": "miopen",
},
"miopen-provider": {
"cmake_options": [
"-DTHEROCK_ENABLE_MIOPENPROVIDER=ON",
"-DTHEROCK_ENABLE_COMPOSABLE_KERNEL=ON",
"-DTHEROCK_ENABLE_HIPDNN_INTEGRATION_TESTS=ON",
],
"projects_to_test": ["miopenprovider"],
"project_to_add": "miopen",
},
"dnn-provider-integration-tests": {
"cmake_options": [
"-DTHEROCK_ENABLE_HIPDNN_INTEGRATION_TESTS=ON",
"-DTHEROCK_ENABLE_MIOPENPROVIDER=ON",
"-DTHEROCK_ENABLE_COMPOSABLE_KERNEL=ON",
],
"projects_to_test": ["hipdnn-integration-tests", "miopenprovider"],
"project_to_add": "miopen",
},
"hipblaslt-provider": {
"cmake_options": [
"-DTHEROCK_ENABLE_HIPBLASLTPROVIDER=ON",
],
"projects_to_test": ["hipblasltprovider"],
"project_to_add": "blas",
},
"rocwmma": {
"cmake_options": ["-DTHEROCK_ENABLE_ROCWMMA=ON"],
"projects_to_test": ["rocwmma"],
"project_to_add": "blas",
},
"rocalution": {
"cmake_options": [
"-DTHEROCK_ENABLE_ROCALUTION=ON",
"-DTHEROCK_ENABLE_SPARSE=ON",
"-DTHEROCK_ENABLE_RAND=ON",
],
"projects_to_test": ["rocalution"],
"project_to_add": "blas",
},
# rocRoller is built under the BLAS umbrella but only tested when its own
# subtree changes. Merges into the "blas" job when a PR touches both, which
# avoids a redundant BLAS build and S3 artifact overlap.
"rocroller": {
"cmake_options": ["-DTHEROCK_ENABLE_BLAS=ON"],
"projects_to_test": ["rocroller"],
"project_to_add": "blas",
},
}
# If a project has dependencies that are also being built, we combine build options and test options
# This way, there will be no S3 upload overlap and we save redundant builds
dependency_graph = {
"miopen": ["blas", "rand"],
}
# When these subtrees change, also activate the given optional matrix project so
# its additional_options merge into the parent job (e.g. hipSPARSELt depends on hipBLASLt).
SUBTREE_EXTRA_MATRIX_PROJECTS = {
"projects/hipblaslt": "sparselt",
# TensileLite is also a real hipSPARSELt dependency (a separate kernel
# generator copy lives there too), so a TensileLite-only change must
# activate "sparselt" the same way a hipblaslt-proper change does.
"projects/hipblaslt/tensilelite": "sparselt",
}
def collect_projects_to_run(subtrees):
subtrees = list(subtrees)
platform = os.getenv("PLATFORM")
projects = set()
# Work on per-call deep copies so module-level state stays immutable across calls.
local_project_map = copy.deepcopy(project_map)
local_additional_options = copy.deepcopy(additional_options)
# collect the associated subtree to project
for subtree in subtrees:
if subtree in subtree_to_project_map:
projects.add(subtree_to_project_map.get(subtree))
extra_matrix = SUBTREE_EXTRA_MATRIX_PROJECTS.get(subtree)
if extra_matrix:
projects.add(extra_matrix)
for project in list(projects):
# Check if an optional math component was included.
if project in local_additional_options:
project_options_to_add = local_additional_options[project]
project_to_add = project_options_to_add["project_to_add"]
# If `project_to_add` is in included, add options to the existing `local_project_map` entry
if project_to_add in projects:
local_project_map[project_to_add]["cmake_options"].extend(
project_options_to_add["cmake_options"]
)
local_project_map[project_to_add]["projects_to_test"].extend(
project_options_to_add["projects_to_test"]
)
# If `project_to_add` is not included, only run build and tests for the optional project
else:
projects.add(project_to_add)
local_project_map[project_to_add]["cmake_options"] = (
project_options_to_add["cmake_options"]
)
local_project_map[project_to_add]["projects_to_test"] = (
project_options_to_add["projects_to_test"]
)
# Check for potential dependencies
to_remove_from_project_map = []
for project in list(projects):
# Check if project has a dependency combine
if project in dependency_graph:
for dependency in dependency_graph[project]:
# If the dependency is also included, let's combine to avoid overlap
if dependency in projects:
local_project_map[project]["cmake_options"].extend(
local_project_map[dependency]["cmake_options"]
)
local_project_map[project]["projects_to_test"].extend(
local_project_map[dependency]["projects_to_test"]
)
to_remove_from_project_map.append(dependency)
# if dependency is included in projects and parent is found, we delete the dependency as the parent will build and test
for to_remove_item in to_remove_from_project_map:
projects.remove(to_remove_item)
del local_project_map[to_remove_item]
# retrieve the subtrees to checkout, cmake options to build, and projects to test
project_to_run = []
for project in projects:
if project in local_project_map:
project_map_data = local_project_map.get(project)
# A project restricted to certain platforms is dropped from the
# other platform's matrix entirely, rather than built there and
# skipped at test time. Absent key means every platform.
supported_platforms = project_map_data.pop("platforms", None)
if supported_platforms is not None and platform not in supported_platforms:
continue
# Check if platform-based additional flags are needed
if (
"additional_flags" in project_map_data
and platform in project_map_data["additional_flags"]
):
project_map_data["cmake_options"].extend(
project_map_data["additional_flags"][platform]
)
# To save time, only build what is needed
project_map_data["cmake_options"].extend(["-DTHEROCK_ENABLE_ALL=OFF"])
# To ensure uniqueness of flags and tests
project_map_data["cmake_options"] = list(
set(project_map_data["cmake_options"])
)
project_map_data["projects_to_test"] = list(
set(project_map_data["projects_to_test"])
)
cmake_flag_options = " ".join(project_map_data["cmake_options"])
projects_to_test_options = ",".join(project_map_data["projects_to_test"])
project_map_data["cmake_options"] = cmake_flag_options
project_map_data["projects_to_test"] = projects_to_test_options
project_to_run.append(project_map_data)
return project_to_run