简体   繁体   English

如何取消设置CUDA事件?

[英]How can I unset a CUDA event?

I have a processing loop on the host, where I record an event in a GPU stream. 我在主机上有一个处理循环,在其中将事件记录在GPU流中。 Then another stream waits for that event (waits for event's state "set" or "true"). 然后另一个流等待该事件(等待事件的状态“设置”或“真”)。 Will this function (cudaStreamWaitEvent) unset this event (so, switching it to "unset" or "false")? 此函数(cudaStreamWaitEvent)是否会取消设置此事件(因此,将其切换为“未设置”或“假”)? If not, what CUDA function I can use to unset this event? 如果没有,我可以使用什么CUDA函数来取消设置此事件?

This sounds very much like an XY question . 这听起来很像一个XY问题 You might be better off describing at a higher level what it is you are trying to accomplish, or what problem you are facing or think you are facing. 您可能最好从更高的层次上描述您要完成的任务,或者面临或认为自己面临的问题。

cudaStreamWaitEvent does not "unset" an event. cudaStreamWaitEvent不会“取消设置”事件。

When the event is encountered in the stream, then cudaStreamWaitEvent will unblock, and any subsequent calls to cudaStreamWaitEvent on the same event will immediately unblock (assuming no cudaEventRecord has again been issued for that event). 当在流中遇到事件时, cudaStreamWaitEvent将取消阻止,并且在同一事件上对cudaStreamWaitEvent任何后续调用都将立即取消阻止 (假定没有再次为该事件发出cudaEventRecord )。 This behavior is easy to prove with a trivial code sample. 用一个简单的代码示例就可以轻松证明这种行为。

The function that "unsets" a cudaEvent is cudaEventRecord() . “重置” cudaEvent的函数是cudaEventRecord() Any cudaStreamWaitEvent calls issued after that event gets recorded will wait again, until it is encountered again. 在记录该事件之后发出的所有cudaStreamWaitEvent调用都将再次等待,直到再次遇到该事件为止。

You may want to read the runtime API documentation for cudaEventRecord and cudaStreamWaitEvent . 您可能需要阅读cudaEventRecordcudaStreamWaitEvent的运行时API文档。 Note the following excerpts: 请注意以下摘录:

cudaEventRecord: cudaEventRecord:

If cudaEventRecord() has previously been called on event, then this call will overwrite any existing state in event. 如果先前已在事件上调用cudaEventRecord(),则此调用将覆盖事件中任何现有状态。 Any subsequent calls which examine the status of event will only examine the completion of this most recent call to cudaEventRecord(). 任何随后的检查事件状态的调用都只会检查对cudaEventRecord()的最新调用的完成。

cudaStreamWaitEvent: cudaStreamWaitEvent:

The stream stream will wait only for the completion of the most recent host call to cudaEventRecord() on event . stream仅等待event上对cudaEventRecord()的最新主机调用完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM