Skip to content

[Cmake] Make SYCL detection more portable #28

[Cmake] Make SYCL detection more portable

[Cmake] Make SYCL detection more portable #28

Workflow file for this run

name: oneDPL CI Testing
on:
push:
branches: [main]
pull_request:
branches:
- release_oneDPL
- main
- 'release/**'
paths:
- '.github/**/*'
- 'cmake/**/*'
- 'include/**/*'
- 'test/**/*'
- 'CMakeLists.txt'
- '.clang-format'
permissions: read-all
env:
BUILD_CONCURRENCY: 4
MACOS_BUILD_CONCURRENCY: 3
TEST_TIMEOUT: 360
WINDOWS_TBB_DOWNLOAD_LINK: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/8222de4d-2c5e-41bc-bdd5-f557a9edda28/w_tbb_oneapi_p_2021.13.0.627_offline.exe
WINDOWS_ICPX_DOWNLOAD_LINK: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/7991e201-ca0f-4689-bdb6-1ed73a8246fd/w_dpcpp-cpp-compiler_p_2024.2.0.491_offline.exe
WINDOWS_ONEAPI_PATH: C:\Program Files (x86)\Intel\oneAPI
LINUX_ONEAPI_PATH: /opt/intel/oneapi
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ !contains(github.ref, 'refs/heads/main') }}
jobs:
clang-format:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Get clang-format
run: sudo apt-get install -yqq clang-format
- name: Applying clang-format for changed files
run: |
MERGE_BASE=$(git merge-base ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.base.sha }})
FILES=$(git diff --diff-filter=d --name-only $MERGE_BASE | grep ^include | grep -v nanorange\.hpp\$ || true)
CLANG_FORMAT_DIFF_PATH=$(which clang-format-diff)
echo $FILES | xargs -n1 -t -r git diff -U0 --no-color --relative $MERGE_BASE | python3 $CLANG_FORMAT_DIFF_PATH -i -p1 -style file
if: github.event_name == 'pull_request' || github.event_name == 'push'
- name: Creating diff
run: git diff > clang-format.diff
- name: Checking if diff is empty
run: if [ -s clang-format.diff ]; then cat clang-format.diff; exit 1; fi
- if: failure()
name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: clang-format-diff
path: clang-format.diff
retention-days: 3
linux-testing:
name: ${{ matrix.device_type }},bknd=${{ matrix.backend }},cmplr=${{ matrix.cxx_compiler }},${{ matrix.os }},std=с++${{ matrix.std }},cfg=${{ matrix.build_type }}
runs-on: ['${{ matrix.os }}']
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
cxx_compiler: icpx
std: 17
build_type: release
backend: dpcpp
device_type: CPU
- os: ubuntu-latest
cxx_compiler: icpx
std: 17
build_type: release
backend: dpcpp
device_type: FPGA_EMU
- os: ubuntu-latest
cxx_compiler: icpx
std: 17
build_type: release
backend: tbb
device_type: HOST
- os: ubuntu-latest
cxx_compiler: icpx
std: 17
build_type: release
backend: omp
device_type: HOST
- os: ubuntu-latest
cxx_compiler: g++
std: 17
build_type: release
backend: omp
device_type: HOST
- os: ubuntu-latest
cxx_compiler: g++
std: 17
build_type: release
backend: tbb
device_type: HOST
- os: ubuntu-latest
cxx_compiler: g++
std: 17
build_type: release
backend: tbb
device_type: HOST
- os: ubuntu-latest
cxx_compiler: clang++
std: 17
build_type: release
backend: tbb
device_type: HOST
- os: ubuntu-latest
cxx_compiler: clang++
std: 17
build_type: release
backend: omp
device_type: HOST
- os: ubuntu-latest
cxx_compiler: clang++
std: 17
build_type: release
backend: tbb
device_type: HOST
- os: ubuntu-latest
cxx_compiler: icpx
std: 17
build_type: release
backend: tbb
device_type: HOST
- os: ubuntu-latest
cxx_compiler: g++
std: 17
build_type: release
backend: serial
device_type: HOST
- os: ubuntu-latest
cxx_compiler: icpx
std: 20
build_type: release
backend: dpcpp
device_type: CPU
- os: ubuntu-latest
cxx_compiler: icpx
std: 20
build_type: release
backend: tbb
device_type: HOST
- os: ubuntu-latest
cxx_compiler: icpx
std: 20
build_type: release
backend: omp
device_type: HOST
steps:
- uses: actions/checkout@v4
- name: Set up Intel APT repository
if: (matrix.backend == 'tbb' || matrix.backend == 'dpcpp' || matrix.cxx_compiler == 'icpx' || matrix.cxx_compiler == 'icx' || matrix.cxx_compiler == 'icx-cl' || matrix.cxx_compiler == 'dpcpp' || matrix.cxx_compiler == 'dpcpp-cl')
run: |
# https://www.intel.com/content/www/us/en/docs/oneapi/installation-guide-linux/2024-0/apt.html
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
| gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update -y
- name: Install Intel® oneAPI Threading Building Blocks
if: (matrix.backend == 'tbb' || matrix.backend == 'dpcpp')
run: |
sudo apt-get install intel-oneapi-tbb-devel -y
- name: Install Intel® oneAPI DPC++/C++ Compiler
if: (matrix.cxx_compiler == 'icpx' || matrix.cxx_compiler == 'icx' || matrix.cxx_compiler == 'icx-cl' || matrix.cxx_compiler == 'dpcpp' || matrix.cxx_compiler == 'dpcpp-cl')
run: |
sudo apt-get install intel-oneapi-compiler-dpcpp-cpp -y
# Avoid accidental use of a released version, keeping libpstloffload.so
sudo rm -rf ${LINUX_ONEAPI_PATH}/dpl/latest/include
- name: Install Intel® oneAPI DPC++/C++ Compiler SYCL* FPGA Emulator Runtime
if: (matrix.device_type == 'FPGA_EMU')
run: |
sudo apt-get install intel-oneapi-compiler-fpga -y
- name: Install OpenMP dependencies
if: (matrix.os == 'ubuntu-latest' && matrix.cxx_compiler == 'clang++' && matrix.backend == 'omp')
run: |
sudo apt-get install libomp5 libomp-dev -y
- name: Run testing
shell: bash
run: |
set -x
if [[ -f "${LINUX_ONEAPI_PATH}/setvars.sh" ]]; then
source ${LINUX_ONEAPI_PATH}/setvars.sh
fi
echo "::warning::CMake: $(cmake --version)"
echo "::warning::Compiler: $(${{ matrix.cxx_compiler }} --version)"
if [[ "${{ matrix.backend }}" == "dpcpp" ]]; then
make_targets="build-onedpl-sycl_iterator-tests build-onedpl-ranges-tests"
ctest_flags="-R (sycl_iterator_.*)|(std_ranges_.*)\.pass"
echo "::warning::dpcpp backend is set. Compile and run only sycl_iterator tests"
else
make_targets="build-onedpl-tests"
fi
mkdir build && cd build
lscpu
cmake -DCMAKE_CXX_STANDARD=${{ matrix.std }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} -DONEDPL_BACKEND=${{ matrix.backend }} -DONEDPL_DEVICE_TYPE=${{ matrix.device_type }} ..
make VERBOSE=1 -j${BUILD_CONCURRENCY} ${make_targets}
ctest --timeout ${TEST_TIMEOUT} --output-on-failure ${ctest_flags}
windows-testing:
name: ${{ matrix.device_type }},bknd=${{ matrix.backend }},cmplr=${{ matrix.cxx_compiler }},${{ matrix.os }},std=c++${{ matrix.std }},cfg=${{ matrix.build_type }}
runs-on: ['${{ matrix.os }}']
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
cxx_compiler: icx-cl
std: 17
build_type: release
backend: tbb
device_type: HOST
- os: windows-latest
cxx_compiler: cl
std: 17
build_type: release
backend: tbb
device_type: HOST
- os: windows-latest
cxx_compiler: icx
std: 17
build_type: release
backend: dpcpp
device_type: CPU
steps:
- uses: actions/checkout@v4
- name: Install Intel® oneAPI Threading Building Blocks
if: (matrix.backend == 'tbb' || matrix.backend == 'dpcpp')
shell: cmd
run: |
curl %WINDOWS_TBB_DOWNLOAD_LINK% --output tbb_install.exe
tbb_install.exe -s -a --silent --eula accept -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0
del tbb_install.exe
- name: Install Intel® oneAPI DPC++/C++ Compiler
shell: cmd
run: |
curl %WINDOWS_ICPX_DOWNLOAD_LINK% --output icpx_install.exe
icpx_install.exe -s -a --silent --eula accept -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0
del icpx_install.exe
:: Avoid accidental use of a released version
rd /s /q "%WINDOWS_ONEAPI_PATH%\dpl"
- name: Run testing
shell: cmd
run: |
if exist "%WINDOWS_ONEAPI_PATH%\setvars.bat" (
call "%WINDOWS_ONEAPI_PATH%\setvars.bat"
)
if "${{ matrix.cxx_compiler }}" == "cl" (
call "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
)
powershell $output = cmake --version; Write-Host ::warning::CMake: $output
powershell $output = ${{ matrix.cxx_compiler }} --version; Write-Host ::warning::Compiler: $output
if "${{ matrix.backend }}" == "dpcpp" (
set ninja_targets="build-onedpl-sycl_iterator-tests"
set ctest_flags=-R sycl_iterator_.*\.pass
echo ::warning::dpcpp backend is set. Compile and run only sycl_iterator tests
) else (
set ninja_targets=build-onedpl-tests
)
mkdir build && cd build
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=${{ matrix.std }} -DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} -DONEDPL_BACKEND=${{ matrix.backend }} -DONEDPL_DEVICE_TYPE=${{ matrix.device_type }} .. || goto :short_circuit_fail
ninja -j 2 -v %ninja_targets% || goto :short_circuit_fail
ctest --timeout %TEST_TIMEOUT% -C ${{ matrix.build_type }} --output-on-failure %ctest_flags% || goto :short_circuit_fail
exit /b 0
:: modify the default behaviour of shell:cmd, which exits with the status of a last command, in order not to unintentially miss an error
:short_circuit_fail
exit /b %errorlevel%
macos-testing:
name: HOST,bknd=${{ matrix.backend }},cmplr=${{ matrix.cxx_compiler }},${{ matrix.os }},std=c++${{ matrix.std }},cfg=${{ matrix.build_type }}
runs-on: ['${{ matrix.os }}']
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
cxx_compiler: clang++
std: 17
build_type: release
backend: omp
steps:
- uses: actions/checkout@v4
- name: Install OpenMP for Clang++
run: |
brew install libomp
- name: Run testing
shell: bash
run: |
set -x
echo "::warning::CMake: $(cmake --version)"
sysctl -a | grep machdep.cpu
# workaround for CMake not being able to find OpenMP: see https://discourse.cmake.org/t/how-to-find-openmp-with-clang-on-macos/8860
# -DCMAKE_POLICY_DEFAULT_CMP0074=NEW below is forced to make sure CMake uses <PackageName>_ROOT variables.
export OpenMP_ROOT=$(brew --prefix)/opt/libomp
mkdir build && cd build
cmake -DCMAKE_CXX_STANDARD=${{ matrix.std }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} -DONEDPL_BACKEND=${{ matrix.backend }} -DCMAKE_POLICY_DEFAULT_CMP0074=NEW ..
make VERBOSE=1 build-onedpl-tests -j${MACOS_BUILD_CONCURRENCY}
ctest --timeout ${TEST_TIMEOUT} --output-on-failure -E "${EXCLUDE_FROM_TESTING}"