Function: memcpy_async_with_condition

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas training product

Atlas inference product

Atlas 200I/500 A2 inference product

Description

Copies memory.

This API extends the functions of aclrtMemcpyAsync. If the input memory is not allocated by using the API provided by pyacl, this API is returned only after the memory copy is complete. Otherwise, this API is an asynchronous API. If the API is successfully called, the task is successfully delivered but not executed. After this API is called, the synchronous waiting API (for example, acl.rt.synchronize_stream) needs to be called to ensure that the memory replication task is complete.

Prototype

  • C Prototype
    1
    aclError aclrtMemcpyAsyncWithCondition(void *dst, size_t destMax, const void *src, size_t count, aclrtMemcpyKind kind, aclrtStream stream)
    
  • Python Function
    1
    ret = acl.rt.memcpy_async_with_condition(dst, dest_max, src, count, kind, stream)
    

Parameters

Parameter

Description

dst

Int, pointer to the destination memory address.

destMax

Int, memory size in bytes in the destination address

src

Int, pointer to the source memory address.

count

Int, size in bytes to copy.

kind

Int, memory copy type.
  • 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.
  • 4: ACL_MEMCPY_DEFAULT. The system determines the copy direction based on the source and destination memory addresses.

stream

Int, stream.

Return Value

Return Value

Description

ret

Int, error code. 0 on success; else, failure.

Restrictions

Atlas inference product:

  • Ascend EP: This API does not support asynchronous memory copy within the host. If the input kind is ACL_MEMCPY_HOST_TO_HOST, the API returns the error message " ACL_ERROR_RT_FEATURE_NOT_SUPPORT."

Atlas 200I/500 A2 inference product:

  • Ascend EP: This API does not support asynchronous memory copy within the host. If the input kind is ACL_MEMCPY_HOST_TO_HOST, the API returns the error message " ACL_ERROR_RT_FEATURE_NOT_SUPPORT."
  • Ascend RC: When the application is running on the board, if the input kind is ACL_MEMCPY_HOST_TO_DEVICE, ACL_MEMCPY_DEVICE_TO_HOST, or ACL_MEMCPY_HOST_TO_HOST, the system uses ACL_MEMCPY_DEVICE_TO_DEVICE by default to copy memory within the device.

Atlas training product, Atlas A2 training product/Atlas A2 inference product, Atlas A3 training product/Atlas A3 inference product:

  • This API does not support asynchronous memory copy within the host. If the input kind is ACL_MEMCPY_HOST_TO_HOST, the API returns the error message "ACL_ERROR_RT_FEATURE_NOT_SUPPORT".