aclrtMemcpyAsync

Description

Copies memory. This API is asynchronous.

Restrictions

Model

Restriction

All models

  • The source address and destination address passed to this call must be 64-byte aligned.
  • 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".
  • This API is asynchronous. The API call delivers a task rather than executes a task. After calling this API, you need to call a synchronization API, such as aclrtSynchronizeStream, to ensure that the memory copy task is complete.

Atlas 200/300/500 Inference Product

Atlas Training Series Product

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 aclrtMallocHost, this API does not report an error, but an unpredictable error may occur when the task is executed.

Atlas 200/300/500 Inference Product

In the Ascend RC form, when an application is running on the board, if the kind input by calling this API is ACL_MEMCPY_HOST_TO_DEVICE or ACL_MEMCPY_DEVICE_TO_HOST, the system uses ACL_MEMCPY_DEVICE_TO_DEVICE to copy the memory in the device by default.

Atlas Training Series Product

To perform inter-device memory copy, call the aclrtDeviceCanAccessPeer API to query whether inter-device memory copy is supported, call the aclrtDeviceEnablePeerAccess API to enable inter-device memory copy, and then call this API to perform memory copy.

Prototype

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

Parameters

Parameter

Input/Output

Description

dst

Input

Pointer to the destination memory address.

destMax

Input

Memory size in bytes in the destination address.

src

Input

Pointer to the source memory address.

count

Input

Size in bytes to copy.

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

For the API call example, see Data Transfer.