Function: dvpp_malloc

Applicable Products

Product

Supported (√/x)

Ascend 950PR&950DT products

x

Atlas A3 products

√

Atlas A2 products

√

Atlas training products

√

Atlas inference products

√

Atlas 200I/500 A2 inference products

√

Description

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
    1
    aclError acldvppMalloc(void **devPtr, size_t size)
    
  • Python Function
    1
    dev_ptr, ret = acl.media.dvpp_malloc(size)
    

Parameters

Parameter

Description

size

Int, allocated memory size, in bytes.

Return Values

Return Value

Description

dev_ptr

Int, pointer address of the allocated device memory.

ret

Int, error code: 0 on success; else, failure.

Constraints

  • 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 Atlas A2 products, the reserved huge page memory in the system is described in Overview.

  • Media data processing can access a maximum of 16-GB address space in each process.

    This constraint applies to the following products:

    Atlas A3 products

    Atlas A2 products

    Atlas inference products

Reference

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