acl.himpi.dvpp_malloc

C Prototype

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

Python Function

dev_ptr, ret = acl.himpi.dvpp_malloc(dev_id, size)

Function Usage

Allocates device memory. The requested allocation must meet the media data processing requirements (for example,128-byte alignment of the start address).

The Atlas 200/300/500 Inference Product does not support this API.

The Atlas Training Series Product does not support this API.

Input Description

dev_id: device ID. This parameter is reserved and is invalid.

size: requested allocation size in bytes.

Return Value

ret: int, error code.

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

Restrictions

  • After this API is called to allocate memory, the lifetime of the memory is managed by the user. If the memory is not used, the acl.himpi.dvpp_free API must be called to free the memory in a timely manner.
  • Memory allocated by this API call is accessible only to the calling process and cannot be shared among processes.
  • When acl.himpi.dvpp_malloc is called to allocate the 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.