Skip to content

Commit 4b77e94

Browse files
Merge pull request #1083 from IntelPython/fix-windows-code-split
Work-around for not applying -fsycl-device-code-split=per_kernel on Windows
2 parents 3247a80 + 73437f6 commit 4b77e94

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

conda-recipe/bld.bat

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set "INCLUDE=%BUILD_PREFIX%\include;%INCLUDE%"
66
"%PYTHON%" setup.py clean --all
77
set "SKBUILD_ARGS=-G Ninja -- -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icx"
88

9-
FOR %%V IN (14.0.0 15.0.0 16.0.0) DO @(
9+
FOR %%V IN (14.0.0 14 15.0.0 15 16.0.0 16) DO @(
1010
REM set DIR_HINT if directory exists
1111
IF EXIST "%BUILD_PREFIX%\Library\lib\clang\%%V\" (
1212
SET "SYCL_INCLUDE_DIR_HINT=%BUILD_PREFIX%\Library\lib\clang\%%V"
@@ -18,11 +18,13 @@ set "FN=Windows-IntelLLVM.cmake"
1818

1919
rem Save the original file, and copy patched file to
2020
rem fix the issue with IntelLLVM integration with cmake on Windows
21-
dir "%PLATFORM_DIR%\%FN%"
22-
copy /Y "%PLATFORM_DIR%\%FN%" .
23-
if errorlevel 1 exit 1
24-
copy /Y .github\workflows\Windows-IntelLLVM.cmake "%PLATFORM_DIR%"
25-
if errorlevel 1 exit 1
21+
if EXIST "%PLATFORM_DIR%" (
22+
dir "%PLATFORM_DIR%\%FN%"
23+
copy /Y "%PLATFORM_DIR%\%FN%" .
24+
if errorlevel 1 exit 1
25+
copy /Y .github\workflows\Windows-IntelLLVM.cmake "%PLATFORM_DIR%"
26+
if errorlevel 1 exit 1
27+
)
2628

2729
if NOT "%WHEELS_OUTPUT_FOLDER%"=="" (
2830
rem Install and assemble wheel package from the build bits

dpctl/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if(WIN32)
2323
set(CMAKE_CXX_FLAGS_DEBUG
2424
"${CMAKE_CXX_FLAGS_DEBUG} ${WARNING_FLAGS} -O0 -g1 -DDEBUG"
2525
)
26-
set(DPCTL_LDFLAGS "/link /NXCompat /DynamicBase")
26+
set(DPCTL_LDFLAGS "/NXCompat;/DynamicBase")
2727
elseif(UNIX)
2828
string(CONCAT WARNING_FLAGS
2929
"-Wall "
@@ -140,7 +140,8 @@ function(build_dpctl_ext _trgt _src _dest)
140140
target_compile_options(${_trgt} PRIVATE -fno-sycl-use-footer)
141141
endif()
142142
target_link_libraries(${_trgt} DPCTLSyclInterface)
143-
target_link_options(${_trgt} PRIVATE "LINKER:${DPCTL_LDFLAGS}")
143+
set(_linker_options "LINKER:${DPCTL_LDFLAGS}")
144+
target_link_options(${_trgt} PRIVATE ${_linker_options})
144145
python_extension_module(${_trgt})
145146
get_filename_component(_name_wle ${_generated_src} NAME_WLE)
146147
get_filename_component(_generated_src_dir ${_generated_src} DIRECTORY)

dpctl/tensor/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ add_custom_target(_dpctl4pybind11_deps
1515
_sycl_event_copy_capi_include
1616
)
1717

18+
if(WIN32)
19+
if (${CMAKE_VERSION} VERSION_LESS "3.23")
20+
# this is a work-around for target_link_options inserting option after -link option, cause
21+
# linker to ignore it.
22+
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel")
23+
endif()
24+
endif()
25+
1826
set(python_module_name _tensor_impl)
1927
pybind11_add_module(${python_module_name} MODULE
2028
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/tensor_py.cpp
@@ -29,7 +37,10 @@ pybind11_add_module(${python_module_name} MODULE
2937
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/device_support_queries.cpp
3038
)
3139
target_link_options(${python_module_name} PRIVATE -fsycl-device-code-split=per_kernel)
32-
target_link_options(${python_module_name} PRIVATE -fsycl-link-huge-device-code)
40+
if(UNIX)
41+
# this option is support on Linux only
42+
target_link_options(${python_module_name} PRIVATE -fsycl-link-huge-device-code)
43+
endif()
3344
target_include_directories(${python_module_name}
3445
PRIVATE
3546
${CMAKE_CURRENT_SOURCE_DIR}/../include

0 commit comments

Comments
 (0)