Add SYCL support #104
This file contains hidden or 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: SYCL CI | |
| on: | |
| pull_request: | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| ADAPTIVECPP_TAG: v25.10.0 | |
| LLVM_MINGW_VERSION: "20231128" | |
| jobs: | |
| build-sycl: | |
| name: ${{ matrix.platform }} | |
| runs-on: ${{ matrix.runner }} | |
| timeout-minutes: 360 | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| include: | |
| - platform: linux-x86_64 | |
| runner: ubuntu-latest | |
| - platform: linux-arm64 | |
| runner: ubuntu-24.04-arm | |
| - platform: macos-arm64 | |
| runner: macos-15 | |
| - platform: windows-x86_64 | |
| runner: windows-2022 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Setup ccache | |
| uses: hendrikmuhs/ccache-action@v1.2 | |
| with: | |
| key: ccache-${{ github.job }}-${{ matrix.platform }} | |
| max-size: 4G | |
| - name: Restore AdaptiveCpp toolchain cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ${{ runner.temp }}/AdaptiveCpp | |
| ${{ runner.temp }}/AdaptiveCpp-build | |
| ${{ runner.temp }}/adaptivecpp-install | |
| ${{ runner.temp }}/llvm | |
| ${{ runner.temp }}/boost_1_87_0 | |
| ${{ runner.temp }}/ninja_install | |
| ${{ runner.temp }}/archives | |
| key: sycl-toolchain-${{ matrix.platform }}-${{ env.ADAPTIVECPP_TAG }}-${{ env.LLVM_MINGW_VERSION }}-v1 | |
| - name: Setup MSVC environment | |
| if: runner.os == 'Windows' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| - name: Prepare AdaptiveCpp toolchain | |
| run: python ./scripts/ci/sycl_setup.py ${{ matrix.platform }} | |
| - name: Configure, build and test | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| for build_type in Debug Release; do | |
| build_dir="build/${build_type}" | |
| cmake_args=( | |
| -S . | |
| -B "${build_dir}" | |
| -G Ninja | |
| -DCMAKE_BUILD_TYPE=${build_type} | |
| -DCMAKE_C_COMPILER=${ITLABAI_CC} | |
| -DCMAKE_CXX_COMPILER=${ITLABAI_CXX} | |
| -DCMAKE_PREFIX_PATH=${ITLABAI_CMAKE_PREFIX_PATH} | |
| -DITLABAI_ENABLE_SYCL=ON | |
| -DITLABAI_SYCL_TARGETS=${ACPP_TARGETS} | |
| ) | |
| if command -v ccache >/dev/null 2>&1; then | |
| cmake_args+=( | |
| -DCMAKE_C_COMPILER_LAUNCHER=ccache | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache | |
| ) | |
| fi | |
| if [ -n "${ITLABAI_OPENMP_ROOT:-}" ]; then | |
| cmake_args+=(-DOpenMP_ROOT=${ITLABAI_OPENMP_ROOT}) | |
| fi | |
| cmake "${cmake_args[@]}" | |
| cmake --build "${build_dir}" --target SYCL_Example run_test --parallel | |
| ctest --test-dir "${build_dir}" --output-on-failure -R '^UnitTests$' | |
| done | |
| - name: Configure, build and test | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| foreach ($buildType in 'Debug', 'Release') { | |
| $buildDir = "build/$buildType" | |
| $cmakeArgs = @( | |
| '-S', '.', | |
| '-B', $buildDir, | |
| '-G', 'Ninja', | |
| "-DCMAKE_BUILD_TYPE=$buildType", | |
| "-DCMAKE_C_COMPILER=$env:ITLABAI_CC", | |
| "-DCMAKE_CXX_COMPILER=$env:ITLABAI_CXX", | |
| "-DCMAKE_PREFIX_PATH=$env:ITLABAI_CMAKE_PREFIX_PATH", | |
| '-DITLABAI_ENABLE_SYCL=ON', | |
| "-DITLABAI_SYCL_TARGETS=$env:ACPP_TARGETS" | |
| ) | |
| if (Get-Command ccache -ErrorAction SilentlyContinue) { | |
| $cmakeArgs += '-DCMAKE_C_COMPILER_LAUNCHER=ccache' | |
| $cmakeArgs += '-DCMAKE_CXX_COMPILER_LAUNCHER=ccache' | |
| } | |
| if ($env:ITLABAI_OPENMP_ROOT) { | |
| $cmakeArgs += "-DOpenMP_ROOT=$env:ITLABAI_OPENMP_ROOT" | |
| } | |
| & cmake @cmakeArgs | |
| if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | |
| & cmake --build $buildDir --target SYCL_Example run_test --parallel | |
| if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | |
| & ctest --test-dir $buildDir --output-on-failure -R '^UnitTests$' | |
| if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | |
| } |