Is cudaEventRecord affected by the identity of the current device?

335 views Asked by At

cudaEventRecord takes an event ID and a stream ID as parameters. The Runtime API reference does not say whether the stream is required to be associated with the current device - and I can't test whether that's the case since I only have one GPU at most on any system I have access to right now.

Assuming that it must be a stream on the current device:

  • what happens if it gets a stream on another device?

Assuming that it can be a stream on any device:

  • What happens when it gets the (current device's) default stream's ID? After all, all devices' default streams have the same (null) ID?
  • Is there any difference in behavior based on whether the stream's device is current or not?
1

There are 1 answers

0
einpoklum On

Combining the information from @Talonmies' answer and the Stream and Event Behavior section of the CUDA C Programming Guide which @RobertCrovella linked to in his comment.

Must the stream be associated with the current device?

No, it can be any device. However, event recording does require that the stream and the event be associated with the same device.

Is there any difference in behavior based on whether the stream's device is current or not?

Typically, no, but...

What happens when it gets the (current device's) default stream's ID?

... the Default stream is an exception to that rule. Since (each device's own) default stream has the same ID, passing the null ID to cudaEventRecord means that it will check what device is currently set to determine which stream to record the event on (and this needs to be the same device the event is associated with).