aclrtRecordEvent

Applicable Products

Product

Supported

Ascend 950PR / Ascend 950DT

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

Function

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

The aclrtRecordEvent and aclrtStreamWaitEvent APIs can be used together to synchronize streams.

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 through 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 tasks recorded in the latest event are 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

1
aclError aclrtRecordEvent(aclrtEvent event, aclrtStream stream)

Parameters

Parameter

Input/Output

Description

event

Input

Event to record. For details about the type definition, see aclrtEvent.

stream

Input

Stream. For details about the type definition, see aclrtStream.

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

Returns

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

API Call Example

For the API call example, see Event Waiting.