Device Synchronization

After APIs are called, add an exception handling branch, and record error logs and warning logs. The following is a code snippet of key steps only, which is not ready to use.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
import acl
# ......

device_id = 0

# Specify a device.
ret = acl.rt.set_device(device_id)

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

# Block app execution until the compute device has completed all preceding requested tasks.
ret = acl.rt.synchronize_device()

# Destroy allocations.
ret = acl.rt.synchronize_stream(stream)
ret = acl.rt.reset_device(device_id)