Commit: 99a6dba08626b739e349c284dcf7cb6175b9964a
Author: Werner, Stefan
Date:   Thu May 19 21:41:30 2022 +0200
Branches: cycles_oneapi
https://developer.blender.org/rB99a6dba08626b739e349c284dcf7cb6175b9964a

Build: More flexible oneAPI options, added explicit inlining threshold

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

M       CMakeLists.txt
M       intern/cycles/kernel/CMakeLists.txt

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51dff4d647e..455d617ba6b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -457,16 +457,13 @@ if(NOT APPLE)
   option(WITH_CYCLES_ONEAPI_BINARIES "Enable Ahead-Of-Time compilation for 
Cycles oneAPI device" OFF)
   option(WITH_CYCLES_ONEAPI_SYCL_HOST_ENABLED "Enable use of SYCL host (CPU) 
device execution by oneAPI implementation. This option is for debugging 
purposes and impacts GPU execution." OFF)
 
-  SET (CYCLES_ONEAPI_SYCL_TARGET GPUTarget CACHE STRING "oneAPI offload target 
to build binaries for")
-  # List of available options can be found here:
   # 
https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compilation/ahead-of-time-compilation.html
-  # Right now public Intel driver don't support this option, because 
corresponding HW haven't released yet
-  SET (CYCLES_ONEAPI_AOT_TARGETS "dg2" CACHE STRING "oneAPI GPU architectures 
to build binaries for")
+  SET (CYCLES_ONEAPI_SPIR64_GEN_DEVICES "dg2" CACHE STRING "oneAPI Intel GPU 
architectures to build binaries for")
+  SET (CYCLES_ONEAPI_SYCL_TARGETS spir64 spir64_gen CACHE STRING "oneAPI 
targets to build AOT binaries for")
 
-  mark_as_advanced(CYCLES_ONEAPI_SYCL_TARGET)
   mark_as_advanced(WITH_CYCLES_ONEAPI_SYCL_HOST_ENABLED)
-  mark_as_advanced(CYCLES_ONEAPI_SYCL_TARGET)
-  mark_as_advanced(CYCLES_ONEAPI_AOT_TARGETS)
+  mark_as_advanced(CYCLES_ONEAPI_SPIR64_GEN_DEVICES)
+  mark_as_advanced(CYCLES_ONEAPI_SYCL_TARGETS)
 endif()
 
 # Draw Manager
diff --git a/intern/cycles/kernel/CMakeLists.txt 
b/intern/cycles/kernel/CMakeLists.txt
index e00c3d93200..052a5656edd 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -717,6 +717,7 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
     ${SRC_UTIL_HEADERS}
   )
 
+  # SYCL_CPP_FLAGS is a variable that the user can set to pass extra compiler 
options
   set(sycl_compiler_flags
       ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_KERNEL_DEVICE_ONEAPI}
       -fsycl
@@ -727,11 +728,12 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
       -ffast-math
       -DNDEBUG
       -O2
+      -mllvm -inlinedefault-threshold=400
       -o ${cycles_kernel_oneapi_lib}
       -I${CMAKE_CURRENT_SOURCE_DIR}/..
       -I${LEVEL_ZERO_INCLUDE_DIR}
       ${LEVEL_ZERO_LIBRARY}
-      ${ONEAPI_DPCPP_FLAGS}
+      ${SYCL_CPP_FLAGS}
       )
 
 
@@ -739,13 +741,26 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
     list(APPEND sycl_compiler_flags -DWITH_ONEAPI_SYCL_HOST_ENABLED)
   endif()
 
-  set (CYCLES_ONEAPI_GPU_COMPILATION_OPTIONS "-internal_options 
'-ze-opt-large-register-file -ze-opt-regular-grf-kernel integrator_intersect'")
+  # Set defaults for spir64 and spir64_gen options
+  if (NOT DEFINED CYCLES_ONEAPI_SYCL_OPTIONS_spir64)
+    set(CYCLES_ONEAPI_SYCL_OPTIONS_spir64 "-internal_options 
'-ze-opt-large-register-file -ze-opt-regular-grf-kernel integrator_intersect'")
+  endif()
+  if (NOT DEFINED CYCLES_ONEAPI_SYCL_OPTIONS_spir64_gen)
+    SET (CYCLES_ONEAPI_SYCL_OPTIONS_spir64_gen "-device 
${CYCLES_ONEAPI_SPIR64_GEN_DEVICES} ${CYCLES_ONEAPI_SYCL_OPTIONS_spir64}" CACHE 
STRING "Extra build options for spir64_gen target")
+  endif()
+
   if (WITH_CYCLES_ONEAPI_BINARIES)
-    list(APPEND sycl_compiler_flags
-      -fsycl-targets=spir64,spir64_gen
-      -Xsycl-target-backend=spir64 "${CYCLES_ONEAPI_GPU_COMPILATION_OPTIONS}"
-      -Xsycl-target-backend=spir64_gen "-device ${CYCLES_ONEAPI_AOT_TARGETS} 
--format zebin ${CYCLES_ONEAPI_GPU_COMPILATION_OPTIONS}")
+    # Iterate over all targest and their options
+    list (JOIN CYCLES_ONEAPI_SYCL_TARGETS "," targets_string)
+    list (APPEND sycl_compiler_flags -fsycl-targets=${targets_string})
+    foreach(target ${CYCLES_ONEAPI_SYCL_TARGETS})
+      if(DEFINED CYCLES_ONEAPI_SYCL_OPTIONS_${target})
+        list (APPEND sycl_compiler_flags -Xsycl-target-backend=${target} 
"${CYCLES_ONEAPI_SYCL_OPTIONS_${target}}")
+      endif()
+    endforeach()
   else()
+    # If AOT is disabled, build for spir64
+    set (CYCLES_ONEAPI_GPU_COMPILATION_OPTIONS "-internal_options 
'-ze-opt-large-register-file -ze-opt-regular-grf-kernel integrator_intersect'")
     list(APPEND sycl_compiler_flags
       -fsycl-targets=spir64
       -Xsycl-target-backend=spir64 "${CYCLES_ONEAPI_GPU_COMPILATION_OPTIONS}")

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to