Event Synchronization

After APIs are called, add an exception handling branch, and record error logs and warning logs. The sample code of key steps is as follows, which is for reference only. Do not directly copy and run the code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
import acl
# ......
# Create an event.
event, ret = acl.rt.create_event()

# Create a stream.
stream, ret = acl.rt.create_stream()

# Append an event to a stream.
ret = acl.rt.record_event(event, stream)

# Block the application execution and wait until the event is complete, that is, the completion of the stream.
# The stream completion event wakes up the control flow, starting the application execution.
ret = acl.rt.synchronize_event(event)

# Explicitly destroy resources.
ret = acl.rt.destroy_stream(stream)
ret = acl.rt.destroy_event(event)
# ......