OpenCL C++ Bindings and premature program deallocation

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

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.

Ah thanks for clarifying that for me and sorry for the bad post.
Marcus