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?
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.
No, it can be any device. However, event recording does require that the stream and the event be associated with the same device.
Typically, no, but...
... 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).