Function: stream_wait_event
Applicable Products
- Ascend 950PR&950DT products: Supported
- Atlas A3 products: Supported
- Atlas A2 products: Supported
- Atlas 200I/500 A2 inference products: Supported
- Atlas inference products: Supported
- Atlas training products: Supported
Function
Blocks the running of a specified stream or multiple streams until the specified event is complete. This API is asynchronous.
All subsequent tasks submitted to the stream can be executed only after all tasks captured by the event are complete. For details about event capture, see acl.rt.record_event.
Prototype
-
C Prototype
aclError aclrtStreamWaitEvent(aclrtStream stream, aclrtEvent event) -
Python Function
ret = acl.rt.stream_wait_event(stream, event)
Parameters
| Parameter | Description |
|---|---|
| stream | Int, pointer address of the stream that needs to wait for the event to complete. Pass 0 if the default stream is used. |
| event | Int, pointer address of the event to be waited for. |
Return Values
| Return Value | Description |
|---|---|
| ret | Int, error code. If 0 is returned, the operation is successful. If other values are returned, the operation fails. |
Constraints
-
This API is asynchronous. A successful call indicates only that the task has been delivered, not that it has completed. After calling this API, call a synchronization API (for example, acl.rt.synchronize_stream) to ensure that the task is complete.
-
acl.rt.record_event and acl.rt.stream_wait_event are used in pair for synchronization between streams. When acl.rt.record_event is called, an event resource is allocated. After acl.rt.stream_wait_event is called, acl.rt.reset_event should be called to free the event resource promptly.
API call sequence: acl.rt.create_event --> acl.rt.record_event --> acl.rt.stream_wait_event --> acl.rt.reset_event
-
After initialization by calling acl.init in a process, you can call acl.rt.set_op_wait_timeout to set the timeout interval. Tasks delivered by calling acl.rt.stream_wait_event in the process can wait within the configured timeout interval. If the wait time exceeds the configured timeout interval, an error is returned.
acl.rt.stream_wait_event is an asynchronous API. When called, it delivers tasks, but not execute them. Therefore, if the wait time exceeds the configured timeout interval, an error is returned after acl.rt.synchronize_stream is called.