如何发布事件?
How to release events?
假设我有一个内核必须等待 5 个事件在 运行 之前完成。内核启动后如何安全地释放这 5 个事件?
一种方法是在内核完成时触发回调,并在那时释放事件,但这看起来很尴尬。
一旦将等待事件的内核加入队列,您就可以安全地释放事件。 OpenCL 规范对 clReleaseEvent
的描述包括以下段落:
The event object is deleted once the reference count becomes zero, the specific command identified by this event has completed (or terminated) and there are no commands in the command-queues of a context that require a wait for this event to complete.
clReleaseEvent
函数只是减少引用计数,但如果有来自正在执行或待执行的命令的其他引用,则不会真正销毁事件。
假设我有一个内核必须等待 5 个事件在 运行 之前完成。内核启动后如何安全地释放这 5 个事件?
一种方法是在内核完成时触发回调,并在那时释放事件,但这看起来很尴尬。
一旦将等待事件的内核加入队列,您就可以安全地释放事件。 OpenCL 规范对 clReleaseEvent
的描述包括以下段落:
The event object is deleted once the reference count becomes zero, the specific command identified by this event has completed (or terminated) and there are no commands in the command-queues of a context that require a wait for this event to complete.
clReleaseEvent
函数只是减少引用计数,但如果有来自正在执行或待执行的命令的其他引用,则不会真正销毁事件。