Event Synchronization
The aclrtSynchronizeEvent API can be called to block the current host thread until the specified event is complete. The following is the sample code, which is for reference only and cannot be directly copied for compilation and running:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | // Create an event. aclrtEvent event; aclrtCreateEventExWithFlag(&event, ACL_EVENT_CAPTURE_STREAM_PROGRESS); // Create a stream. aclrtStream stream; aclrtCreateStream(&stream); // Deliver tasks to the stream. ...... // Record an event in the stream. aclrtRecordEvent(event, stream); // Block the application running until the event occurs. aclrtSynchronizeEvent(event); // Explicitly destroy resources. aclrtDestroyStream(stream); aclrtDestroyEvent(event); |
Parent topic: Event-based synchronization