View Full Version : Issue with clRelease functions

11-21-2012, 02:46 AM

I have an issue with clRelease functions (clReleaseContext, ...). I developped a C++ library to manage easily OpenCL functions and a test application to control its working.

This application works fine and all clRelease functions are call with success.

Then I developped an other library that uses the first lib to use OpenCL and a test application to control its working.

This application stops when I try to enter in the first clRelease functions namely clReleaseContext.

The same problem appears with Intel and NVidia OpenCL driver. So this is not a driver problem but a usage problem.

To summarize:

OpenCL -> LIB_A -> TEST_APP_A : OK

OpenCL -> LIB_A -> LIB_B -> TEST_APP_B : not OK

Is someone could help me to find the problem?

I have to precise that I use boost shared_ptr in all the library to manage pointers.


11-21-2012, 03:14 AM
I found a solution but I still don't understand the problem.

Here is the architecture:

class A is a singleton and creates the context.
class B is a singleton and have the member static A* instance.

If I remove the static member of A* in class B and I give the instantiation of A to other functions calls to clRelease functions work fine.

So this is the only way to avoid the issue, but I don't understand why I can't have a static instantiation of a singleton in a class.


11-21-2012, 09:48 AM
On the face of it, I don't know of any reason why you can't use a singleton but I have the following suggestions:

Check the error codes returned by every single OpenCL function. You probably do but I'm just being certain.
Make sure that the number of calls to clReleaseContext for the context in A matches the number of times that clRetainContext was called plus one for creating the context (implicit retain).