OpenCL/C++ hybrid rendering

Discussion related to the Engine functionality, implementations and API.
User avatar
Dade
Developer
Posts: 1336
Joined: Mon Dec 04, 2017 8:36 pm

OpenCL/C++ hybrid rendering

Post by Dade » Sat Feb 10, 2018 2:45 pm

Introduction

LuxCore supports GPU+CPU rendering since the first days thanks to OpenCL CPU device. However the performance of OpenCL CPU devices (from AMD and Intel) are very disappointing. They are a lot slower than C++ code and they can even slow down the GPU performance. So GPU+CPU rendering is often slower than GPU-only rendering.

OpenCL/C++ hybrid rendering

OpenCL/C++ hybrid rendering is the solution to this problem. OpenCL is used to run the rendering on GPUs while native C++ code is used for the CPU rendering. This solution has 3 major advantages:

1) there is no need to install an OpenCL CPU device driver. NVIDA doens't include one in their drivers and it is complex and cumbersome to have to install another driver from AMD/Intel.

2) there is no slowdown of GPU rendering so using GPU+CPU rendering is always faster. I have worked to have maximum GPU performance even with a 100% load on CPU.

3) C++ written code is a LOT faster than OpenCL running on CPU device. It is usually 4-6 times faster in my tests.

A test

This is a rendering with a OpenCL GPU (AMD R290X) and OpenCL CPU (i7 3630k, 6 cores + hyper-threading):
hotel-ocl.jpg
and this is with a OpenCL GPU (AMD R290X) and C++ code (i7 3630k, 6 cores + hyper-threading):
hotel-hybrid.jpg
The 12 threads runs at about 2,750K rays/sec with C++ while at a miserable 762K rays/sec with the OpenCL CPU device. The GPU runs slightly faster with the hybrid rendering too.
The result is that hybrid rendering runs at 3.03M samples/sec while OpenCL GPU+CPU at 2.52M samples/sec. Now the contribute of CPU can be significative (and more complex is the scene and more significative is going to be).

Metropolis sampler

A word of caution for Metropolis sampler: the OpenCL implementation is different from the C++ one so there may be differences in the output and mixing the results may not be a good idea.

LuxCore API

Hybrid rendering is now enabled by default with PATHOCL and TILEPATHOCL. It is disabled and not usable with RTPATHOCL for obvious reasons. The number of hybrid rendering threads lunched is the same of cores+hyper-threading and can be controlled by this property:

Code: Select all

opencl.native.threads.count = 12
Support LuxCoreRender project with salts and bounties

User avatar
Sharlybg
Supporting Users
Posts: 744
Joined: Mon Dec 04, 2017 10:11 pm
Location: Ivory Coast

Re: OpenCL/C++ hybrid rendering

Post by Sharlybg » Sat Feb 10, 2018 3:19 pm

Luxcore The way it's mean to be Rendered :twisted: . impressive
Support LuxCoreRender project with salts and bounties

david57
Posts: 103
Joined: Mon Jan 22, 2018 11:30 pm

Re: OpenCL/C++ hybrid rendering

Post by david57 » Tue Feb 13, 2018 4:19 am

Yes, I did notice that rendering with CPU + GPU did not boost speed much so I just left it with only GPU.
I already think, its a very fast renderer even without the help of the CPU.
LuxCore should bring thousands of Architects and Artist to using it.

User avatar
B.Y.O.B.
Developer
Posts: 1589
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: OpenCL/C++ hybrid rendering

Post by B.Y.O.B. » Thu Feb 15, 2018 10:42 am

Is it a good idea to hide the OpenCL CPU devices in BlendLuxCore now? (Remove them from UI)
Attachments
Unbenannt.PNG
Unbenannt.PNG (6.8 KiB) Viewed 1172 times
Support LuxCoreRender project with salts and bounties

User avatar
Dade
Developer
Posts: 1336
Joined: Mon Dec 04, 2017 8:36 pm

Re: OpenCL/C++ hybrid rendering

Post by Dade » Thu Feb 15, 2018 10:51 am

B.Y.O.B. wrote:
Thu Feb 15, 2018 10:42 am
Is it a good idea to hide the OpenCL CPU devices in BlendLuxCore now? (Remove them from UI)
It should be never used but you can never know, we could have a checkbox "Hide CPU devices", enabled by default :idea:
Support LuxCoreRender project with salts and bounties

User avatar
B.Y.O.B.
Developer
Posts: 1589
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: OpenCL/C++ hybrid rendering

Post by B.Y.O.B. » Thu Feb 15, 2018 11:30 am

The "Use CPUs" toggle button is already disabled by default.
I could add an info label explaining that CPUs are already used even with "Use CPUs" disabled but I think this will be very confusing.
Is it really important to keep this option? I can also add it again if we later notice that some users need the OpenCL CPU device.
Support LuxCoreRender project with salts and bounties

User avatar
Dade
Developer
Posts: 1336
Joined: Mon Dec 04, 2017 8:36 pm

Re: OpenCL/C++ hybrid rendering

Post by Dade » Thu Feb 15, 2018 11:42 am

B.Y.O.B. wrote:
Thu Feb 15, 2018 11:30 am
The "Use CPUs" toggle button is already disabled by default.
I could add an info label explaining that CPUs are already used even with "Use CPUs" disabled but I think this will be very confusing.
Is it really important to keep this option? I can also add it again if we later notice that some users need the OpenCL CPU device.
Ok, let's remove it (but is the management of opencl.native.threads.account available ?)
Support LuxCoreRender project with salts and bounties

User avatar
B.Y.O.B.
Developer
Posts: 1589
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: OpenCL/C++ hybrid rendering

Post by B.Y.O.B. » Thu Feb 15, 2018 12:07 pm

Dade wrote:
Thu Feb 15, 2018 11:42 am
but is the management of opencl.native.threads.account available ?
I'll rework the whole thing and make it available.

By the way can the user disable hybrid rendering?
E.g. by setting opencl.native.threads.count = 0?
Support LuxCoreRender project with salts and bounties

User avatar
Dade
Developer
Posts: 1336
Joined: Mon Dec 04, 2017 8:36 pm

Re: OpenCL/C++ hybrid rendering

Post by Dade » Thu Feb 15, 2018 12:10 pm

B.Y.O.B. wrote:
Thu Feb 15, 2018 12:07 pm
Dade wrote:
Thu Feb 15, 2018 11:42 am
but is the management of opencl.native.threads.account available ?
I'll rework the whole thing and make it available.

By the way can the user disable hybrid rendering?
E.g. by setting opencl.native.threads.count = 0?
Yes, the 0 value is intended exactly for that purpose.
Support LuxCoreRender project with salts and bounties

User avatar
B.Y.O.B.
Developer
Posts: 1589
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: OpenCL/C++ hybrid rendering

Post by B.Y.O.B. » Thu Feb 15, 2018 12:26 pm

This is the new menu.
If "Use CPUs" is disabled, native thread count will be set to 0.
If all OpenCL devices are disabled, a warning label is shown.
Unbenannt2.PNG
Unbenannt2.PNG (7.91 KiB) Viewed 1152 times
I'll also add a warning in case of hybrid + Metropolis sampler.
edit: with warning:
Attachments
Unbenannt3.PNG
Support LuxCoreRender project with salts and bounties

Post Reply