aclrtMemcpy

Applicable Products

Product

Supported

Ascend 950PR/Ascend 950DT

√

Atlas A3 training products/Atlas A3 inference products

√

Atlas A2 training products/Atlas A2 inference products

√

Atlas 200I/500 A2 inference products

√

Atlas inference products

√

Atlas training products

√

Function

Copies memory.

This is an encapsulated API that applies only to C++ programs. It internally calls the C API aclrtMemcpy.

Prototype

1
2
template <typename T, typename U>
aclError aclrtMemcpy(T *dst, size_t destMax, const U *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.

For details about the type definition, see aclrtMemcpyKind.

Returns

0 on success; otherwise, failure. For details, see aclError.

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 aclrtDeviceCanAccessPeer to query whether inter-device data exchange is supported, call aclrtDeviceEnablePeerAccess to enable inter-device data exchange, 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