aclrtCreateEventExWithFlag

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

Creates an event with a flag. Events with different flags are used for different functions. When an event is created, multiple flags can be carried (bitwise OR operation) to enable the corresponding flag function. Event resources are not restricted by hardware for the creation of events.

Prototype

aclError aclrtCreateEventExWithFlag(aclrtEvent *event, uint32_t flag)

Parameters

Parameter

Input/Output

Description

event

Output

Event pointer.

flag

Input

Flag of the event pointer.

The supported macros are as follows:

  • ACL_EVENT_TIME_LINE
    If this bit is enabled, the timestamp information needs to be recorded for the created event. Note: Enabling the timestamp function affects the performance of event-related APIs.
    #define ACL_EVENT_TIME_LINE 0x00000008U
  • ACL_EVENT_SYNC
    If this bit is enabled, the created event supports synchronization between multiple streams.
    #define ACL_EVENT_SYNC 0x00000001U
  • ACL_EVENT_CAPTURE_STREAM_PROGRESS

    If this bit is enabled, the created event is used to trace the task execution progress of the stream.

    #define ACL_EVENT_CAPTURE_STREAM_PROGRESS 0x00000002U 
  • ACL_EVENT_IPC

    If this bit is enabled, the created event is used for inter-process communication. For details, see aclrtIpcGetEventHandle. Note: This flag cannot be used with other flags in a bitwise OR operation.

    Events created with this flag cannot be used in the following APIs: aclrtResetEvent, aclrtQueryEvent, aclrtQueryEventWaitStatus, aclrtEventElapsedTime, aclrtEventGetTimestamp and aclrtGetEventId. Otherwise, an error will be reported.

    #define ACL_EVENT_IPC 0x00000040U

Returns

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

Restrictions

  • Events created using this API cannot be used in the following APIs: aclrtResetEvent, aclrtQueryEvent, and aclrtQueryEventWaitStatus. Otherwise, an error will be reported.
  • When this API is called to create an event, the flag is a bitmap. You can set the flag to a single macro or perform the OR operation on multiple macros.
    • If the value of flag contains the ACL_EVENT_SYNC macro, the system applies for event resources only when the aclrtRecordEvent API is called. Therefore, the number of events is limited. When the number of events reaches the upper limit, the system waits for resource release.

      The number of events supported varies depending on the hardware model, as shown in the following table.

      Model

      Maximum Number of Events Supported by a Device

      Atlas inference products

      1,023

      Atlas training products

      65,535

      Atlas A3 training products/Atlas A3 inference products

      Atlas A2 training products/Atlas A2 inference products

      Atlas 200I/500 A2 inference products

      65536

    • If the value of flag does not contain ACL_EVENT_SYNC, the event created by this API cannot be used in the aclrtStreamWaitEvent API.