aclrtMemcpy2d

Description

Implements synchronous memory copy, which is mainly used for matrix data replication.

Prototype

aclError aclrtMemcpy2d(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, aclrtMemcpyKind kind)

Restrictions

  • Currently, only memory copy of the ACL_MEMCPY_HOST_TO_DEVICE and ACL_MEMCPY_DEVICE_TO_HOST types is supported.
  • This API is not supported in the Ascend RC form.

    Currently, the following models support the Ascend RC form:

    • Atlas 200/300/500 Inference Product

Parameters

Parameter

Input/Output

Description

dst

Input

Pointer to the destination memory address.

dpitch

Input

Address distance between two adjacent columns of vectors in the destination memory.

src

Input

Pointer to the source memory address.

spitch

Input

Address distance between two adjacent columns of vectors in the source memory.

width

Input

Width of the data to be copied.

height

Input

Height of the data to be copied.

kind

Input

Memory copy kind.

typedef enum aclrtMemcpyKind {
ACL_MEMCPY_HOST_TO_HOST,     / /Memory copy within the host
ACL_MEMCPY_HOST_TO_DEVICE,   // Memory copy from host to device
ACL_MEMCPY_DEVICE_TO_HOST,   // Memory copy from device to host
ACL_MEMCPY_DEVICE_TO_DEVICE     //Memory copy within a device or between devices
ACL_MEMCPY_DEFAULT,         // The system determines the copy direction based on the source and destination memory addresses.
} aclrtMemcpyKind;

Returns

The value 0 indicates success, and other values indicate failure. For details, see aclError.

See Also

The following figure shows the memory copy of this API.