aclrtMemcpy

Description

Implements synchronous memory copy within the host, within a device, between devices, or between the host and device.

Restrictions

Ascend 910 AI Processor: To perform memory copy between two devices, call aclrtDeviceCanAccessPeer to query whether inter-device memory copy is supported by the devices, call aclrtDeviceEnablePeerAccess to enable inter-device memory copy between the devices, and then call this API to perform memory copy.

Ascend 310P AI Processor: To perform memory copy between two devices, call aclrtDeviceCanAccessPeer to query whether inter-device memory copy is supported by the devices, call aclrtDeviceEnablePeerAccess to enable inter-device memory copy between the devices, and then call this API to perform memory copy.

Prototype

aclError aclrtMemcpy(void *dst, size_t destMax, const void *src, size_t count, aclrtMemcpyKind kind)

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, reserved. If the configured enum value is invalid, the system determines whether to copy data from the source address to the destination address based on the source and destination memory address pointers. If no, the system returns an error message.

typedef enum aclrtMemcpyKind {
ACL_MEMCPY_HOST_TO_HOST, //Memory copy within the host
ACL_MEMCPY_HOST_TO_DEVICE, //Host to device memory copy
ACL_MEMCPY_DEVICE_TO_HOST, //Device to host memory copy
ACL_MEMCPY_DEVICE_TO_DEVICE     //Memory copy within a device or between devices
} aclrtMemcpyKind;

Returns

0 on success; else, failure.

See Also

For the API call example, see Data Transfer.