FetchEventID

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 TPipe::FetchEventID()
__aicore__ inline TEventID TPipe::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).

Availability

Atlas Training Series Product

Precautions

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, developers 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);