## LuxCore: OpenCL image pipeline support

Discussion related to the implementation of new features & algorithms to the Core Engine.

Moderators: Dade, jromang, tomb, zcott, coordinators

### LuxCore: OpenCL image pipeline support

Introduction

The execution of Film image pipeline can become quite slow if one or more of the following conditions is met:

1) multiple radiance groups (and double the execution times for BIDIRCPU as it has eye and light buffers);
2) high rendering resolutions;
3) complex image pipeline plugins used (i.e. bloom, etc.);
4) high screen refrash rate (i.e. RT rendering modes).

For instance, this is a 1920x1280 rendering with 2 radiance buffers, Reinhard02 tone mapping plus bloom and BIDIRCPU:

Code: Select all
[LuxCore][9.450] MergeSampleBuffers time: 91ms[LuxCore][10.615] Image pipeline 0 time: 1153ms

More than a second of CPU time (all cores used) wasted just to refresh the screen. This is also clearly a huge bottleneck for RT modes.

Film OpenCL support for merging sample buffers and running plug-ins

Both Film and image pipeline plugins code has been updated to use an OpenCL device to run the same tasks. This is the result in the above case:

Code: Select all
[LuxCore][7.425] MergeSampleBuffers time: 34ms[LuxCore][7.476] Image pipeline 0 time: 51ms

It is more than 10 times faster.

Film OpenCL new parameters

The are 3 new properties to control the Film OpenCL support:

Code: Select all
# Enable/disable the OpenCL usage (default: true)film.opencl.enable = 1# The index of OpenCl platform to use (default: -1, check all platforms)film.opencl.platform = -1# The index of OpenCl device to use (default: -1, the first GPU available)film.opencl.device = -1

CPU render engines

This feature can be useful for CPU render engines as you have seen, it frees CPU time that can be used for the rendering instead of image pipeline. This is quite nice for BIDIRCPU as it can still get some benefit from having a GPU even it runs only on CPUs.

Image pipeline plugins

The support for OpenCL is optional for image pipeline plugins. The frame work will take care to move stuff around (i.e. CPU <=> GPU) if a particular plugin doesn't support OpenCL. But, indeed, is better to have full OpenCL compatibile image pipeline.
There are currently only 2 plugins where I don't plan to support OpenCL for the moment: OutputSwitcher and ContourLines.

Posts: 8393
Joined: Sat Apr 19, 2008 6:04 pm
Location: Italy

### Re: LuxCore: OpenCL image pipeline support

Dade wrote:This feature can be useful for CPU render engines as you have seen, it frees CPU time that can be used for the rendering instead of image pipeline. This is quite nice for BIDIRCPU as it can still get some benefit from having a GPU even it runs only on CPUs.

Whoa, awesome!
Linux builds packager

SATtva

Posts: 7164
Joined: Tue Apr 07, 2009 12:19 pm
Location: from Siberia with love

### Re: LuxCore: OpenCL image pipeline support

I found out why blender preview is crashing with activated cl imagepipeline now.
Seems we have a numerical problem somewhat.

Try to render with this luxball.cfg ( slg4, luxcoreui, whatever you like ):
Code: Select all
film.width = 643film.height = 480# Use a value > 0 to enable batch modebatch.halttime = 0scene.file = scenes/luxball/luxball.scnscene.fieldofview = 45opencl.cpu.use = 0opencl.gpu.use = 1# Select the OpenCL platform to use (0=first platform available, 1=second, etc.)#opencl.platform.index = 0# The string select the OpenCL devices to use (i.e. first "0" disable the first# device, second "1" enable the second).#opencl.devices.select = 10# Use a value of 0 to enable default valueopencl.gpu.workgroup.size = 64screen.refresh.interval = 100path.maxdepth = 16path.russianroulette.depth = 5light.maxdepth = 16light.russianroulette.depth = 5# BIASPATH settingstile.multipass.enable = 1tile.multipass.convergencetest.threshold = 0.09#tile.multipass.convergencetest.threshold.reduction = 0.5#screen.tiles.converged.show = 1#screen.tiles.passcount.show = 1#screen.tiles.notconverged.show = 1biaspath.sampling.aa.size = 3biaspath.sampling.specular.size = 5biaspath.pathdepth.specular = 4# Film image pipeline plug-insfilm.imagepipeline.0.type = TONEMAP_AUTOLINEAR

This will crash with 643 x 480 -> OpenCL ERROR: clEnqueueNDRangeKernel(CL_INVALID_WORK_GROUP_SIZE)
In blender, final render masks this issue cause of "even" filmsize presets, but 643 x 480 or certain viewport resolutions show this issue.

Did not tested all other stuff, todo ...
EDIT: film.imagepipeline.0.type = TONEMAP_REINHARD02 crashes too.

Jens

jensverwiebe

Posts: 3420
Joined: Wed Apr 02, 2008 4:34 pm

### Re: LuxCore: OpenCL image pipeline support

Dade, i pushed a fix for the former problem: https://bitbucket.org/luxrender/luxrays ... 043dc05ac1

Pls check if the value is choosen okay now.

BTW: i just miss the densitygrid tex in luxcore, to do smoke/fire animations. I'll try if i can port this from classic soemehow.

Jens

jensverwiebe

Posts: 3420
Joined: Wed Apr 02, 2008 4:34 pm

### Re: LuxCore: OpenCL image pipeline support

jensverwiebe wrote:Dade, i pushed a fix for the former problem: https://bitbucket.org/luxrender/luxrays ... 043dc05ac1

Pls check if the value is choosen okay now.

I should have applied the strictly correct work size now.