Hi,
I would like to know what is the difference between :
oclBuff = clCreateBuffer(gpu_context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, mem_size, dataSet, &err);
...and...
oclBuff = clCreateBuffer(gpu_context, CL_MEM_READ_ONLY, mem_size, NULL, &err);
err = clEnqueueWriteBuffer(cmd_queue, dataSet, CL_TRUE, 0, mem_size, a, 0, NULL, NULL);
Which one I should use in which case ? and why ? Or it is exactly the same ?
Thanks
viewon01,
In both cases, you are creating buffer and initializing the buffer with your own data. only thing is that you are using two functions to do that in the second case.
One difference i can tell you. Choose first case if you want create buffer and initialize only once in whole program. Use clEnqueueWriteBuffer if you want to update the buffer values with new data set more than once.
Thanks for the precision,
Regards
Originally posted by: genaganna viewon01,
In both cases, you are creating buffer and initializing the buffer with your own data. only thing is that you are using two functions to do that in the second case.
One difference i can tell you. Choose first case if you want create buffer and initialize only once in whole program. Use clEnqueueWriteBuffer if you want to update the buffer values with new data set more than once.
Your hint, what the difference is, just fixed a memory leak, that i've been working on for 2 weeks now.
Thanks!
Originally posted by: viewon01
oclBuff = clCreateBuffer(gpu_context, CL_MEM_READ_ONLY, mem_size, NULL, &err);
err = clEnqueueWriteBuffer(cmd_queue, dataSet, CL_TRUE, 0, mem_size, a, 0, NULL, NULL);
Does clCreateBuffer() include an implicit call to clEnqueueWriteBuffer() too ?
I mean, for a read only buffer, is it required to call clEnqueueWriteBuffer() after the creation of the buffer of it is implicitaly done buy clCreateBuffer() ?
Thanks,
David
Originally posted by: davibu Originally posted by: viewon01
oclBuff = clCreateBuffer(gpu_context, CL_MEM_READ_ONLY, mem_size, NULL, &err);
err = clEnqueueWriteBuffer(cmd_queue, dataSet, CL_TRUE, 0, mem_size, a, 0, NULL, NULL);
Does clCreateBuffer() include an implicit call to clEnqueueWriteBuffer() too ?
No
I mean, for a read only buffer, is it required to call clEnqueueWriteBuffer() after the creation of the buffer of it is implicitaly done buy clCreateBuffer() ?
You need to call clEnqueueWriteBuffer if CL_MEM_COPY_HOST_PTR is not used in clCreateBuffer. Please read spec for more details.
Originally posted by: genaganna
You need to call clEnqueueWriteBuffer if CL_MEM_COPY_HOST_PTR is not used in clCreateBuffer. Please read spec for more details.
Thank you very much.
Thank you. It's very important addition.