Function: dvpp_malloc
Applicability
|
Product |
Supported (√/x) |
|---|---|
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Function Usage
Allocates device memory for media processing. The allocated huge memory page meets the data processing requirements (for example, the start address is 128-byte aligned).
Prototype
- C Prototype
1aclError acldvppMalloc(void **devPtr, size_t size)
- Python Function
1dev_ptr, ret = acl.media.dvpp_malloc(size)
Parameter Description
|
Parameter |
Description |
|---|---|
|
size |
Int, allocated memory size, in bytes. |
Return Value Description
|
Return Value |
Description |
|---|---|
|
dev_ptr |
Int, pointer address of the allocated device memory. |
|
ret |
Int, error code: 0 on success; else, failure. |
Restrictions
- After this API is called to allocate memory, the acl.media.dvpp_free API must be called to free the memory if the memory is not used.
- Performance will be compromised if acl.media.dvpp_malloc and acl.media.dvpp_free are called too frequently. You are advised to allocate or manage memory in advance to avoid unnecessary memory allocation and deallocation.
- When acl.media.dvpp_malloc is called to allocate memory, 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 memory allocation by this API call fails, it only indicates that huge memory is insufficient.
For the
Atlas A2 training products /Atlas A2 inference products , the reserved huge page memory in the system is described in Overview. - Media data processing can access up to 16 GB of address space in each process.
This restriction applies to the following products:
Atlas A3 training products /Atlas A3 inference products Atlas A2 training products /Atlas A2 inference products Atlas inference products