Skip to content

.github/workflows/sycl-linux-build.yml #35

.github/workflows/sycl-linux-build.yml

.github/workflows/sycl-linux-build.yml #35

name: Reusable SYCL Linux build workflow
defaults:
run:
shell: bash
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_target:
type: string
required: false
default: sycl-toolchain
changes:
type: string
description: 'Filter matches for the changed files in the PR'
default: '[llvm, clang, sycl, llvm_spirv, xptifw, libclc]'
required: false
# Artifacts:
retention-days:
description: 'Artifacts retention period'
type: string
default: 3
toolchain_artifact:
type: string
required: true
toolchain_artifact_filename:
type: string
default: llvm_sycl.tar.zst
release_toolchain_artifact:
type: string
required: false
description: |
If provided, create an additional toolchain artifact without utilities
used for testing in it. File name of the archive is the same as in the
`toolchain_artifact` above.
e2e_binaries_artifact:
type: string
required: false
e2e_binaries_spirv_backend_artifact:
type: string
required: false
e2e_binaries_preview_artifact:
type: string
required: false
outputs:
build_conclusion:
value: ${{ jobs.build.outputs.build_conclusion }}
toolchain_artifact:
value: ${{ inputs.toolchain_artifact }}
toolchain_artifact_filename:
value: ${{ jobs.build.outputs.toolchain_artifact_filename }}
toolchain_decompress_command:
value: ${{ jobs.build.outputs.toolchain_decompress_command }}
workflow_dispatch:
inputs:
changes:
description: 'Filter matches for the changed files in the PR'
type: choice
options:
- "[]"
- '[sycl]'
- '[llvm, clang, sycl, llvm_spirv, xptifw, libclc]'
build_image:
type: choice
options:
- 'ghcr.io/intel/llvm/sycl_ubuntu2404_nightly:latest'
- 'ghcr.io/intel/llvm/ubuntu2204_build: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"
retention-days:
type: choice
options:
- 3
toolchain_artifact:
type: choice
options:
- "sycl_linux_default"
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 }}
toolchain_artifact_filename: ${{ steps.artifact_info.outputs.ARCHIVE_NAME }}
toolchain_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.toolchain_artifact_filename}}"
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@v5
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: list devops
run: ls -R ./devops/
- name: Setup oneAPI env
if: ${{ inputs.cc == 'icx' || inputs.cxx == 'icpx' }}
uses: ./devops/actions/setup_linux_oneapi_env
- name: Configure
# Setting `CMAKE_INSTALL_PREFIX` is important because that's the location
# where `sycl-linux-run-tests.yml` unpacks the toolchain to. That location
# *must* match between build-only and run-only E2E tests runs and we might
# be creating pre-built E2E tests' binaries in this workflow.
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 \
-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/toolchain \
-t Release \
--ci-defaults --use-zstd ${{ inputs.build_configure_extra_args }} \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DLLVM_INSTALL_UTILS=ON
- name: Compile
id: build
# Emulate default value for manual dispatch as we've run out of available arguments.
run: cmake --build $GITHUB_WORKSPACE/build --target ${{ inputs.build_target || 'sycl-toolchain' }}
- name: check-llvm
if: always() && !cancelled() && contains(inputs.changes, 'llvm')
env:
# Can't inline to support possible quotes inside:
BUILD_CONFIGURE_EXTRA_ARGS: ${{ inputs.build_configure_extra_args }}
run: |
if [[ "${BUILD_CONFIGURE_EXTRA_ARGS}" == *"--use-libcxx"* ]]; then
# https://github.com/llvm/llvm-project/issues/59429
export LIT_FILTER_OUT="ExecutionEngine/MCJIT"
fi
cmake --build $GITHUB_WORKSPACE/build --target check-llvm
- name: check-clang
if: always() && !cancelled() && contains(inputs.changes, 'clang')
env:
# Can't inline to support possible quotes inside:
BUILD_CONFIGURE_EXTRA_ARGS: ${{ inputs.build_configure_extra_args }}
run: |
# Can we move this to Dockerfile? Hopefully, noop on Windows.
export XDG_CACHE_HOME=$GITHUB_WORKSPACE/os_cache
if [[ "${BUILD_CONFIGURE_EXTRA_ARGS}" == *"--use-libcxx"* ]]; then
# https://github.com/llvm/llvm-project/issues/59428
export LIT_FILTER_OUT="(E|e)xception"
fi
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, 'sycl')
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.release_toolchain_artifact != '' }}
run: tar -I '${{ steps.artifact_info.outputs.COMPRESS }}' -cf ${{ steps.artifact_info.outputs.ARCHIVE_NAME }} -C $GITHUB_WORKSPACE/toolchain .
- name: Upload toolchain release
if: ${{ always() && !cancelled() && steps.build.conclusion == 'success' && inputs.release_toolchain_artifact != '' }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.release_toolchain_artifact }}
path: ${{ steps.artifact_info.outputs.ARCHIVE_NAME }}
retention-days: ${{ inputs.retention-days }}
- name: Install utilities
if: ${{ always() && !cancelled() && steps.build.conclusion == 'success' }}
run: |
chmod +x $GITHUB_WORKSPACE/src/devops/scripts/install_test_utilities.sh
$GITHUB_WORKSPACE/src/devops/scripts/install_test_utilities.sh
- 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/toolchain .
- name: Upload toolchain
if: ${{ always() && !cancelled() && steps.build.conclusion == 'success' }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.toolchain_artifact }}
path: ${{ steps.artifact_info.outputs.ARCHIVE_NAME }}
retention-days: ${{ inputs.retention-days }}
- name: Source OneAPI TBB vars.sh
# Tasks that use the just built toolchain below, need extra environment
# setup. No harm in it if all of those tasks would get skipped.
if: ${{ always() && !cancelled() && steps.build.conclusion == 'success' }}
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 }}
sycl_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_spirv_backend_artifact && always() && !cancelled() && steps.build.conclusion == 'success' }}
run: rm -rf build-e2e
- name: Build E2E tests with SPIR-V Backend
if: ${{ inputs.e2e_binaries_spirv_backend_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_spirv_backend_artifact }}
sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++
extra_lit_opts: --param spirv-backend=True
- name: Remove E2E tests before preview-mode run
if: ${{ inputs.e2e_binaries_preview_artifact && always() && !cancelled() && steps.build.conclusion == 'success' }}
run: rm -rf build-e2e
- name: Build E2E tests in Preview Mode
if: ${{ inputs.e2e_binaries_preview_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_preview_artifact }}
sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++
extra_lit_opts: --param test-preview-mode=True