aclrtMemcpy2dAsync
Applicable Products
|
Product |
Supported |
|---|---|
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Function
Implements asynchronous memory copy, which is mainly used for matrix data replication. This is an asynchronous API.
The host memory in this API can be page-locked memory (for example, the memory allocated by the aclrtMallocHost API) or non-page-locked memory (allocated by the malloc API). If the host memory is non-page-locked memory, this API returns only after the memory copy task is complete. If the host memory is page-locked memory, this API is asynchronous. A successful API call only indicates that the task is delivered, not executed. After this API is called, call the synchronization API (for example, aclrtSynchronizeStream) to ensure that the memory copy task is complete.
This is an encapsulated API that applies only to C++ programs. It internally calls the C API aclrtMemcpy2dAsync.
Prototype
1 2 |
template <typename T, typename U> aclError aclrtMemcpy2dAsync(T *dst, size_t dpitch, const U *src, size_t spitch, size_t width, size_t height, aclrtMemcpyKind kind, aclrtStream stream) |
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. It must be less than or equal to dpitch and spitch. The maximum value of width is 5000000. |
|
height |
Input |
Height of the data to be copied. The maximum height should be set to 5242880 (5 x 1024 x 1024). Otherwise, a failure is returned. |
|
kind |
Input |
Memory copy kind. For details about the type definition, see aclrtMemcpyKind. |
|
stream |
Input |
Stream for executing the memory copy task. For details about the type definition, see aclrtStream. |
Returns
0 on success; otherwise, failure. For details, see aclError.
Restrictions
- This API supports only the ACL_MEMCPY_HOST_TO_DEVICE, ACL_MEMCPY_DEVICE_TO_HOST, and ACL_MEMCPY_DEVICE_TO_DEVICE memory copy kinds. Different models support different memory copy kinds. For unsupported memory copy kinds, the API returns ACL_ERROR_INVALID_PARAM.
- The following models support the ACL_MEMCPY_HOST_TO_DEVICE and ACL_MEMCPY_DEVICE_TO_HOST memory copy kinds:
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 - The following models support the ACL_MEMCPY_DEVICE_TO_DEVICE memory copy kind:
Ascend 950PR /Ascend 950DT Atlas A3 training products /Atlas A3 inference products Atlas A2 training products /Atlas A2 inference products
- The following models support the ACL_MEMCPY_HOST_TO_DEVICE and ACL_MEMCPY_DEVICE_TO_HOST memory copy kinds:
Atlas inference products in Open Ctrl CPU form: This API is not supported.Atlas inference accelerator module : This API is not supported.Atlas 200I/500 A2 inference products in Ascend RC form: This API is not supported.
Reference
The following figure shows the memory copy of this API.
