[Bf-blender-cvs] [12458daa766] cycles_oneapi: Cycles oneAPI: Tweaks to support pre-compiled DPC++

Sergey Sharybin noreply at git.blender.org
Wed Jun 8 11:16:54 CEST 2022


Commit: 12458daa7666d352b40cac4f307db7cca966f77c
Author: Sergey Sharybin
Date:   Wed Jun 8 11:13:22 2022 +0200
Branches: cycles_oneapi
https://developer.blender.org/rB12458daa7666d352b40cac4f307db7cca966f77c

Cycles oneAPI: Tweaks to support pre-compiled DPC++

Compilation of Blender and kernel now works on Linux (did not test Windows).

Ahead-of-time compilation of kernels does not work because the compiled OCLOC
uses shared linking to its components and it seems to need special handling.

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

M	build_files/cmake/Modules/FindSYCL.cmake
M	build_files/cmake/platform/platform_unix.cmake
M	intern/cycles/cmake/external_libs.cmake

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

diff --git a/build_files/cmake/Modules/FindSYCL.cmake b/build_files/cmake/Modules/FindSYCL.cmake
index fcd8eaaa97b..227858eefb1 100644
--- a/build_files/cmake/Modules/FindSYCL.cmake
+++ b/build_files/cmake/Modules/FindSYCL.cmake
@@ -23,6 +23,11 @@ SET(_sycl_search_dirs
   C:/Program\ Files\ \(x86\)/Intel/oneAPI/compiler/latest/windows
 )
 
+# Find DPC++ compiler.
+# Since the compiler name is possibly conflicting with the system-wide
+# CLang start with looking for either dpcpp or clang binary in the given
+# list of search paths only. If that fails, try to look for a system-wide
+# dpcpp binary.
 FIND_PROGRAM(SYCL_COMPILER
   NAMES
     dpcpp
@@ -31,8 +36,22 @@ FIND_PROGRAM(SYCL_COMPILER
     ${_sycl_search_dirs}
   PATH_SUFFIXES
     bin
+  NO_CMAKE_FIND_ROOT_PATH
 )
 
+# NOTE: No clang++ here so that we do not pick up a system-wide CLang
+# compiler.
+if(NOT SYCL_COMPILER)
+  FIND_PROGRAM(SYCL_COMPILER
+   NAMES
+      dpcpp
+    HINTS
+      ${_sycl_search_dirs}
+    PATH_SUFFIXES
+      bin
+  )
+endif()
+
 FIND_LIBRARY(SYCL_LIBRARY
   NAMES
     sycl
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index 20771c47155..90d21463f0e 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -276,6 +276,11 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
   if(EXISTS ${CYCLES_LEVEL_ZERO} AND NOT LEVEL_ZERO_ROOT_DIR)
     set(LEVEL_ZERO_ROOT_DIR ${CYCLES_LEVEL_ZERO})
   endif()
+
+  set(CYCLES_SYCL ${LIBDIR}/dpcpp CACHE PATH "Path to DPC++ and SYCL installation")
+  if(EXISTS ${CYCLES_SYCL} AND NOT SYCL_ROOT_DIR)
+    set(SYCL_ROOT_DIR ${CYCLES_SYCL})
+  endif()
 endif()
 
 if(WITH_OPENVDB)
diff --git a/intern/cycles/cmake/external_libs.cmake b/intern/cycles/cmake/external_libs.cmake
index 6bcd8152874..51830250f2e 100644
--- a/intern/cycles/cmake/external_libs.cmake
+++ b/intern/cycles/cmake/external_libs.cmake
@@ -92,6 +92,7 @@ if(CYCLES_STANDALONE_REPOSITORY)
     _set_default(WEBP_ROOT_DIR "${_cycles_lib_dir}/webp")
     _set_default(ZLIB_ROOT "${_cycles_lib_dir}/zlib")
     _set_default(LEVEL_ZERO_ROOT_DIR "${_cycles_lib_dir}/level-zero")
+    _set_default(SYCL_ROOT_DIR "${_cycles_lib_dir}/dpcpp")
 
     # Ignore system libraries
     set(CMAKE_IGNORE_PATH "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES};${CMAKE_SYSTEM_INCLUDE_PATH};${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES};${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}")
@@ -652,6 +653,7 @@ endif()
 ###########################################################################
 # oneAPI
 ###########################################################################
+
 if (WITH_CYCLES_DEVICE_ONEAPI)
   find_package(SYCL)
   find_package(LevelZero)



More information about the Bf-blender-cvs mailing list