aclrtMallocPhysical
Applicability
|
Product |
Supported |
|---|---|
|
Atlas 350 Accelerator Card |
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Function
Allocates physical host or device memory. A physical memory handle will be returned.
This API can be used together with aclrtReserveMemAddress (for allocating virtual memory) and aclrtMapMem (for mapping virtual memory and physical memory) to allocate contiguous virtual memory and maximize the use of physical memory.
This API can be used together with aclrtMemExportToShareableHandle (for exporting the physical memory handle) and aclrtMemImportFromShareableHandle (for importing the shared handle) to implement physical memory sharing among multiple processes. In addition, the virtual memory can be used when the physical memory is shared. For details, see the description of aclrtMemExportToShareableHandle.
Prototype
1
|
aclError aclrtMallocPhysical(aclrtDrvMemHandle *handle, size_t size, const aclrtPhysicalMemProp *prop, uint64_t flags) |
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
handle |
Output |
Handle for storing physical memory information. For the type definition, see aclrtDrvMemHandle. |
|
size |
Input |
Physical memory size, in bytes. Call aclrtMemGetAllocationGranularity to obtain the memory granularity, and then call this API to allocate the physical memory. The size is aligned based on the obtained memory granularity to save memory. |
|
prop |
Input |
Physical memory attribute. For the type definition, see aclrtPhysicalMemProp. |
|
flags |
Input |
This parameter is reserved and can only be set to 0. |
Returns
0 on success; otherwise, failure. For details, see aclError.
Restrictions
Atlas 200I/500 A2 inference product and Ascend RC: This API is not supported.- For SuperPoDs in the
Atlas A3 training product /Atlas A3 inference product , when the memory location aclrtPhysicalMemProp.location.type is set to ACL_MEM_LOCATION_TYPE_HOST_NUMA and the memory attribute type aclrtPhysicalMemProp.aclrtMemAttr is set to a P2P option (for example, ACL_MEM_P2P_HUGE), the maximum memory size that can be allocated varies depending on the server model and BIOS version. You are advised to call the aclrtMallocPhysical API to allocate memory based on the memory plan and check whether there are sufficient memory resources. - aclrtPhysicalMemProp.aclrtMemAttr supports only the following memory attribute types:
- ACL_MEM_NORMAL: common memory.
- ACL_MEM_HUGE: 2 MB huge page memory.
- ACL_MEM_HUGE1G: 1 GB huge page memory. This option is supported only on the device.
Only the
Atlas A3 training product /Atlas A3 inference product andAtlas A2 training product /Atlas A2 inference product support this type.Other models do not support this type.
- ACL_MEM_P2P_NORMAL: common memory for inter-device data copy.
- ACL_MEM_P2P_HUGE: 2 MB huge page memory for inter-device data copy.
- ACL_MEM_P2P_HUGE1G: 1 GB huge page memory for inter-device data copy. This option is supported only on the device.
Only some interconnection forms of the
Atlas A3 training product /Atlas A3 inference product support this type. The actual return result of the API is used.Other models do not support this type.
- ACL_HBM_MEM_HUGE: 2 MB huge page memory.
- ACL_HBM_MEM_HUGE1G: 1 GB huge page memory. This option is supported only on the device.
Atlas 350 Accelerator Card: This type is supported.
Atlas A3 training product /Atlas A3 inference product andAtlas A2 training product /Atlas A2 inference product : This type is supported.Other models do not support this type.
- ACL_HBM_MEM_NORMAL: common memory. The API allocates huge page memory using ACL_HBM_MEM_HUGE.
- ACL_DDR_MEM_HUGE: huge page memory. Only host memory is supported.
- ACL_DDR_MEM_NORMAL: common memory. Only host memory is supported.
- ACL_DDR_MEM_P2P_HUGE: huge page memory used for inter-device data copy. Only host memory is supported.
- ACL_DDR_MEM_P2P_NORMAL: common memory used for inter-device data copy. Only host memory is supported.