Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Dinges <blender@dingto.org>2016-05-06 23:34:15 +0300
committerThomas Dinges <blender@dingto.org>2016-05-07 00:13:33 +0300
commit734d1aec3f93b8757533284330afc2ac651442bd (patch)
tree98bbf8ea18392b09355c8b041b7727f9af88b2c4
parentbd335f13fe3d25e8e6bb472acb9c727d1629e582 (diff)
Cycles: Make CUDA adaptive feature compile a Debug flag.
If the CUDA Toolkit is installed and the user is on Linux, adaptive, feature based CUDA runtime compile is now possible to enable via: * Environment flag CYCLES_CUDA_ADAPTIVE_COMPILE or * Debug menu (Debug value 256) in the Cycles UI.
-rw-r--r--intern/cycles/blender/addon/properties.py2
-rw-r--r--intern/cycles/blender/addon/ui.py4
-rw-r--r--intern/cycles/blender/blender_python.cpp2
-rw-r--r--intern/cycles/device/device_cuda.cpp42
-rw-r--r--intern/cycles/util/util_debug.cpp15
-rw-r--r--intern/cycles/util/util_debug.h15
6 files changed, 61 insertions, 19 deletions
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 6f8383fc0af..eed86a6e65a 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -594,6 +594,8 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
cls.debug_use_cpu_sse2 = BoolProperty(name="SSE2", default=True)
cls.debug_use_qbvh = BoolProperty(name="QBVH", default=True)
+ cls.debug_use_cuda_adaptive_compile = BoolProperty(name="Adaptive Compile", default=False)
+
cls.debug_opencl_kernel_type = EnumProperty(
name="OpenCL Kernel Type",
default='DEFAULT',
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index a4e6809390d..023841a7a17 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -1554,6 +1554,10 @@ class CyclesRender_PT_debug(CyclesButtonsPanel, Panel):
col.prop(cscene, "debug_use_qbvh")
col = layout.column()
+ col.label('CUDA Flags:')
+ col.prop(cscene, "debug_use_cuda_adaptive_compile")
+
+ col = layout.column()
col.label('OpenCL Flags:')
col.prop(cscene, "debug_opencl_kernel_type", text="Kernel")
col.prop(cscene, "debug_opencl_device_type", text="Device")
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index ceb9cbf242e..0161b5b192c 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -70,6 +70,8 @@ bool debug_flags_sync_from_scene(BL::Scene b_scene)
flags.cpu.sse3 = get_boolean(cscene, "debug_use_cpu_sse3");
flags.cpu.sse2 = get_boolean(cscene, "debug_use_cpu_sse2");
flags.cpu.qbvh = get_boolean(cscene, "debug_use_qbvh");
+ /* Synchronize CUDA flags. */
+ flags.cuda.adaptive_compile = get_boolean(cscene, "debug_use_cuda_adaptive_compile");
/* Synchronize OpenCL kernel type. */
switch(get_enum(cscene, "debug_opencl_kernel_type")) {
case 0:
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index f7c985e787d..5362623247f 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -41,11 +41,6 @@
#include "util_types.h"
#include "util_time.h"
-/* use feature-adaptive kernel compilation.
- * Requires CUDA toolkit to be installed and currently only works on Linux.
- */
-/* #define KERNEL_USE_ADAPTIVE */
-
CCL_NAMESPACE_BEGIN
#ifndef WITH_CUDA_DYNLOAD
@@ -245,6 +240,11 @@ public:
return true;
}
+ bool use_adaptive_compilation()
+ {
+ return DebugFlags().cuda.adaptive_compile;
+ }
+
string compile_kernel(const DeviceRequestedFeatures& requested_features)
{
/* compute cubin name */
@@ -252,6 +252,9 @@ public:
cuDeviceComputeCapability(&major, &minor, cuDevId);
string cubin;
+ /* adaptive compile */
+ bool use_adaptive_compile = use_adaptive_compilation();
+
/* attempt to use kernel provided with blender */
cubin = path_get(string_printf("lib/kernel_sm_%d%d.cubin", major, minor));
VLOG(1) << "Testing for pre-compiled kernel " << cubin;
@@ -264,17 +267,19 @@ public:
string kernel_path = path_get("kernel");
string md5 = path_files_md5_hash(kernel_path);
-#ifdef KERNEL_USE_ADAPTIVE
- string feature_build_options = requested_features.get_build_options();
- string device_md5 = util_md5_string(feature_build_options);
- cubin = string_printf("cycles_kernel_%s_sm%d%d_%s.cubin",
- device_md5.c_str(),
- major, minor,
- md5.c_str());
-#else
- (void)requested_features;
- cubin = string_printf("cycles_kernel_sm%d%d_%s.cubin", major, minor, md5.c_str());
-#endif
+ string feature_build_options;
+ if(use_adaptive_compile) {
+ feature_build_options = requested_features.get_build_options();
+ string device_md5 = util_md5_string(feature_build_options);
+ cubin = string_printf("cycles_kernel_%s_sm%d%d_%s.cubin",
+ device_md5.c_str(),
+ major, minor,
+ md5.c_str());
+ }
+ else {
+ (void)requested_features;
+ cubin = string_printf("cycles_kernel_sm%d%d_%s.cubin", major, minor, md5.c_str());
+ }
cubin = path_user_get(path_join("cache", cubin));
VLOG(1) << "Testing for locally compiled kernel " << cubin;
@@ -331,9 +336,8 @@ public:
"-DNVCC -D__KERNEL_CUDA_VERSION__=%d",
nvcc, major, minor, machine, kernel.c_str(), cubin.c_str(), include.c_str(), cuda_version);
-#ifdef KERNEL_USE_ADAPTIVE
- command += " " + feature_build_options;
-#endif
+ if(use_adaptive_compile)
+ command += " " + feature_build_options;
const char* extra_cflags = getenv("CYCLES_CUDA_EXTRA_CFLAGS");
if(extra_cflags) {
diff --git a/intern/cycles/util/util_debug.cpp b/intern/cycles/util/util_debug.cpp
index 448c6223765..80d177d2cae 100644
--- a/intern/cycles/util/util_debug.cpp
+++ b/intern/cycles/util/util_debug.cpp
@@ -57,6 +57,18 @@ void DebugFlags::CPU::reset()
qbvh = true;
}
+DebugFlags::CUDA::CUDA()
+ : adaptive_compile(false)
+{
+ reset();
+}
+
+void DebugFlags::CUDA::reset()
+{
+ if(getenv("CYCLES_CUDA_ADAPTIVE_COMPILE") != NULL)
+ adaptive_compile = true;
+}
+
DebugFlags::OpenCL::OpenCL()
: device_type(DebugFlags::OpenCL::DEVICE_ALL),
kernel_type(DebugFlags::OpenCL::KERNEL_DEFAULT),
@@ -123,6 +135,9 @@ std::ostream& operator <<(std::ostream &os,
<< " SSE3 : " << string_from_bool(debug_flags.cpu.sse3) << "\n"
<< " SSE2 : " << string_from_bool(debug_flags.cpu.sse2) << "\n";
+ os << "CUDA flags:\n"
+ << " Adaptive Compile: " << string_from_bool(debug_flags.cuda.adaptive_compile) << "\n";
+
const char *opencl_device_type,
*opencl_kernel_type;
switch(debug_flags.opencl.device_type) {
diff --git a/intern/cycles/util/util_debug.h b/intern/cycles/util/util_debug.h
index 6ec5188049d..641abcc0668 100644
--- a/intern/cycles/util/util_debug.h
+++ b/intern/cycles/util/util_debug.h
@@ -46,6 +46,18 @@ public:
bool qbvh;
};
+ /* Descriptor of CUDA feature-set to be used. */
+ struct CUDA {
+ CUDA();
+
+ /* Reset flags to their defaults. */
+ void reset();
+
+ /* Whether adaptive feature based runtime compile is enabled or not.
+ * Requires the CUDA Toolkit and only works on Linux atm. */
+ bool adaptive_compile;
+ };
+
/* Descriptor of OpenCL feature-set to be used. */
struct OpenCL {
OpenCL();
@@ -107,6 +119,9 @@ public:
/* Requested CPU flags. */
CPU cpu;
+ /* Requested CUDA flags. */
+ CUDA cuda;
+
/* Requested OpenCL flags. */
OpenCL opencl;