aclrtMallocHost
Applicable Products
Product |
Supported |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
Function
Allocates host memory (page-locked memory). The system ensures that the start address of the memory is 64-byte aligned.
The memory allocated by this API can only be freed by calling aclrtFreeHost or aclrtFreeHostWithDevSync.
This is an encapsulated API that applies only to C++ programs. It internally calls the C API aclrtMallocHostWithCfg.
Prototype
1 2 | template <typename T> aclError aclrtMallocHost(T **hostPtr, size_t size, aclrtMallocConfig *cfg = nullptr) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
hostPtr |
Output |
Pointer to the pointer to the allocated memory. |
size |
Input |
Allocated memory size, in bytes. size cannot be 0. |
policy |
Input |
Memory allocation policy. For details about the type definition, see aclrtMemMallocPolicy. If the configured memory allocation policy is beyond the value range of aclrtMemMallocPolicy, and size is greater than or equal to 2 MB, huge page memory is allocated; otherwise, common page memory is allocated. |
cfg |
Input |
Memory configuration. For details about the type definition, see aclrtMallocConfig. |
Returns
0 on success; otherwise, failure. For details, see aclError.