1
votes

I would like to know if its possible to write to the same opencl buffer twice using clEnqueueWriteBuffer. Because I am writing to the same buffer using a loop and from the second iteration of the loop the values present in the buffer (when the kernel begins execution) are not correct. I checked the host side memory and that data is correct.

I am writing to the buffer using the following command

ciErr1 = clEnqueueWriteBuffer(queue1, l_shipDate_buf, CL_FALSE, 0, l_shipDate_buf_size, l_shipDate_tiled_buf, 1, eventList+8, &eventList[1]);

The buffer was created using:

l_shipDate_buf = clCreateBuffer(context, CL_MEM_READ_ONLY, l_shipDate_buf_size, NULL, &ciErr1);
1

1 Answers

0
votes

No, with CL_FALSE you're doing a non blocking transfer to the device - I believe at this point OpenCL backs out all ordering guarantees, so if you clEnqueueWriteBuffer twice to the same buffer with CL_FALSE the data can arrive in any order - you'll need to use events to force ordering in this case. If you already are using events to force ordering between the two writes, then something has gone horribly wrong and you should post your loop