cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

arsenm
Adept III

Properly cleaning up on failure?

I recently found that I have a bunch of code in my CAL application to manually clean up all buffers and such when anything fails that doesn't need to exist. I found that calShutdown() cleans up any allocated resources for you. I then was wondering if the same was true with OpenCL contexts. The documentation states for clReleaseContext():

After the context reference count becomes zero and all the objects attached to context (such as memory objects, command-queues) are released, the context is deleted.



Does clReleaseContext deref all of the associated resources so that supposing you haven't reffed any of the resources somewhere they will be destroyed immediately, or do you need to explicitly release them?

0 Likes
3 Replies
himanshu_gautam
Grandmaster

As per openCL the resources will only be dereferred when reference count reaches zero. If the reference count does not become 0 after clReleaseContext call the objects associated with the context persists.

0 Likes

Originally posted by: himanshu.gautam As per openCL the resources will only be dereferred when reference count reaches zero. If the reference count does not become 0 after clReleaseContext call the objects associated with the context persists.

 

My question is whether or not clReleaseContext derefs the objects it has references to, not when things are actually released.

0 Likes

The answer is it should if the refence count is zero and otherwise not. Although i recently found a bug related to reference count.

So currently i suggest you to deref your buffers/kernels/program objects yourself.

0 Likes