SetFlag/WaitFlag
Function Usage
Synchronizes instructions with data dependencies between different pipelines in the same core.
- SetFlag: The current instruction starts to be executed after all read and write operations of the current instruction are completed and the corresponding flag bit in hardware is set to 1.
- WaitFlag: When this instruction is executed, if the corresponding flag bit is 0, the subsequent instructions in the queue are blocked; if the corresponding flag bit is 1, the subsequent instructions are executed after this bit is changed to 0.
Prototype
1 2 | __aicore__ inline void SetFlag(TEventID id) __aicore__ inline void WaitFlag(TEventID id) |
Parameters
Parameter |
Input/Output |
Description |
||
|---|---|---|---|---|
id |
Input |
Event ID. The value is an integer and can be specified by users.
|
Returns
None
Availability
Constraints
- SetFlag and WaitFlag must be used in pairs.
- When using SetFlag and WaitFlag, you need to specify eventID and ensure that the ID is within the range.
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 | AscendC::GlobalTensor<half> dstGlobal; AscendC::LocalTensor<half> dstLocal; dstLocal.SetValue(0, 0); AscendC::TQueSync<PIPE_S, PIPE_MTE3> sync; sync.SetFlag(0); sync.WaitFlag(0); AscendC::DataCopy(dstGlobal, dstLocal, dataSize); |
Parent topic: TQueSync