forked from bartvdbraak/blender
Cycles: Add option for building CUDA kernels sequentially
Building the CUDA kernels takes quite a bit of memory, and when building all of them the combined usage can be too much on some systems (especially VMs). Therefore, this patch adds an option to force the build system to build them sequentially by making each build step depend on the previous kernel. Reviewers: brecht, sergey Differential Revision: https://developer.blender.org/D3623
This commit is contained in:
parent
53527ac10f
commit
b3ac3d13a2
@ -411,6 +411,8 @@ option(WITH_CYCLES_OSL "Build Cycles with OSL support" ${_init_CYCLES_OSL})
|
|||||||
option(WITH_CYCLES_OPENSUBDIV "Build Cycles with OpenSubdiv support" ${_init_CYCLES_OPENSUBDIV})
|
option(WITH_CYCLES_OPENSUBDIV "Build Cycles with OpenSubdiv support" ${_init_CYCLES_OPENSUBDIV})
|
||||||
option(WITH_CYCLES_CUDA_BINARIES "Build Cycles CUDA binaries" OFF)
|
option(WITH_CYCLES_CUDA_BINARIES "Build Cycles CUDA binaries" OFF)
|
||||||
option(WITH_CYCLES_CUBIN_COMPILER "Build cubins with nvrtc based compiler instead of nvcc" OFF)
|
option(WITH_CYCLES_CUBIN_COMPILER "Build cubins with nvrtc based compiler instead of nvcc" OFF)
|
||||||
|
option(WITH_CYCLES_CUDA_BUILD_SERIAL "Build cubins one after another (useful on machines with limited RAM)" OFF)
|
||||||
|
mark_as_advanced(WITH_CYCLES_CUDA_BUILD_SERIAL)
|
||||||
set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 CACHE STRING "CUDA architectures to build binaries for")
|
set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 CACHE STRING "CUDA architectures to build binaries for")
|
||||||
mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
|
mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
|
||||||
unset(PLATFORM_DEFAULT)
|
unset(PLATFORM_DEFAULT)
|
||||||
|
@ -357,8 +357,14 @@ if(WITH_CYCLES_CUDA_BINARIES)
|
|||||||
)
|
)
|
||||||
set(cuda_cubins)
|
set(cuda_cubins)
|
||||||
|
|
||||||
macro(CYCLES_CUDA_KERNEL_ADD arch name flags sources experimental)
|
macro(CYCLES_CUDA_KERNEL_ADD arch prev_arch name flags sources experimental)
|
||||||
set(cuda_cubin ${name}_${arch}.cubin)
|
set(cuda_cubin ${name}_${arch}.cubin)
|
||||||
|
|
||||||
|
set(kernel_sources ${sources})
|
||||||
|
if(NOT ${prev_arch} STREQUAL "none")
|
||||||
|
set(kernel_sources ${kernel_sources} ${name}_${prev_arch}.cubin)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(cuda_kernel_src "/kernels/cuda/${name}.cu")
|
set(cuda_kernel_src "/kernels/cuda/${name}.cu")
|
||||||
|
|
||||||
set(cuda_flags
|
set(cuda_flags
|
||||||
@ -402,7 +408,7 @@ if(WITH_CYCLES_CUDA_BINARIES)
|
|||||||
${cuda_flags}
|
${cuda_flags}
|
||||||
-v
|
-v
|
||||||
-cuda-toolkit-dir "${CUDA_TOOLKIT_ROOT_DIR}"
|
-cuda-toolkit-dir "${CUDA_TOOLKIT_ROOT_DIR}"
|
||||||
DEPENDS ${sources} cycles_cubin_cc)
|
DEPENDS ${kernel_sources} cycles_cubin_cc)
|
||||||
else()
|
else()
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${cuda_cubin}
|
OUTPUT ${cuda_cubin}
|
||||||
@ -413,7 +419,7 @@ if(WITH_CYCLES_CUDA_BINARIES)
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}${cuda_kernel_src}
|
${CMAKE_CURRENT_SOURCE_DIR}${cuda_kernel_src}
|
||||||
--ptxas-options="-v"
|
--ptxas-options="-v"
|
||||||
${cuda_flags}
|
${cuda_flags}
|
||||||
DEPENDS ${sources})
|
DEPENDS ${kernel_sources})
|
||||||
endif()
|
endif()
|
||||||
delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${cuda_cubin}" ${CYCLES_INSTALL_PATH}/lib)
|
delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${cuda_cubin}" ${CYCLES_INSTALL_PATH}/lib)
|
||||||
list(APPEND cuda_cubins ${cuda_cubin})
|
list(APPEND cuda_cubins ${cuda_cubin})
|
||||||
@ -421,18 +427,23 @@ if(WITH_CYCLES_CUDA_BINARIES)
|
|||||||
unset(cuda_debug_flags)
|
unset(cuda_debug_flags)
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
set(prev_arch "none")
|
||||||
foreach(arch ${CYCLES_CUDA_BINARIES_ARCH})
|
foreach(arch ${CYCLES_CUDA_BINARIES_ARCH})
|
||||||
if(${arch} MATCHES "sm_2.")
|
if(${arch} MATCHES "sm_2.")
|
||||||
message(STATUS "CUDA binaries for ${arch} are no longer supported, skipped.")
|
message(STATUS "CUDA binaries for ${arch} are no longer supported, skipped.")
|
||||||
else()
|
else()
|
||||||
# Compile regular kernel
|
# Compile regular kernel
|
||||||
CYCLES_CUDA_KERNEL_ADD(${arch} filter "" "${cuda_filter_sources}" FALSE)
|
CYCLES_CUDA_KERNEL_ADD(${arch} ${prev_arch} filter "" "${cuda_filter_sources}" FALSE)
|
||||||
CYCLES_CUDA_KERNEL_ADD(${arch} kernel "" "${cuda_sources}" FALSE)
|
CYCLES_CUDA_KERNEL_ADD(${arch} ${prev_arch} kernel "" "${cuda_sources}" FALSE)
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WITH_CYCLES_CUDA_SPLIT_KERNEL_BINARIES)
|
if(WITH_CYCLES_CUDA_SPLIT_KERNEL_BINARIES)
|
||||||
# Compile split kernel
|
# Compile split kernel
|
||||||
CYCLES_CUDA_KERNEL_ADD(${arch} kernel_split "-D __SPLIT__" ${cuda_sources} FALSE)
|
CYCLES_CUDA_KERNEL_ADD(${arch} ${prev_arch} kernel_split "-D __SPLIT__" "${cuda_sources}" FALSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WITH_CYCLES_CUDA_BUILD_SERIAL)
|
||||||
|
set(prev_arch ${arch})
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user