HIAI_DMalloc
Allocates memory blocks on the host side or device side to support efficient data transmission. This API is defined in c_graph.h.
To allocate memory for DVPP on the device side, see HIAI_DVPP_DMalloc.
Application scenario:
With Matrix, this API is used to send large data from the host side to the device side. It must be used together with Macro: HIAI_REGISTER_SERIALIZE_FUNC.
For example, a 1080p or 4K image needs to be sent to the device side. To improve the data sending performance, you must register the structure serialization and deserialization functions through HIAI_REGISTER_SERIALIZE_FUNC. In addition, the large data block memory is allocated through HIAI_DMalloc. This greatly improves the data sending performance.

This API is used to send large data between the host side and the device side. If there is no performance requirement or no data sending is involved, this API is not recommended.
Syntax
void* HIAI_DMalloc (const uint32_t dataSize, const uint32_t timeOut, uint32_t flag)
Parameter Description
Parameter |
Description |
Value Range |
---|---|---|
dataSize |
Size of a memory block |
|
timeOut |
Timeout when memory fails to be allocated. The default value is 500 ms. |
- |
flag |
|
typedef enum { MEMORY_ATTR_NONE = 0, // The framework automatically frees the memory allocated by using DMalloc. MEMORY_ATTR_AUTO_FREE = (0x1 << 1), // DFree needs to be called manually to free the memory. MEMORY_ATTR_MANUAL_FREE = (0x1 << 2), MEMORY_ATTR_MAX } HIAI_MEMORY_ATTR; |
Return Value
Address of the memory allocated by using HIAI_DMalloc. If the memory fails to be allocated, a null pointer is returned.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot