Results 1 to 3 of 3

Thread: completion of the kernel to retrieve buffer from device

  1. #1
    Junior Member
    Join Date
    Jul 2009

    completion of the kernel to retrieve buffer from device


    As I understand, clEnqueueNDRangeKernel(), enqueues the kernel and returns. If the kernel writes to a memory that I have to retrieve, I will have to wait for the kernel to complete before I can copy the data from the device memory to the host memory. So will one come to know if the kernel hash finished execution. Will clEnqueueReadBuffer() wait till the kernel, which is using the buffer object that it(clEnqueueReadBuffer() ) is trying to retrieve, to finish execution, before retrieving the buffer object?

  2. #2
    Junior Member
    Join Date
    Jun 2009

    Re: completion of the kernel to retrieve buffer from device

    One of the ways you could accomplish that is by using what OpenCL defines as an "event". By placing your work in the command queue with help of clEnqueueNDRangeKernel, you may provide a pointer to an event variable (last argument -> see documentation) that will be updated upon completion of the work. Following the NDRangeKernel you may wait for the execution to complete by using clWaitForEvents(1,&eventp)... then proceed with your buffer read/copy.

  3. #3
    Senior Member
    Join Date
    Jul 2009
    Northern Europe

    Re: completion of the kernel to retrieve buffer from device

    An easier way is just to set blocking to CL_TRUE in clEnqueueRead(). As long as you are running on an in-order queue this will work fine. Remember that to get best performance you want to make sure you queue up enough work to keep the device busy. If you have to synchronize with your application by waiting for each kernel to finish you'll have periods of time where the device is idle. You should consider double-buffering strategies to get around this.

Similar Threads

  1. Reuse device buffer across kernel batches
    By burdeman in forum OpenCL
    Replies: 4
    Last Post: 02-15-2013, 07:10 AM
  2. Retrieve OpenglES video buffer address...
    By Lorenzo in forum OpenGL ES general technical discussions
    Replies: 3
    Last Post: 06-06-2007, 10:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts