[Bf-committers] Patch submitted to fix OpenCL render, support multiple platforms, and save preprocessed kernel in cache for debugging.
Doug Gale
doug65536 at gmail.com
Sun May 26 21:20:32 CEST 2013
I've submitted a patch that fixes the broken OpenCL renderer, see the
tracker page.
<http://projects.blender.org/tracker/index.php?func=detail&aid=35514&group_id=9&atid=127>
Here is the description:
The OpenCL renderer was completely broken - it would fail to compile
on any OpenCL implementation. This was caused by a missing function
implementation (fmodf). This was missed by the NVidia compiler and
ended up being an extremely cryptic error in the generated PTX (IL ASM).
Also fixed in this patch is support for multiple OpenCL platforms.
The code was blindly picking platform[0], which is very poor
implementation. Now, the devices are assigned IDs in increasing
order across all platforms. For example, if platform[0] has 2
devices, then those will get OPENCL_0 and OPENCL_1 for their name.
The first device in platform[1] will then get OPENCL_2, etc. The
code to instantiate a device walks the platforms, tracking the
number of devices, until a platform is reached that contains the
specified ID. This kept the code changes to an absolute minimum and
didn't require any changes to data structures.
The Intel CPU OpenCL compiler has the capability to debug at source
level. This requires that the full path to a file containing the
kernel source be specified as an option to the OpenCL compiler. I
have added the infrastructure to save the preprocessed source file
alongside the compiled kernel binary. Source level debugging
capability promised by the Intel OpenCL implementation is only
partially working because the -g option crashes the compiler on my
system. You can actually place a working breakpoint at a kernel
function, but (at least on my system, in qtcreator) it does not show
the kernel source. In any case, it is useful to have the
preprocessed source on disk for other OpenCL implementations that
may be able to debug at source level.
I have changed the OpenCL kernel compile code to show the "program
build log" even if the compile succeeds. Compile warnings (if any)
will show up in the console even if the compile succeeds.
I have tested my changes pretty thoroughly on my system (Linux Mint
14 64-bit Mate desktop (which roughly corresponds to Ubuntu 12.10
release), GTX 580 dual-GPU system, Core I7 990x 6-core CPU), using
nvidia-experimental-310 display driver, and Intel's
opencl-1.2-intel-cpu OpenCL implementation. I have opened and
rendered all of the files at
https://svn.blender.org/svnroot/bf-blender/trunk/lib/tests/cycles/
and they all render correctly, except the "hair" demo.
The Intel CPU OpenCL implementation works, but everything is shades
of gray and images don't work. It is drastically faster than the CPU
renderer though (but it may be doing less work since images don't
appear to work).
Smaller changes:
- Fixed missing space at end of compile options in Apple case (all
other vendor's options end with a space for obvious reasons)
- Added missing error check after the creation of the "null" buffer.
- Initialize cdDevice to NULL in OpenCL initialization.
Thanks.
-Doug
More information about the Bf-committers
mailing list