aclrtMallocPhysical

Applicability

Product

Supported

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

Description

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 virtual memory with consecutive addresses 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

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.

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.

flags

Input

This parameter is reserved and can only be set to 0.

Returns

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

Restrictions

  • This API is not supported in the Ascend RC form of the Atlas 200I/500 A2 inference products.
  • 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: huge page memory for inter-device data copy. The memory granularity is 2 MB.
    • ACL_MEM_P2P_HUGE1G: huge page memory for inter-device data copy. The memory granularity is 1 GB. 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.

      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_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.