Stream and Event Behavior
Operators will fail to be delivered in a stream that does not belong to the current device. The sample code is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 | aclrtSetDevice(0); // Specify device 0 as the compute device. aclrtStream s0; aclrtCreateStream(&s0); // Create stream s0 on device 0. myKernel<<<8, nullptr, s0>>>(); // Deliver operators on device 0 through stream s0. aclrtSetDevice(1); // Specify device 1 as the compute device. aclrtStream s1; aclrtCreateStream(&s1); // Create stream s1 on device 1. myKernel<<<8, nullptr, s1>>>(); // Deliver operators on device 1 through stream s1. // Operator delivery failure myKernel<<<8, nullptr, s0>>>(); // Deliver operators on device 1 through stream s0. |
- If the device to which a stream belongs is different from the current device, calling aclrtMemcpyAsync in the stream will fail.
- If an event and a stream are associated with different devices, calling aclrtRecordEvent will fail.
- If an event and a stream are associated with different devices, calling aclrtStreamWaitEvent will fail.
- If the device to which an event belongs is different from the current device, calling aclrtSynchronizeEvent and aclrtQueryEvent will be successful.
Parent topic: Multi-device programming