Function: memcpy2d_async

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

Implements asynchronous memory copy, which is mainly used for matrix data replication. This API is asynchronous.

The Atlas inference accelerator module does not support this API.

Prototype

  • C Prototype
    1
    aclError aclrtMemcpy2dAsync(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, aclrtMemcpyKind kind, aclrtStream stream)
    
  • Python Function
    1
    ret = acl.rt.memcpy2d_async(dst, dpitch, src, spitch, width, height, kind, stream)
    

Parameters

Parameter

Description

dst

Int, pointer address of the destination memory address.

dpitch

Int, address distance between two adjacent columns of vectors in the destination memory.

src

Int, pointer address of the source memory address.

spitch

Int, address distance between two adjacent columns of vectors in the source memory.

width

Int, matrix width to be copied.

The maximum value of width is 5000000, and the value must be less than or equal to the sum of dpitch and spitch.

height

Int, matrix height to be copied.

The maximum height can be set to 5242880 (5 x 1024 x 1024). Otherwise, a failure is returned.

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.
ACL_MEMCPY_DEFAULT = 4 // The system determines the copy direction based on the source and destination memory addresses.

stream

Int, pointer address of the stream.

Return Value

Return Value

Description

ret

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

Restrictions

  • This API is asynchronous. The API call delivers a task rather than executes a task. After this API is called, call the synchronization API (for example, acl.rt.synchronize_stream) to ensure that the memory copy task is complete.
  • This API supports only the ACL_MEMCPY_HOST_TO_DEVICE, ACL_MEMCPY_DEVICE_TO_HOST, and ACL_MEMCPY_DEVICE_TO_DEVICE memory copy types. Different models support different types. For unsupported memory copy types, the API returns ACL_ERROR_INVALID_PARAM.
    • The ACL_MEMCPY_HOST_TO_DEVICE and ACL_MEMCPY_DEVICE_TO_HOST types are supported by the following models:

      Atlas 350 Accelerator Card

      Atlas A3 training product/Atlas A3 inference product

      Atlas A2 training product/Atlas A2 inference product

      Atlas 200I/500 A2 inference product

      Atlas inference product

      Atlas training product

    • ACL_MEMCPY_DEVICE_TO_DEVICE type. The following models are supported:

      Atlas 350 Accelerator Card

      Atlas A3 training product/Atlas A3 inference product

      Atlas A2 training product/Atlas A2 inference product

  • For the Atlas inference product in Ctrl CPU open form, this API is not supported. In addition, the Atlas inference accelerator module does not support this API.
  • For the Atlas 200I/500 A2 inference product in Ascend RC form, this API is not supported.