Function: notify_get_export_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

Sets a specified Notify object in the current process as an inter-process communication (IPC) one, and returns the key (Notify share name) to synchronize tasks between processes on multiple devices. Before calling this API, call acl.rt.device_enable_peer_access to enable data exchange between two devices.

This API must be used together with the key APIs described below. The following uses process A on device 0 and process B on device 1 as an example to describe the API call sequence for synchronizing tasks between the two processes.

  1. In process A:
    1. Call acl.rt.create_notify to create a Notify.
    2. Call acl.rt.notify_get_export_key to export the key (Notify share name).
    3. Obtain the ID of process B and call acl.rt.notify_set_import_pid to add the ID of process B to the trustlist.
    4. Call acl.rt.wait_and_reset_notify to deliver a wait task.
    5. Call acl.rt.destroy_notify to destroy the Notify. All processes involving IPC Notify need to release Notify. The release occurs only when every involved process finishes its part of the operation.
  2. In process B:
    1. Call acl.rt.device_get_bare_tgid to obtain the ID of process B. This API adapts to both PMs and VMs when obtaining the process ID. You only need to call this API to obtain the process ID and use the API with other APIs to share memory. If you obtain the process ID without calling this API, an exception may occur when you use the process ID.
    2. Call acl.rt.notify_import_by_key to obtain the key information and return the Notify pointer that can be used by the current process. Before calling acl.rt.notify_import_by_key, ensure that IPC Notify cannot be released in advance.
    3. Call acl.rt.record_notify to deliver a record task.
    4. Call acl.rt.destroy_notify to destroy the Notify.

Prototype

  • C Prototype
    aclError aclrtNotifyGetExportKey(aclrtNotify notify, char *key, size_t len, uint64_t flag)
  • Python Function
    1
    key, ret = acl.rt.notify_get_export_key(notify, len, flags)
    

Parameter Description

Parameter

Description

notify

Int, pointer address of the Notify.

len

Int, length of the Notify share name. The minimum value is 65.

flags

Int, whether to enable process trustlist verification. The values are as follows:

  • 0: ACL_RT_NOTIFY_EXPORT_FLAG_DEFAULT (default value), indicating that the process trustlist verification is enabled.

    If you set the parameter to this value, call the aclrtNotifySetImportPid API separately to add the ID of the process that uses the Notify share name to the trustlist.

  • 2: ACL_RT_NOTIFY_EXPORT_FLAG_DISABLE_PID_VALIDATION, indicating that the process trustlist verification is disabled.

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

Return Value Description

Return Value

Description

key

Str, Notify share name.

ret

Int, 0 on success; else, failure.

Restrictions

This operation is not supported in the Ascend virtual instance scenario.