FetchEventID
Applicability
Product |
Supported |
|---|---|
√ |
|
√ |
|
x |
|
√ |
|
x |
|
√ |
Function
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 |
Description |
|---|---|---|
evt |
Input |
Parameter of the 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 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); |