SetFlag/WaitFlag(ISASI)
Function Usage
Synchronization instruction between different pipelines in the same core. This synchronization operation needs to be inserted between different pipeline instructions with data dependency.
Prototype
1 2 3 4 | template <HardEvent event> __aicore__ inline void SetFlag(int32_t eventID) template <HardEvent event> __aicore__ inline void WaitFlag(int32_t eventID) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
event |
Input |
Template parameter. Synchronization event of the HardEvent data type. For details, see the following description of synchronization types. |
eventID |
Input |
Event ID. The data type is int32_t. The definition is as follows: The event ID needs to be obtained through AllocEventID or FetchEventID. |
The synchronization types are described as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | enum class HardEvent : uint8_t { // Name (source pipeline_target pipeline). For example, MTE2_V indicates that PIPE_MTE2 is the source pipeline and PIPE_V is the target pipeline. Synchronization is performed between PIPE_MTE2 and PIPE_V, and PIPE_V waits for PIPE_MTE2. MTE2_MTE1 MTE1_MTE2 MTE1_M M_MTE1 MTE2_V V_MTE2 MTE3_V V_MTE3 M_V V_M V_V MTE3_MTE1 MTE1_MTE3 MTE1_V MTE2_M M_MTE2 V_MTE1 M_FIX // Not supported in the current version FIX_M // Not supported in the current version MTE3_MTE2 MTE2_MTE3 S_V V_S S_MTE2 MTE2_S S_MTE3 MTE3_S MTE2_FIX // Not supported in the current version FIX_MTE2 // Not supported in the current version FIX_S // Not supported in the current version M_S FIX_MTE3 // Not supported in the current version } |
Returns
None
Availability
Constraints
- SetFlag and WaitFlag must appear in pairs.
- You are not allowed to specify the event ID when using SetFlag and WaitFlag. Otherwise, the event ID may conflict with the framework synchronization event, causing suspension. The event ID
is obtained through AllocEventID or FetchEventID.
Example
DataCopy can be executed only after SetValue is executed. In this case, you need to insert the synchronization operation between PIPE_S and PIPE_MTE3.
1 2 3 4 5 6 7 8 | AscendC::GlobalTensor<half> dstGlobal; AscendC::LocalTensor<half> dstLocal; dstLocal.SetValue(0, 0); uint32_t dataSize = 512; int32_t eventIDSToMTE3 = static_cast<int32_t>(GetTPipePtr()->FetchEventID(AscendC::HardEvent::S_MTE3)); AscendC::SetFlag<AscendC::HardEvent::S_MTE3>(eventIDSToMTE3); AscendC::WaitFlag<AscendC::HardEvent::S_MTE3>(eventIDSToMTE3); AscendC::DataCopy(dstGlobal, dstLocal, dataSize); |