Function: dvpp_malloc

C Prototype

aclError acldvppMalloc(void **devPtr, size_t size)

Python Function

dev_ptr, ret = acl.media.dvpp_malloc(size)

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).

Input Description

size: int, size of the allocated memory, in bytes.

Return Value

dev_ptr: int, pointer address of the allocated device memory.

ret: int, error code.

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]).
    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 huge memory allocation by this API call fails, it only indicates that huge memory is insufficient.

    For Atlas 200/300/500 Inference Product, the reserved huge page memory in the system is described in Overview.

Reference

For details about the API call sequence and example, see Media Data Processing V1.