Skip to content

Commit 9be6ac3

Browse files
authored
Merge pull request #2419 from IntelPython/add-windows-os-compiler-workflow
[MAINT] Add Windows OS compiler workflow
2 parents 2ed816f + c1c9b41 commit 9be6ac3

7 files changed

Lines changed: 277 additions & 8 deletions

File tree

‎.github/sycl-build-deps.env‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# Open source SYCL build deps, loaded by os-llvm-sycl-build.yml and bumped by
2-
# bump-sycl-deps.yml from intel/llvm devops/dependencies.json.
1+
# Open source SYCL build deps, loaded by os-llvm-sycl-build.yml and
2+
# os-llvm-sycl-build-windows.yml, and bumped by bump-sycl-deps.yml from
3+
# intel/llvm devops/dependencies.json.
34
# Kept out of .github/workflows/ since GITHUB_TOKEN can't push workflow files.
45
DRIVER_PATH=2026-WW28
56
OCLCPUEXP_FN=oclcpuexp-2026.22.6.1.17_160000_rel.tar.gz
7+
WIN_OCLCPUEXP_FN=win-oclcpuexp-2026.22.6.1.17_160000_rel.zip
68
TBB_URL=https://github.com/uxlfoundation/oneTBB/releases/download/v2023.1.0/
79
TBB_INSTALL_DIR=oneapi-tbb-2023.1.0
810
TBB_FN=oneapi-tbb-2023.1.0-lin.tgz

‎.github/workflows/bump-sycl-deps.yml‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name: Bump open source SYCL build deps
22

33
# Syncs the oclcpuexp and oneTBB pins in .github/sycl-build-deps.env, used by
4-
# os-llvm-sycl-build.yml, with intel/llvm devops/dependencies.json.
4+
# os-llvm-sycl-build.yml and os-llvm-sycl-build-windows.yml, with intel/llvm
5+
# devops/dependencies.json.
56

67
on:
78
schedule:
@@ -63,16 +64,23 @@ jobs:
6364
6465
OCL_TAG=$(jq -er '.linux.oclcpu.github_tag' "${DEPS}")
6566
OCL_URL=$(jq -er '.linux.oclcpu.url' "${DEPS}")
67+
WIN_OCL_URL=$(jq -er '.windows.oclcpu.url' "${DEPS}")
6668
TBB_VER=$(jq -er '.linux.tbb.version' "${DEPS}")
6769
TBB_FULL_URL=$(jq -er '.linux.tbb.url' "${DEPS}")
6870
OCLCPUEXP_FN=${OCL_URL##*/}
71+
WIN_OCLCPUEXP_FN=${WIN_OCL_URL##*/}
6972
7073
# os-llvm-sycl-build.yml rebuilds these URLs from the pins
7174
[[ "${OCL_TAG}" =~ ^[0-9]{4}-WW[0-9]+$ ]] || fail "unexpected oclcpu tag: ${OCL_TAG}"
7275
[[ "${OCLCPUEXP_FN}" =~ ^oclcpuexp-[0-9A-Za-z._]+_rel\.tar\.gz$ ]] \
7376
|| fail "unexpected oclcpu asset: ${OCLCPUEXP_FN}"
7477
[[ "${OCL_URL}" == "https://github.com/intel/llvm/releases/download/${OCL_TAG}/${OCLCPUEXP_FN}" ]] \
7578
|| fail "unexpected oclcpu url: ${OCL_URL}"
79+
# both platforms download from the same DRIVER_PATH release
80+
[[ "${WIN_OCLCPUEXP_FN}" =~ ^win-oclcpuexp-[0-9A-Za-z._]+_rel\.zip$ ]] \
81+
|| fail "unexpected Windows oclcpu asset: ${WIN_OCLCPUEXP_FN}"
82+
[[ "${WIN_OCL_URL}" == "https://github.com/intel/llvm/releases/download/${OCL_TAG}/${WIN_OCLCPUEXP_FN}" ]] \
83+
|| fail "unexpected Windows oclcpu url: ${WIN_OCL_URL}"
7684
[[ "${TBB_VER}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || fail "unexpected tbb version: ${TBB_VER}"
7785
[[ "${TBB_FULL_URL}" == "https://github.com/uxlfoundation/oneTBB/releases/download/v${TBB_VER}/oneapi-tbb-${TBB_VER}-lin.tgz" ]] \
7886
|| fail "unexpected tbb url: ${TBB_FULL_URL}"
@@ -81,6 +89,7 @@ jobs:
8189
echo "llvm_sha=${LLVM_SHA}"
8290
echo "driver_tag=${OCL_TAG}"
8391
echo "oclcpuexp_fn=${OCLCPUEXP_FN}"
92+
echo "win_oclcpuexp_fn=${WIN_OCLCPUEXP_FN}"
8493
echo "tbb_ver=${TBB_VER}"
8594
echo "tbb_url=${TBB_FULL_URL%/*}/"
8695
echo "tbb_fn=${TBB_FULL_URL##*/}"
@@ -91,6 +100,7 @@ jobs:
91100
env:
92101
DRIVER_TAG: ${{ steps.resolve.outputs.driver_tag }}
93102
OCLCPUEXP_FN: ${{ steps.resolve.outputs.oclcpuexp_fn }}
103+
WIN_OCLCPUEXP_FN: ${{ steps.resolve.outputs.win_oclcpuexp_fn }}
94104
TBB_URL: ${{ steps.resolve.outputs.tbb_url }}
95105
TBB_FN: ${{ steps.resolve.outputs.tbb_fn }}
96106
TBB_DIR: ${{ steps.resolve.outputs.tbb_dir }}
@@ -99,6 +109,7 @@ jobs:
99109
sed -i -E \
100110
-e "s|^(DRIVER_PATH=).*|\1${DRIVER_TAG}|" \
101111
-e "s|^(OCLCPUEXP_FN=).*|\1${OCLCPUEXP_FN}|" \
112+
-e "s|^(WIN_OCLCPUEXP_FN=).*|\1${WIN_OCLCPUEXP_FN}|" \
102113
-e "s|^(TBB_URL=).*|\1${TBB_URL}|" \
103114
-e "s|^(TBB_INSTALL_DIR=).*|\1${TBB_DIR}|" \
104115
-e "s|^(TBB_FN=).*|\1${TBB_FN}|" \
@@ -114,9 +125,10 @@ jobs:
114125
delete-branch: true
115126
labels: autoupdate
116127
commit-message: |
117-
Bump oclcpuexp/oneTBB pins for os-llvm-sycl-build workflow
128+
Bump oclcpuexp/oneTBB pins for os-llvm-sycl-build workflows
118129
119130
oclcpuexp: ${{ steps.resolve.outputs.driver_tag }} / ${{ steps.resolve.outputs.oclcpuexp_fn }}
131+
oclcpuexp (Windows): ${{ steps.resolve.outputs.win_oclcpuexp_fn }}
120132
oneTBB: ${{ steps.resolve.outputs.tbb_ver }}
121133
intel/llvm: ${{ steps.resolve.outputs.llvm_sha }}
122134
title: "Bump open source SYCL build dependencies"
@@ -128,7 +140,10 @@ jobs:
128140
| --- | --- |
129141
| intel/llvm driver release | `${{ steps.resolve.outputs.driver_tag }}` |
130142
| oclcpuexp | `${{ steps.resolve.outputs.oclcpuexp_fn }}` |
143+
| oclcpuexp (Windows) | `${{ steps.resolve.outputs.win_oclcpuexp_fn }}` |
131144
| oneTBB | `${{ steps.resolve.outputs.tbb_ver }}` |
132145
133146
Pull requests opened by this workflow don't trigger CI: run
134-
**Build with Open Source LLVM SYCL compiler** on this branch before merging.
147+
**Build with Open Source LLVM SYCL compiler** and
148+
**Build with Open Source LLVM SYCL compiler on Windows** on this
149+
branch before merging.
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
name: Build with Open Source LLVM SYCL compiler on Windows
2+
on:
3+
pull_request:
4+
push:
5+
branches: [master]
6+
workflow_dispatch:
7+
inputs:
8+
nightly-tag:
9+
description: "intel/llvm nightly tag, e.g. nightly-2026-11-03 (default: latest with a Windows build)"
10+
required: false
11+
default: ""
12+
13+
permissions:
14+
contents: read
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
install-compiler:
22+
name: Build with nightly build of DPC++ toolchain on Windows
23+
runs-on: windows-latest
24+
timeout-minutes: 120
25+
26+
env:
27+
PINS: .github/sycl-build-deps.env
28+
29+
steps:
30+
- name: Checkout repo
31+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
32+
with:
33+
persist-credentials: false
34+
fetch-depth: 0
35+
36+
- name: Load pinned SYCL build deps
37+
shell: bash
38+
run: |
39+
set -euo pipefail
40+
# checkout may convert line endings to CRLF
41+
VARS=$(grep -E '^(DRIVER_PATH|WIN_OCLCPUEXP_FN)=' "${PINS}" | tr -d '\r' || true)
42+
if [[ $(wc -l <<< "${VARS}") -ne 2 ]]; then
43+
echo "::error::expected 2 pins in ${PINS}, got:"
44+
echo "${VARS}"
45+
exit 1
46+
fi
47+
echo "${VARS}" | tee -a "${GITHUB_ENV}"
48+
49+
- name: Resolve nightly build
50+
shell: bash
51+
env:
52+
GH_TOKEN: ${{ github.token }}
53+
NIGHTLY_TAG: ${{ inputs.nightly-tag }}
54+
run: |
55+
set -euo pipefail
56+
if [[ -z "${NIGHTLY_TAG}" ]]; then
57+
NIGHTLY_TAG=$(gh api 'repos/intel/llvm/releases?per_page=30' \
58+
--jq '[.[] | select(.tag_name | startswith("nightly-"))
59+
| select(any(.assets[]; .name == "sycl_windows.tar.gz"))][0].tag_name // empty')
60+
fi
61+
if [[ ! "${NIGHTLY_TAG}" =~ ^nightly-[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
62+
echo "::error::unexpected nightly tag: ${NIGHTLY_TAG}"
63+
exit 1
64+
fi
65+
echo "NIGHTLY_TAG=${NIGHTLY_TAG}" | tee -a "${GITHUB_ENV}"
66+
67+
- name: Download and install nightly and components
68+
shell: pwsh
69+
env:
70+
GH_TOKEN: ${{ github.token }}
71+
run: |
72+
$ErrorActionPreference = 'Stop'
73+
$PSNativeCommandUseErrorActionPreference = $true
74+
$ProgressPreference = 'SilentlyContinue'
75+
76+
$root = Join-Path $env:RUNNER_TEMP 'sycl_bundle'
77+
$compiler = Join-Path $root 'dpcpp_compiler'
78+
$oclcpu = Join-Path $root 'oclcpuexp'
79+
New-Item -ItemType Directory -Force -Path $compiler, $oclcpu | Out-Null
80+
81+
gh release download $env:NIGHTLY_TAG -R intel/llvm -p sycl_windows.tar.gz -D $root
82+
$bundle = Join-Path $root 'sycl_windows.tar.gz'
83+
& "$env:SystemRoot\System32\tar.exe" -xzf $bundle -C $compiler
84+
Remove-Item $bundle
85+
86+
gh release download $env:DRIVER_PATH -R intel/llvm -p $env:WIN_OCLCPUEXP_FN -D $root
87+
$zip = Join-Path $root $env:WIN_OCLCPUEXP_FN
88+
Expand-Archive -Path $zip -DestinationPath $oclcpu
89+
Remove-Item $zip
90+
91+
# register the CPU runtime with the ICD loader without install.bat;
92+
# runner steps are elevated, so the loader ignores OCL_ICD_FILENAMES
93+
$vendors = 'HKLM:\SOFTWARE\Khronos\OpenCL\Vendors'
94+
if (-not (Test-Path $vendors)) {
95+
# -Force creates the missing parent keys
96+
New-Item -Path $vendors -Force | Out-Null
97+
}
98+
New-ItemProperty -Path $vendors -Name (Join-Path $oclcpu 'intelocl64.dll') `
99+
-PropertyType DWord -Value 0 -Force | Out-Null
100+
# the runtime directory on PATH also provides tbb12.dll
101+
Add-Content -Path $env:GITHUB_ENV -Value "SYCL_BUNDLE_FOLDER=$root"
102+
Add-Content -Path $env:GITHUB_PATH -Value $oclcpu
103+
Add-Content -Path $env:GITHUB_PATH -Value (Join-Path $compiler 'bin')
104+
105+
- name: Setup Python
106+
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
107+
with:
108+
python-version: '3.15'
109+
architecture: x64
110+
111+
- name: Create virtual environment
112+
shell: pwsh
113+
run: |
114+
$ErrorActionPreference = 'Stop'
115+
$PSNativeCommandUseErrorActionPreference = $true
116+
117+
$venv = Join-Path $env:RUNNER_TEMP 'venv'
118+
python -m venv $venv
119+
# dpctl adds <venv>\Library\bin to the DLL search path, so link it to
120+
# the DPC++ runtime
121+
New-Item -ItemType Directory -Path (Join-Path $venv 'Library') | Out-Null
122+
New-Item -ItemType Junction -Path (Join-Path $venv 'Library\bin') `
123+
-Target (Join-Path $env:SYCL_BUNDLE_FOLDER 'dpcpp_compiler\bin') | Out-Null
124+
Add-Content -Path $env:GITHUB_ENV -Value "VIRTUAL_ENV=$venv"
125+
Add-Content -Path $env:GITHUB_PATH -Value (Join-Path $venv 'Scripts')
126+
127+
- name: Install dpctl dependencies
128+
shell: pwsh
129+
run: |
130+
$ErrorActionPreference = 'Stop'
131+
$PSNativeCommandUseErrorActionPreference = $true
132+
python -m pip install numpy cython "setuptools<80" pytest scikit-build cmake ninja "versioneer[toml]==0.29"
133+
134+
- name: Report compiler version
135+
shell: pwsh
136+
run: clang-cl --version
137+
138+
- name: Run sycl-ls
139+
shell: pwsh
140+
run: |
141+
$ErrorActionPreference = 'Stop'
142+
$PSNativeCommandUseErrorActionPreference = $true
143+
$devices = sycl-ls
144+
$devices
145+
if (-not ($devices -match '^\[opencl:cpu\]')) {
146+
sycl-ls --verbose
147+
Write-Output '::error::no OpenCL CPU device found'
148+
exit 1
149+
}
150+
151+
- name: Build dpctl
152+
shell: cmd
153+
run: |
154+
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
155+
for /f "usebackq delims=" %%i in (`"%VSWHERE%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VS_PATH=%%i"
156+
if not defined VS_PATH (
157+
echo ::error::Visual Studio with MSVC x64 tools not found
158+
exit /b 1
159+
)
160+
call "%VS_PATH%\VC\Auxiliary\Build\vcvars64.bat" || exit /b 1
161+
rem -fsycl links sycl9.lib, which the linker looks up on LIB
162+
set "LIB=%SYCL_BUNDLE_FOLDER%\dpcpp_compiler\lib;%LIB%"
163+
rem link.exe can't link the LTO bitcode pybind11 would otherwise build
164+
python scripts\build_locally.py --c-compiler=clang-cl.exe --cxx-compiler=clang-cl.exe ^
165+
--compiler-root="%SYCL_BUNDLE_FOLDER%\dpcpp_compiler\bin" ^
166+
--cmake-opts="-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF" || exit /b 1
167+
168+
- name: Run lsplatforms
169+
shell: pwsh
170+
run: |
171+
$ErrorActionPreference = 'Stop'
172+
$PSNativeCommandUseErrorActionPreference = $true
173+
python -m dpctl -f
174+
175+
- name: Run dpctl/tests
176+
shell: pwsh
177+
env:
178+
SYCL_CACHE_PERSISTENT: 1
179+
run: |
180+
$ErrorActionPreference = 'Stop'
181+
$PSNativeCommandUseErrorActionPreference = $true
182+
python -m pytest -sv dpctl/tests

‎CMakeLists.txt‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
cmake_minimum_required(VERSION 3.21...3.27 FATAL_ERROR)
22

3+
# link clang-cl targets through the compiler driver, unless the user
4+
# provides their own rules
5+
foreach(_lang C CXX)
6+
if(NOT DEFINED CMAKE_USER_MAKE_RULES_OVERRIDE_${_lang})
7+
set(CMAKE_USER_MAKE_RULES_OVERRIDE_${_lang}
8+
${CMAKE_CURRENT_SOURCE_DIR}/cmake/WindowsClangClLinkRules.cmake)
9+
endif()
10+
endforeach()
11+
312
project(dpctl
413
VERSION 0.24
514
LANGUAGES CXX
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# CMake links clang-cl targets by calling the linker directly, so link options
2+
# such as -fsycl never reach the compiler driver. Link through the driver
3+
# instead, like Platform/Windows-IntelLLVM does for icx, passing linker flags
4+
# with -Xlinker (clang-cl drops -Wl, arguments).
5+
6+
if(CMAKE_GENERATOR MATCHES "Visual Studio")
7+
return()
8+
endif()
9+
10+
foreach(_lang C CXX)
11+
if(NOT CMAKE_${_lang}_COMPILER_ID STREQUAL "Clang"
12+
OR NOT CMAKE_${_lang}_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC"
13+
OR CMAKE_${_lang}_LINK_MODE STREQUAL "DRIVER")
14+
continue()
15+
endif()
16+
17+
if(NOT _dpctl_clang_cl_linker_flags_wrapped)
18+
set(_dpctl_clang_cl_linker_flags_wrapped TRUE)
19+
foreach(_t EXE SHARED MODULE)
20+
foreach(_cfg "" _DEBUG _RELEASE _RELWITHDEBINFO _MINSIZEREL)
21+
set(_var CMAKE_${_t}_LINKER_FLAGS${_cfg}_INIT)
22+
separate_arguments(_flags WINDOWS_COMMAND "${${_var}}")
23+
list(TRANSFORM _flags PREPEND "-Xlinker ")
24+
list(JOIN _flags " " ${_var})
25+
endforeach()
26+
endforeach()
27+
set(CMAKE_LIBRARY_PATH_FLAG "-Xlinker /LIBPATH:")
28+
set(CMAKE_LINK_DEF_FILE_FLAG "-Xlinker /DEF:")
29+
endif()
30+
31+
set(CMAKE_${_lang}_LINK_MODE DRIVER)
32+
set(CMAKE_${_lang}_LINKER_WRAPPER_FLAG "-Xlinker" " ")
33+
unset(CMAKE_${_lang}_LINKER_WRAPPER_FLAG_SEP)
34+
set(CMAKE_${_lang}_LINK_DEF_FILE_FLAG "-Xlinker /DEF:")
35+
set(CMAKE_${_lang}_CREATE_WIN32_EXE "-Xlinker /subsystem:windows")
36+
set(CMAKE_${_lang}_CREATE_CONSOLE_EXE "-Xlinker /subsystem:console")
37+
38+
set(CMAKE_${_lang}_LINK_EXECUTABLE
39+
"${_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}")
40+
set(CMAKE_${_lang}_CREATE_SHARED_LIBRARY
41+
"${_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}")
42+
set(CMAKE_${_lang}_CREATE_SHARED_MODULE "${CMAKE_${_lang}_CREATE_SHARED_LIBRARY}")
43+
endforeach()
44+
45+
unset(_lang)
46+
unset(_t)
47+
unset(_cfg)
48+
unset(_var)
49+
unset(_flags)

‎dpctl/CMakeLists.txt‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ set(CYTHON_FLAGS "-t -w \"${CMAKE_SOURCE_DIR}\"")
66
find_package(Cython REQUIRED)
77

88
if(WIN32)
9+
# clang-cl reads -Wall as /Wall, i.e. -Weverything
10+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
11+
set(_dpctl_wall_flag "/W3 ")
12+
else()
13+
set(_dpctl_wall_flag "-Wall ")
14+
endif()
915
string(CONCAT WARNING_FLAGS
10-
"-Wall "
16+
"${_dpctl_wall_flag}"
1117
"-Wextra "
1218
"-Winit-self "
1319
"-Wunused-function "
@@ -35,7 +41,7 @@ if(WIN32)
3541
"${CMAKE_CXX_FLAGS_DEBUG} ${WARNING_FLAGS} ${SDL_FLAGS} -O1 -g1 -DDEBUG"
3642
)
3743
set(CMAKE_MODULE_LINKER_FLAGS_COVERAGE "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}")
38-
set(DPCTL_LDFLAGS "/NXCompat;/DynamicBase")
44+
set(DPCTL_LDFLAGS "/NXCompat,/DynamicBase")
3945
mark_as_advanced(
4046
CMAKE_CXX_FLAGS_COVERAGE
4147
CMAKE_C_FLAGS_COVERAGE

‎libsyclinterface/CMakeLists.txt‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,14 @@ configure_file(
181181
set(CMAKE_CXX_STANDARD 17)
182182

183183
if(WIN32)
184+
# clang-cl reads -Wall as /Wall, i.e. -Weverything
185+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
186+
set(_dpctl_wall_flag "/W3 ")
187+
else()
188+
set(_dpctl_wall_flag "-Wall ")
189+
endif()
184190
string(CONCAT WARNING_FLAGS
185-
"-Wall "
191+
"${_dpctl_wall_flag}"
186192
"-Wextra "
187193
"-Winit-self "
188194
"-Wunused-function "

0 commit comments

Comments
 (0)