From e5179bfefc649cca07077d34d13c574e712d82d0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 14 Jan 2013 17:30:33 +0000 Subject: [PATCH] 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. --- intern/cycles/CMakeLists.txt | 4 ---- intern/cycles/SConscript | 3 --- intern/cycles/blender/addon/__init__.py | 3 ++- intern/cycles/device/device_cuda.cpp | 18 ++++++++++-------- intern/cycles/util/util_cuda.cpp | 20 +++++++++++--------- intern/cycles/util/util_cuda.h | 1 + 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index 3242acf3edd..048a2a50a7f 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -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) diff --git a/intern/cycles/SConscript b/intern/cycles/SConscript index dcb684c4be7..44a17ac0cd6 100644 --- a/intern/cycles/SConscript +++ b/intern/cycles/SConscript @@ -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()) diff --git a/intern/cycles/blender/addon/__init__.py b/intern/cycles/blender/addon/__init__.py index dddf7bafb14..39871bc2289 100644 --- a/intern/cycles/blender/addon/__init__.py +++ b/intern/cycles/blender/addon/__init__.py @@ -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() diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 040f3044457..ae540710b50 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -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) diff --git a/intern/cycles/util/util_cuda.cpp b/intern/cycles/util/util_cuda.cpp index 12cb0d3e254..ddd8b001465 100644 --- a/intern/cycles/util/util_cuda.cpp +++ b/intern/cycles/util/util_cuda.cpp @@ -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 diff --git a/intern/cycles/util/util_cuda.h b/intern/cycles/util/util_cuda.h index 9682f1cfe1d..69cf025de77 100644 --- a/intern/cycles/util/util_cuda.h +++ b/intern/cycles/util/util_cuda.h @@ -30,6 +30,7 @@ CCL_NAMESPACE_BEGIN * matrixMulDynlinkJIT in the CUDA SDK. */ bool cuLibraryInit(); +bool cuHavePrecompiledKernels(); string cuCompilerPath(); CCL_NAMESPACE_END