aclrtMemImportFromShareableHandle
Applicability
|
Product |
Supported |
|---|---|
|
Atlas 350 Accelerator Card |
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Function
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
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 is in the range of [0, Device count – 1]. Call aclrtGetDeviceCount to obtain the device count. |
|
handle |
Output |
Physical memory handle to the process. For 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 released 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 used, call aclrtFreePhysical to destroy the handle. The handle is destroyed only when all processes that call this API destroy shareableHandle.