Function: malloc_host

Applicable Products

Product

Supported (√/x)

Ascend 950PR/Ascend 950DT

√

Atlas A3 training products/Atlas A3 inference products

√

Atlas A2 training products/Atlas A2 inference products

√

Atlas training products

√

Atlas inference products

√

Atlas 200I/500 A2 inference products

√

Description

Allocates the host memory (lock page memory) if the app is running on the host. The system ensures that the start address of the memory is 64-byte aligned.

For the following product forms, the host and device are integrated. Therefore, allocating host memory is equivalent to allocating device memory. In addition, memory is allocated based on normal pages. If the start address needs to be 64-byte aligned, you need to handle the alignment problem by yourself.

Prototype

Parameters

Parameter

Description

size

Int, allocated memory size, in bytes. Must not be 0.

Return Values

Return Value

Description

host_ptr

Int, address of the pointer to the allocated host memory.

ret

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

Restrictions