Skip to content

Add SYCL support

Add SYCL support #120

Workflow file for this run

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
ADAPTIVECPP_CACHE_VERSION: v3
ACPP_TARGETS: omp.library-only
jobs:
prepare-sycl-toolchain:
name: prepare ${{ matrix.platform }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 180
strategy:
fail-fast: true
matrix:
platform:
- linux-x86_64
- linux-arm64
- windows-x86_64
include:
- platform: linux-x86_64
runner: ubuntu-latest
- platform: linux-arm64
runner: ubuntu-24.04-arm
- platform: windows-x86_64
runner: windows-2022
steps:
- name: Setup MSVC environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ccache-${{ github.job }}-${{ matrix.platform }}
max-size: 4G
- name: Restore or save AdaptiveCpp toolchain cache
id: sycl-toolchain-cache
uses: actions/cache@v4
with:
path: |
${{ runner.temp }}/AdaptiveCpp
${{ runner.temp }}/AdaptiveCpp-build
${{ runner.temp }}/adaptivecpp-install
${{ runner.temp }}/archives
key: sycl-toolchain-${{ matrix.platform }}-${{ env.ADAPTIVECPP_TAG }}-${{ env.ADAPTIVECPP_CACHE_VERSION }}
- name: Install Linux toolchain dependencies
if: runner.os == 'Linux' && steps.sycl-toolchain-cache.outputs.cache-hit != 'true'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
ccache \
clang-18 \
cmake \
libboost-context-dev \
libboost-fiber-dev \
libboost-filesystem-dev \
libboost-system-dev \
libboost-test-dev \
libclang-18-dev \
libomp-18-dev \
llvm-18-dev \
ninja-build \
python3
- name: Build Linux AdaptiveCpp
if: runner.os == 'Linux' && steps.sycl-toolchain-cache.outputs.cache-hit != 'true'
shell: bash
env:
ACPP_INSTALL_DIR: ${{ runner.temp }}/adaptivecpp-install
ACPP_SOURCE_DIR: ${{ runner.temp }}/AdaptiveCpp
ACPP_BUILD_DIR: ${{ runner.temp }}/AdaptiveCpp-build
ACPP_ARCHIVE_DIR: ${{ runner.temp }}/archives
run: |
mkdir -p "${ACPP_ARCHIVE_DIR}" "${ACPP_BUILD_DIR}" "${ACPP_INSTALL_DIR}"
archive="${ACPP_ARCHIVE_DIR}/AdaptiveCpp-${ADAPTIVECPP_TAG}.tar.gz"
curl -L "https://github.com/AdaptiveCpp/AdaptiveCpp/archive/refs/tags/${ADAPTIVECPP_TAG}.tar.gz" -o "${archive}"
tar -xzf "${archive}" -C "${RUNNER_TEMP}"
extracted_dir="$(find "${RUNNER_TEMP}" -maxdepth 2 -type f -path '*/AdaptiveCpp-*/CMakeLists.txt' -print | head -n 1)"
rm -rf "${ACPP_SOURCE_DIR}" "${ACPP_BUILD_DIR}"
mv "$(dirname "${extracted_dir}")" "${ACPP_SOURCE_DIR}"
mkdir -p "${ACPP_BUILD_DIR}"
cmake -S "${ACPP_SOURCE_DIR}" -B "${ACPP_BUILD_DIR}" -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${ACPP_INSTALL_DIR}" \
-DCMAKE_C_COMPILER=/usr/bin/clang-18 \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++-18 \
-DLLVM_DIR=/usr/lib/llvm-18/lib/cmake/llvm \
-DClang_DIR=/usr/lib/llvm-18/lib/cmake/clang \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build "${ACPP_BUILD_DIR}" --target install --parallel
- name: Locate Windows LLVM toolchain
if: runner.os == 'Windows'
shell: pwsh
run: |
$clangCl = Get-Command clang-cl.exe -ErrorAction SilentlyContinue
if (-not $clangCl -and $env:ProgramFiles) {
$programFilesClang = Join-Path $env:ProgramFiles 'LLVM/bin/clang-cl.exe'
if (Test-Path $programFilesClang) {
$clangCl = Get-Item $programFilesClang
}
}
if (-not $clangCl -and $env:VCToolsInstallDir) {
$vcToolsRoot = Resolve-Path (Join-Path $env:VCToolsInstallDir '../..')
$vsClang = Join-Path $vcToolsRoot 'Llvm/x64/bin/clang-cl.exe'
if (Test-Path $vsClang) {
$clangCl = Get-Item $vsClang
}
}
if (-not $clangCl) {
throw 'clang-cl.exe was not found. Install the Visual Studio LLVM/Clang toolset on the Windows runner.'
}
$clangClPath = $clangCl.Source
if (-not $clangClPath) {
$clangClPath = $clangCl.FullName
}
$clangBin = Split-Path $clangClPath -Parent
$clangCxxPath = Join-Path $clangBin 'clang++.exe'
if (-not (Test-Path $clangCxxPath)) {
throw "clang++.exe was not found next to $clangClPath. Install the Visual Studio LLVM/Clang toolset on the Windows runner."
}
"ITLABAI_CC=$clangClPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"ITLABAI_CXX=$clangClPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"ITLABAI_ACPP_CPU_CXX=$clangCxxPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"$clangBin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install Windows Ninja
if: runner.os == 'Windows' && steps.sycl-toolchain-cache.outputs.cache-hit != 'true'
shell: pwsh
run: |
if (-not (Get-Command ninja.exe -ErrorAction SilentlyContinue)) {
choco install ninja --yes --no-progress
}
- name: Build Windows AdaptiveCpp
if: runner.os == 'Windows' && steps.sycl-toolchain-cache.outputs.cache-hit != 'true'
shell: pwsh
env:
ACPP_INSTALL_DIR: ${{ runner.temp }}\adaptivecpp-install
ACPP_SOURCE_DIR: ${{ runner.temp }}\AdaptiveCpp
ACPP_BUILD_DIR: ${{ runner.temp }}\AdaptiveCpp-build
ACPP_ARCHIVE_DIR: ${{ runner.temp }}\archives
run: |
New-Item -ItemType Directory -Force -Path $env:ACPP_ARCHIVE_DIR,$env:ACPP_BUILD_DIR,$env:ACPP_INSTALL_DIR | Out-Null
$archive = Join-Path $env:ACPP_ARCHIVE_DIR "AdaptiveCpp-$env:ADAPTIVECPP_TAG.tar.gz"
Invoke-WebRequest "https://github.com/AdaptiveCpp/AdaptiveCpp/archive/refs/tags/$env:ADAPTIVECPP_TAG.tar.gz" -OutFile $archive
Remove-Item $env:ACPP_SOURCE_DIR,$env:ACPP_BUILD_DIR -Recurse -Force -ErrorAction SilentlyContinue
tar -xzf $archive -C $env:RUNNER_TEMP
$extractedAcpp = Get-ChildItem $env:RUNNER_TEMP -Directory | Where-Object { $_.Name -like 'AdaptiveCpp-*' } | Select-Object -First 1
Move-Item $extractedAcpp.FullName $env:ACPP_SOURCE_DIR
New-Item -ItemType Directory -Force -Path $env:ACPP_BUILD_DIR | Out-Null
cmake -S $env:ACPP_SOURCE_DIR -B $env:ACPP_BUILD_DIR -G Ninja `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_INSTALL_PREFIX=$env:ACPP_INSTALL_DIR `
-DCMAKE_C_COMPILER="$env:ITLABAI_CC" `
-DCMAKE_CXX_COMPILER="$env:ITLABAI_CXX" `
-DCMAKE_C_COMPILER_LAUNCHER=ccache `
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
cmake --build $env:ACPP_BUILD_DIR --target install --parallel
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
build-sycl:
name: ${{ matrix.platform }} ${{ matrix.build_type }}
needs: prepare-sycl-toolchain
runs-on: ${{ matrix.runner }}
timeout-minutes: 180
strategy:
fail-fast: true
matrix:
platform:
- linux-x86_64
- linux-arm64
- macos-arm64
- windows-x86_64
build_type:
- Debug
- Release
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 MSVC environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ccache-${{ github.job }}-${{ matrix.platform }}-${{ matrix.build_type }}
max-size: 4G
- name: Restore AdaptiveCpp toolchain cache
if: runner.os != 'macOS'
uses: actions/cache/restore@v4
with:
path: |
${{ runner.temp }}/AdaptiveCpp
${{ runner.temp }}/AdaptiveCpp-build
${{ runner.temp }}/adaptivecpp-install
${{ runner.temp }}/archives
key: sycl-toolchain-${{ matrix.platform }}-${{ env.ADAPTIVECPP_TAG }}-${{ env.ADAPTIVECPP_CACHE_VERSION }}
fail-on-cache-miss: true
- name: Install macOS toolchain dependencies
if: runner.os == 'macOS'
shell: bash
run: brew install adaptivecpp libomp ninja
- name: Configure macOS toolchain environment
if: runner.os == 'macOS'
shell: bash
run: |
{
echo "ITLABAI_CC=$(xcrun --find clang)"
echo "ITLABAI_CXX=$(xcrun --find clang++)"
echo "ITLABAI_CMAKE_PREFIX_PATH=$(brew --prefix adaptivecpp);$(brew --prefix libomp)"
echo "ITLABAI_OPENMP_ROOT=$(brew --prefix libomp)"
} >> "${GITHUB_ENV}"
- name: Install Linux toolchain dependencies
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
ccache \
clang-18 \
cmake \
libboost-context-dev \
libboost-fiber-dev \
libboost-filesystem-dev \
libboost-system-dev \
libboost-test-dev \
libclang-18-dev \
libomp-18-dev \
llvm-18-dev \
ninja-build \
python3
- name: Configure Linux toolchain environment
if: runner.os == 'Linux'
shell: bash
run: |
{
echo "ITLABAI_CC=/usr/bin/clang-18"
echo "ITLABAI_CXX=/usr/bin/clang++-18"
echo "ITLABAI_CMAKE_PREFIX_PATH=${RUNNER_TEMP}/adaptivecpp-install"
echo "ITLABAI_OPENMP_ROOT=/usr/lib/llvm-18"
} >> "${GITHUB_ENV}"
echo "${RUNNER_TEMP}/adaptivecpp-install/bin" >> "${GITHUB_PATH}"
- name: Locate Windows LLVM toolchain
if: runner.os == 'Windows'
shell: pwsh
run: |
$clangCl = Get-Command clang-cl.exe -ErrorAction SilentlyContinue
if (-not $clangCl -and $env:ProgramFiles) {
$programFilesClang = Join-Path $env:ProgramFiles 'LLVM/bin/clang-cl.exe'
if (Test-Path $programFilesClang) {
$clangCl = Get-Item $programFilesClang
}
}
if (-not $clangCl -and $env:VCToolsInstallDir) {
$vcToolsRoot = Resolve-Path (Join-Path $env:VCToolsInstallDir '../..')
$vsClang = Join-Path $vcToolsRoot 'Llvm/x64/bin/clang-cl.exe'
if (Test-Path $vsClang) {
$clangCl = Get-Item $vsClang
}
}
if (-not $clangCl) {
throw 'clang-cl.exe was not found. Install the Visual Studio LLVM/Clang toolset on the Windows runner.'
}
$clangClPath = $clangCl.Source
if (-not $clangClPath) {
$clangClPath = $clangCl.FullName
}
$clangBin = Split-Path $clangClPath -Parent
$clangCxxPath = Join-Path $clangBin 'clang++.exe'
if (-not (Test-Path $clangCxxPath)) {
throw "clang++.exe was not found next to $clangClPath. Install the Visual Studio LLVM/Clang toolset on the Windows runner."
}
"ITLABAI_CC=$clangClPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"ITLABAI_CXX=$clangClPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"ITLABAI_ACPP_CPU_CXX=$clangCxxPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"ITLABAI_CMAKE_PREFIX_PATH=$env:RUNNER_TEMP\adaptivecpp-install" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"$clangBin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
"$env:RUNNER_TEMP\adaptivecpp-install\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install Windows Ninja
if: runner.os == 'Windows'
shell: pwsh
run: |
if (-not (Get-Command ninja.exe -ErrorAction SilentlyContinue)) {
choco install ninja --yes --no-progress
}
- name: Configure
if: runner.os != 'Windows'
shell: bash
run: |
cmake -S . -B "build/${{ matrix.build_type }}" -G Ninja \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_C_COMPILER="${ITLABAI_CC}" \
-DCMAKE_CXX_COMPILER="${ITLABAI_CXX}" \
-DCMAKE_PREFIX_PATH="${ITLABAI_CMAKE_PREFIX_PATH}" \
-DOpenMP_ROOT="${ITLABAI_OPENMP_ROOT}" \
-DITLABAI_ENABLE_SYCL=ON \
-DACPP_TARGETS="${ACPP_TARGETS}" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: Configure
if: runner.os == 'Windows'
shell: pwsh
run: |
cmake -S . -B "build/${{ matrix.build_type }}" -G Ninja `
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} `
-DCMAKE_C_COMPILER="$env:ITLABAI_CC" `
-DCMAKE_CXX_COMPILER="$env:ITLABAI_CXX" `
-DCMAKE_PREFIX_PATH="$env:ITLABAI_CMAKE_PREFIX_PATH" `
-DITLABAI_ENABLE_SYCL=ON `
-DACPP_TARGETS="$env:ACPP_TARGETS" `
-DACPP_CPU_CXX="$env:ITLABAI_ACPP_CPU_CXX" `
-DCMAKE_C_COMPILER_LAUNCHER=ccache `
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Build
run: cmake --build "build/${{ matrix.build_type }}" --target SYCL_Example run_test --parallel
- name: Test
run: ctest --test-dir "build/${{ matrix.build_type }}" --output-on-failure -R '^UnitTests$'