aclrtMemImportFromShareableHandleV2

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

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

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 shared handle. For details about the type definition, see aclrtMemSharedHandleType.

flags

Input

Reserved. The value is fixed at 0.

handle

Output

Physical memory handle to the 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 released 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.