PDA

View Full Version : OpenCL C++ Bindings and premature program deallocation



toastedcrumpets
11-19-2010, 02:25 AM
Hello, I hope this is the right place for C++ bindings improvements.

The current C++ headers allow for a possible premature destruction of program objects before the kernels using them have been destroyed.

When a kernel is created from a program object, it does not increment the program objects ref counter. If the program object goes out of scope (let's say you had a single compilation function) before the kernel object this might cause trouble.

I haven't noticed this as an error in my programs on ATI/NVidia's platforms but Gremedy certainly reports it as an OpenCL error.

Marcus

david.garcia
11-19-2010, 06:48 AM
When a kernel is created from a program object, it does not increment the program objects ref counter. If the program object goes out of scope (let's say you had a single compilation function) before the kernel object this might cause trouble.


It is not necessary to explicitly increment the ref counter in the program each time a new kernel is created. This happens automatically. A program will stay alive as long as at least one of its kernels is alive.

This is explained in section 5.7.1: "clCreateKernel or clCreateKernelsInProgram do an implicit retain."

Please file a bug on GRemedy's tool.

toastedcrumpets
11-24-2010, 12:13 PM
Ah thanks for clarifying that for me and sorry for the bad post.
Marcus