FetchEventID

Applicability

Product

Supported/Unsupported

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

x

Atlas inference product 's AI Core

Atlas inference product 's Vector Core

x

Atlas training products

Function Usage

Obtains available TEventIDs based on HardEvent (hardware synchronization event). This API does not allocate TEventIDs, but provides available TEventIDs.

Prototype

1
2
3
template <HardEvent evt>
__aicore__ inline TEventID FetchEventID()
__aicore__ inline TEventID FetchEventID(HardEvent evt)

Parameters

Parameter

Input/Output

Meaning

evt

Input

HardEvent hardware synchronization type.

For details about this type, see the description of synchronization types in the SetFlag/WaitFlag(ISASI).

Restrictions

Compared with AllocEventID, FetchEventID is applicable to the scenario where IDs are temporarily used. After an ID is obtained, the ID is not occupied. In some complex application scenarios, you need to ensure that the usage is correct. For example, if SetFlag and WaitFlag are called consecutively in the same pipeline and the two IDs are obtained using FetchEventID, undefined behaviors such as program suspension may occur because the two IDs are the same. In this case, AllocEventID is recommended.

Returns

TEventID

Example

1
2
3
AscendC::TEventID eventIdVToS = GetTPipePtr()->FetchEventID(AscendC::HardEvent::V_S); //The scalar needs to wait for vector synchronization and the HardEvent ID is required.
AscendC::SetFlag<AscendC::HardEvent::V_S>(eventIdVToS);
AscendC::WaitFlag<AscendC::HardEvent::V_S>(eventIdVToS);