Single-threading, Single-streaming Scenario
Following the API calls, add exception handling branches and specify log printing of error and information levels. 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 | import acl # ...... ACL_MEMCPY_HOST_TO_DEVICE = 1 # Explicitly create a stream. stream, ret = acl.rt.create_stream() # Pass the stream argument to the task triggering call. ret = acl.rt.memcpy_async(dev_ptr, dev_size, host_ptr, host_size, ACL_MEMCPY_HOST_TO_DEVICE, stream) # Call acl.rt.synchronize_stream to block the app until all tasks in the specified stream are complete. ret = acl.rt.synchronize_stream(stream) # Explicitly destroy the stream after using the stream. ret = acl.rt.destroy_stream(stream) # ...... |
Parent topic: Stream Management