Remove usage WITH_CYCLES_CUDA_BINARIES in code, use check for
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 14 Jan 2013 17:30:33 +0000 (17:30 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 14 Jan 2013 17:30:33 +0000 (17:30 +0000)
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.

intern/cycles/CMakeLists.txt
intern/cycles/SConscript
intern/cycles/blender/addon/__init__.py
intern/cycles/device/device_cuda.cpp
intern/cycles/util/util_cuda.cpp
intern/cycles/util/util_cuda.h

index 3242acf3edd03c9db7f37ff3eb2d75ea1037adc3..048a2a50a7fe141d7046d6898bdf109a73118e68 100644 (file)
@@ -47,10 +47,6 @@ if(WITH_CYCLES_OSL)
        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)
index dcb684c4be78e56287b3bc167ec00795943d4de9..44a17ac0cd61393f7ceb17cdbeeed0dd8a203812 100644 (file)
@@ -53,9 +53,6 @@ if env['WITH_BF_CYCLES_OSL']:
     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())
index dddf7bafb1460067b9a113d6226078ba943e3af3..39871bc22898a4cef6cfd0e0fc977b4c8d26ab42 100644 (file)
@@ -40,7 +40,6 @@ class CyclesRender(bpy.types.RenderEngine):
     bl_use_shading_nodes = True
 
     def __init__(self):
-        engine.init()
         self.session = None
 
     def __del__(self):
@@ -88,6 +87,8 @@ def register():
     from . import properties
     from . import presets
 
+    engine.init()
+
     properties.register()
     ui.register()
     presets.register()
index 040f3044457c5a6be14300edeb5356598472d68f..ae540710b50baa07a0618ec66385c6a1508a4aed 100644 (file)
@@ -238,13 +238,16 @@ public:
                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 @@ public:
                printf("Kernel compilation finished in %.2lfs.\n", time_dt() - starttime);
 
                return cubin;
-#endif
        }
 
        bool load_kernels(bool experimental)
index 12cb0d3e254a3548339536b4cbd8cc5b0786142e..ddd8b0014655895a299e3dce8735bbcaca2bcacd 100644 (file)
@@ -376,21 +376,23 @@ bool cuLibraryInit()
        /* 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
index 9682f1cfe1d075ae758110374790413a20f4491e..69cf025de7733165aab71f004088ecd0674b16e8 100644 (file)
@@ -30,6 +30,7 @@ CCL_NAMESPACE_BEGIN
  * matrixMulDynlinkJIT in the CUDA SDK. */
 
 bool cuLibraryInit();
+bool cuHavePrecompiledKernels();
 string cuCompilerPath();
 
 CCL_NAMESPACE_END