FetchEventID

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

Atlas inference product Vector Core

x

Atlas training product

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 SetFlag/WaitFlag(ISASI).

Constraints

Compared with AllocEventID, FetchEventID is suitable for scenarios requiring temporary ID usage, as it does not occupy the ID after acquisition. 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);