Cycles:
* Add back option to bundle CUDA kernel binaries with builds. * Disable runtime CUDA kernel compilation on Windows, couldn't get this working, since it seems to depend on visual studio being installed, even though for this particular case it shouldn't be needed. CMake only at the moment. * Runtime compilation on linux/mac should now work if nvcc is not installed in the default location, but available in PATH.
This commit is contained in:
@@ -214,8 +214,10 @@ endif()
|
|||||||
option(WITH_PYTHON_INSTALL "Copy system python into the blender install folder" ON)
|
option(WITH_PYTHON_INSTALL "Copy system python into the blender install folder" ON)
|
||||||
|
|
||||||
# Cycles
|
# Cycles
|
||||||
option(WITH_CYCLES "Enable Cycles Render Engine" ON)
|
option(WITH_CYCLES "Enable cycles Render Engine" ON)
|
||||||
OPTION(WITH_CYCLES_TEST "Build cycles test application" OFF)
|
option(WITH_CYCLES_TEST "Build cycles test application" OFF)
|
||||||
|
option(WITH_CYCLES_CUDA_BINARIES "Build cycles CUDA binaries" OFF)
|
||||||
|
set(CYCLES_CUDA_BINARIES_ARCH sm_13 sm_20 sm_21 CACHE STRING "CUDA architectures to build binaries for")
|
||||||
|
|
||||||
# disable for now, but plan to support on all platforms eventually
|
# disable for now, but plan to support on all platforms eventually
|
||||||
option(WITH_MEM_JEMALLOC "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF)
|
option(WITH_MEM_JEMALLOC "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF)
|
||||||
|
@@ -49,6 +49,10 @@ if(WITH_CYCLES_PARTIO)
|
|||||||
add_definitions(-DWITH_PARTIO)
|
add_definitions(-DWITH_PARTIO)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(WITH_CYCLES_CUDA_BINARIES)
|
||||||
|
add_definitions(-DWITH_CUDA_BINARIES)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_definitions(-DWITH_OPENCL)
|
add_definitions(-DWITH_OPENCL)
|
||||||
add_definitions(-DWITH_CUDA)
|
add_definitions(-DWITH_CUDA)
|
||||||
add_definitions(-DWITH_MULTI)
|
add_definitions(-DWITH_MULTI)
|
||||||
@@ -72,3 +76,4 @@ add_subdirectory(kernel)
|
|||||||
add_subdirectory(render)
|
add_subdirectory(render)
|
||||||
add_subdirectory(subd)
|
add_subdirectory(subd)
|
||||||
add_subdirectory(util)
|
add_subdirectory(util)
|
||||||
|
|
||||||
|
@@ -85,3 +85,16 @@ if(WITH_CYCLES_BLENDER)
|
|||||||
add_definitions(-DBLENDER_PLUGIN)
|
add_definitions(-DBLENDER_PLUGIN)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
# CUDA
|
||||||
|
|
||||||
|
if(WITH_CYCLES_CUDA_BINARIES)
|
||||||
|
find_package(CUDA) # Try to auto locate CUDA toolkit
|
||||||
|
if(CUDA_FOUND)
|
||||||
|
message(STATUS "CUDA nvcc = ${CUDA_NVCC_EXECUTABLE}")
|
||||||
|
else()
|
||||||
|
message(STATUS "CUDA compiler not found, disabling WITH_CYCLES_CUDA_BINARIES")
|
||||||
|
set(WITH_CYCLES_CUDA_BINARIES OFF)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
@@ -223,6 +223,10 @@ public:
|
|||||||
if(path_exists(cubin))
|
if(path_exists(cubin))
|
||||||
return cubin;
|
return cubin;
|
||||||
|
|
||||||
|
#ifdef WITH_CUDA_BINARIES
|
||||||
|
fprintf(stderr, "CUDA binary kernel for this graphics card not found.\n");
|
||||||
|
return "";
|
||||||
|
#else
|
||||||
/* if not, find CUDA compiler */
|
/* if not, find CUDA compiler */
|
||||||
string nvcc = cuCompilerPath();
|
string nvcc = cuCompilerPath();
|
||||||
|
|
||||||
@@ -260,6 +264,7 @@ public:
|
|||||||
printf("Kernel compilation finished in %.2lfs.\n", time_dt() - starttime);
|
printf("Kernel compilation finished in %.2lfs.\n", time_dt() - starttime);
|
||||||
|
|
||||||
return cubin;
|
return cubin;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool load_kernels()
|
bool load_kernels()
|
||||||
|
@@ -83,6 +83,32 @@ set(SRC_UTIL_HEADERS
|
|||||||
../util/util_transform.h
|
../util/util_transform.h
|
||||||
../util/util_types.h
|
../util/util_types.h
|
||||||
)
|
)
|
||||||
|
# CUDA module
|
||||||
|
|
||||||
|
if(WITH_CYCLES_CUDA_BINARIES)
|
||||||
|
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
|
||||||
|
set(CUDA_BITS 64)
|
||||||
|
else()
|
||||||
|
set(CUDA_BITS 32)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(cuda_sources kernel.cu ${headers} ${svm_headers})
|
||||||
|
set(cuda_cubins)
|
||||||
|
|
||||||
|
foreach(arch ${CYCLES_CUDA_BINARIES_ARCH})
|
||||||
|
set(cuda_cubin kernel_${arch}.cubin)
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${cuda_cubin}
|
||||||
|
COMMAND ${CUDA_NVCC_EXECUTABLE} -arch=${arch} -m${CUDA_BITS} --cubin ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cu --use_fast_math -o ${CMAKE_CURRENT_BINARY_DIR}/${cuda_cubin} --ptxas-options="-v" --maxrregcount=24 --opencc-options -OPT:Olimit=0 -I${CMAKE_CURRENT_SOURCE_DIR}/../util -I${CMAKE_CURRENT_SOURCE_DIR}/svm -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DNVCC
|
||||||
|
DEPENDS ${cuda_sources})
|
||||||
|
|
||||||
|
delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${cuda_cubin}" ${CYCLES_INSTALL_PATH}/lib)
|
||||||
|
list(APPEND cuda_cubins ${cuda_cubin})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_custom_target(cycles_kernel_cuda ALL DEPENDS ${cuda_cubins})
|
||||||
|
endif()
|
||||||
|
|
||||||
# OSL module
|
# OSL module
|
||||||
|
|
||||||
|
@@ -373,8 +373,14 @@ bool cuLibraryInit()
|
|||||||
/* cuda 4.0 */
|
/* cuda 4.0 */
|
||||||
CUDA_LIBRARY_FIND(cuCtxSetCurrent);
|
CUDA_LIBRARY_FIND(cuCtxSetCurrent);
|
||||||
|
|
||||||
|
#ifndef WITH_CUDA_BINARIES
|
||||||
|
#ifdef _WIN32
|
||||||
|
return false; /* runtime build doesn't work at the moment */
|
||||||
|
#else
|
||||||
if(cuCompilerPath() == "")
|
if(cuCompilerPath() == "")
|
||||||
return false;
|
return false;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* success */
|
/* success */
|
||||||
result = true;
|
result = true;
|
||||||
@@ -401,7 +407,15 @@ string cuCompilerPath()
|
|||||||
else
|
else
|
||||||
nvcc = path_join(defaultpath, executable);
|
nvcc = path_join(defaultpath, executable);
|
||||||
|
|
||||||
return (path_exists(nvcc))? nvcc: "";
|
if(path_exists(nvcc))
|
||||||
|
return nvcc;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
if(system("which nvcc") == 0)
|
||||||
|
return "nvcc";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
CCL_NAMESPACE_END
|
CCL_NAMESPACE_END
|
||||||
|
Reference in New Issue
Block a user