cmake: Disable clspv spirv build (#733) #1412
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ccache-action@v1.2 | |
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 |