diff options
author | Mai Lavelle <mai.lavelle@gmail.com> | 2017-11-02 15:10:24 +0300 |
---|---|---|
committer | Mai Lavelle <mai.lavelle@gmail.com> | 2017-11-02 15:14:21 +0300 |
commit | 5cb873068920aad7be92439c69e75c553edff4b5 (patch) | |
tree | 20a35f690264109097d83dc3850f8a7aad6d7c19 /intern | |
parent | be5123a0a9c1aa9d4fa4dadcf754c65109ee2c2c (diff) |
Cycles: Add another limit to OpenCL memory usage
Some drivers may report very large allocation sizes, which could cause
unnecessary memory usage. This is now limited to 2gb which should
still be enough to get the needed performance benefits without waste.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/device/opencl/opencl_split.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp index ae623d22f07..2125f3d126f 100644 --- a/intern/cycles/device/opencl/opencl_split.cpp +++ b/intern/cycles/device/opencl/opencl_split.cpp @@ -430,7 +430,10 @@ public: << string_human_readable_number(max_buffer_size) << " bytes. (" << string_human_readable_size(max_buffer_size) << ")."; - size_t num_elements = max_elements_for_max_buffer_size(kg, data, max_buffer_size / 2); + /* Limit to 2gb, as we shouldn't need more than that and some devices may support much more. */ + max_buffer_size = min(max_buffer_size / 2, (cl_ulong)2l*1024*1024*1024); + + size_t num_elements = max_elements_for_max_buffer_size(kg, data, max_buffer_size); int2 global_size = make_int2(max(round_down((int)sqrt(num_elements), 64), 64), (int)sqrt(num_elements)); VLOG(1) << "Global size: " << global_size << "."; return global_size; |