diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2020-09-24 01:37:23 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2020-10-31 03:57:39 +0300 |
commit | 517ff40b124bc9d1324ccf7561a59ac51bf86602 (patch) | |
tree | 96295b1b6a11a597f7927cc61ce9371077bc7e54 /intern/cycles/device | |
parent | 523414dda2bf81b69b1c04e1145ac21758fa4268 (diff) |
Cycles: Implement tile stealing to improve CPU+GPU rendering performance
While Cycles already supports using both CPU and GPU at the same time, there
currently is a large problem with it: Since the CPU grabs one tile per thread,
at the end of the render the GPU runs out of new work but the CPU still needs
quite some time to finish its current times.
Having smaller tiles helps somewhat, but especially OpenCL rendering tends to
lose performance with smaller tiles.
Therefore, this commit adds support for tile stealing: When a GPU device runs
out of new tiles, it can signal the CPU to release one of its tiles.
This way, at the end of the render, the GPU quickly finishes the remaining
tiles instead of having to wait for the CPU.
Thanks to AMD for sponsoring this work!
Differential Revision: https://developer.blender.org/D9324
Diffstat (limited to 'intern/cycles/device')
-rw-r--r-- | intern/cycles/device/device_cpu.cpp | 5 | ||||
-rw-r--r-- | intern/cycles/device/device_memory.h | 8 | ||||
-rw-r--r-- | intern/cycles/device/device_task.h | 1 |
3 files changed, 14 insertions, 0 deletions
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index 23aedcd0c48..6912ac1e638 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -932,6 +932,11 @@ class CPUDevice : public Device { break; } + if (tile.stealing_state == RenderTile::CAN_BE_STOLEN && task.get_tile_stolen()) { + tile.stealing_state = RenderTile::WAS_STOLEN; + break; + } + if (tile.task == RenderTile::PATH_TRACE) { for (int y = tile.y; y < tile.y + tile.h; y++) { for (int x = tile.x; x < tile.x + tile.w; x++) { diff --git a/intern/cycles/device/device_memory.h b/intern/cycles/device/device_memory.h index 32654e62a6f..00b2aa864aa 100644 --- a/intern/cycles/device/device_memory.h +++ b/intern/cycles/device/device_memory.h @@ -450,6 +450,14 @@ template<typename T> class device_vector : public device_memory { device_zero(); } + void move_device(Device *new_device) + { + copy_from_device(); + device_free(); + device = new_device; + copy_to_device(); + } + protected: size_t size(size_t width, size_t height, size_t depth) { diff --git a/intern/cycles/device/device_task.h b/intern/cycles/device/device_task.h index fd380788282..f819f84eb43 100644 --- a/intern/cycles/device/device_task.h +++ b/intern/cycles/device/device_task.h @@ -159,6 +159,7 @@ class DeviceTask { function<void(RenderTile &)> update_tile_sample; function<void(RenderTile &)> release_tile; function<bool()> get_cancel; + function<bool()> get_tile_stolen; function<void(RenderTileNeighbors &, Device *)> map_neighbor_tiles; function<void(RenderTileNeighbors &, Device *)> unmap_neighbor_tiles; |