aclrtIpcMemImportByKey

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

x

Atlas inference product

Atlas training product

Function

Imports key information in the current process and returns the device memory address pointer that can be used by this process.

This API must work with other APIs to implement memory sharing. For details, see the description of aclrtIpcMemGetExportKey.

Prototype

1
aclError aclrtIpcMemImportByKey(void **devPtr, const char *key, uint64_t flags)

Parameters

Parameter

Input/Output

Description

devPtr

Output

Pointer to the device memory address.

key

Input

Key of the shared memory.

First call aclrtIpcMemGetExportKey to obtain the shared memory key and then pass it as an input.

flags

Input

Controls whether to enable data exchange between two devices.

The options include the following macros:

  • ACL_RT_IPC_MEM_IMPORT_FLAG_DEFAULT: Default value, which disables data exchange between two devices.

    If you set the parameter to this value, call the aclrtDeviceEnablePeerAccess API separately to enable data exchange between two devices.

  • ACL_RT_IPC_MEM_IMPORT_FLAG_ENABLE_PEER_ACCESS: Enables data exchange between two devices.

    If you set the parameter to this value, you do not need to call the aclrtDeviceEnablePeerAccess API.

The macros are defined as follows:

#define ACL_RT_IPC_MEM_IMPORT_FLAG_DEFAULT            0x0UL
#define ACL_RT_IPC_MEM_IMPORT_FLAG_ENABLE_PEER_ACCESS 0x1UL

Returns

0 on success; otherwise, failure. For details, see aclError.

API Call Example

For the API call example, see Interprocess communication.