aclrtNotifyGetExportKey

Applicability

Product

Supported

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

Description

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.

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 aclrtCreateNotify to create a Notify object.
    2. Call aclrtNotifyGetExportKey to export the key (Notify share name).

      Call aclrtNotifyGetExportKey to specify whether to enable process trustlist verification. If the verification is enabled, call aclrtNotifySetImportPid separately to add the ID of process B to the trustlist. If the verification is disabled, there is no need to call aclrtNotifySetImportPid.

    3. Call aclrtWaitAndResetNotify to deliver a wait task.
    4. Call aclrtDestroyNotify to destroy the Notify object.

      All processes involving an IPC Notify object need to release the object. This object is completely released only after all processes have released it.

  2. In process B:
    1. Call aclrtDeviceGetBareTgid 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 obtain the process ID without calling this API, an exception may occur when you use the process ID.

    2. Call aclrtNotifyImportByKey to obtain the key information and return the Notify pointer that can be used by the current process.

      Before calling aclrtIpcMemImportByKey, ensure that the IPC Notify object cannot be freed in advance.

    3. Call aclrtRecordNotify to deliver a record task.
    4. Call aclrtDestroyNotify to destroy the Notify object.

Prototype

aclError aclrtNotifyGetExportKey(aclrtNotify notify, char *key, size_t len, uint64_t flags)

Parameters

Parameter

Input/Output

Description

notify

Input

Notify object.

key

Output

Share name of the Notify object.

len

Input

Length of the Notify share name. The minimum length is 65.

flags

Input

Whether to enable process trustlist verification.

The value can be either of the following macros:

  • ACL_RT_NOTIFY_EXPORT_FLAG_DEFAULT: Default value. It means enabling process trustlist verification.

    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.

  • ACL_RT_NOTIFY_EXPORT_FLAG_DISABLE_PID_VALIDATION: Disables process trustlist verification.

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

The macros are defined as follows:

#define ACL_RT_NOTIFY_EXPORT_FLAG_DEFAULT                0x0UL
#define ACL_RT_NOTIFY_EXPORT_FLAG_DISABLE_PID_VALIDATION 0x02UL

Returns

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

Restrictions

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