PDA

View Full Version : how to create and init gpu memory buff to be all 0s



lxu
02-11-2013, 09:31 PM
Hi all, to create a GPU buffer and init it to be all 0s, what I am doing right now is:
clCreateBuffer
then
clEnqueueWriteBuffer()
copy an array of 0s to the buff

I am wondering if there is anyway to create a GPU buffer and init it to be all 0s without calling clEnqueueWriteBuffer() ?

Thanks!

matthiasv
02-12-2013, 09:30 AM
Just write a simple kernel that sets the zeros.

affie
02-13-2013, 08:18 AM
You can also use clEnqueueFillBuffer to fill the buffer with a pattern which in your case will be 0s.

matthiasv
02-13-2013, 08:25 AM
AFAICT, this is OpenCL 1.2 only, right? I'm praying for the day NVIDIA will release an SDK with OpenCL 1.2 support.