Function: memcpy_async_with_desc

Applicability

Product

Supported (√/x)

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas training products

x

Atlas inference products

x

Atlas 200I/500 A2 inference products

Function Usage

Copies memory using a memory copy descriptor (level-2 pointer mode).

This API is asynchronous. The API call delivers a task rather than executes a task. After this API is called, you need to call a synchronization API (for example, acl.rt.synchronize_stream) to ensure that the task is complete. Otherwise, service exceptions (such as training or inference exception) or unknown situations (such as device link or card disconnection) may occur.

This API must be used together with the following APIs to implement memory copy:

  • Call acl.rt.get_memcpy_desc_size to obtain the memory size required by the memory descriptor.
  • Allocate the device memory for storing the memory descriptor.
  • Allocate the source and destination memory for storing the data before and after the copy.
  • Call acl.rt.set_memcpy_desc to set the source and destination memory addresses in the memory descriptor.
  • Call acl.rt.memcpy_async_with_desc to implement memory copy.

Prototype

  • C Prototype
    1
    aclError aclrtMemcpyAsyncWithDesc(void *desc, aclrtMemcpyKind kind, aclrtStream stream)
    
  • Python Function
    1
    ret= acl.rt.memcpy_async_with_desc(desc, kind, stream)
    

Parameter Description

Parameter

Description

desc

Int, pointer to the memory copy descriptor address on the device. Call acl.rt.set_memcpy_desc to set the memory copy descriptor, and then pass the pointer to the memory copy descriptor address as an input parameter.

kind

Int, memory copy type. Currently, only ACL_MEMCPY_INNER_DEVICE_TO_DEVICE is supported, indicating memory copy within a device.

stream

Int, stream.

Return Value Description

Return Value

Description

ret

Int, error code: 0 on success; else, failure.