aclrtMemcpyAsync
Description
Copies memory. This API is asynchronous.
Restrictions
|
Model |
Restriction |
|---|---|
|
All models |
|
|
|
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. |
|
|
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. |
|
|
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.