aclrtMemExportToShareableHandleV2
Applicability
Product |
Supported |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
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 NPUs.
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
aclError aclrtMemExportToShareableHandleV2(aclrtDrvMemHandle handle, uint64_t flags, aclrtMemSharedHandleType shareType, void *shareableHandle)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
handle |
Input |
Handle for storing physical memory information. 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:
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. |
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
- This API is not supported in the Ascend RC form of the
Atlas 200I/500 A2 inference products .
- The following product models support inter-process physical memory sharing within an AI server. If inter-device sharing is required, call the aclrtDeviceEnablePeerAccess API.
Atlas A3 training products /Atlas A3 inference products Atlas A2 training products /Atlas A2 inference products Atlas training products Atlas inference products - Only the
Atlas A3 training products /Atlas A3 inference products 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.