aclrtMallocPhysical

Applicable Products

Product

Supported

Ascend 950PR / Ascend 950DT

√

Atlas A3 training products / Atlas A3 inference products

√

Atlas A2 training products / Atlas A2 inference products

√

Atlas 200I/500 A2 inference products

√

Atlas inference products

√

Atlas training products

√

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 share physical memory among multiple processes. In addition, virtual memory can be used when physical memory is shared. For details, see 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 details about the type definition, see aclrtDrvMemHandle.

size

Input

Size of the physical memory, 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 information. For details about the type definition, see aclrtPhysicalMemProp.

flags

Input

Reserved. The value is fixed at 0.

Returns

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

Restrictions

  • Atlas 200I/500 A2 inference products in Ascend RC form: 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 products / Atlas A3 inference products and Atlas A2 training products / Atlas A2 inference products 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 products / Atlas A3 inference products 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.

      Ascend 950PR / Ascend 950DT : This type is supported.

      Atlas A3 training products / Atlas A3 inference products and Atlas A2 training products / Atlas A2 inference products : 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.

API Call Example

For the API call example, see Virtual Memory Management.