aclrtMemcpyAsyncWithCondition

Description

Copies memory.

This API extends the functions of aclrtMemcpyAsync. If the input memory is not allocated by using the AscendCL API, this API is returned only after the memory copy is complete. Otherwise, this API is an asynchronous API. If the API is successfully called, the task is successfully delivered but not executed. After this API is called, the synchronous waiting API (for example, aclrtSynchronizeStream) needs to be called to ensure that the memory replication task is complete.

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".

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 aclrtMemcpyAsyncWithCondition(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.