Skip to content

Commit af7756c

Browse files
committed
Fix Windows SYCL clang-cl pipeline
1 parent b9a167d commit af7756c

4 files changed

Lines changed: 17 additions & 73 deletions

File tree

.github/actions/setup-sycl-toolchain/action.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,11 @@ runs:
131131
$clangClPath = $clangCl.FullName
132132
}
133133
$clangBin = Split-Path $clangClPath -Parent
134-
$clangPath = Join-Path $clangBin 'clang.exe'
135-
$clangCxxPath = Join-Path $clangBin 'clang++.exe'
136-
if (-not (Test-Path $clangPath)) {
137-
throw "clang.exe was not found next to $clangClPath. Install the Visual Studio LLVM/Clang toolset on the Windows runner."
138-
}
139-
if (-not (Test-Path $clangCxxPath)) {
140-
throw "clang++.exe was not found next to $clangClPath. Install the Visual Studio LLVM/Clang toolset on the Windows runner."
141-
}
142-
$clangShortPath = Get-ShortPath $clangPath
143-
$clangCxxShortPath = Get-ShortPath $clangCxxPath
134+
$clangClShortPath = Get-ShortPath $clangClPath
144135
145-
"ITLABAI_CC=$clangShortPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
146-
"ITLABAI_CXX=$clangCxxShortPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
147-
"ITLABAI_ACPP_CPU_CXX=$clangCxxShortPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
148-
"ITLABAI_WINDOWS_CLANG_FLAGS=--target=x86_64-pc-windows-msvc" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
136+
"ITLABAI_CC=$clangClShortPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
137+
"ITLABAI_CXX=$clangClShortPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
138+
"ITLABAI_ACPP_CPU_CXX=$clangClShortPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
149139
"$clangBin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
150140
151141
- name: Configure Windows toolchain environment
@@ -187,8 +177,6 @@ runs:
187177
"-DCMAKE_INSTALL_PREFIX=$env:ACPP_INSTALL_DIR" `
188178
"-DCMAKE_C_COMPILER=$env:ITLABAI_CC" `
189179
"-DCMAKE_CXX_COMPILER=$env:ITLABAI_CXX" `
190-
"-DCMAKE_C_FLAGS=$env:ITLABAI_WINDOWS_CLANG_FLAGS" `
191-
"-DCMAKE_CXX_FLAGS=$env:ITLABAI_WINDOWS_CLANG_FLAGS" `
192180
-DCMAKE_C_COMPILER_LAUNCHER=ccache `
193181
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
194182
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

app/SYCL/CMakeLists.txt

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,57 +6,8 @@ add_executable(SYCL_Example
66
target_link_libraries(SYCL_Example PRIVATE layers_lib AdaptiveCpp::acpp-rt)
77

88
if(WIN32)
9-
target_compile_definitions(SYCL_Example PRIVATE _USE_MATH_DEFINES)
10-
11-
set(SYCL_EXAMPLE_KERNEL_OBJECT "${CMAKE_CURRENT_BINARY_DIR}/sycl_kernel.cpp.obj")
12-
set(_sycl_cpu_cxx "${ACPP_CPU_CXX}")
13-
if(NOT _sycl_cpu_cxx)
14-
get_filename_component(_sycl_compiler_dir "${CMAKE_CXX_COMPILER}" DIRECTORY)
15-
if(EXISTS "${_sycl_compiler_dir}/clang++.exe")
16-
set(_sycl_cpu_cxx "${_sycl_compiler_dir}/clang++.exe")
17-
endif()
18-
endif()
19-
if(NOT _sycl_cpu_cxx)
20-
message(FATAL_ERROR "ACPP_CPU_CXX must point to the Visual Studio LLVM clang++.exe when building SYCL on Windows")
21-
endif()
22-
23-
set(_sycl_kernel_command python "${ACPP_COMPILER}")
24-
if(ACPP_TARGETS)
25-
list(APPEND _sycl_kernel_command "--acpp-targets=${ACPP_TARGETS}")
26-
endif()
27-
list(APPEND _sycl_kernel_command
28-
"--acpp-cpu-cxx=${_sycl_cpu_cxx}"
29-
-std=c++20
30-
-fms-runtime-lib=dll
31-
-DITLABAI_HAS_SYCL
32-
-D_USE_MATH_DEFINES
33-
-I "${CMAKE_SOURCE_DIR}/include"
34-
)
35-
get_target_property(_acpp_include_dirs AdaptiveCpp::acpp-rt INTERFACE_INCLUDE_DIRECTORIES)
36-
foreach(_acpp_include_dir IN LISTS _acpp_include_dirs)
37-
list(APPEND _sycl_kernel_command -isystem "${_acpp_include_dir}")
38-
endforeach()
39-
list(APPEND _sycl_kernel_command
40-
-c "${CMAKE_CURRENT_SOURCE_DIR}/sycl_kernel.cpp"
41-
-o "${SYCL_EXAMPLE_KERNEL_OBJECT}"
42-
)
43-
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
44-
list(APPEND _sycl_kernel_command -g)
45-
else()
46-
list(APPEND _sycl_kernel_command -O2)
47-
endif()
48-
49-
add_custom_command(
50-
OUTPUT "${SYCL_EXAMPLE_KERNEL_OBJECT}"
51-
COMMAND ${_sycl_kernel_command}
52-
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/sycl_kernel.cpp"
53-
VERBATIM
54-
)
55-
set_source_files_properties("${SYCL_EXAMPLE_KERNEL_OBJECT}" PROPERTIES
56-
EXTERNAL_OBJECT TRUE
57-
GENERATED TRUE
58-
)
59-
target_sources(SYCL_Example PRIVATE "${SYCL_EXAMPLE_KERNEL_OBJECT}")
9+
target_sources(SYCL_Example PRIVATE sycl_kernel.cpp)
10+
target_compile_definitions(SYCL_Example PRIVATE _USE_MATH_DEFINES ITLABAI_HAS_SYCL)
6011
else()
6112
add_library(SYCL_Example_kernel OBJECT sycl_kernel.cpp)
6213
target_compile_definitions(SYCL_Example_kernel PRIVATE ITLABAI_HAS_SYCL)

src/layers/CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ target_link_libraries(layers_lib PUBLIC Kokkos_imported)
99
if(ITLABAI_ENABLE_SYCL)
1010
find_package(AdaptiveCpp CONFIG REQUIRED)
1111
target_compile_definitions(layers_lib PUBLIC ITLABAI_HAS_SYCL)
12-
target_link_libraries(layers_lib PUBLIC AdaptiveCpp::acpp-rt)
1312
if(WIN32)
14-
set_property(TARGET layers_lib PROPERTY CXX_COMPILER_LAUNCHER "")
13+
target_compile_definitions(layers_lib PUBLIC
14+
_ENABLE_EXTENDED_ALIGNED_STORAGE
15+
_USE_MATH_DEFINES
16+
__ACPP_ENABLE_OMPHOST_TARGET__
17+
)
18+
endif()
19+
target_link_libraries(layers_lib PUBLIC AdaptiveCpp::acpp-rt)
20+
if(NOT WIN32)
21+
add_sycl_to_target(TARGET layers_lib SOURCES ${layers_src})
1522
endif()
16-
add_sycl_to_target(TARGET layers_lib SOURCES ${layers_src})
1723
endif()

test/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ itlabai_copy_opencv_runtime(run_test)
1313

1414
if(ITLABAI_ENABLE_SYCL)
1515
find_package(AdaptiveCpp CONFIG REQUIRED)
16-
if(WIN32)
17-
set_property(TARGET run_test PROPERTY CXX_COMPILER_LAUNCHER "")
16+
if(NOT WIN32)
17+
add_sycl_to_target(TARGET run_test SOURCES ${TEST_SRC_FILES})
1818
endif()
19-
add_sycl_to_target(TARGET run_test SOURCES ${TEST_SRC_FILES})
2019
endif()
2120

2221
target_include_directories(run_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")

0 commit comments

Comments
 (0)