Function: memcpy2d_async
Applicable Products
- Ascend 950PR&950DT products: Supported
- Atlas A3 products: Supported
- Atlas A2 products: Supported
- Atlas 200I/500 A2 inference products: Supported
- Atlas inference products: Supported
- Atlas training products: Supported
Function
Implements asynchronous memory copy, often used for matrix data replication. This API is asynchronous.
Prototype
-
C Prototype
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
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. It must be less than or equal to dpitch and spitch. The maximum value of width is 5,000,000. |
| height | Int, matrix height to be copied. The maximum value of height is 5 x 1024 x 1024 = 5,242,880. Otherwise, the API returns a failure message. |
| 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 the 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 Values
| Return Value | Description |
|---|---|
| ret | Int, error code. If 0 is returned, the operation is successful. If other values are returned, the operation fails. |
Constraints
-
This API is asynchronous. A successful call indicates only that the task has been delivered, not that it has completed. 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, or ACL_MEMCPY_DEVICE_TO_DEVICE memory copy type. The supported types vary according to the model. For unsupported memory copy types, the API returns ACL_ERROR_INVALID_PARAM.
The
ACL\_MEMCPY\_DEVICE\_TO\_DEVICEtype is supported by the following models:Ascend 950PR&950DT products
Atlas A3 products
Atlas A2 products
- On Atlas inference products, this API cannot be called in open Ctrl CPU mode. In addition, Atlas inference acceleration modules do not support this API.
- On Atlas 200I/500 A2 inference products, this API cannot be called in Ascend RC mode.