acldvppMalloc
Description
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.
Restrictions
- After this API is called to allocate memory, the acldvppFree API must be called to free the memory if the memory is not used.
- Performance deterioration will be caused by too frequent calls to acldvppMalloc and acldvppFree. You are advised to allocate or manage memory in advance to avoid unnecessary memory allocation and freeing.
- The allocation size is the input size rounded up to the nearest multiple of 32, plus 32 bytes.
- 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:
- The memory size is rounded up to the nearest multiple of 32 plus 32 bytes (m = ALIGN_UP[len,32] + 32 bytes).
- The memory start address must be 128-byte aligned (ALIGN_UP[m, 128]).
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 huge page memory allocation by this API call fails, it only indicates that huge page memory is insufficient. The reserved huge page memory in the system is described in Overview.
Prototype
aclError acldvppMalloc(void **devPtr, size_t size)
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
devPtr |
Output |
Pointer to the pointer to the allocated device memory. |
|
size |
Input |
Requested allocation size in bytes. |
Returns
The value 0 indicates success, and other values indicate failure. For details, see aclError.
Parent topic: Memory Allocation and Deallocation