diff options
author | Mai Lavelle <mai.lavelle@gmail.com> | 2017-07-06 03:16:41 +0300 |
---|---|---|
committer | Mai Lavelle <mai.lavelle@gmail.com> | 2017-07-06 12:25:46 +0300 |
commit | 9c3f1ad003fcee40ca8f6d8091461bb8cee3db33 (patch) | |
tree | 80dd526f0d49a231f2581eb2a9735b865929fae5 /intern/cycles/device | |
parent | 95b345b2fe42573e0fad4c30adb865fd675316fc (diff) |
Cycles: Add artificial memory limit debug option for OpenCL
Diffstat (limited to 'intern/cycles/device')
-rw-r--r-- | intern/cycles/device/opencl/opencl_base.cpp | 5 | ||||
-rw-r--r-- | intern/cycles/device/opencl/opencl_split.cpp | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/intern/cycles/device/opencl/opencl_base.cpp b/intern/cycles/device/opencl/opencl_base.cpp index cf2ef45205e..49d7a228524 100644 --- a/intern/cycles/device/opencl/opencl_base.cpp +++ b/intern/cycles/device/opencl/opencl_base.cpp @@ -20,6 +20,7 @@ #include "kernel/kernel_types.h" +#include "util/util_algorithm.h" #include "util/util_foreach.h" #include "util/util_logging.h" #include "util/util_md5.h" @@ -280,6 +281,10 @@ void OpenCLDeviceBase::mem_alloc(const char *name, device_memory& mem, MemoryTyp cl_ulong max_alloc_size = 0; clGetDeviceInfo(cdDevice, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong), &max_alloc_size, NULL); + if(DebugFlags().opencl.mem_limit) { + max_alloc_size = min(max_alloc_size, DebugFlags().opencl.mem_limit - stats.mem_used); + } + if(size > max_alloc_size) { string error = "Scene too complex to fit in available memory."; if(name != NULL) { diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp index 50345613b6d..fdaca2252d9 100644 --- a/intern/cycles/device/opencl/opencl_split.cpp +++ b/intern/cycles/device/opencl/opencl_split.cpp @@ -25,6 +25,7 @@ #include "device/device_split_kernel.h" +#include "util/util_algorithm.h" #include "util/util_logging.h" #include "util/util_md5.h" #include "util/util_path.h" @@ -423,6 +424,11 @@ public: cl_ulong max_buffer_size; clGetDeviceInfo(device->cdDevice, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong), &max_buffer_size, NULL); + + if(DebugFlags().opencl.mem_limit) { + max_buffer_size = min(max_buffer_size, DebugFlags().opencl.mem_limit - device->stats.mem_used); + } + VLOG(1) << "Maximum device allocation size: " << string_human_readable_number(max_buffer_size) << " bytes. (" << string_human_readable_size(max_buffer_size) << ")."; |