aclrtMemImportFromShareableHandle
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 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
1
|
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. The value must be in the range of [0, (Available device count – 1)]. Call aclrtGetDeviceCount to obtain the device count. |
|
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 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 this API to generate a handle on another device.
- 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.