-
Notifications
You must be signed in to change notification settings - Fork 766
[SYCL][UR] Add Windows debug libs to install target #17512
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: sycl
Are you sure you want to change the base?
Changes from all commits
b8631ed
0211c9c
763bc73
a23b230
a2e75e3
c3e02d1
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 |
---|---|---|
|
@@ -317,6 +317,109 @@ if("native_cpu" IN_LIST SYCL_ENABLE_BACKENDS) | |
endif() | ||
endif() | ||
|
||
if(CMAKE_SYSTEM_NAME STREQUAL Windows) | ||
# On Windows, also build/install debug libraries with the d suffix that are | ||
# compiled with /MDd so users can link against these in debug builds. | ||
include(ExternalProject) | ||
set(URD_BINARY_DIR ${CMAKE_BINARY_DIR}/unified-runtimed) | ||
set(URD_INSTALL_DIR ${URD_BINARY_DIR}/install) | ||
|
||
# This creates a subbuild which can be used in dependencies with the | ||
# unified-runtimed target. It invokes the install-unified-runtime-libraries | ||
# target to install the UR runtime libraries. | ||
ExternalProject_Add(unified-runtimed | ||
SOURCE_DIR ${UNIFIED_RUNTIME_SOURCE_DIR} | ||
BINARY_DIR ${URD_BINARY_DIR} | ||
INSTALL_DIR ${URD_INSTALL_DIR} | ||
INSTALL_COMMAND ${CMAKE_COMMAND} | ||
--build <BINARY_DIR> | ||
--target install-unified-runtime-libraries | ||
CMAKE_CACHE_ARGS | ||
-DCMAKE_BUILD_TYPE:STRING=Debug | ||
-DCMAKE_INSTALL_PREFIX:STRING=<INSTALL_DIR> | ||
# Enable d suffix on libraries | ||
-DUR_USE_DEBUG_POSTFIX:BOOL=ON | ||
# Don't build unnecessary targets in subbuild. | ||
-DUR_BUILD_EXAMPLES:BOOL=OFF | ||
-DUR_BUILD_TESTS:BOOL=OFF | ||
-DUR_BUILD_TOOLS:BOOL=OFF | ||
# Sanitizer layer is not supported on Windows. | ||
-DUR_ENABLE_SYMBOLIZER:BOOL=OFF | ||
# Inherit settings from parent build. | ||
-DUR_ENABLE_TRACING:BOOL=${UR_ENABLE_TRACING} | ||
-DUR_ENABLE_COMGR:BOOL=${UR_ENABLE_COMGR} | ||
-DUR_BUILD_ADAPTER_L0:BOOL=${UR_BUILD_ADAPTER_L0} | ||
-DUR_BUILD_ADAPTER_L0_V2:BOOL=${UR_BUILD_ADAPTER_L0_V2} | ||
-DUR_BUILD_ADAPTER_OPENCL:BOOL=${UR_BUILD_ADAPTER_OPENCL} | ||
-DUR_BUILD_ADAPTER_CUDA:BOOL=${UR_BUILD_ADAPTER_CUDA} | ||
-DUR_BUILD_ADAPTER_HIP:BOOL=${UR_BUILD_ADAPTER_HIP} | ||
-DUR_BUILD_ADAPTER_NATIVE_CPU:BOOL=${UR_BUILD_ADAPTER_NATIVE_CPU} | ||
-DUMF_BUILD_EXAMPLES:BOOL=${UMF_BUILD_EXAMPLES} | ||
-DUMF_BUILD_SAHRED_LIBRARY:BOOL=${UMF_BUILD_SHARED_LIBRARY} | ||
-DUMF_LINK_HWLOC_STATICALLY:BOOL=${UMF_LINK_HWLOC_STATICALLY} | ||
-DUMF_DISABLE_HWLOC:BOOL=${UMF_DISABLE_HWLOC} | ||
# TODO: Enable d suffix in UMF | ||
# -DUMF_USE_DEBUG_POSTFIX=ON | ||
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. Enable building |
||
) | ||
|
||
# Copy the debug UR runtime libraries to <build>/bin & <build>/lib for use in | ||
# the parent build, e.g. integration testing. | ||
set(URD_COPY_FILES) | ||
macro(urd_copy_library_to_build library) | ||
list(APPEND URD_COPY_FILES | ||
${LLVM_BINARY_DIR}/bin/${library}.dll | ||
${LLVM_BINARY_DIR}/lib/${library}.lib | ||
) | ||
add_custom_command( | ||
OUTPUT | ||
${LLVM_BINARY_DIR}/bin/${library}.dll | ||
${LLVM_BINARY_DIR}/lib/${library}.lib | ||
COMMAND ${CMAKE_COMMAND} -E copy | ||
${URD_INSTALL_DIR}/bin/${library}.dll | ||
${LLVM_BINARY_DIR}/bin/${library}.dll | ||
COMMAND ${CMAKE_COMMAND} -E copy | ||
${URD_INSTALL_DIR}/lib/${library}.lib | ||
${LLVM_BINARY_DIR}/lib/${library}.lib | ||
) | ||
endmacro() | ||
|
||
urd_copy_library_to_build(ur_loaderd) | ||
foreach(adapter ${SYCL_ENABLE_BACKENDS}) | ||
urd_copy_library_to_build(ur_adapter_${adapter}d) | ||
endforeach() | ||
# TODO: Also copy umfd.dll/umfd.lib | ||
# urd_copy_library_to_build(umfd) | ||
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. Copy |
||
|
||
add_custom_target(unified-runtimed-copy-to-build DEPENDS ${URD_COPY_FILES}) | ||
add_dependencies(unified-runtimed-copy-to-build unified-runtimed) | ||
|
||
# Add the debug UR runtime libraries to the parent install. | ||
install( | ||
FILES ${URD_INSTALL_DIR}/bin/ur_loaderd.dll | ||
DESTINATION "bin" COMPONENT unified-runtime-loader) | ||
install( | ||
FILES ${URD_INSTALL_DIR}/lib/ur_loaderd.lib | ||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT unified-runtime-loader) | ||
|
||
foreach(adapter ${SYCL_ENABLE_BACKENDS}) | ||
install( | ||
FILES ${URD_INSTALL_DIR}/bin/ur_adapter_${adapter}d.dll | ||
DESTINATION "bin" COMPONENT ur_adapter_${adapter}) | ||
install( | ||
FILES ${URD_INSTALL_DIR}/lib/ur_adapter_${adapter}d.lib | ||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT ur_adapter_${adapter}) | ||
add_dependencies(install-sycl-ur-adapter-${adapter} unified-runtimed) | ||
endforeach() | ||
|
||
# TODO: Also install umfd.dll/umfd.lib | ||
# install( | ||
# FILES ${URD_INSTALL_DIR}/bin/umfd.dll | ||
# DESTINATION "bin" COMPONENT unified-memory-framework) | ||
# install( | ||
# FILES ${URD_INSTALL_DIR}/lib/umfd.lib | ||
# DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT unified-memory-framework) | ||
Comment on lines
+414
to
+420
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. Add |
||
endif() | ||
|
||
install(TARGETS umf | ||
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT unified-memory-framework | ||
ARCHIVE DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT unified-memory-framework | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -197,20 +197,40 @@ function(add_ur_library name) | |
$<$<STREQUAL:$<TARGET_LINKER_FILE_NAME:${name}>,link.exe>:LINKER:/DEPENDENTLOADFLAG:0x2000> | ||
) | ||
endif() | ||
if(UR_USE_DEBUG_POSTFIX) | ||
set_target_properties(${name} PROPERTIES DEBUG_POSTFIX d) | ||
kbenzie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
endif() | ||
if(UR_EXTERNAL_DEPENDENCIES) | ||
add_dependencies(${name} ${UR_EXTERNAL_DEPENDENCIES}) | ||
endif() | ||
add_dependencies(unified-runtime-libraries ${name}) | ||
endfunction() | ||
|
||
if(NOT TARGET unified-runtime-libraries) | ||
add_custom_target(unified-runtime-libraries) | ||
endif() | ||
|
||
function(install_ur_library name) | ||
install(TARGETS ${name} | ||
COMPONENT unified-runtime | ||
EXPORT ${PROJECT_NAME}-targets | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT unified-runtime | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
) | ||
endfunction() | ||
|
||
if(NOT TARGET install-unified-runtime-libraries) | ||
add_custom_target(install-unified-runtime-libraries | ||
COMMAND ${CMAKE_COMMAND} | ||
-DCOMPONENT=unified-runtime | ||
-P ${CMAKE_BINARY_DIR}/cmake_install.cmake | ||
# TODO: Also install debug UMF runtime libraries component | ||
DEPENDS unified-runtime-libraries | ||
# TODO: Add dependency on building debug UMF libraries | ||
Comment on lines
+227
to
+230
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. Add command to install only 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. Please, see changes in oneapi-src/unified-memory-framework#1238 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. Thanks, I'll test this today. 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. This is mostly working, I've commented on the PR with one issue. |
||
) | ||
endif() | ||
|
||
include(FetchContent) | ||
|
||
function(FetchSource GIT_REPOSITORY GIT_TAG GIT_DIR DEST) | ||
|
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.
Windows generators might ignore
CMAKE_BUILD_TYPE
. Consider using a cmake argument--config Debug
instead.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.
That would need to be included in the install command?
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.
Yes, in the install command add:
--config Debug
. And perhaps leave-DCMAKE_BUILD_TYPE:STRING=Debug
here as well, just for the case whereUnix Makefiles
generator is used on Windows.