aclrtMemcpy2dAsync

Description

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

Restrictions

  • This API is asynchronous. The API call delivers a task rather than executes a task. After this API is called, you need to call a synchronization API (for example, aclrtSynchronizeStream) to ensure that the memory copy task is complete. Otherwise, service exceptions (such as training or inference exception) or unknown situations (such as device link or card disconnection) may occur.
  • Currently, only memory copy of the ACL_MEMCPY_HOST_TO_DEVICE and ACL_MEMCPY_DEVICE_TO_HOST types is supported.
  • This API is not supported in the Ascend RC form.

    Currently, the following models support the Ascend RC form:

    • Atlas 200/300/500 Inference Product

Prototype

aclError aclrtMemcpy2dAsync(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, aclrtMemcpyKind kind, aclrtStream stream)

Parameters

Parameter

Input/Output

Description

dst

Input

Pointer to the destination memory address.

dpitch

Input

Address distance between two adjacent columns of vectors in the destination memory.

src

Input

Pointer to the source memory address.

spitch

Input

Address distance between two adjacent columns of vectors in the source memory.

width

Input

Width of the data to be copied.

height

Input

Height of the data to be copied.

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

kind

Input

Memory copy kind.

typedef enum aclrtMemcpyKind {
ACL_MEMCPY_HOST_TO_HOST,     / /Memory copy within the host
ACL_MEMCPY_HOST_TO_DEVICE,   // Memory copy from host to device
ACL_MEMCPY_DEVICE_TO_HOST,   // Memory copy from device to host
ACL_MEMCPY_DEVICE_TO_DEVICE     //Memory copy within a device or between devices
ACL_MEMCPY_DEFAULT,         // The system determines the copy direction based on the source and destination memory addresses.
} aclrtMemcpyKind;

stream

Input

Stream.

Returns

The value 0 indicates success, and other values indicate failure. For details, see aclError.

See Also

The following figure shows the memory copy of this API.