Call the following APIs for memory re-allocation. Pay attention to the restrictions on the memory address and memory size of each API. Otherwise, memory overwriting may occur.
For details about memory management, see Overview.
API |
Description |
Input/Output Buffer |
|---|---|---|
Implements asynchronous memory copy within the host, within a device, between devices, or between the host and device. |
|
|
Allocates size bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. This API is synchronous. |
|
|
Allocates device memory for media processing. The allocated huge page memory meets the data processing requirements (for example, the start address is 128-byte aligned). This API is synchronous. For details, see Media Data Processing V1. |
When the output of media data processing is used as the input of model inference, if you use this API to allocate a large memory block and divide and manage the memory, each memory segment must meet the following requirements:
NOTE:
len indicates the size of a memory segment. ALIGN_UP[len,k] indicates rounding up to a multiple of k bytes as in this formula: ((len – 1)/k + 1) x k. |
|
Allocates device memory. The requested allocation must meet the media data processing requirements (for example,128-byte alignment of the start address). For details, see Media Data Processing V2. |
When the output of media data processing is used as the input of model inference, if you use this API to allocate a large memory block and divide and manage the memory, each memory segment must meet the following requirements:
NOTE:
len indicates the size of a memory segment. ALIGN_UP[len,k] indicates rounding up to a multiple of k bytes as in this formula: ((len – 1)/k + 1) x k. |
|
If your app runs on the host, this API is called to allocate the host memory, and the system guarantees that the start address of the memory is 64-byte aligned. If your app runs on the device, this API is called to allocate the device memory by normal page. If 64-byte alignment is required for the start address, you need to guarantee the alignment. This API is synchronous. |
|
|
Allocates size bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. The allocated memory is cacheable. This API is synchronous. |
Other restrictions are the same as those of aclrtMalloc. |
In the computer vision field, the media data processing function is often used. Therefore, multiple memory allocation APIs are involved. The memory start address involves 64-byte or 128-byte alignment. To facilitate unified management, you are advised to select a large alignment value, for example, 128-byte alignment.