Function: memcpy

Applicable Products

Product

Supported (√/x)

Ascend 950PR/Ascend 950DT

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas training products

Atlas inference products

Atlas 200I/500 A2 inference products

Description

Copies memory.

Prototype

  • C Prototype
    1
    aclError aclrtMemcpy(void *dst, size_t destMax, const void *src, size_t count, aclrtMemcpyKind kind)
    
  • Python Function
    1
    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 by the Atlas 500 Pro (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. 0 on success; else, failure.

Restrictions

  • 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/Ascend 950DT

    Atlas A2 training products/Atlas A2 inference products

    Atlas inference products

    Atlas training products