Repository navigation
[MAINT] Add Windows OS compiler workflow #2419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
0171b18
84ba234
95dd48d
7ddd835
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| # Open source SYCL build deps, loaded by os-llvm-sycl-build.yml and bumped by | ||
| # bump-sycl-deps.yml from intel/llvm devops/dependencies.json. | ||
| # Open source SYCL build deps, loaded by os-llvm-sycl-build.yml and | ||
| # os-llvm-sycl-build-windows.yml, and bumped by bump-sycl-deps.yml from | ||
| # intel/llvm devops/dependencies.json. | ||
| # Kept out of .github/workflows/ since GITHUB_TOKEN can't push workflow files. | ||
| DRIVER_PATH=2026-WW28 | ||
| OCLCPUEXP_FN=oclcpuexp-2026.22.6.1.17_160000_rel.tar.gz | ||
| WIN_OCLCPUEXP_FN=win-oclcpuexp-2026.22.6.1.17_160000_rel.zip | ||
| TBB_URL=https://github.com/uxlfoundation/oneTBB/releases/download/v2023.1.0/ | ||
| TBB_INSTALL_DIR=oneapi-tbb-2023.1.0 | ||
| TBB_FN=oneapi-tbb-2023.1.0-lin.tgz |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
| name: Build with Open Source LLVM SYCL compiler on Windows | ||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: [master] | ||
| workflow_dispatch: | ||
| inputs: | ||
| nightly-tag: | ||
| description: "intel/llvm nightly tag, e.g. nightly-2026-11-03 (default: latest with a Windows build)" | ||
| required: false | ||
| default: "" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| install-compiler: | ||
| name: Build with nightly build of DPC++ toolchain on Windows | ||
| runs-on: windows-latest | ||
| timeout-minutes: 120 | ||
|
|
||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| PINS: .github/sycl-build-deps.env | ||
|
|
||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Load pinned SYCL build deps | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| # checkout may convert line endings to CRLF | ||
| VARS=$(grep -E '^(DRIVER_PATH|WIN_OCLCPUEXP_FN)=' "${PINS}" | tr -d '\r' || true) | ||
| if [[ $(wc -l <<< "${VARS}") -ne 2 ]]; then | ||
| echo "::error::expected 2 pins in ${PINS}, got:" | ||
| echo "${VARS}" | ||
| exit 1 | ||
| fi | ||
| echo "${VARS}" | tee -a "${GITHUB_ENV}" | ||
|
|
||
| - name: Resolve nightly build | ||
| shell: bash | ||
| env: | ||
| NIGHTLY_TAG: ${{ inputs.nightly-tag }} | ||
| run: | | ||
| set -euo pipefail | ||
| if [[ -z "${NIGHTLY_TAG}" ]]; then | ||
| NIGHTLY_TAG=$(gh api 'repos/intel/llvm/releases?per_page=30' \ | ||
| --jq '[.[] | select(.tag_name | startswith("nightly-")) | ||
| | select(any(.assets[]; .name == "sycl_windows.tar.gz"))][0].tag_name // empty') | ||
| fi | ||
| if [[ ! "${NIGHTLY_TAG}" =~ ^nightly-[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then | ||
| echo "::error::unexpected nightly tag: ${NIGHTLY_TAG}" | ||
| exit 1 | ||
| fi | ||
| echo "NIGHTLY_TAG=${NIGHTLY_TAG}" | tee -a "${GITHUB_ENV}" | ||
|
|
||
| - name: Download and install nightly and components | ||
| shell: pwsh | ||
| run: | | ||
| $ErrorActionPreference = 'Stop' | ||
| $PSNativeCommandUseErrorActionPreference = $true | ||
| $ProgressPreference = 'SilentlyContinue' | ||
|
|
||
| $root = Join-Path $env:RUNNER_TEMP 'sycl_bundle' | ||
| $compiler = Join-Path $root 'dpcpp_compiler' | ||
| $oclcpu = Join-Path $root 'oclcpuexp' | ||
| New-Item -ItemType Directory -Force -Path $compiler, $oclcpu | Out-Null | ||
|
|
||
| gh release download $env:NIGHTLY_TAG -R intel/llvm -p sycl_windows.tar.gz -D $root | ||
| $bundle = Join-Path $root 'sycl_windows.tar.gz' | ||
| & "$env:SystemRoot\System32\tar.exe" -xzf $bundle -C $compiler | ||
| Remove-Item $bundle | ||
|
|
||
| gh release download $env:DRIVER_PATH -R intel/llvm -p $env:WIN_OCLCPUEXP_FN -D $root | ||
|
Comment on lines
+79
to
+84
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Unlike |
||
| $zip = Join-Path $root $env:WIN_OCLCPUEXP_FN | ||
| Expand-Archive -Path $zip -DestinationPath $oclcpu | ||
| Remove-Item $zip | ||
|
|
||
| # register the CPU runtime with the ICD loader without install.bat; | ||
| # runner steps are elevated, so the loader ignores OCL_ICD_FILENAMES | ||
| $vendors = 'HKLM:\SOFTWARE\Khronos\OpenCL\Vendors' | ||
| if (-not (Test-Path $vendors)) { | ||
| # -Force creates the missing parent keys | ||
| New-Item -Path $vendors -Force | Out-Null | ||
| } | ||
| New-ItemProperty -Path $vendors -Name (Join-Path $oclcpu 'intelocl64.dll') ` | ||
| -PropertyType DWord -Value 0 -Force | Out-Null | ||
| # the runtime directory on PATH also provides tbb12.dll | ||
| Add-Content -Path $env:GITHUB_ENV -Value "SYCL_BUNDLE_FOLDER=$root" | ||
| Add-Content -Path $env:GITHUB_PATH -Value $oclcpu | ||
| Add-Content -Path $env:GITHUB_PATH -Value (Join-Path $compiler 'bin') | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 | ||
| with: | ||
| python-version: '3.15' | ||
| architecture: x64 | ||
|
|
||
| - name: Create virtual environment | ||
| shell: pwsh | ||
| run: | | ||
| $ErrorActionPreference = 'Stop' | ||
| $PSNativeCommandUseErrorActionPreference = $true | ||
|
|
||
| $venv = Join-Path $env:RUNNER_TEMP 'venv' | ||
| python -m venv $venv | ||
| # dpctl adds <venv>\Library\bin to the DLL search path, so link it to | ||
| # the DPC++ runtime | ||
| New-Item -ItemType Directory -Path (Join-Path $venv 'Library') | Out-Null | ||
| New-Item -ItemType Junction -Path (Join-Path $venv 'Library\bin') ` | ||
| -Target (Join-Path $env:SYCL_BUNDLE_FOLDER 'dpcpp_compiler\bin') | Out-Null | ||
| Add-Content -Path $env:GITHUB_ENV -Value "VIRTUAL_ENV=$venv" | ||
| Add-Content -Path $env:GITHUB_PATH -Value (Join-Path $venv 'Scripts') | ||
|
|
||
| - name: Install dpctl dependencies | ||
| shell: pwsh | ||
| run: | | ||
| $ErrorActionPreference = 'Stop' | ||
| $PSNativeCommandUseErrorActionPreference = $true | ||
| python -m pip install numpy cython "setuptools<80" pytest scikit-build cmake ninja "versioneer[toml]==0.29" | ||
|
|
||
| - name: Report compiler version | ||
| shell: pwsh | ||
| run: clang-cl --version | ||
|
|
||
| - name: Run sycl-ls | ||
| shell: pwsh | ||
| run: | | ||
| $ErrorActionPreference = 'Stop' | ||
| $PSNativeCommandUseErrorActionPreference = $true | ||
| $devices = sycl-ls | ||
| $devices | ||
| if (-not ($devices -match '^\[opencl:cpu\]')) { | ||
| sycl-ls --verbose | ||
| Write-Output '::error::no OpenCL CPU device found' | ||
| exit 1 | ||
| } | ||
|
|
||
| - name: Build dpctl | ||
| shell: cmd | ||
| run: | | ||
| set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" | ||
| for /f "usebackq delims=" %%i in (`"%VSWHERE%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VS_PATH=%%i" | ||
| if not defined VS_PATH ( | ||
| echo ::error::Visual Studio with MSVC x64 tools not found | ||
| exit /b 1 | ||
| ) | ||
| call "%VS_PATH%\VC\Auxiliary\Build\vcvars64.bat" || exit /b 1 | ||
| rem -fsycl links sycl9.lib, which the linker looks up on LIB | ||
| set "LIB=%SYCL_BUNDLE_FOLDER%\dpcpp_compiler\lib;%LIB%" | ||
| rem link.exe can't link the LTO bitcode pybind11 would otherwise build | ||
| python scripts\build_locally.py --c-compiler=clang-cl.exe --cxx-compiler=clang-cl.exe ^ | ||
| --compiler-root="%SYCL_BUNDLE_FOLDER%\dpcpp_compiler\bin" ^ | ||
| --cmake-opts="-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF" || exit /b 1 | ||
|
|
||
| - name: Run lsplatforms | ||
| shell: pwsh | ||
| run: | | ||
| $ErrorActionPreference = 'Stop' | ||
| $PSNativeCommandUseErrorActionPreference = $true | ||
| python -m dpctl -f | ||
|
|
||
| - name: Run dpctl/tests | ||
| shell: pwsh | ||
| env: | ||
| SYCL_CACHE_PERSISTENT: 1 | ||
| run: | | ||
| $ErrorActionPreference = 'Stop' | ||
| $PSNativeCommandUseErrorActionPreference = $true | ||
| python -m pytest -sv dpctl/tests | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,11 @@ | ||
| cmake_minimum_required(VERSION 3.21...3.27 FATAL_ERROR) | ||
|
|
||
| # link clang-cl targets through the compiler driver | ||
| set(CMAKE_USER_MAKE_RULES_OVERRIDE_C | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/cmake/WindowsClangClLinkRules.cmake) | ||
| set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/cmake/WindowsClangClLinkRules.cmake) | ||
|
Comment on lines
+3
to
+7
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These if(NOT DEFINED CMAKE_USER_MAKE_RULES_OVERRIDE_CXX)
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ...)
endif() |
||
|
|
||
| project(dpctl | ||
| VERSION 0.24 | ||
| LANGUAGES CXX | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # CMake links clang-cl targets by calling the linker directly, so link options | ||
| # such as -fsycl never reach the compiler driver. Link through the driver | ||
| # instead, like Platform/Windows-IntelLLVM does for icx, passing linker flags | ||
| # with -Xlinker (clang-cl drops -Wl, arguments). | ||
|
|
||
| if(CMAKE_GENERATOR MATCHES "Visual Studio") | ||
| return() | ||
| endif() | ||
|
|
||
| foreach(_lang C CXX) | ||
| if(NOT CMAKE_${_lang}_COMPILER_ID STREQUAL "Clang" | ||
| OR NOT CMAKE_${_lang}_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC" | ||
| OR CMAKE_${_lang}_LINK_MODE STREQUAL "DRIVER") | ||
| continue() | ||
| endif() | ||
|
|
||
| if(NOT _dpctl_clang_cl_linker_flags_wrapped) | ||
| set(_dpctl_clang_cl_linker_flags_wrapped TRUE) | ||
| foreach(_t EXE SHARED MODULE) | ||
| foreach(_cfg "" _DEBUG _RELEASE _RELWITHDEBINFO _MINSIZEREL) | ||
| set(_var CMAKE_${_t}_LINKER_FLAGS${_cfg}_INIT) | ||
| separate_arguments(_flags WINDOWS_COMMAND "${${_var}}") | ||
| list(TRANSFORM _flags PREPEND "-Xlinker ") | ||
| list(JOIN _flags " " ${_var}) | ||
| endforeach() | ||
| endforeach() | ||
| set(CMAKE_LIBRARY_PATH_FLAG "-Xlinker /LIBPATH:") | ||
| set(CMAKE_LINK_DEF_FILE_FLAG "-Xlinker /DEF:") | ||
| endif() | ||
|
|
||
| set(CMAKE_${_lang}_LINK_MODE DRIVER) | ||
| set(CMAKE_${_lang}_LINKER_WRAPPER_FLAG "-Xlinker" " ") | ||
| unset(CMAKE_${_lang}_LINKER_WRAPPER_FLAG_SEP) | ||
| set(CMAKE_${_lang}_LINK_DEF_FILE_FLAG "-Xlinker /DEF:") | ||
| set(CMAKE_${_lang}_CREATE_WIN32_EXE "-Xlinker /subsystem:windows") | ||
| set(CMAKE_${_lang}_CREATE_CONSOLE_EXE "-Xlinker /subsystem:console") | ||
|
|
||
| set(CMAKE_${_lang}_LINK_EXECUTABLE | ||
| "${_CMAKE_VS_LINK_EXE}<CMAKE_${_lang}_COMPILER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <LINK_LIBRARIES> -link /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} ${CMAKE_END_TEMP_FILE}") | ||
| set(CMAKE_${_lang}_CREATE_SHARED_LIBRARY | ||
| "${_CMAKE_VS_LINK_DLL}<CMAKE_${_lang}_COMPILER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} -LD <LINK_FLAGS> <LINK_LIBRARIES> -link /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} ${CMAKE_END_TEMP_FILE}") | ||
| set(CMAKE_${_lang}_CREATE_SHARED_MODULE "${CMAKE_${_lang}_CREATE_SHARED_LIBRARY}") | ||
| endforeach() | ||
|
|
||
| unset(_lang) | ||
| unset(_t) | ||
| unset(_cfg) | ||
| unset(_var) | ||
| unset(_flags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GH_TOKENis set for the whole job, so the build and pytest steps, which run the PR's code, also get the token. Only the "Resolve nightly build" and "Download and install" steps usegh. CouldGH_TOKENmove into theenv:of those two steps?