diff options
author | Xavier Hallade <xavier.hallade@intel.com> | 2022-10-06 21:49:53 +0300 |
---|---|---|
committer | Xavier Hallade <xavier.hallade@intel.com> | 2022-10-07 17:14:50 +0300 |
commit | 3714d3c3ce8a64a027012653ee8372617f0ce3f8 (patch) | |
tree | 7f1e5daef070a7b7745ee12dd1a69ca6322dd0e9 /intern | |
parent | 331f8500569df9b3b2aa776c5bcaad7b99c57295 (diff) |
Cycles: link oneAPI backend with debug version of sycl when in Debug
It fixes SYCL runtime issues in Debug builds that were due to mixing
Release and Debug MSVC runtimes.
This commit also removes specific handling of dpcpp compiler executable
to simplify the CMake implementation. Using it like clang++ works and
clang++ executable is also available from Intel oneAPI DPC++ compiler in
case it doesn't.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/device/CMakeLists.txt | 5 | ||||
-rw-r--r-- | intern/cycles/kernel/CMakeLists.txt | 92 |
2 files changed, 48 insertions, 49 deletions
diff --git a/intern/cycles/device/CMakeLists.txt b/intern/cycles/device/CMakeLists.txt index e5467121497..5516e97f34f 100644 --- a/intern/cycles/device/CMakeLists.txt +++ b/intern/cycles/device/CMakeLists.txt @@ -193,8 +193,11 @@ if (WITH_CYCLES_DEVICE_ONEAPI) set(cycles_kernel_oneapi_lib ${CMAKE_CURRENT_BINARY_DIR}/../kernel/libcycles_kernel_oneapi.so) endif() list(APPEND LIB - ${SYCL_LIBRARY} ${cycles_kernel_oneapi_lib} + "$<$<CONFIG:Debug>:${SYCL_LIBRARY_DEBUG}>" + "$<$<CONFIG:Release>:${SYCL_LIBRARY}>" + "$<$<CONFIG:RelWithDebInfo>:${SYCL_LIBRARY}>" + "$<$<CONFIG:MinSizeRel>:${SYCL_LIBRARY}>" ) add_definitions(-DWITH_ONEAPI) list(APPEND SRC diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index bbf8fb8682b..d678351e69b 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -758,7 +758,6 @@ if(WITH_CYCLES_DEVICE_ONEAPI) ${SYCL_CPP_FLAGS} ) - if (WITH_CYCLES_ONEAPI_SYCL_HOST_ENABLED) list(APPEND sycl_compiler_flags -DWITH_ONEAPI_SYCL_HOST_ENABLED) endif() @@ -826,36 +825,43 @@ if(WITH_CYCLES_DEVICE_ONEAPI) -D_CRT_SECURE_NO_DEPRECATE -DONEAPI_EXPORT) - if(sycl_compiler_compiler_name MATCHES "dpcpp") - # The oneAPI distribution calls the compiler "dpcpp" and comes with a script that sets environment variables. - add_custom_command( - OUTPUT ${cycles_kernel_oneapi_lib} - COMMAND "${sycl_compiler_root}/../../env/vars.bat" - COMMAND ${SYCL_COMPILER} $<$<CONFIG:Debug>:-g>$<$<CONFIG:RelWithDebInfo>:-g> ${sycl_compiler_flags} - DEPENDS ${cycles_oneapi_kernel_sources}) + string(REPLACE /Redist/ /Tools/ MSVC_TOOLS_DIR ${MSVC_REDIST_DIR}) + if(NOT CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) # case for Ninja on Windows + get_filename_component(cmake_mt_dir ${CMAKE_MT} DIRECTORY) + string(REPLACE /bin/ /Lib/ WINDOWS_KIT_DIR ${cmake_mt_dir}) + get_filename_component(WINDOWS_KIT_DIR "${WINDOWS_KIT_DIR}/../" ABSOLUTE) else() - # The open source SYCL compiler just goes by clang++ and does not have such a script. - # Set the variables manually. - string(REPLACE /Redist/ /Tools/ MSVC_TOOLS_DIR ${MSVC_REDIST_DIR}) - if(NOT CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) # case for Ninja on Windows - get_filename_component(cmake_mt_dir ${CMAKE_MT} DIRECTORY) - string(REPLACE /bin/ /Lib/ WINDOWS_KIT_DIR ${cmake_mt_dir}) - get_filename_component(WINDOWS_KIT_DIR "${WINDOWS_KIT_DIR}/../" ABSOLUTE) - else() - set(WINDOWS_KIT_DIR ${WINDOWS_KITS_DIR}/Lib/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}) - endif() - list(APPEND sycl_compiler_flags - -L "${MSVC_TOOLS_DIR}/lib/x64" - -L "${WINDOWS_KIT_DIR}/um/x64" - -L "${WINDOWS_KIT_DIR}/ucrt/x64") - add_custom_command( - OUTPUT ${cycles_kernel_oneapi_lib} - COMMAND ${CMAKE_COMMAND} -E env - "LIB=${sycl_compiler_root}/../lib" # for compiler to find sycl.lib - "PATH=${OCLOC_INSTALL_DIR};${sycl_compiler_root}" - ${SYCL_COMPILER} $<$<CONFIG:Debug>:-g>$<$<CONFIG:RelWithDebInfo>:-g> ${sycl_compiler_flags} - DEPENDS ${cycles_oneapi_kernel_sources}) + set(WINDOWS_KIT_DIR ${WINDOWS_KITS_DIR}/Lib/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}) endif() + list(APPEND sycl_compiler_flags + -L "${MSVC_TOOLS_DIR}/lib/x64" + -L "${WINDOWS_KIT_DIR}/um/x64" + -L "${WINDOWS_KIT_DIR}/ucrt/x64") + + set(sycl_compiler_flags_Release ${sycl_compiler_flags}) + set(sycl_compiler_flags_Debug ${sycl_compiler_flags}) + set(sycl_compiler_flags_RelWithDebInfo ${sycl_compiler_flags}) + set(sycl_compiler_flags_MinSizeRel ${sycl_compiler_flags}) + list(APPEND sycl_compiler_flags_RelWithDebInfo -g) + get_filename_component(sycl_library_debug_name ${SYCL_LIBRARY_DEBUG} NAME_WE) + list(APPEND sycl_compiler_flags_Debug + -g + -D_DEBUG + -nostdlib -Xclang --dependent-lib=msvcrtd + -Xclang --dependent-lib=${sycl_library_debug_name}) + + add_custom_command( + OUTPUT ${cycles_kernel_oneapi_lib} + COMMAND ${CMAKE_COMMAND} -E env + "LIB=${sycl_compiler_root}/../lib" # for compiler to find sycl.lib + "PATH=${OCLOC_INSTALL_DIR}\;${sycl_compiler_root}" + ${SYCL_COMPILER} + "$<$<CONFIG:Release>:${sycl_compiler_flags_Releas}>" + "$<$<CONFIG:RelWithDebInfo>:${sycl_compiler_flags_RelWithDebInfo}>" + "$<$<CONFIG:Debug>:${sycl_compiler_flags_Debug}>" + "$<$<CONFIG:MinSizeRel>:${sycl_compiler_flags_Release}>" + COMMAND_EXPAND_LISTS + DEPENDS ${cycles_oneapi_kernel_sources}) else() list(APPEND sycl_compiler_flags -fPIC) @@ -867,26 +873,16 @@ if(WITH_CYCLES_DEVICE_ONEAPI) # libpi_level_zero.so can be placed next to it and get found. list(APPEND sycl_compiler_flags -Wl,-rpath,'$$ORIGIN') - # The oneAPI distribution calls the compiler "dpcpp" and comes with a script that sets environment variables. - if(sycl_compiler_compiler_name MATCHES "dpcpp") - add_custom_command( - OUTPUT ${cycles_kernel_oneapi_lib} - COMMAND bash -c \"source ${sycl_compiler_root}/../../env/vars.sh&&${SYCL_COMPILER} $<$<CONFIG:Debug>:-g>$<$<CONFIG:RelWithDebInfo>:-g> ${sycl_compiler_flags}\" - DEPENDS ${cycles_oneapi_kernel_sources}) - else() - # The open source SYCL compiler just goes by clang++ and does not have such a script. - # Set the variables manually. - if(NOT IGC_INSTALL_DIR) - get_filename_component(IGC_INSTALL_DIR "${sycl_compiler_root}/../lib/igc" ABSOLUTE) - endif() - add_custom_command( - OUTPUT ${cycles_kernel_oneapi_lib} - COMMAND ${CMAKE_COMMAND} -E env - "LD_LIBRARY_PATH=${sycl_compiler_root}/../lib:${OCLOC_INSTALL_DIR}/lib:${IGC_INSTALL_DIR}/lib" - "PATH=${OCLOC_INSTALL_DIR}/bin:${sycl_compiler_root}:$ENV{PATH}" # env PATH is for compiler to find ld - ${SYCL_COMPILER} $<$<CONFIG:Debug>:-g>$<$<CONFIG:RelWithDebInfo>:-g> ${sycl_compiler_flags} - DEPENDS ${cycles_oneapi_kernel_sources}) + if(NOT IGC_INSTALL_DIR) + get_filename_component(IGC_INSTALL_DIR "${sycl_compiler_root}/../lib/igc" ABSOLUTE) endif() + add_custom_command( + OUTPUT ${cycles_kernel_oneapi_lib} + COMMAND ${CMAKE_COMMAND} -E env + "LD_LIBRARY_PATH=${sycl_compiler_root}/../lib:${OCLOC_INSTALL_DIR}/lib:${IGC_INSTALL_DIR}/lib" + "PATH=${OCLOC_INSTALL_DIR}/bin:${sycl_compiler_root}:$ENV{PATH}" # env PATH is for compiler to find ld + ${SYCL_COMPILER} $<$<CONFIG:Debug>:-g>$<$<CONFIG:RelWithDebInfo>:-g> ${sycl_compiler_flags} + DEPENDS ${cycles_oneapi_kernel_sources}) endif() if(NOT WITH_BLENDER) |