Synchronization clEnqueueMarkerWithWaitList用法

Synchronization clEnqueueMarkerWithWaitList用法,synchronization,opencl,Synchronization,Opencl,我最近读了一本关于OpenCL和队列同步方法的书,但我不理解使用clEnqueueMarkerWithWaitList和clWaitforEvents的区别 例如,在下面的示例中,kernel_2实例的执行取决于向设备写入两个缓冲区clmem_A和clmem_B。当我们删除clenqueemarkerwithwaitlist命令并将clwaitforEvents的参数更改为write_事件时,我不明白有什么区别 cl_event write_event[2]; clEnqueueWriteBuf

我最近读了一本关于OpenCL和队列同步方法的书,但我不理解使用clEnqueueMarkerWithWaitList和clWaitforEvents的区别

例如,在下面的示例中,kernel_2实例的执行取决于向设备写入两个缓冲区clmem_A和clmem_B。当我们删除clenqueemarkerwithwaitlist命令并将clwaitforEvents的参数更改为write_事件时,我不明白有什么区别

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, *** );

我相信在这两种情况下,内核2都将在写入设备后执行,如果队列出现故障,内核1可以并发执行。

是的,这是等效的

clEnqueueMarkerWithWaitList
是OpenCL 1.2中的新起点,它提供了比
clWaitForEvents
更大的灵活性,因为您可以执行单个事件,而不是它们的集合

如果您为OpenCL 1.1编写代码(例如,由于NVIDIA落后于行业),则不能使用
clEnqueueMarkerWithWaitList