cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

shingoxlf
Journeyman III

can I have two cl_mem point to the same memory?

for example:

cl_mem a=clCreateBuffer(clGPUContext, CL_MEM_READ_WRITE, sizeof(double)*100, NULL, &errcode);

errcode = clEnqueueWriteBuffer(clCommandQue, a, CL_FALSE, 0, sizeof(double)*100, temp, 0, NULL, NULL);

cl_mem b=a;

I got error by doing this.

0 Likes
3 Replies
nou
Exemplar

what error?

0 Likes

sorry, it is working now. The error was caused the the other problem.

But do I need release both of them? Or just release a? Thanks!

0 Likes

no just once. under the hood all cl_* objects are just pointer to some struct. you should call clRetain on object if you want copy cl object handler somewhere else. for example when you pass cl_mem into some fucntion and want ensure that object remain valid whole time.

0 Likes