Function: memcpy_async

C Prototype

aclError aclrtMemcpyAsync(void *dst, size_t destMax, const void *src, size_t count, aclrtMemcpyKind kind, aclrtStream stream)

Python Function

ret = acl.rt.memcpy_async(dst, dest_max, src, count, kind, stream)

Function Usage

Copies memory. This API is asynchronous.

Input Description

dst: pointer address of the destination memory address.

dest_max: int, maximum memory length of the destination memory address, in bytes.

src: pointer address of the source memory address.

count: int, length of the copied memory, in bytes.

kind: int, copy memory kind.
  • ACL_MEMCPY_HOST_TO_HOST = 0 // Copy memory within the host.
  • ACL_MEMCPY_HOST_TO_DEVICE = 1 // Copy memory from the host to the device.
  • ACL_MEMCPY_DEVICE_TO_HOST = 2 // Copy memory from the device to the host.
  • ACL_MEMCPY_DEVICE_TO_DEVICE = 3 // Copy memory within a device.

stream: int, stream ID.

Return Value

ret: int, error code.

Restrictions

  • The source address and destination address passed to this call must be 64-byte aligned.
  • This API is asynchronous. The API call delivers a task rather than executes a task. After calling this API, acl.rt.synchronize_stream must be called to ensure that the memory copy task is complete.
  • If the value of kind passed by this API is ACL_MEMCPY_HOST_TO_DEVICE or ACL_MEMCPY_DEVICE_TO_HOST and the host memory is not allocated by acl.rt.malloc_host, this API does not report an error, but an unpredictable error may occur when the task is executed.
  • Asynchronous memory copy within the host is not supported. If kind = ACL_MEMCPY_HOST_TO_HOST is passed to this API call, a success response is returned. However, a failure response may be returned when the task is processed in the system.
  • Atlas 200/300/500 Inference Product
    • In Ascend RC form, if your app runs on the board while the configured memory copy direction involves the host, memory copy within the device is performed.

Reference

For details about the API call example, see Data Copy.