Skip to content

Work-around for not applying -fsycl-device-code-split=per_kernel on Windows #1083

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

Merged
merged 4 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions conda-recipe/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set "INCLUDE=%BUILD_PREFIX%\include;%INCLUDE%"
"%PYTHON%" setup.py clean --all
set "SKBUILD_ARGS=-G Ninja -- -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icx"

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

rem Save the original file, and copy patched file to
rem fix the issue with IntelLLVM integration with cmake on Windows
dir "%PLATFORM_DIR%\%FN%"
copy /Y "%PLATFORM_DIR%\%FN%" .
if errorlevel 1 exit 1
copy /Y .github\workflows\Windows-IntelLLVM.cmake "%PLATFORM_DIR%"
if errorlevel 1 exit 1
if EXIST "%PLATFORM_DIR%" (
dir "%PLATFORM_DIR%\%FN%"
copy /Y "%PLATFORM_DIR%\%FN%" .
if errorlevel 1 exit 1
copy /Y .github\workflows\Windows-IntelLLVM.cmake "%PLATFORM_DIR%"
if errorlevel 1 exit 1
)

if NOT "%WHEELS_OUTPUT_FOLDER%"=="" (
rem Install and assemble wheel package from the build bits
Expand Down
5 changes: 3 additions & 2 deletions dpctl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if(WIN32)
set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} ${WARNING_FLAGS} -O0 -g1 -DDEBUG"
)
set(DPCTL_LDFLAGS "/link /NXCompat /DynamicBase")
set(DPCTL_LDFLAGS "/NXCompat;/DynamicBase")
elseif(UNIX)
string(CONCAT WARNING_FLAGS
"-Wall "
Expand Down Expand Up @@ -140,7 +140,8 @@ function(build_dpctl_ext _trgt _src _dest)
target_compile_options(${_trgt} PRIVATE -fno-sycl-use-footer)
endif()
target_link_libraries(${_trgt} DPCTLSyclInterface)
target_link_options(${_trgt} PRIVATE "LINKER:${DPCTL_LDFLAGS}")
set(_linker_options "LINKER:${DPCTL_LDFLAGS}")
target_link_options(${_trgt} PRIVATE ${_linker_options})
python_extension_module(${_trgt})
get_filename_component(_name_wle ${_generated_src} NAME_WLE)
get_filename_component(_generated_src_dir ${_generated_src} DIRECTORY)
Expand Down
13 changes: 12 additions & 1 deletion dpctl/tensor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ add_custom_target(_dpctl4pybind11_deps
_sycl_event_copy_capi_include
)

if(WIN32)
if (${CMAKE_VERSION} VERSION_LESS "3.23")
# this is a work-around for target_link_options inserting option after -link option, cause
# linker to ignore it.
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel")
endif()
endif()

set(python_module_name _tensor_impl)
pybind11_add_module(${python_module_name} MODULE
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/tensor_py.cpp
Expand All @@ -29,7 +37,10 @@ pybind11_add_module(${python_module_name} MODULE
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/device_support_queries.cpp
)
target_link_options(${python_module_name} PRIVATE -fsycl-device-code-split=per_kernel)
target_link_options(${python_module_name} PRIVATE -fsycl-link-huge-device-code)
if(UNIX)
# this option is support on Linux only
target_link_options(${python_module_name} PRIVATE -fsycl-link-huge-device-code)
endif()
target_include_directories(${python_module_name}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../include
Expand Down