aclrtMemcpyAsync

Applicable Products

Product

Supported

Ascend 950PR/Ascend 950DT

√

Atlas A3 training products/Atlas A3 inference products

√

Atlas A2 training products/Atlas A2 inference products

√

Atlas 200I/500 A2 inference products

√

Atlas inference products

√

Atlas training products

√

Function

Copies memory.

The host memory in this API can be page-locked memory (for example, the memory allocated using aclrtMallocHost) or non-page-locked memory (allocated using malloc). If the host memory is page-locked memory, this API is asynchronous. A successful API call indicates that the task is issued, not executed. After this API is called, call the synchronization API (for example, aclrtSynchronizeStream) to ensure that the memory copy task is complete. If the host memory is non-page-locked memory, this API returns only after the memory copy task is complete.

This is an encapsulated API that applies only to C++ programs. It internally calls the C API aclrtMemcpyAsync.

Prototype

1
2
template <typename T, typename U>
aclError aclrtMemcpyAsync(T *dst, size_t destMax, const U *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. For details about the type definition, see aclrtMemcpyKind.

stream

Input

Stream for executing the memory copy task. For details about the type definition, see aclrtStream.

Returns

0 on success; otherwise, failure. For details, see aclError.

Restrictions

  • Ascend EP form: This API does not support asynchronous memory copy within the host. If the input kind is ACL_MEMCPY_HOST_TO_HOST, the API returns ACL_ERROR_RT_FEATURE_NOT_SUPPORT.
  • Ascend RC form: If the value of kind passed by this API is ACL_MEMCPY_HOST_TO_DEVICE, ACL_MEMCPY_DEVICE_TO_HOST, or ACL_MEMCPY_HOST_TO_HOST when the application is running on the board, the system uses ACL_MEMCPY_DEVICE_TO_DEVICE by default to copy memory within the device.
  • Ctrl CPU open form: If the value of kind passed by this API is ACL_MEMCPY_HOST_TO_DEVICE, ACL_MEMCPY_DEVICE_TO_HOST, or ACL_MEMCPY_HOST_TO_HOST when the application is running on the device, the system uses ACL_MEMCPY_DEVICE_TO_DEVICE by default to copy memory within the device.