Updated on 2022-03-13 GMT+08:00

HIAIMemory::HIAI_DVPP_DMalloc

Allocates memory for DVPP on the device side. This API is defined in ai_memory.h. After this API is called to allocate memory, HIAIMemory::HIAI_DVPP_DFree must be called to free the memory.

Syntax

HIAI_StatusT HIAI_DVPP_DMalloc(const uint32_t dataSize, void*& dataBuffer)

Parameter Description

Parameter

Description

Value Range

dataSize

Size of a memory block

0 to (256 MB – 96 bytes), excluding 0. The recommended range is (256 KB – 96 bytes) to (256 MB – 96 bytes).

The model manager on the device side occupies 96 bytes.

dataBuffer

Allocated memory address. If the allocation fails, a null pointer is returned.

-

Return Value

For details about the returned error codes, see "Error Codes."

Error Codes

No.

Error Code

Description

1

HIAI_OK

The running is OK.

2

HIAI_GRAPH_NOT_EXIST

The graph does not exist.

3

HIAI_GRAPH_MEMORY_POOL_NOT_EXISTED

The memory pool does not exist.

4

HIAI_GRAPH_MALLOC_LARGER

The buffer fails to be allocated because the size is larger than 256 MB.

5

HIAI_MEMORY_POOL_UPDATE_FAILED

The memory pool fails to be updated.

6

HIAI_GRAPH_SENDMSG_FAILED

The HDC module fails to send a message.

7

HIAI_GRAPH_MEMORY_POOL_INITED

The memory pool has been initialized.

8

HIAI_GRAPH_NO_MEMORY

There is no memory.

Remarks

HIAIMemory::HIAI_DVPP_DMalloc is a new API for allocating memory to DVPP. The memory allocated by using this API can meet the various memory requirements of DVPP.

If HIAIMemory::HIAI_DMalloc(1000, buffer, 1000, HIAI_MEMORY_HUGE_PAGE) is called to allocate memory for DVPP in the earlier version, use HIAIMemory::HIAI_DVPP_DMalloc instead. For details, see HIAIMemory::HIAI_DMalloc.

Usage Example:

// Allocate memory by using HIAI_DVPP_DMalloc.
uint32_t allocSize = 1000;
char* allocBuffer  = nullptr;
HIAI_StatusT ret = hiai::HIAIMemory::HIAI_DVPP_DMalloc(allocSize, (void*&)allocBuffer);
if (ret != HIAI_OK || allocBuffer == nullptr) {
   // If the allocation fails, handle the exception.
}