Function: ipc_mem_import_by_key

Applicability

Product

Supported (√/x)

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas training products

Atlas inference products

Atlas 200I/500 A2 inference products

x

Function Usage

Obtains the key information in the current process and returns the device memory address pointer that can be used by the current process. This API must be used together with other APIs to implement memory sharing. For details about the usage process, see the description of the Function: ipc_mem_get_export_keyAPI.

Prototype

  • C Prototype
    aclError aclrtIpcMemImportByKey(void **devPtr, const char *key, uint64_t flag)
  • Python Function
    1
    dev_ptr, ret = acl.rt.ipc_mem_import_by_key(key, flags)
    

Parameter Description

Parameter

Description

key

Str, shared memory key.

flags

Whether to enable data exchange between two devices.

The value can be either of the following macros:

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

    If the parameter is set to this value, call the acl.rt.device_enable_peer_access 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 this macro is used, you do not need to call the acl.rt.device_enable_peer_access 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

Return Value Description

Return Value

Description

dev_ptr

Int, pointer to the device memory address.

ret

Int, error code: 0 on success; else, failure.