Function: memcpy

Applicable Products

  • Ascend 950PR&950DT products: Supported
  • Atlas A3 products: Supported
  • Atlas A2 products: Supported
  • Atlas 200I/500 A2 inference products: Supported
  • Atlas inference products: Supported
  • Atlas training products: Supported

Function

Copies memory.

Prototype

  • C Prototype

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

    ret = acl.rt.memcpy(dst, dest_max, src, count, kind)
    

Parameters

Parameter Description
dst Int, pointer address of the destination memory address.
destMax Int, memory size in bytes in the destination address
src Int, pointer address of the source memory address.
count Int, size in bytes to copy.
kind Int, memory copy type, reserved. The enumerated values are invalid. The system determines whether the data from the source address can be copied to the destination address based on the pointer addresses of the source and destination memory addresses. If the data cannot be copied to the destination address, the system returns an error.
0: ACL_MEMCPY_HOST_TO_HOST, memory copy within the host.
1: ACL_MEMCPY_HOST_TO_DEVICE, memory copy from the host to the device.
2: ACL_MEMCPY_DEVICE_TO_HOST, memory copy from the device to the host.
3: ACL_MEMCPY_DEVICE_TO_DEVICE, memory copy within the device. This API is not supported on the Atlas 500 Pro AI edge server (model 3000).
4: ACL_MEMCPY_DEFAULT. The system determines the copy direction based on the source and destination memory addresses.

Return Values

Return Value Description
ret Int, error code. If 0 is returned, the operation is successful. If other values are returned, the operation fails.

Constraints

  • This API copies the memory immediately. No implicit device synchronization or stream synchronization is performed within the function.
  • To perform memory copy between two devices, call acl.rt.device_can_access_peer to query whether inter-device data exchange is supported by the devices, call acl.rt.device_enable_peer_access to enable inter-device data exchange between the devices, and then call this API to perform memory copy.

    This restriction applies to the following models:

    Ascend 950PR&950DT products

    Atlas A2 products

    Atlas inference products

    Atlas training products