[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53792] trunk/blender/intern/cycles: Remove usage WITH_CYCLES_CUDA_BINARIES in code, use check for

Sergey Sharybin sergey.vfx at gmail.com
Mon Jan 14 18:30:34 CET 2013


Revision: 53792
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53792
Author:   nazgul
Date:     2013-01-14 17:30:33 +0000 (Mon, 14 Jan 2013)
Log Message:
-----------
Remove usage WITH_CYCLES_CUDA_BINARIES in code, use check for
precompiled cubins instead,

Logic here is following now:
- If there're precompiled cubins, assume CUDA compute is available,
  otherwise
- If cuda toolkit found, assume CUDA compute is available
- In all other cases CUDA compute is not available

For windows there're still check for only precompiled binaries,
no runtime compilation is allowed.

Ended up with such decision after discussion with Brecht. The thing
is, if we'll support runtime compilation on windows we'll end up
having lots of reports about different aspects of something doesn't
work (you need particular toolkit version, msvc installed, environment
variables set properly and so) and giving feedback on such reports
will waste time.

Modified Paths:
--------------
    trunk/blender/intern/cycles/CMakeLists.txt
    trunk/blender/intern/cycles/SConscript
    trunk/blender/intern/cycles/blender/addon/__init__.py
    trunk/blender/intern/cycles/device/device_cuda.cpp
    trunk/blender/intern/cycles/util/util_cuda.cpp
    trunk/blender/intern/cycles/util/util_cuda.h

Modified: trunk/blender/intern/cycles/CMakeLists.txt
===================================================================
--- trunk/blender/intern/cycles/CMakeLists.txt	2013-01-14 17:30:20 UTC (rev 53791)
+++ trunk/blender/intern/cycles/CMakeLists.txt	2013-01-14 17:30:33 UTC (rev 53792)
@@ -47,10 +47,6 @@
 	include_directories(${OSL_INCLUDES})
 endif()
 
-if(WITH_CYCLES_CUDA_BINARIES)
-	add_definitions(-DWITH_CUDA_BINARIES)
-endif()
-
 add_definitions(-DWITH_OPENCL)
 add_definitions(-DWITH_CUDA)
 add_definitions(-DWITH_MULTI)

Modified: trunk/blender/intern/cycles/SConscript
===================================================================
--- trunk/blender/intern/cycles/SConscript	2013-01-14 17:30:20 UTC (rev 53791)
+++ trunk/blender/intern/cycles/SConscript	2013-01-14 17:30:33 UTC (rev 53792)
@@ -53,9 +53,6 @@
     defs.append('WITH_OSL')
     incs.append(cycles['BF_OSL_INC'])
 
-if env['WITH_BF_CYCLES_CUDA_BINARIES']:
-    defs.append('WITH_CUDA_BINARIES')
-
 incs.extend('. bvh render device kernel kernel/osl kernel/svm util subd'.split())
 incs.extend('#intern/guardedalloc #source/blender/makesrna #source/blender/makesdna'.split())
 incs.extend('#source/blender/blenloader ../../source/blender/makesrna/intern'.split())

Modified: trunk/blender/intern/cycles/blender/addon/__init__.py
===================================================================
--- trunk/blender/intern/cycles/blender/addon/__init__.py	2013-01-14 17:30:20 UTC (rev 53791)
+++ trunk/blender/intern/cycles/blender/addon/__init__.py	2013-01-14 17:30:33 UTC (rev 53792)
@@ -40,7 +40,6 @@
     bl_use_shading_nodes = True
 
     def __init__(self):
-        engine.init()
         self.session = None
 
     def __del__(self):
@@ -88,6 +87,8 @@
     from . import properties
     from . import presets
 
+    engine.init()
+
     properties.register()
     ui.register()
     presets.register()

Modified: trunk/blender/intern/cycles/device/device_cuda.cpp
===================================================================
--- trunk/blender/intern/cycles/device/device_cuda.cpp	2013-01-14 17:30:20 UTC (rev 53791)
+++ trunk/blender/intern/cycles/device/device_cuda.cpp	2013-01-14 17:30:33 UTC (rev 53792)
@@ -238,13 +238,16 @@
 		if(path_exists(cubin))
 			return cubin;
 
-#if defined(WITH_CUDA_BINARIES) && defined(_WIN32)
-		if(major <= 1 && minor <= 2)
-			cuda_error(string_printf("CUDA device supported only compute capability 1.3 or up, found %d.%d.", major, minor));
-		else
-			cuda_error(string_printf("CUDA binary kernel for this graphics card compute capability (%d.%d) not found.", major, minor));
-		return "";
-#else
+#ifdef _WIN32
+		if(cuHavePrecompiledKernels()) {
+			if(major <= 1 && minor <= 2)
+				cuda_error(string_printf("CUDA device supported only compute capability 1.3 or up, found %d.%d.", major, minor));
+			else
+				cuda_error(string_printf("CUDA binary kernel for this graphics card compute capability (%d.%d) not found.", major, minor));
+			return "";
+		}
+#endif
+
 		/* if not, find CUDA compiler */
 		string nvcc = cuCompilerPath();
 
@@ -282,7 +285,6 @@
 		printf("Kernel compilation finished in %.2lfs.\n", time_dt() - starttime);
 
 		return cubin;
-#endif
 	}
 
 	bool load_kernels(bool experimental)

Modified: trunk/blender/intern/cycles/util/util_cuda.cpp
===================================================================
--- trunk/blender/intern/cycles/util/util_cuda.cpp	2013-01-14 17:30:20 UTC (rev 53791)
+++ trunk/blender/intern/cycles/util/util_cuda.cpp	2013-01-14 17:30:33 UTC (rev 53792)
@@ -376,21 +376,23 @@
 	/* cuda 4.0 */
 	CUDA_LIBRARY_FIND(cuCtxSetCurrent);
 
-#ifndef WITH_CUDA_BINARIES
+	if(cuHavePrecompiledKernels())
+		result = true;
 #ifdef _WIN32
-	return false; /* runtime build doesn't work at the moment */
-#else
-	if(cuCompilerPath() == "")
-		return false;
+	else if(cuCompilerPath() != "")
+		result = true;
 #endif
-#endif
 
-	/* success */
-	result = true;
-
 	return result;
 }
 
+bool cuHavePrecompiledKernels()
+{
+	string cubins_path = path_get("lib");
+
+	return path_exists(cubins_path);
+}
+
 string cuCompilerPath()
 {
 #ifdef _WIN32

Modified: trunk/blender/intern/cycles/util/util_cuda.h
===================================================================
--- trunk/blender/intern/cycles/util/util_cuda.h	2013-01-14 17:30:20 UTC (rev 53791)
+++ trunk/blender/intern/cycles/util/util_cuda.h	2013-01-14 17:30:33 UTC (rev 53792)
@@ -30,6 +30,7 @@
  * matrixMulDynlinkJIT in the CUDA SDK. */
 
 bool cuLibraryInit();
+bool cuHavePrecompiledKernels();
 string cuCompilerPath();
 
 CCL_NAMESPACE_END




More information about the Bf-blender-cvs mailing list