AnsweredAssumed Answered

Understanding buffer creation

Question asked by andyste1 on Nov 8, 2018
Latest reply on Nov 8, 2018 by dipak

Hi, I'm new to OpenCL and am trying to get a better understanding of how clCreateBuffer works. Does this command simply "reserve" an area of memory on the device, or does an implicit "copy" occur, e.g. to initialise the buffer? Regardless of what happens, is the created buffer guaranteed to be initialised with all zeros?

 

In my scenario I want to create a buffer that my kernel will write to. I don't need to copy anything to this buffer from the host, the only requirement is that the buffer is initialised with zeros before the kernel executes. What is the best/most perfomant way of doing so? (The host will need to read the contents of this buffer once the kernel has executed though).

 

Also, I will need to periodically initialise this buffer to zeros - do I use `clEnqeueFillBuffer`? I read elsewhere that it may be more performant to execute a kernel to do this?

Outcomes