cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

bardia
Journeyman III

C++ Wrapper Release ?

Jump to solution

Hi All,

I need to release a cl::Buffer object and reallocate with different size during program execution. I have to declare it global to be available in other files and functions. Since cl::Buffer has not any direct desstructor, is it safe to use its parent (Wrapper) destructor? In other words: mycl_Buf.~Wrapper();

If no, what is the safe method?


Thanks in Advance

Bardia 

Tags (2)
0 Likes
Reply
1 Solution

Accepted Solutions
kozmo
Adept I

Re: C++ Wrapper Release ?

Jump to solution

You can just assign a new cl::Buffer with different size to your global one like so:

mycl_Buf = cl::Buffer(...);

Assign operator will take care of the rest.

View solution in original post

0 Likes
Reply
2 Replies
kozmo
Adept I

Re: C++ Wrapper Release ?

Jump to solution

You can just assign a new cl::Buffer with different size to your global one like so:

mycl_Buf = cl::Buffer(...);

Assign operator will take care of the rest.

View solution in original post

0 Likes
Reply
LeeHowes
Staff
Staff

Re: C++ Wrapper Release ?

Jump to solution

Yes, it all reference counts. That's the biggest benefit over using the C API, I think. You can pass objects around and the retain/release behaviour is automatic. Never call the destructors directly unless you really know what you are doing because it may end up being called again on object destruction.