aclrtMemImportFromShareableHandle
Applicability
Product |
Supported |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
Description
Obtains the information in shareableHandle in this process and returns the handle in this process to establish the mapping between virtual addresses and physical addresses in this process. This API can also be used to generate a handle for a specified device.
This API must work with other APIs to implement memory sharing. For details, see the description of aclrtMemExportToShareableHandle.
Prototype
aclError aclrtMemImportFromShareableHandle(uint64_t shareableHandle, int32_t deviceId, aclrtDrvMemHandle *handle)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
shareableHandle |
Input |
shareableHandle to share. It must be the same as the value of shareableHandle exported using aclrtMemExportToShareableHandle. Each handle must correspond to only one shareableHandle in the same process. One-to-many or many-to-one mapping is not allowed. |
deviceId |
Input |
ID of the device for which a handle is to be generated. Must be in the range of [0, Device count – 1]. Call aclrtGetDeviceCount to obtain the device count. |
handle |
Output |
Physical memory handle to the process. |
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 .
- Before calling this API, ensure that the physical memory to be shared exists and cannot be freed in advance.
- The aclrtMemImportFromShareableHandle and aclrtMemExportToShareableHandle APIs cannot be called in the same process. Only cross-process calling is supported.
- You can call aclrtMemExportToShareableHandle on a device to export the handle, and then call aclrtMemImportFromShareableHandle to generate a handle on another device.
- After the memory is used, call aclrtFreePhysical to destroy the handle. The handle is destroyed only when all processes that call aclrtMemImportFromShareableHandle destroy shareableHandle.