5 Replies Latest reply on Jul 10, 2013 11:32 PM by himanshu.gautam

    clEnqueueWriteBuffer for part of array



      I want to write a part of array into the buffer and run the kernel code in parallel  for that part of the array, To do that, is there any way to directly write the part of the array to the buffer using clEnqueueWriteBuffer or do we have to write to a temporary array and then write to the buffer?

        • Re: clEnqueueWriteBuffer for part of array

          As i understand it, you have a big array at host side, and you only want to do some computations on a part of it? Are you talking about a 2-D array here, where   doing a clEnqueueWriteBuffer using a simple pointer is not possible?  clEnqueueWriteBufferRect might be helpful in that case.


          You can also look into creating a subBuffer from the original cl_buffer and populate this subbuffer instead of the actual buffer. In case subBuffer is considerably smaller as compared to original buffer, you can save time for transferring data to the GPU and back.

          • Re: clEnqueueWriteBuffer for part of array

            I don't quite understand your question.


            The first part makes no sense, saying that you wish to write from a host array to a device buffer, and use that very part in a kernel simultaneously? Is the kernel running on a CPU? It is wrong to use the buffer's contents before they arrive on device, because you have no control over in what order and when data will appear (without proper syncing).


            The second part, clEnqueueWrite buffer has an input parameter of a host pointer to start reading from. Why would you want to create a temporary array?