aclrtRecordEvent

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

Records an event in a specified stream. This API is asynchronous.

When used with the aclrtStreamWaitEvent API, aclrtRecordEvent synchronizes streams. When aclrtRecordEvent is called, the system applies for event resources.

When aclrtRecordEvent is called, the tasks delivered on the current stream are captured and then recorded in the event. Therefore, you can later call aclrtQueryEventStatus to check whether all tasks captured in the event are completed or call aclrtStreamWaitEvent to wait until all tasks are completed.

In addition, for events created using aclrtCreateEventExWithFlag:

  • aclrtRecordEvent supports event reuse for multiple records of the same event. Each record captures the tasks that have been delivered on the current stream and overwrites the tasks in the event. When aclrtStreamWaitEvent is called, the task saved in the latest event is used and will not be affected by subsequent calling of aclrtRecordEvent.
  • Before the aclrtRecordEvent API is called for the first time, ACL_EVENT_RECORDED_STATUS_COMPLETE is returned when aclrtQueryEventStatus is called because there is no task in the event.

Prototype

aclError aclrtRecordEvent(aclrtEvent event, aclrtStream stream)

Parameters

Parameter

Input/Output

Description

event

Input

Event to record.

stream

Input

Stream.

For stream synchronization, for example, Stream2 waits for Stream1, set this parameter to Stream1.

To specify the default stream, pass NULL.

Returns

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

See Also

For details about the API call sequence and example, see Synchronous Wait of an Event and Synchronous Wait of Tasks Between Streams (Implemented Using Events).