aclrtMallocHostWithCfg

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Function

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

Compared with aclrtMallocHost, this API can also specify memory configuration when allocating memory.

The memory allocated by this API must be freed by calling aclrtFreeHost or aclrtFreeHostWithDevSync.

For the Ascend RC form and Ctrl CPU open form, the host and device are integrated. Therefore, allocating the host memory is equivalent to allocating the 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

1
aclError aclrtMallocHostWithCfg(void **ptr, uint64_t size, aclrtMallocConfig *cfg)

Parameters

Parameter

Input/Output

Description

ptr

Output

Pointer to the allocated memory.

size

Input

Allocated memory size, in bytes.

The size cannot be 0.

cfg

Input

Memory configuration. For the type definition, see aclrtMallocConfig.

If it is not specified, NULL can be passed.

Returns

0 on success; otherwise, failure. For details, see aclError.