Revision: 41730
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41730
Author: blendix
Date: 2011-11-10 12:52:17 +0000 (Thu, 10 Nov 2011)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/CMakeLists.txt
trunk/blender/intern/cycles/CMakeLists.txt
trunk/blender/intern/cycles/cmake/external_libs.cmake
trunk/blender/intern/cycles/device/device_cuda.cpp
trunk/blender/intern/cycles/kernel/CMakeLists.txt
trunk/blender/intern/cycles/util/util_cuda.cpp
Modified: trunk/blender/CMakeLists.txt
===================================================================
--- trunk/blender/CMakeLists.txt 2011-11-10 12:28:26 UTC (rev 41729)
+++ trunk/blender/CMakeLists.txt 2011-11-10 12:52:17 UTC (rev 41730)
@@ -214,8 +214,10 @@
option(WITH_PYTHON_INSTALL "Copy system python into the blender install
folder" ON)
# Cycles
-option(WITH_CYCLES "Enable Cycles Render Engine" ON)
-OPTION(WITH_CYCLES_TEST "Build cycles test application" OFF)
+option(WITH_CYCLES "Enable cycles Render
Engine" ON)
+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
option(WITH_MEM_JEMALLOC "Enable malloc replacement
(http://www.canonware.com/jemalloc)" OFF)
Modified: trunk/blender/intern/cycles/CMakeLists.txt
===================================================================
--- trunk/blender/intern/cycles/CMakeLists.txt 2011-11-10 12:28:26 UTC (rev
41729)
+++ trunk/blender/intern/cycles/CMakeLists.txt 2011-11-10 12:52:17 UTC (rev
41730)
@@ -49,6 +49,10 @@
add_definitions(-DWITH_PARTIO)
endif()
+if(WITH_CYCLES_CUDA_BINARIES)
+ add_definitions(-DWITH_CUDA_BINARIES)
+endif()
+
add_definitions(-DWITH_OPENCL)
add_definitions(-DWITH_CUDA)
add_definitions(-DWITH_MULTI)
@@ -72,3 +76,4 @@
add_subdirectory(render)
add_subdirectory(subd)
add_subdirectory(util)
+
Modified: trunk/blender/intern/cycles/cmake/external_libs.cmake
===================================================================
--- trunk/blender/intern/cycles/cmake/external_libs.cmake 2011-11-10
12:28:26 UTC (rev 41729)
+++ trunk/blender/intern/cycles/cmake/external_libs.cmake 2011-11-10
12:52:17 UTC (rev 41730)
@@ -85,3 +85,16 @@
add_definitions(-DBLENDER_PLUGIN)
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()
+
Modified: trunk/blender/intern/cycles/device/device_cuda.cpp
===================================================================
--- trunk/blender/intern/cycles/device/device_cuda.cpp 2011-11-10 12:28:26 UTC
(rev 41729)
+++ trunk/blender/intern/cycles/device/device_cuda.cpp 2011-11-10 12:52:17 UTC
(rev 41730)
@@ -223,6 +223,10 @@
if(path_exists(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 */
string nvcc = cuCompilerPath();
@@ -260,6 +264,7 @@
printf("Kernel compilation finished in %.2lfs.\n", time_dt() -
starttime);
return cubin;
+#endif
}
bool load_kernels()
Modified: trunk/blender/intern/cycles/kernel/CMakeLists.txt
===================================================================
--- trunk/blender/intern/cycles/kernel/CMakeLists.txt 2011-11-10 12:28:26 UTC
(rev 41729)
+++ trunk/blender/intern/cycles/kernel/CMakeLists.txt 2011-11-10 12:52:17 UTC
(rev 41730)
@@ -83,7 +83,33 @@
../util/util_transform.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
if(WITH_CYCLES_OSL)
Modified: trunk/blender/intern/cycles/util/util_cuda.cpp
===================================================================
--- trunk/blender/intern/cycles/util/util_cuda.cpp 2011-11-10 12:28:26 UTC
(rev 41729)
+++ trunk/blender/intern/cycles/util/util_cuda.cpp 2011-11-10 12:52:17 UTC
(rev 41730)
@@ -373,8 +373,14 @@
/* cuda 4.0 */
CUDA_LIBRARY_FIND(cuCtxSetCurrent);
+#ifndef WITH_CUDA_BINARIES
+#ifdef _WIN32
+ return false; /* runtime build doesn't work at the moment */
+#else
if(cuCompilerPath() == "")
return false;
+#endif
+#endif
/* success */
result = true;
@@ -401,7 +407,15 @@
else
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
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs