Suppose I call cuEventRecord(0, my_event_handle)
.
cuEventRecord()
requires the stream and the event to belong to the same context. Now, one can interpret the 0
as "the default stream in the appropriate context" - the requirements are satisfied and this should work; but one can also interpret it as "the default stream in the current context" - in which case if the current context is not the event's context - this should fail. Or it may all just be undefined/inconsistent behavior.
My question: Is cuEventRecord()
guaranteed to prefer one interpretation over the other?
My personal tinkering suggests that the CUDA driver expects the current context to be the event and the stream's context. Perhaps it even expects that for any stream, not just the default one. Try this program:
with this commit of my cuda-api-wrappers library to see for yourself; if you replace
pc_0
withpc_1
- it all works.