aclrtMallocPhysical

The Atlas 200/300/500 Inference Product does not support this API.

Description

Allocates physical device memory. A physical memory handle will be returned.

This API can be used together with aclrtReserveMemAddress (for allocating virtual memory) and aclrtMapMem (for establishing the mapping between the virtual memory and the 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.

Restrictions

  • This API is not supported in Ascend RC form.

    Currently, the following models support the Ascend RC form:

    • Atlas 200/300/500 Inference Product
  • The current version supports only ACL_HBM_MEM_HUGE (huge page memory) and ACL_HBM_MEM_NORMAL (common page memory). If ACL_HBM_MEM_NORMAL is specified, the system applies for huge page memory.

Prototype

aclError aclrtMallocPhysical(aclrtDrvMemHandle *handle, size_t size, const aclrtPhysicalMemProp *prop, uint64_t flags)

Parameters

Parameter

Input/Output

Description

handle

Output

Handle to 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.

The memory allocation granularity is fixed to 2 MB. Therefore, the memory size must be 2 MB aligned.

prop

Input

Physical memory attribute information.

flags

Input

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

Returns

The value 0 indicates success, and other values indicate failure. For details, see aclError.