aclrtMemImportFromShareableHandleV2
Applicable Products
Product |
Supported |
|---|---|
√ |
|
☓ |
|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
Function
Obtains the information in shareableHandle in the current process and returns the handle in the process to establish a mapping between virtual addresses and physical addresses in the process.
This API is enhanced based on aclrtMemImportFromShareableHandle. You can use the shareType parameter to specify whether to export a shareableHandle within an AI server or from another AI server.
The usage of this API is similar to that of aclrtMemExportToShareableHandle. However, this API must be used together with aclrtMemExportToShareableHandleV2 to export a shareableHandle and with aclrtMemSetPidToShareableHandleV2 to set the process trustlist.
Prototype
1 | aclError aclrtMemImportFromShareableHandleV2(void *shareableHandle, aclrtMemSharedHandleType shareType, uint64_t flags, aclrtDrvMemHandle *handle); |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
shareableHandle |
Input |
shareableHandle to share. It must be the same as the value of shareableHandle exported using aclrtMemExportToShareableHandleV2. Each handle must correspond to only one shareableHandle in the same process. One-to-many or many-to-one mapping is not allowed. |
shareType |
Input |
Type of the exported shareableHandle. For details about the type definition, see aclrtMemSharedHandleType. |
flags |
Input |
Reserved. The value is fixed at 0. |
handle |
Output |
Physical memory handle in the current process. For details about the type definition, see aclrtDrvMemHandle. |
Returns
0 on success; otherwise, failure. For details, see aclError.
Restrictions
- Before calling this API, ensure that the physical memory to be shared exists and cannot be freed in advance.
- The aclrtMemImportFromShareableHandleV2 and aclrtMemExportToShareableHandleV2 APIs cannot be called in the same process. Only cross-process calling is supported.
- After the memory is no longer used, call aclrtFreePhysical to destroy the handle. The handle is truly destroyed only after all processes that called this API have destroyed the shareableHandle.