forked from Rmalavally/rocm-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
396 lines (369 loc) · 12.6 KB
/
.gitlab-ci.yml
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
# MIT License
#
# Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
include:
- project: 'amd/ci-templates'
ref: main
file:
- /defaults.yaml
- /gpus-rocm.yaml
- /gpus-nvcc.yaml
- /rules.yaml
variables:
CUDA_FLAGS: "-Xcompiler -Wall,-Wextra,-Werror --Werror all-warnings"
CXX_FLAGS: "-Wall -Wextra -Werror"
HIP_FLAGS: "-Wall -Wextra -Werror"
stages:
- lint
- build
- test
clang-format:
image: $DOCKER_TAG_PREFIX:rocm-ubuntu
stage: lint
needs: []
tags:
- rocm-build
variables:
CLANG_FORMAT: "/opt/rocm/llvm/bin/clang-format"
GIT_CLANG_FORMAT: "/opt/rocm/llvm/bin/git-clang-format"
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
script:
- cd $CI_PROJECT_DIR
- git config --global --add safe.directory $CI_PROJECT_DIR
- Scripts/CodeFormat/check_format.sh $CI_MERGE_REQUEST_DIFF_BASE_SHA --binary "$CLANG_FORMAT"
.build:dockerfiles:
timeout: 20m
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
stage: build
needs: []
tags:
- rocm-build
script:
- mkdir -p /kaniko/.docker
- echo "${DOCKER_AUTH_CONFIG}" > /kaniko/.docker/config.json
- if [ "$CI_COMMIT_BRANCH" != "$CI_DEFAULT_BRANCH" ]; then NO_PUSH="--no-push"; fi;
- >-
/kaniko/executor
--context "${CI_PROJECT_DIR}/Dockerfiles"
--dockerfile "${CI_PROJECT_DIR}/Dockerfiles/hip-libraries-${TAG}.Dockerfile"
--destination "docker.io/${DOCKER_TAG_PREFIX}:${TAG}"
${NO_PUSH}
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- Dockerfiles/hip-libraries-${TAG}.Dockerfile
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
- Dockerfiles/hip-libraries-${TAG}.Dockerfile
build:rocm-ubuntu-dockerfile:
extends:
- .build:dockerfiles
variables:
TAG: rocm-ubuntu
build:cuda-ubuntu-dockerfile:
extends:
- .build:dockerfiles
variables:
TAG: cuda-ubuntu
build:make-rocm:
image: $DOCKER_TAG_PREFIX:rocm-ubuntu
stage: build
extends:
- .rules:build
tags:
- rocm-build
needs: []
script:
- cd $CI_PROJECT_DIR && make CXXFLAGS="$HIP_FLAGS" -j $(nproc)
build:make-cuda:
image: $DOCKER_TAG_PREFIX:cuda-ubuntu
stage: build
extends:
- .rules:build
tags:
- nvcc-build
needs: []
script:
- cd $CI_PROJECT_DIR && make CXXFLAGS="$CUDA_FLAGS" GPU_RUNTIME=CUDA -j $(nproc)
.build:cmake:
stage: build
extends:
- .rules:build
needs: []
artifacts:
paths:
- $CI_PROJECT_DIR/build
build:cmake-rocm:
image: $DOCKER_TAG_PREFIX:rocm-ubuntu
extends:
- .build:cmake
- .gpus:rocm-gpus
tags:
- rocm-build
script:
- cmake
-S $CI_PROJECT_DIR
-B $CI_PROJECT_DIR/build
-D CMAKE_HIP_ARCHITECTURES="$GPU_TARGETS"
-D CMAKE_CXX_FLAGS="$CXX_FLAGS"
-D CMAKE_HIP_FLAGS="$HIP_FLAGS"
2>&1 | tee cmake_log.txt
# check if all dependencies were found
- |-
if grep -qi "could not find" cmake_log.txt; then
echo "Some CMake libraries could not be found"
exit 1
fi
- cmake --build $CI_PROJECT_DIR/build
- cmake --install $CI_PROJECT_DIR/build --prefix $CI_PROJECT_DIR/install
build:cmake-cuda:
image: $DOCKER_TAG_PREFIX:cuda-ubuntu
extends:
- .build:cmake
tags:
- nvcc-build
script:
- cmake
-S $CI_PROJECT_DIR
-B $CI_PROJECT_DIR/build
-D GPU_RUNTIME=CUDA
-D CMAKE_CXX_FLAGS="$CXX_FLAGS"
-D CMAKE_CUDA_FLAGS="$CUDA_FLAGS"
-D CMAKE_MODULE_PATH=/opt/rocm/hip/cmake
2>&1 | tee cmake_log.txt
# check if all dependencies were found
- |-
if grep -qi "could not find" cmake_log.txt; then
echo "Some CMake libraries could not be found"
exit 1
fi
- cmake --build $CI_PROJECT_DIR/build
- cmake --install $CI_PROJECT_DIR/build --prefix $CI_PROJECT_DIR/install
.test:
stage: test
extends:
- .rules:test
script:
- cd $CI_PROJECT_DIR/build && ctest --output-on-failure
test:rocm:
image: $DOCKER_TAG_PREFIX:rocm-ubuntu
extends:
- .test
- .gpus:rocm
needs:
- build:cmake-rocm
test:cuda:
image: $DOCKER_TAG_PREFIX:cuda-ubuntu
extends:
- .test
- .gpus:nvcc
needs:
- build:cmake-cuda
.test:windows:
extends:
- .rules:test
stage: test
needs: []
parallel:
matrix:
- BUILD_TYPE: [Debug, Release]
.test:rocm-windows:
extends:
- .test:windows
tags:
- windows
- shell
- rx6900
.test:windows-vs:
script:
# MSBuild cannot properly resolve the `<Content Include=` dependencies, and will sometimes try to copy
# two or more files at once. This results in a warning before it retries, which is counted towards
# /warnAsError by default. For this reason, we disable the relevant warning (MSB3026).
- >
& $MSBUILD
/maxCpuCount
"/p:Configuration=$BUILD_TYPE"
/warnAsError
/warnAsMessage:MSB3026
$MSBUILD_EXTRA_OPTIONS
"$CI_PROJECT_DIR/$SOLUTION"
test:rocm-windows-vs2019:
extends:
- .test:rocm-windows
- .test:windows-vs
variables:
MSBUILD: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe"
SOLUTION: "ROCm-Examples-VS2019.sln"
script:
- !reference [".test:windows-vs", script]
- |-
$SkippedExamples = @(
"hip_vulkan_interop_vs2019.exe" # Graphical
"hip_texture_management_vs2019.exe" # Hangs sometimes
"hip_hello_world_vs2019.exe" # Crashes (known driver issue)
)
Get-ChildItem -Path "$CI_PROJECT_DIR/$BUILD_TYPE" -Filter "*_vs2019.exe" |
ForEach-Object {
if ($SkippedExamples -NotContains $_.Name) {
echo "--" $_.Name
& "$_"
if (!$?) {
throw "{0} returned: {1}" -f $_.Name, $LASTEXITCODE
}
} else {
echo "-- SKIPPING " $_.Name
}
}
test:rocm-windows-vs2017:
extends:
- .test:rocm-windows
- .test:windows-vs
variables:
MSBUILD: "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin/MSBuild.exe"
SOLUTION: "ROCm-Examples-VS2017.sln"
# See https://developercommunity.visualstudio.com/t/windowstargetplatformversion-makes-it-impossible-t/140294
MSBUILD_EXTRA_OPTIONS: "/p:WindowsTargetPlatformVersion=10.0.20348.0"
test:rocm-windows-vs2022:
extends:
- .test:rocm-windows
- .test:windows-vs
variables:
MSBUILD: "C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/MSBuild.exe"
SOLUTION: "ROCm-Examples-VS2022.sln"
test:rocm-windows-cmake:
extends:
- .test:rocm-windows
script:
- Import-Module 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll'
- Enter-VsDevShell -InstallPath 'C:\Program Files\Microsoft Visual Studio\2022\Community' -SkipAutomaticLocation -DevCmdArguments '/arch=x64 /host_arch=x64 /no_logo'
- cmake
-S "$CI_PROJECT_DIR"
-B "$CI_PROJECT_DIR/build"
-G Ninja
-D CMAKE_CXX_COMPILER:PATH="${env:HIP_PATH}\bin\clang++.exe"
-D CMAKE_HIP_COMPILER:PATH="${env:HIP_PATH}\bin\clang++.exe"
-D CMAKE_HIP_LINK_EXECUTABLE:PATH="${env:HIP_PATH}\bin\lld-link.exe"
-D CMAKE_HIP_FLAGS="-fuse-ld=lld"
-D CMAKE_CXX_FLAGS="$CXX_FLAGS"
-D CMAKE_CXX_COMPILER:PATH="${env:HIP_PATH}\bin\clang++.exe"
-D CMAKE_PREFIX_PATH:PATH="${env:HIP_PATH}"
-D CMAKE_HIP_FLAGS="$HIP_FLAGS"
-D CMAKE_BUILD_TYPE="$BUILD_TYPE"
-D CMAKE_HIP_ARCHITECTURES=gfx1030
-D CMAKE_TOOLCHAIN_FILE:PATH="C:\Tools\Microsoft\vcpkg\scripts\buildsystems\vcpkg.cmake"
2>&1 | Tee-Object -filepath cmake_log.txt
- |-
if (Select-String -Path cmake_log.txt -Pattern "could not find") {
throw "Some cmake libraries are missing"
}
- cmake --build "$CI_PROJECT_DIR/build"
# CMake does not copy the dependencies to the test folder, and there is no sufficiently concise way of doing it.
# So for now, just add the library path here.
- $env:PATH = "${env:HIP_PATH}\bin;" + $env:PATH
- cd "$CI_PROJECT_DIR/build" && ctest --output-on-failure --timeout 10
- cmake --install "$CI_PROJECT_DIR/build" --prefix "$CI_PROJECT_DIR/install"
.test:nvcc-windows:
extends:
- .test:windows
tags:
- nvcc-windows
before_script:
# To test for NVIDIA, we need to set the platform toolset to HIP_nvcc. This cannot be done with /p:PlatformToolset
# though, as some examples use the regular msvc toolchain.
- |
Foreach ($f in (Get-ChildItem -Recurse -Filter "*.vcxproj" "$CI_PROJECT_DIR").FullName) {
(Get-Content $f) |
% { $_ -replace "<PlatformToolset>HIP_clang</PlatformToolset>","<PlatformToolset>HIP_nvcc</PlatformToolset>" } |
Set-Content $f
}
test:nvcc-windows-vs2019:
extends:
- .test:nvcc-windows
- .test:windows-vs
variables:
MSBUILD: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe"
SOLUTION: "ROCm-Examples-Portable-VS2019.sln"
script:
- !reference [".test:windows-vs", script]
- |-
$SkippedExamples = @(
"hip_vulkan_interop_vs2019.exe" # Graphical
"hip_opengl_interop_vs2019.exe" # Graphical
)
Get-ChildItem -Path "$CI_PROJECT_DIR/$BUILD_TYPE" -Filter "*_vs2019.exe" |
ForEach-Object {
if ($SkippedExamples -NotContains $_.Name) {
echo "--" $_.Name
& "$CI_PROJECT_DIR/$BUILD_TYPE/$_"
if (!$?) {
throw "{0} returned: {1}" -f $_.Name, $LASTEXITCODE
}
} else {
echo "-- SKIPPING " $_.Name
}
}
test:nvcc-windows-vs2017:
extends:
- .test:nvcc-windows
- .test:windows-vs
variables:
MSBUILD: "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin/MSBuild.exe"
SOLUTION: "ROCm-Examples-Portable-VS2017.sln"
# See https://developercommunity.visualstudio.com/t/windowstargetplatformversion-makes-it-impossible-t/140294
MSBUILD_EXTRA_OPTIONS: "/p:WindowsTargetPlatformVersion=10.0.20348.0"
test:nvcc-windows-vs2022:
extends:
- .test:nvcc-windows
- .test:windows-vs
variables:
MSBUILD: "C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/MSBuild.exe"
SOLUTION: "ROCm-Examples-Portable-VS2022.sln"
test:nvcc-windows-cmake:
extends:
- .test:nvcc-windows
script:
# Import the VisualStudio 2022 development environment
- |-
$vs = &"C:/Program Files (x86)/Microsoft Visual Studio/Installer/vswhere.exe" -version 17.0 -property InstallationPath
Import-Module (Join-Path $vs "Common7/Tools/Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $vs -SkipAutomaticLocation -DevCmdArguments "/arch=x64 /host_arch=x64 /no_logo"
# Note: The current version of the HIP SDK does not ship with CMake config files for Nvidia, so we can only test
# the HIP-Basic and Applications examples. It is expected that some dependencies will not be found for this.
- cmake
-S "$CI_PROJECT_DIR"
-B "$CI_PROJECT_DIR/build"
-G Ninja
-D CMAKE_CXX_COMPILER="cl.exe"
-D CMAKE_BUILD_TYPE="$BUILD_TYPE"
-D CMAKE_TOOLCHAIN_FILE="C:/Tools/Microsoft/vcpkg/scripts/buildsystems/vcpkg.cmake"
-D GPU_RUNTIME=CUDA
2>&1 | Tee-Object -filepath cmake_log.txt
- |-
if (Select-String -Path cmake_log.txt -Pattern "could not find") {
throw "Some cmake libraries are missing"
}
- cmake --build "$CI_PROJECT_DIR/build"
- cd "$CI_PROJECT_DIR/build"
- ctest --output-on-failure --timeout 10
- cmake --install "$CI_PROJECT_DIR/build" --prefix "$CI_PROJECT_DIR/install"