cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

spectral
Adept II

OpenCL memory management questions ?

Hi,

I have a few questions about the way we must handle the 'CL buffer'.

Case 1
------

I create a buffer with 'clCreateBuffer' the use it. Then I use it several times in a loop, something like this

cl_mem buffer = clCreateBuffer(...)
...
kernel->setArg(4, buffer);

...
for(int i=0; i < 1000; i++)
{
queue->enqueueNDRangeKernel(...)
}

Question 1 : Does my buffer is sent each time from CPU memory to GPU memory, or only once ?

Case 2
------

After I need to changes some informations in the buffer, then I do the following :

queue->Finish(); // Insure that the CL commands are completed !
delete buffer; // Release the buffer

Questions :

1) Does 'queue->Finish()' is enough to complete the OpenCL command ?

2) Should I use 'delete' or clReleaseMemObject ?

3) Then I must call 'buffer = clCreateBuffer(...)' and also 'kernel->setArg(4, buffer);' to set up the new buffer ?



0 Likes
1 Reply
nou
Exemplar

it should be send just once. but it is not guaranteed that it stay on the GPU. driver it can swap off from it. and you can not be sure that it stay.

 

0 Likes