[Bf-blender-cvs] [79e57452982] cycles_oneapi: Cycles: Add intel/llvm sycl compiler support for Linux

Werner, Stefan noreply at git.blender.org
Tue Apr 26 15:30:36 CEST 2022


Commit: 79e57452982670000763c034564a934d3dba8db3
Author: Werner, Stefan
Date:   Tue Apr 26 15:28:48 2022 +0200
Branches: cycles_oneapi
https://developer.blender.org/rB79e57452982670000763c034564a934d3dba8db3

Cycles: Add intel/llvm sycl compiler support for Linux

Unlike the oneAPI compiler, the OSS llvm/sycl compiler does not
include a script to set the environment automatically.
The CMake script will now set LD_LIBRARY_PATH explicitly.

===================================================================

M	intern/cycles/kernel/CMakeLists.txt

===================================================================

diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index 1464f66e512..77ec35bb8b0 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -764,12 +764,15 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
     -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} ${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.
       string(REPLACE /Redist/ /Tools/ MSVC_TOOLS_DIR ${MSVC_REDIST_DIR})
       list(APPEND sycl_compiler_flags
 	      -L "${MSVC_TOOLS_DIR}/lib/x64"
@@ -777,18 +780,29 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
 	      -L "${WINDOWS_KITS_DIR}/Lib/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}/ucrt/x64")
       add_custom_command(
         OUTPUT ${cycles_kernel_oneapi_lib}
-	COMMAND ${CMAKE_COMMAND} -E env
-	        "LIB=${sycl_compiler_root}/../lib;${LIB}"
-		"PATH=${sycl_compiler_root}/../lib/ocloc;${sycl_compiler_root};${PATH}"
+	      COMMAND ${CMAKE_COMMAND} -E env
+	              "LIB=${sycl_compiler_root}/../lib;${LIB}"
+		            "PATH=${sycl_compiler_root}/../lib/ocloc;${sycl_compiler_root};${PATH}"
                 ${SYCL_COMPILER} ${sycl_compiler_flags}
         DEPENDS ${cycles_oneapi_kernel_sources})
     endif()
   else()
     list(APPEND sycl_compiler_flags -fPIC)
-    add_custom_command(
-      OUTPUT ${cycles_kernel_oneapi_lib}
-      COMMAND bash -c \"source ${sycl_compiler_root}/../../env/vars.sh&&${SYCL_COMPILER} ${sycl_compiler_flags}\"
-      DEPENDS ${cycles_oneapi_kernel_sources})
+    # 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} ${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.
+      add_custom_command(
+        OUTPUT ${cycles_kernel_oneapi_lib}
+        COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_DIR="${sycl_compiler_root}/lib:${LD_LIBRARY_DIR}"
+                ${SYCL_COMPILER} ${sycl_compiler_flags}
+        DEPENDS ${cycles_oneapi_kernel_sources})
+    endif()
   endif()
 
   delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${cycles_kernel_oneapi_lib}" ${CYCLES_INSTALL_PATH}/lib)



More information about the Bf-blender-cvs mailing list