Function: memcpy

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas training product

Atlas inference product

Atlas 200I/500 A2 inference product

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.

  • ACL_MEMCPY_HOST_TO_HOST = 0 // Copy memory within the host.
  • ACL_MEMCPY_HOST_TO_DEVICE = 1 // Copy memory from the host to the device.
  • ACL_MEMCPY_DEVICE_TO_HOST = 2 // Copy memory from the device to the host.
  • ACL_MEMCPY_DEVICE_TO_DEVICE = 3 // Copy memory within a device.
  • 4: ACL_MEMCPY_DEFAULT. The system determines the copy direction based on the source and destination memory addresses.

Return Value

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 the acl.rt.device_can_access_peer API to query whether data exchange is supported between the two devices, call the acl.rt.device_enable_peer_access API to enable data exchange between the two devices, and then call this API to perform memory copy.

    This restriction applies to the following models:

    Atlas 350 Accelerator Card

    Atlas A2 training product/Atlas A2 inference product

    Atlas inference product

    Atlas training product