Skip to content

Reusable SYCL Linux build workflow #16

Reusable SYCL Linux build workflow

Reusable SYCL Linux build workflow #16

name: Reusable SYCL Linux build workflow
on:
workflow_call:
inputs:
cc:
type: string
required: false
default: "gcc"
cxx:
type: string
required: false
default: "g++"
build_image:
type: string
required: false
default: "ghcr.io/intel/llvm/ubuntu2404_intel_drivers:alldeps"
build_ref:
type: string
required: false
build_cache_root:
type: string
required: true
build_cache_suffix:
type: string
required: false
default: "default"
build_configure_extra_args:
type: string
required: false
default: "--hip --cuda --native_cpu"
build_artifact_suffix:
type: string
required: true
artifact_archive_name:
type: string
default: llvm_sycl.tar.zst
changes:
type: string
description: 'Filter matches for the changed files in the PR'
default: '[llvm, clang, sycl, llvm_spirv, xptifw, libclc, libdevice]'
required: false
retention-days:
description: 'Artifacts retention period'
type: string
default: 3
e2e_binaries_artifact:
type: string
required: false
pack_release:
type: string
required: false
outputs:
build_conclusion:
value: ${{ jobs.build.outputs.build_conclusion }}
artifact_archive_name:
value: ${{ jobs.build.outputs.artifact_archive_name }}
artifact_decompress_command:
value: ${{ jobs.build.outputs.artifact_decompress_command }}
workflow_dispatch:
inputs:
changes:
description: 'Filter matches for the changed files in the PR'
type: choice
options:
- "[]"
- '[llvm, clang, sycl, llvm_spirv, xptifw, libclc, libdevice]'
build_image:
type: choice
options:
- 'ghcr.io/intel/llvm/sycl_ubuntu2404_nightly:latest'
cc:
type: choice
options:
- gcc
cxx:
type: choice
options:
- g++
build_configure_extra_args:
type: choice
options:
- "--hip --cuda --native_cpu"
# Cache properties need to match CC/CXX/CMake opts. Any additional choices
# would need extra care.
build_cache_root:
type: choice
options:
- "/__w/"
build_cache_suffix:
type: choice
options:
- "default"
build_artifact_suffix:
type: choice
options:
- "default"
retention-days:
type: choice
options:
- 3
pack_release:
type: string
required: false
permissions: read-all
jobs:
build:
name: Build + LIT
runs-on: [Linux, build]
container:
image: ${{ inputs.build_image }}
options: -u 1001:1001
outputs:
build_conclusion: ${{ steps.build.conclusion }}
artifact_archive_name: ${{ steps.artifact_info.outputs.ARCHIVE_NAME }}
artifact_decompress_command: ${{ steps.artifact_info.outputs.DECOMPRESS }}
env:
CCACHE_DIR: ${{ inputs.build_cache_root }}/build_cache_${{ inputs.build_cache_suffix }}
CCACHE_MAXSIZE: 8G
steps:
- name: Deduce artifact archive params
# To reduce number of inputs parameters that is limited for manual triggers.
id: artifact_info
run: |
NAME="${{inputs.artifact_archive_name}}"
if [ -z "$NAME" ]; then
NAME=llvm_sycl.tar.zst
fi
echo ARCHIVE_NAME="$NAME" >> $GITHUB_OUTPUT
if [ "${NAME}" != "${NAME%.tar.gz}" ]; then
echo COMPRESS="gzip" >> $GITHUB_OUTPUT
echo DECOMPRESS="gunzip" >> $GITHUB_OUTPUT
elif [ "${NAME}" != "${NAME%.tar.zst}" ]; then
echo COMPRESS="zstd -9" >> $GITHUB_OUTPUT
echo DECOMPRESS="zstd" >> $GITHUB_OUTPUT
else
echo "Unsupported extension"
exit 1
fi
- uses: actions/checkout@v4
with:
sparse-checkout: |
devops/actions
# Cleanup will be run after all actions are completed.
- name: Register cleanup after job is finished
uses: ./devops/actions/cleanup
- uses: ./devops/actions/cached_checkout
with:
path: src
ref: ${{ inputs.build_ref || github.sha }}
cache_path: "/__w/repo_cache/"
- name: Setup oneAPI env
if: ${{ inputs.cc == 'icx' || inputs.cxx == 'icpx' }}
uses: ./devops/actions/setup_linux_oneapi_env
- name: Configure
env:
CC: ${{ inputs.cc }}
CXX: ${{ inputs.cxx }}
CUDA_LIB_PATH: "/usr/local/cuda/lib64/stubs"
run: |
mkdir -p $CCACHE_DIR
mkdir -p $GITHUB_WORKSPACE/build
cd $GITHUB_WORKSPACE/build
python3 $GITHUB_WORKSPACE/src/buildbot/configure.py -w $GITHUB_WORKSPACE \
-s $GITHUB_WORKSPACE/src -o $GITHUB_WORKSPACE/build -t Release \
--ci-defaults ${{ inputs.build_configure_extra_args }} \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DLLVM_INSTALL_UTILS=ON \
-DNATIVECPU_USE_OCK=Off \
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=SPIRV
- name: Compile
id: build
run: cmake --build $GITHUB_WORKSPACE/build --target sycl-toolchain
- name: check-llvm
if: always() && !cancelled() && contains(inputs.changes, 'llvm')
run: |
cmake --build $GITHUB_WORKSPACE/build --target check-llvm
- name: check-clang
if: always() && !cancelled() && contains(inputs.changes, 'clang')
run: |
# Can we move this to Dockerfile? Hopefully, noop on Windows.
export XDG_CACHE_HOME=$GITHUB_WORKSPACE/os_cache
cmake --build $GITHUB_WORKSPACE/build --target check-clang
- name: check-sycl
if: always() && !cancelled() && contains(inputs.changes, 'sycl')
run: |
# TODO consider moving this to Dockerfile.
export LD_LIBRARY_PATH=/usr/local/cuda/compat/:/usr/local/cuda/lib64:$LD_LIBRARY_PATH
cmake --build $GITHUB_WORKSPACE/build --target check-sycl
- name: check-sycl-unittests
if: always() && !cancelled() && contains(inputs.changes, 'sycl')
run: |
# TODO consider moving this to Dockerfile.
export LD_LIBRARY_PATH=/usr/local/cuda/compat/:/usr/local/cuda/lib64:$LD_LIBRARY_PATH
cmake --build $GITHUB_WORKSPACE/build --target check-sycl-unittests
- name: check-llvm-spirv
if: always() && !cancelled() && contains(inputs.changes, 'llvm_spirv')
run: |
cmake --build $GITHUB_WORKSPACE/build --target check-llvm-spirv
- name: check-xptifw
if: always() && !cancelled() && contains(inputs.changes, 'xptifw')
run: |
cmake --build $GITHUB_WORKSPACE/build --target check-xptifw
- name: check-libclc
if: always() && !cancelled() && contains(inputs.changes, 'libclc')
run: |
cmake --build $GITHUB_WORKSPACE/build --target check-libclc
- name: check-libdevice
if: always() && !cancelled() && contains(inputs.changes, 'libdevice')
run: |
cmake --build $GITHUB_WORKSPACE/build --target check-libdevice
- name: Check E2E test requirements
if: always() && !cancelled() && !contains(inputs.changes, 'sycl')
run: |
# TODO consider moving this to Dockerfile.
export LD_LIBRARY_PATH=/usr/local/cuda/compat/:/usr/local/cuda/lib64:$LD_LIBRARY_PATH
LIT_OPTS="--allow-empty-runs" LIT_FILTER="e2e_test_requirements" cmake --build $GITHUB_WORKSPACE/build --target check-sycl
- name: Install sycl-toolchain
if: ${{ always() && !cancelled() && steps.build.conclusion == 'success' }}
run: |
cmake --build $GITHUB_WORKSPACE/build --target deploy-sycl-toolchain
- name: Pack toolchain release
if: ${{ always() && !cancelled() && steps.build.conclusion == 'success' && inputs.pack_release == 'true' }}
run: tar -I '${{ steps.artifact_info.outputs.COMPRESS }}' -cf ${{ steps.artifact_info.outputs.ARCHIVE_NAME }} -C $GITHUB_WORKSPACE/build/install .
- name: Upload toolchain release
if: ${{ always() && !cancelled() && steps.build.conclusion == 'success' && inputs.pack_release == 'true' }}
uses: actions/upload-artifact@v4
with:
name: sycl_linux_release
path: ${{ steps.artifact_info.outputs.ARCHIVE_NAME }}
retention-days: ${{ inputs.retention-days }}
- name: Install utilities
if: ${{ always() && !cancelled() && steps.build.conclusion == 'success' }}
# TODO replace utility installation with a single CMake target
run: |
cmake --build $GITHUB_WORKSPACE/build --target deploy-sycl-toolchain
cmake --build $GITHUB_WORKSPACE/build --target utils/FileCheck/install
cmake --build $GITHUB_WORKSPACE/build --target utils/count/install
cmake --build $GITHUB_WORKSPACE/build --target utils/not/install
cmake --build $GITHUB_WORKSPACE/build --target utils/lit/install
cmake --build $GITHUB_WORKSPACE/build --target utils/llvm-lit/install
cmake --build $GITHUB_WORKSPACE/build --target install-llvm-size
cmake --build $GITHUB_WORKSPACE/build --target install-llvm-cov
cmake --build $GITHUB_WORKSPACE/build --target install-llvm-profdata
cmake --build $GITHUB_WORKSPACE/build --target install-compiler-rt
- name: Additional Install for "--shared-libs" build
if: ${{ always() && !cancelled() && steps.build.conclusion == 'success' && contains(inputs.build_configure_extra_args, '--shared-libs') }}
run: |
cmake --build $GITHUB_WORKSPACE/build --target install-clang-libraries
cmake --build $GITHUB_WORKSPACE/build --target install-llvm-libraries
- name: Pack toolchain
if: ${{ always() && !cancelled() && steps.build.conclusion == 'success' }}
run: tar -I '${{ steps.artifact_info.outputs.COMPRESS }}' -cf ${{ steps.artifact_info.outputs.ARCHIVE_NAME }} -C $GITHUB_WORKSPACE/build/install .
- name: Upload toolchain
if: ${{ always() && !cancelled() && steps.build.conclusion == 'success' }}
uses: actions/upload-artifact@v4
with:
name: sycl_linux_${{ inputs.build_artifact_suffix }}
path: ${{ steps.artifact_info.outputs.ARCHIVE_NAME }}
retention-days: ${{ inputs.retention-days }}
- name: Copy toolchain
if: ${{ inputs.e2e_binaries_artifact && always() && !cancelled() && steps.build.conclusion == 'success' }}
# We must have the compiler in the same location as it will be in the E2E
# run-tests job.
run: cp -r $GITHUB_WORKSPACE/build/install $GITHUB_WORKSPACE/toolchain
- name: Source OneAPI TBB vars.sh
if: ${{ inputs.e2e_binaries_artifact && always() && !cancelled() && steps.build.conclusion == 'success' }}
shell: bash
run: |
# https://github.com/actions/runner/issues/1964 prevents us from using
# the ENTRYPOINT in the image.
env | sort > env_before
if [ -e /runtimes/oneapi-tbb/env/vars.sh ]; then
source /runtimes/oneapi-tbb/env/vars.sh;
elif [ -e /opt/runtimes/oneapi-tbb/env/vars.sh ]; then
source /opt/runtimes/oneapi-tbb/env/vars.sh;
else
echo "no TBB vars in /opt/runtimes or /runtimes";
fi
env | sort > env_after
comm -13 env_before env_after >> $GITHUB_ENV
rm env_before env_after
- name: Build E2E tests
if: ${{ inputs.e2e_binaries_artifact && always() && !cancelled() && steps.build.conclusion == 'success' }}
uses: ./devops/actions/run-tests/e2e
with:
ref: ${{ inputs.ref || github.sha }}
testing_mode: build-only
target_devices: all
binaries_artifact: ${{ inputs.e2e_binaries_artifact }}
cxx_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++
extra_lit_opts: --param sycl_build_targets="spir;nvidia;amd"
- name: Remove E2E tests before spirv-backend run
if: ${{ inputs.e2e_binaries_artifact && always() && !cancelled() && steps.build.conclusion == 'success' }}
run: rm -rf build-e2e
- name: Build E2E tests with SPIR-V Backend
if: ${{ inputs.e2e_binaries_artifact && always() && !cancelled() && steps.build.conclusion == 'success' }}
uses: ./devops/actions/run-tests/e2e
with:
ref: ${{ inputs.ref || github.sha }}
testing_mode: build-only
target_devices: all
binaries_artifact: ${{ inputs.e2e_binaries_artifact }}_spirv_backend
cxx_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++
extra_lit_opts: --param spirv-backend=True