aclrtMemcpy
Description
Copies memory.
Restrictions
- This API copies the memory immediately. No implicit device synchronization or stream synchronization is performed within the function.
- To perform inter-device memory copy, call the aclrtDeviceCanAccessPeer API to query whether inter-device memory copy is supported, call the aclrtDeviceEnablePeerAccess API to enable inter-device memory copy, and then call this API to perform memory copy.
This restriction applies to the following models:
Atlas Training Series Product
Prototype
aclError aclrtMemcpy(void *dst, size_t destMax, const void *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. 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; |
Parent topic: Memory Management