问题
I recently read a book about OpenCL and queue synchronizing methods, but I didn't understand difference between using clEnqueueMarkerWithWaitList and clWaitforEvents.
For example, in the below example, The kernel_2 instance's execution is dependent on writing of two buffers clmem_A and clmem_B to the device. I don't understand what is the difference when we delete the clEnqueueMarkerWithWaitList command and change the argument of clwaitforEvents to write_event.
cl_event write_event[2];
clEnqueueWriteBuffer(queue, clmem_A, ***, &write_event[0] );
clEnqueueWriteBuffer(queue, clmem_B, ***, &write_event[1] );
clEnqueueMarkerWithWaitList (queue, 2, write_event, &marker); //deleting this command
clEnqueueNDRangeKernel(queue, kernel_1, *** );
clWaitForEvents(1, &marker);// and replace marker with write_event
clEnqueueNDRangeKernel(queue, kernel_2, *** );
I believe in both cases the kernel_2 will execute after writing to device and kernel_1 could execute concurrently if the queue is out of order.
回答1:
Yes, that would be equivalent.
clEnqueueMarkerWithWaitList
is new starting in OpenCL 1.2 and offers more flexibility than clWaitForEvents
in that you can carry around a single event rather than a collection of them.
If you code for OpenCL 1.1 (e.g., because of NVIDIA lagging the industry) you can't use clEnqueueMarkerWithWaitList
.
来源:https://stackoverflow.com/questions/24974206/clenqueuemarkerwithwaitlist-usage