aclrtMemImportFromShareableHandleV2

Applicability

Product

Supported

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

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 is enhanced based on aclrtMemImportFromShareableHandle. You can use the shareType parameter to specify whether to export the shared handle 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 shared handle and with aclrtMemSetPidToShareableHandleV2 to set the process trustlist.

Prototype

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 shared handle.

flags

Input

Reserved. The value is fixed at 0.

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 aclrtMemImportFromShareableHandleV2 and aclrtMemExportToShareableHandleV2 APIs cannot be called in the same process. Only cross-process calling is supported.
  • 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.