Function: notify_get_export_key

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas training product

Atlas inference product

Atlas 200I/500 A2 inference product

x

Description

Sets the specified Notify in this process to IPC (Inter-Process Communication) Notify and returns the key (that is, the Notify shared name) to implement task synchronization between different processes on multiple devices. Before calling this API, you need to call the acl.rt.device_enable_peer_access API to enable data interaction between two devices.

This API needs to work with other key APIs to synchronize tasks between different processes on multiple devices. The following uses process A on device 0 and process B on device 1 as an example to describe the process of calling this API.

  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 the acl.rt.notify_set_import_pid API to add the ID of process B to the whitelist.
    4. Call the acl.rt.wait_and_reset_notify API to deliver a waiting task.
    5. Call acl.rt.destroy_notify to destroy the Notify. All processes involving IPC Notify need to release Notify. Notify is released only after all processes involving IPC Notify complete the release 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 physical machines 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 do not call this API to obtain the process ID, 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)
    

Parameters

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 options 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

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.