hi_mpi_dvpp_malloc

Applicable Products

Product

Supported

Ascend 950PR / Ascend 950DT

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

Function

Allocates a buffer on the device. The requested allocation must meet the media data processing requirements (for example,128-byte alignment of the start address). The buffer size is the input size rounded up to the nearest multiple of 32, plus 32 bytes. After this API is called to allocate a buffer, the buffer lifetime is managed by the user. If the buffer is not used, the hi_mpi_dvpp_free API must be called to free the buffer in a timely manner.

Prototype

hi_s32 hi_mpi_dvpp_malloc(hi_u32 dev_id, hi_void **dev_ptr, hi_u64 size)

Parameters

Parameter

Input/Output

Description

dev_id

Input

Device ID. This parameter is reserved and invalid.

dev_ptr

Output

Pointer to the pointer to the allocated buffer.

size

Input

Buffer size to allocate, in bytes.

Returns

  • 0: success
  • Other values: failure

Restrictions

  • The buffer allocated by this API call is accessible only to the calling process and cannot be shared among processes.
  • Media data processing can access a maximum of 16-GB 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

  • If the output of media data processing is used as the input of model inference and 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) × k.

Reference

For details about the API call sequence and example, see DVPP Image/Video Processing.