aclrtMemExportToShareableHandleV2

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Description

Export the physical device memory handle obtained by the current process through the aclrtMallocPhysical API so that the physical device memory can be shared with other processes.

This API is enhanced based on aclrtMemExportToShareableHandle. You can use the shareType parameter to specify whether to export the shared handle within an AI server or from another AI server. AI server is an umbrella term for servers consisting of multiple devices.

The usage of this API is similar to that of aclrtMemExportToShareableHandle. However, this API must be used together with aclrtMemSetPidToShareableHandleV2 to set the process trustlist and with aclrtMemImportFromShareableHandleV2 to import a shared handle.

Prototype

1
aclError aclrtMemExportToShareableHandleV2(aclrtDrvMemHandle handle, uint64_t flags, aclrtMemSharedHandleType shareType, void *shareableHandle)

Parameters

Parameter

Input/Output

Description

handle

Input

Handle for storing physical memory information. For details about the type definition, see aclrtDrvMemHandle.

You need to call aclrtMallocPhysical in this process to allocate physical memory. If this API is successfully called, a handle is returned.

There is a one-to-one mapping between handles and shareableHandles. In the same process, one-to-many or many-to-one mapping is not allowed. Otherwise, an error is reported. For example, if this API is repeatedly called to export data, an error is reported.

flags

Input

Whether to enable process trustlist verification.

The value can be either of the following macros:

  • ACL_RT_VMM_EXPORT_FLAG_DEFAULT: Default value. It means enabling the process trustlist verification.

    If you set the parameter to this value, call the aclrtMemSetPidToShareableHandleV2 API separately to add the ID of the process that uses shareableHandle to the trustlist.

  • ACL_RT_VMM_EXPORT_FLAG_DISABLE_PID_VALIDATION: Disables the process trustlist verification.

    If you set the parameter to this value, you do not need to call the aclrtMemSetPidToShareableHandleV2 API.

The macros are defined as follows:

#define ACL_RT_VMM_EXPORT_FLAG_DEFAULT                0x0UL
#define ACL_RT_VMM_EXPORT_FLAG_DISABLE_PID_VALIDATION 0x1UL

shareType

Input

Type of the exported shared handle. For details about the type definition, see aclrtMemSharedHandleType.

shareableHandle

Output

Pointer to the shared handle. The memory to which the pointer points is provided by the caller. The size is determined by shareType.

If shareType is ACL_MEM_SHARE_HANDLE_TYPE_DEFAULT, the pointer points to an uint64_t variable.

If shareType is ACL_MEM_SHARE_HANDLE_TYPE_FABRIC, the pointer points to an aclrtMemFabricHandle structure.

typedef struct aclrtMemFabricHandle { 
    uint8_t data[128];
} aclrtMemFabricHandle;

Returns

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

Restrictions

  • Atlas 200I/500 A2 inference product and Ascend RC: This API is not supported.
  • Inter-process physical memory sharing within an AI server is supported. If inter-device sharing is required, call the aclrtDeviceEnablePeerAccess API.
  • Only the Atlas A3 training product/Atlas A3 inference product support inter-process physical memory sharing across AI servers.
  • This API does not support the Ascend virtual instance scenario.
  • This API does not support the computing power allocation scenario.

    For details about computing power allocation APIs, see Group Management.