clEnqueueMarkerWithWaitList usage

荒凉一梦 提交于 2019-12-11 18:51:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!