Cycles: Improve denoising speed on GPUs with small tile sizes
authorLukas Stockner <lukas.stockner@freenet.de>
Fri, 10 Nov 2017 03:34:14 +0000 (04:34 +0100)
committerLukas Stockner <lukas.stockner@freenet.de>
Thu, 30 Nov 2017 06:37:08 +0000 (07:37 +0100)
commitfa3d50af95fde76ef08590d2f86444f2f9fdca95
tree516ea6cce9b6b3708389ad182a7dddf2974a1a10
parentdf7b9fa2eeb5908de4e1b3c2c6f7cf30329f1e3d
Cycles: Improve denoising speed on GPUs with small tile sizes

Previously, the NLM kernels would be launched once per offset with one thread per pixel.
However, with the smaller tile sizes that are now feasible, there wasn't enough work to fully occupy GPUs which results in a significant slowdown.

Therefore, the kernels are now launched in a single call that handles all offsets at once.
This has two downsides: Memory accesses to accumulating buffers are now atomic, and more importantly, the temporary memory now has to be allocated for every shift at once, increasing the required memory.
On the other hand, of course, the smaller tiles significantly reduce the size of the memory.

The main bottleneck right now is the construction of the transformation - there is nothing to be parallelized there, one thread per pixel is the maximum.
I tried to parallelize the SVD implementation by storing the matrix in shared memory and launching one block per pixel, but that wasn't really going anywhere.

To make the new code somewhat readable, the handling of rectangular regions was cleaned up a bit and commented, it should be easier to understand what's going on now.
Also, some variables have been renamed to make the difference between buffer width and stride more apparent, in addition to some general style cleanup.
18 files changed:
intern/cycles/device/device_cpu.cpp
intern/cycles/device/device_cuda.cpp
intern/cycles/device/device_denoising.cpp
intern/cycles/device/device_denoising.h
intern/cycles/device/opencl/opencl.h
intern/cycles/device/opencl/opencl_base.cpp
intern/cycles/kernel/CMakeLists.txt
intern/cycles/kernel/filter/filter_nlm_cpu.h
intern/cycles/kernel/filter/filter_nlm_gpu.h
intern/cycles/kernel/filter/filter_reconstruction.h
intern/cycles/kernel/kernels/cpu/filter_cpu.h
intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h
intern/cycles/kernel/kernels/cuda/filter.cu
intern/cycles/kernel/kernels/opencl/filter.cl
intern/cycles/util/CMakeLists.txt
intern/cycles/util/util_math.h
intern/cycles/util/util_math_matrix.h
intern/cycles/util/util_rect.h [new file with mode: 0644]