-
Notifications
You must be signed in to change notification settings - Fork 41
289 lines (287 loc) · 12.9 KB
/
presubmit.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
name: Presubmit
on:
push:
branches:
- main
pull_request:
jobs:
format:
name: Code formatting check
runs-on: ubuntu-22.04
steps:
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install -y clang-format clang-format-15
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check format
run: |
./tests/check-format.sh
env:
CLANG_FORMAT_BINARY: clang-format-15
build:
name: Build ${{ matrix.os }} ${{ matrix.android }} ${{ matrix.android-abi }} compiler ${{ matrix.compiler-available }} online ${{ matrix.online-compiler }}
needs: format
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-latest, windows-2019]
online-compiler: [true, false]
compiler-available: [true]
android: ['']
include:
- os: ubuntu-22.04
online-compiler: false
compiler-available: false
- os: ubuntu-22.04
online-compiler: true
compiler-available: true
android-abi: arm64-v8a
android: Android
- os: windows-2019
online-compiler: true
unit: true
- os: ubuntu-22.04
online-compiler: false
unit: true
perfetto: true
- os: macos-latest
online-compiler: true
unit: true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Free space on runner
if: ${{ matrix.android-abi != '' }}
run: |
set +x
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
sudo apt-get update
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y '^temurin-.*'
sudo apt-get remove -y azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox
sudo apt-get autoremove -y
sudo apt-get clean
sudo rm -rf /usr/share/dotnet/
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/local/share/chromium
sudo rm -rf /usr/local/lib/node_modules
df -h
- name: Setup Ninja
uses: ./.github/actions/setup-ninja
- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
variant: sccache
max-size: 2G
key: ${{ matrix.os }}-${{ matrix.android-abi }}-${{ matrix.online-compiler }}
- name: Download and extract Android NDK
if: ${{ matrix.android-abi != '' }}
run: |
mkdir ndk
cd ndk
wget https://dl.google.com/android/repository/android-ndk-r25c-linux.zip
unzip android-ndk-r25c-linux.zip
rm android-ndk-r25c-linux.zip
ls -l
- name: Select build directory
shell: bash
run: |
df -h
if [ "$RUNNER_OS" == "Windows" ]; then
echo "builddir=C:/build" >> $GITHUB_ENV
else
echo "builddir=${{ github.workspace }}/build" >> $GITHUB_ENV
fi
- name: Fetch LLVM
run: python ./external/clspv/utils/fetch_sources.py --shallow --deps llvm
- name: Install Vulkan SDK and Runtime
if: ${{ matrix.android-abi == '' }}
uses: ./.github/actions/install-vulkan-sdk
with:
version: 1.3.250.1
rt-dir: ${{ github.workspace }}/vulkanrt
- name: Build libclc
if: ${{ matrix.android-abi != '' }}
env:
LLVM_NATIVE_DIR: ${{ github.workspace }}/build_llvm_native/
LLVM_ARCHIVE_PREFIX: LLVM-19.1.0-rc2-Linux-X64
LIBCLC_DIR: ${{ github.workspace }}/build_libclc
run: |
set -x
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0-rc2/${LLVM_ARCHIVE_PREFIX}.tar.xz
mkdir -p ${LLVM_NATIVE_DIR}
tar -xf ${LLVM_ARCHIVE_PREFIX}.tar.xz -C ${LLVM_NATIVE_DIR}
cmake -S '${{ github.workspace }}/external/clspv/third_party/llvm/libclc' -B ${LIBCLC_DIR} -G Ninja \
-DLLVM_CMAKE_DIR=${LLVM_NATIVE_DIR}/${LLVM_ARCHIVE_PREFIX}/lib/cmake \
-DCMAKE_CXX_COMPILER=${LLVM_NATIVE_DIR}/${LLVM_ARCHIVE_PREFIX}/bin/clang++ \
-DCMAKE_CXX_FLAGS="-fuse-ld=lld" \
-DLIBCLC_TARGETS_TO_BUILD="clspv--;clspv64--"
cmake --build ${LIBCLC_DIR}
ls -l ${LIBCLC_DIR}
rm -rf ${LLVM_NATIVE_DIR} ${LLVM_ARCHIVE_PREFIX}.tar.xz
- name: Prepare Android CMake arguments
if: ${{ matrix.android-abi != '' }}
run: |
echo "android-cmake-args=-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/ndk/android-ndk-r25c/build/cmake/android.toolchain.cmake -DANDROID_ABI=${{ matrix.android-abi }} -DVulkan_LIBRARY=${{ github.workspace }}/ndk/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/33/libvulkan.so -DCLSPV_EXTERNAL_LIBCLC_DIR=${{ github.workspace }}/build_libclc" >> $GITHUB_ENV
- name: Build Perfetto
if: ${{ matrix.perfetto }}
shell: bash
env:
PERFETTO_DIR: ${{ github.workspace }}/external/perfetto
run: |
echo "perfettodir=${PERFETTO_DIR}" >> $GITHUB_ENV
git clone --depth 1 --branch v46.0 https://android.googlesource.com/platform/external/perfetto ${PERFETTO_DIR}
${PERFETTO_DIR}/tools/install-build-deps
${PERFETTO_DIR}/tools/setup_all_configs.py
${PERFETTO_DIR}/tools/ninja -C ${PERFETTO_DIR}/out/linux_clang_release trace_processor_shell
- name: Configure
shell: bash
run: |
set -x
ls -l '${{ github.workspace }}'
mkdir '${{ env.builddir }}'
cd '${{ env.builddir }}'
mkdir install
cmake '${{ github.workspace }}' -G Ninja \
-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DCMAKE_BUILD_TYPE=Release \
-DCLVK_ENABLE_ASSERTIONS=ON \
-DCLVK_VULKAN_IMPLEMENTATION=swiftshader \
-DCMAKE_INSTALL_PREFIX='${{ env.builddir}}'/install \
-DCLVK_COMPILER_AVAILABLE=${{ matrix.compiler-available }} \
-DCLVK_UNIT_TESTING=${{ matrix.unit }} \
-DCLVK_PERFETTO_ENABLE=${{ matrix.perfetto }} \
-DCLVK_PERFETTO_SDK_DIR=${{ env.perfettodir }}/sdk \
${{ env.android-cmake-args }} \
-DCLVK_CLSPV_ONLINE_COMPILER=${{ matrix.online-compiler }}
- name: Build
run: cmake --build '${{ env.builddir }}' --config Release -j2
- name: Build clspv
run: cmake --build '${{ env.builddir }}' --config Release --target clspv -j2
- name: Build clang
run: cmake --build '${{ env.builddir }}' --config Release --target clang -j2
if: ${{ matrix.compiler-available && matrix.android-abi == '' }}
- name: Install
run: cmake --install '${{ env.builddir }}'
- uses: actions/upload-artifact@v4
with:
name: clvk-${{ matrix.os }}-${{ matrix.android }}-${{ matrix.android-abi }}-compiler-${{ matrix.compiler-available }}-online-${{ matrix.online-compiler }}
path: ${{ env.builddir }}/install
- name: Show stats
shell: bash
run: df -h
- name: Download Swiftshader artifacts
uses: dawidd6/action-download-artifact@v6
with:
workflow: build-swiftshader.yml
workflow_conclusion: success
name: swiftshader-${{ runner.os }}
path: swiftshader
- name: Register Swiftshader ICD
if: ${{ matrix.os == 'windows-2019' }}
run: |
reg query 'HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\Drivers'
reg add 'HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\Drivers' /v '${{ github.workspace }}\swiftshader\vk_swiftshader_icd.json' /t REG_DWORD /d 0
reg query 'HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\Drivers'
- name: Prepare test execution
shell: bash
run: |
ls -l '${{ github.workspace }}'/swiftshader
ls -l '${{ env.builddir }}'
echo "VK_ICD_FILENAMES=${{ github.workspace }}/swiftshader/vk_swiftshader_icd.json" >> $GITHUB_ENV
echo "CLVK_LOG=3" >> $GITHUB_ENV
echo "CLVK_LOG_DEST=stderr" >> $GITHUB_ENV
echo "VK_LOADER_DEBUG=all" >> $GITHUB_ENV
if [ "$RUNNER_OS" == "Windows" ]; then
echo "exe-ext=.exe" >> $GITHUB_ENV
else
echo "exe-ext=" >> $GITHUB_ENV
fi
if [ "$RUNNER_OS" == "Windows" ]; then
find '${{ env.builddir }}' -name clang.exe
find '${{ env.builddir }}' -name OpenCL.dll
cat '${{ github.workspace }}'/swiftshader/vk_swiftshader_icd.json
cp '${{ github.workspace }}'/vulkanrt/vulkan-1.dll '${{ env.builddir }}'
cp '${{ github.workspace }}'/swiftshader/vk_swiftshader.dll '${{ github.workspace }}'/..
cp '${{ env.builddir }}'/src/OpenCL.dll '${{ env.builddir }}'
fi
echo "testbindir=${{ env.builddir }}" >> $GITHUB_ENV
- name: Config tests
shell: bash
if: ${{ matrix.unit }}
run: ./tests/config/run_test.sh ${{ env.testbindir }}
- name: SHA-1 tests
if: ${{ matrix.android-abi == '' }}
run: ${{ env.testbindir }}/sha1_tests${{ env.exe-ext }}
- name: Simple test (static)
if: ${{ matrix.compiler-available && matrix.android-abi == '' }}
run: ${{ env.testbindir }}/simple_test_static${{ env.exe-ext }}
- name: Simple test
if: ${{ matrix.compiler-available && matrix.android-abi == '' }}
run: ${{ env.testbindir }}/simple_test${{ env.exe-ext }}
- name: API tests
if: ${{ matrix.compiler-available && matrix.android-abi == '' }}
run: ${{ env.testbindir }}/api_tests${{ env.exe-ext }}
env:
CLVK_LOG: 2
# TODO #477 - enable these tests
# - name: API tests (physical addressing)
# if: ${{ matrix.compiler-available && matrix.android-abi == '' }}
# run: ${{ env.testbindir }}/api_tests${{ env.exe-ext }}
# env:
# CLVK_LOG: 2
# CLVK_SPIRV_ARCH: spir64
# CLVK_PHYSICAL_ADDRESSING: 1
- name: Offline compilation simple tests
if: ${{ matrix.android-abi == '' }}
run: |
${{ env.builddir }}/clspv${{ env.exe-ext }} -o simple.spv ./tests/simple-from-binary/simple.cl
${{ env.testbindir }}/simple_test_from_binary${{ env.exe-ext }}
${{ env.testbindir }}/simple_test_from_binary_static${{ env.exe-ext }}
- name: Offline IL compilation simple tests
if: ${{ matrix.compiler-available && matrix.android-abi == '' }}
run: |
${{ env.builddir }}/external/clspv/third_party/llvm/bin/clang${{ env.exe-ext }} -Xclang -finclude-default-header -c -target spir -O0 -emit-llvm -o simple-cl.bc ./tests/simple-from-il-binary/simple.cl
${{ env.builddir }}/llvm-spirv${{ env.exe-ext }} simple-cl.bc -o simple-cl.spv
${{ env.testbindir }}/simple_test_from_il_binary${{ env.exe-ext }}
${{ env.testbindir }}/simple_test_from_il_binary_static${{ env.exe-ext }}
- name: Offline LLVM-IR compilation simple tests
if: ${{ matrix.compiler-available && matrix.android-abi == '' }}
run: |
${{ env.builddir }}/clspv${{ env.exe-ext }} -output-format=bc -o simple.bc ./tests/simple-from-llvm-ir-binary/simple.cl
${{ env.testbindir }}/simple_test_from_llvm_ir_binary${{ env.exe-ext }}
${{ env.testbindir }}/simple_test_from_llvm_ir_binary_static${{ env.exe-ext }}
- name: API tests (with validation layers)
if: ${{ matrix.compiler-available && matrix.android-abi == '' }}
shell: bash
run: |
${{ env.testbindir }}/api_tests${{ env.exe-ext }}
cat validation.log
if [ -s validation.log ]; then
echo "VALIDATION LAYERS REPORTED ERRORS"
exit 1
fi
env:
CLVK_LOG: 1
CLVK_LOG_GROUPS: validation
CLVK_LOG_DEST: file:validation.log
CLVK_VALIDATION_LAYERS: 1
VK_ADD_LAYER_PATH: ${{ env.VULKAN_SDK_LAYERS_MANIFEST_PATH }}
LD_LIBRARY_PATH: ${{ env.VULKAN_SDK_LIB_PATH }}
- name: Perfetto test
if: ${{ matrix.perfetto }}
run: |
${{ env.testbindir }}/simple_test
./tests/perfetto/check-perfetto-trace.sh ${CLVK_PERFETTO_TRACE_DEST} ./tests/perfetto/simple_test-expectation.txt
${{ env.testbindir}}/api_tests --gtest_filter=WithCommandQueue.EnqueueTooManyCommandsWithRetry
./tests/perfetto/check-perfetto-trace.sh ${CLVK_PERFETTO_TRACE_DEST} ./tests/perfetto/api_tests.EnqueueTooManyCommandWithRetry-expectation.txt
env:
CLVK_PERFETTO_TRACE_DEST: ${{ env.testbindir }}/perfetto.trace
TRACE_PROCESSOR_SHELL: ${{ env.perfettodir }}/out/linux_clang_release/trace_processor_shell